@Override public boolean parseArgument(String arg, String a, String b) { // System.err.println("Calling parseArgument("+arg+","+a+","+b+")"); if (a.equals("minq")) { minq = (int) Tools.parseKMG(b); return true; } else if (a.equals("maxq")) { maxq = (int) Tools.parseKMG(b); return true; } else if (a.equals("keepperfect")) { keepPerfect = Tools.parseBoolean(b); return true; } else if (a.equals("countindels")) { countIndels = Tools.parseBoolean(b); return true; } // There was no match to the argument return false; }
public static void main(String[] args) { String in1 = args[0]; String in2 = (args.length < 2 || args[1].equalsIgnoreCase("null") || args[1].contains("=") ? null : args[1]); if (in2 != null) { assert (!in1.equalsIgnoreCase(in2)); FASTQ.TEST_INTERLEAVED = false; } else { FASTQ.TEST_INTERLEAVED = true; FASTQ.FORCE_INTERLEAVED = true; } long maxReads = -1; for (int i = 1; i < args.length; i++) { final String arg = args[i]; final String[] split = arg.split("="); String a = split[0].toLowerCase(); String b = (split.length > 1 ? split[1] : "true"); if (Parser.isJavaFlag(arg)) { // jvm argument; do nothing } else if (Parser.parseZip(arg, a, b)) { // do nothing } else if (Parser.parseQuality(arg, a, b)) { // do nothing } else if (Parser.parseFasta(arg, a, b)) { // do nothing } else if (a.equals("reads") || a.startsWith("maxreads")) { maxReads = Tools.parseKMG(b); } else { throw new RuntimeException("Unknown parameter " + args[i]); } } Parser.processQuality(); assert (FastaReadInputStream.settingsOK()); Timer t = new Timer(); ConcurrentReadInputStream cris = getReadInputStream(maxReads, false, true, in1, in2); System.out.println("Fetched " + cris.getClass().getName()); { Object[] p = cris.producers(); // while(p[0]==null){ // p=cris.producers(); // } System.out.print("Producers: "); String comma = ""; for (Object o : p) { System.out.print(comma + (o == null ? "null" : o.getClass().getName())); comma = ", "; } System.out.println(); } boolean paired = cris.paired(); System.out.println("paired=" + paired); cris.start(); // 4567 ListNum<Read> ln = cris.nextList(); ArrayList<Read> reads = (ln != null ? ln.list : null); if (reads != null && !reads.isEmpty()) { Read r = reads.get(0); assert ((r.mate != null) == paired); } long readCount = 0; long baseCount = 0; while (reads != null && reads.size() > 0) { for (Read r : reads) { Read r2 = r.mate; if (r != null) { readCount++; if (r.bases != null) { baseCount += r.length(); } } if (r2 != null) { readCount++; if (r2.bases != null) { baseCount += r2.length(); } } } cris.returnList(ln.id, ln.list.isEmpty()); // System.err.println("fetching list"); ln = cris.nextList(); reads = (ln != null ? ln.list : null); // System.out.println("reads: "+(reads==null ? "null" : reads.size())); } System.err.println("Finished reading"); cris.returnList(ln.id, ln.list.isEmpty()); cris.close(); t.stop(); System.out.println("Reads: \t" + readCount); System.out.println("Bases: \t" + baseCount); System.out.println("Avg Length: \t" + String.format("%.2f", baseCount * 1.0 / readCount)); System.out.println("Time: \t" + t); }