virtual void main() { //init StatisticsReads stats; FastqEntry entry; QStringList infiles; QStringList in1 = getInfileList("in1"); QStringList in2 = getInfileList("in2"); if (in2.count()!=0 && in1.count()!=in2.count()) { THROW(CommandLineParsingException, "Input file lists 'in1' and 'in2' differ in counts!"); } //process for (int i=0; i<in1.count(); ++i) { //forward FastqFileStream stream(in1[i]); while(!stream.atEnd()) { stream.readEntry(entry); stats.update(entry, StatisticsReads::FORWARD); } infiles << in1[i]; //reverse (optional) if (i<in2.count()) { FastqFileStream stream2(in2[i]); while(!stream2.atEnd()) { stream2.readEntry(entry); stats.update(entry, StatisticsReads::REVERSE); } //check read counts matches if (stream.index()!=stream2.index()) { THROW(ArgumentException, "Differing number of reads in file '" + in1[i] + "' and '" + in2[i] + "'!"); } infiles << in2[i]; } } //store output QCCollection metrics = stats.getResult(); if (getFlag("txt")) { QStringList output; metrics.appendToStringList(output); Helper::storeTextFile(Helper::openFileForWriting(getOutfile("out"), true), output); } else { metrics.storeToQCML(getOutfile("out"), infiles, ""); } }
virtual void main() { //init StatisticsReads stats; FastqEntry entry; QStringList infiles; //process forward read file QString in1 = getInfile("in1"); FastqFileStream stream(in1); while(!stream.atEnd()) { stream.readEntry(entry); stats.update(entry, StatisticsReads::FORWARD); } infiles << in1; //process reverse read file QString in2 = getInfile("in2"); if (in2!="") { FastqFileStream stream2(in2); while(!stream2.atEnd()) { stream2.readEntry(entry); stats.update(entry, StatisticsReads::REVERSE); } //check read counts matches if (stream.index()!=stream2.index()) { THROW(ArgumentException, "Differing number of reads in file '" + in1 + "' and '" + in2 + "'!"); } infiles << in2; } //store output QCCollection metrics = stats.getResult(); if (getFlag("txt")) { QStringList output; metrics.appendToStringList(output); Helper::storeTextFile(Helper::openFileForWriting(getOutfile("out"), true), output); } else { metrics.storeToQCML(getOutfile("out"), infiles, ""); } }