(String path, int minLength, int sample)
| 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; |
no test coverage detected