use of com.github.lindenb.jvarkit.util.picard.FourLinesFastqReader in project jvarkit by lindenb.
the class FastqJavascript method doWork.
@Override
public int doWork(List<String> args) {
if ((this.R1FileOut == null && this.R2FileOut != null) || (this.R1FileOut != null && this.R2FileOut == null)) {
LOG.error("Option OPTION_R1FILEOUT / OPTION_R2FILEOUT must be both defined");
return -1;
}
try {
this.script = super.compileJavascript(this.javascriptExpr, this.javascriptFile);
if (args.isEmpty()) {
final FastqReader in = new FourLinesFastqReader(stdin());
doWork(in);
in.close();
} else if (args.size() == 2) {
LOG.info("2 fastqs: Reading as interleavel fastqs");
final FastqReader in1 = new FourLinesFastqReader(new File(args.get(0)));
final FastqReader in2 = new FourLinesFastqReader(new File(args.get(1)));
final FastqReader in = new InterleavedFastqReader(in1, in2);
this.interleaved = true;
doWork(in);
in.close();
} else if (args.size() == 1) {
final FastqReader in = new FourLinesFastqReader(new File(args.get(0)));
doWork(in);
in.close();
} else {
LOG.error("Illegal number of arguments");
return -1;
}
return RETURN_OK;
} catch (final Exception err) {
LOG.error(err);
return -1;
} finally {
CloserUtil.close(failingReadsWriter);
}
}
use of com.github.lindenb.jvarkit.util.picard.FourLinesFastqReader in project jvarkit by lindenb.
the class FastqShuffle method doWork.
@Override
public int doWork(final List<String> args) {
FastqReader r1 = null;
FastqReader r2 = null;
FastqWriter w = null;
try {
if (fileout == null) {
w = new BasicFastqWriter(stdout());
} else {
w = new BasicFastqWriter(this.fileout);
}
if (args.isEmpty()) {
LOG.info("Reading from stdin");
r1 = new FourLinesFastqReader(stdin());
if (interleaved_input) {
runPaired(r1, null, w);
} else {
runSingle(r1, w);
}
} else if (args.size() == 1) {
r1 = new FourLinesFastqReader(new File(args.get(0)));
if (interleaved_input) {
runPaired(r1, null, w);
} else {
runSingle(r1, w);
}
} else if (args.size() == 2) {
r1 = new FourLinesFastqReader(new File(args.get(0)));
r2 = new FourLinesFastqReader(new File(args.get(1)));
runPaired(r1, r2, w);
} else {
LOG.error("illegal.number.of.arguments");
return -1;
}
return 0;
} catch (final Exception err) {
LOG.error(err);
return -1;
} finally {
CloserUtil.close(r1);
CloserUtil.close(r2);
CloserUtil.close(w);
}
}
use of com.github.lindenb.jvarkit.util.picard.FourLinesFastqReader in project jvarkit by lindenb.
the class BioAlcidae method execute_fastq.
private int execute_fastq(String source) throws IOException {
InputStream in = null;
FourLinesFastqReader iter = null;
try {
if (source == null) {
in = stdin();
} else {
in = IOUtils.openURIForReading(source);
}
iter = new FourLinesFastqReader(in);
bindings.put("iter", in);
bindings.put("format", "fastq");
this.script.eval(bindings);
this.writer.flush();
return RETURN_OK;
} catch (Exception e) {
LOG.error(e);
return -1;
} finally {
CloserUtil.close(iter);
CloserUtil.close(in);
bindings.remove("header");
bindings.remove("iter");
bindings.remove("format");
}
}
Aggregations