MCPcopy Create free account
hub / github.com/BirolLab/RNA-Bloom / getReadLengths

Method getReadLengths

src/rnabloom/RNABloom.java:917–956  ·  view source on GitHub ↗
(String path, int minLength, int sample)

Source from the content-addressed store, hash-verified

915 }
916
917 public static int[] getReadLengths(String path, int minLength, int sample) throws FileFormatException, IOException{
918 int[] lengths = new int[sample];
919 int i = 0;
920
921 if (FastqReader.isCorrectFormat(path)) {
922 FastqRecord r = new FastqRecord();
923 FastqReader fr = new FastqReader(path);
924 for (; i< sample && fr.hasNext();) {
925 fr.nextWithoutName(r);
926 int len = r.seq.length();
927 if (len < minLength) {
928 continue;
929 }
930 lengths[i] = len;
931 ++i;
932 }
933 fr.close();
934 }
935 else if (FastaReader.isCorrectFormat(path)) {
936 FastaReader fr = new FastaReader(path);
937 for (; i< sample && fr.hasNext();) {
938 int len = fr.next().length();
939 if (len < minLength) {
940 continue;
941 }
942 lengths[i] = len;
943 ++i;
944 }
945 fr.close();
946 }
947 else {
948 throw new FileFormatException("Incompatible file format for `" + path + "`");
949 }
950
951 if (i < sample) {
952 return Arrays.copyOfRange(lengths, 0, i);
953 }
954
955 return lengths;
956 }
957
958 public static int getMaxReadLength(String path) throws FileFormatException, IOException{
959 int max = -1;

Callers 1

Calls 6

isCorrectFormatMethod · 0.95
hasNextMethod · 0.95
closeMethod · 0.95
isCorrectFormatMethod · 0.95
nextMethod · 0.95
nextWithoutNameMethod · 0.45

Tested by

no test coverage detected