use of com.github.lindenb.jvarkit.util.picard.FourLinesFastqReader in project jvarkit by lindenb.
the class PadEmptyFastq method doWork.
@Override
public int doWork(final List<String> args) {
FastqWriter fqw = null;
try {
if (this.outFile == null) {
LOG.info("writing to stdout");
fqw = new BasicFastqWriter(stdout());
} else {
LOG.info("writing to " + this.outFile);
fqw = new FastqWriterFactory().newWriter(this.outFile);
}
if (args.isEmpty()) {
LOG.info("Reading from stdin");
FastqReader fqr = new FourLinesFastqReader(stdin());
copyTo(fqr, fqw);
fqr.close();
} else {
for (final String filename : args) {
LOG.info("Reading from " + filename);
FastqReader fqr = new FourLinesFastqReader(new File(filename));
copyTo(fqr, fqw);
fqr.close();
}
}
return 0;
} catch (final Exception err) {
LOG.error(err);
return -1;
} finally {
CloserUtil.close(fqw);
}
}
use of com.github.lindenb.jvarkit.util.picard.FourLinesFastqReader in project jvarkit by lindenb.
the class FastqRevComp method doWork.
@Override
public int doWork(List<String> args) {
if (only_R1 && only_R2) {
LOG.error("Both options -1 && -2 used.");
return -1;
}
PrintStream out = null;
try {
out = super.openFileOrStdoutAsPrintStream(outputFile);
if (args.isEmpty()) {
LOG.info("Reading from stdin");
FastqReader fqR = new FourLinesFastqReader(stdin());
run(fqR, out);
fqR.close();
} else
for (final String fn : args) {
File f = new File(fn);
LOG.info("Reading from " + f);
FastqReader fqR = new FourLinesFastqReader(f);
run(fqR, out);
fqR.close();
}
out.flush();
} catch (Exception err) {
LOG.error(err);
return -1;
} finally {
CloserUtil.close(out);
}
return 0;
}
use of com.github.lindenb.jvarkit.util.picard.FourLinesFastqReader in project jvarkit by lindenb.
the class FastqGrep method doWork.
@Override
public int doWork(List<String> args) {
BufferedReader in = null;
FastqWriter out = null;
try {
if (this.readNameFile != null) {
in = IOUtils.openFileForBufferedReading(this.readNameFile);
String line;
while ((line = in.readLine()) != null) {
line = line.trim();
if (line.isEmpty())
continue;
this.readNames.put(getReadName(line), 0);
}
in.close();
}
for (final String r : this.readNamesInput) {
this.readNames.put(getReadName(r), 0);
}
if (readNames.isEmpty()) {
LOG.warn("no read name found.");
}
if (this.outputFile != null) {
LOG.info("Writing to " + this.outputFile);
out = new BasicFastqWriter(this.outputFile);
} else {
LOG.info("Writing to stdout");
out = new BasicFastqWriter(stdout());
}
if (args.isEmpty()) {
LOG.info("Reading from stdin");
FastqReader fqR = new FourLinesFastqReader(System.in);
run(fqR, out);
fqR.close();
} else
for (String fname : args) {
File f = new File(fname);
LOG.info("Reading from " + f);
FastqReader fqR = new FourLinesFastqReader(f);
run(fqR, out);
fqR.close();
}
CloserUtil.close(out);
return 0;
} catch (Exception err) {
LOG.error(err);
return -1;
} finally {
CloserUtil.close(in);
}
}
use of com.github.lindenb.jvarkit.util.picard.FourLinesFastqReader in project jvarkit by lindenb.
the class FastqToFasta method doWork.
@Override
public int doWork(final List<String> args) {
PrintStream out = null;
try {
out = super.openFileOrStdoutAsPrintStream(outputFile);
if (args.isEmpty()) {
LOG.info("Reading from stdin");
FastqReader fqR = new FourLinesFastqReader(stdin());
run(fqR, out);
fqR.close();
} else
for (String fname : args) {
File f = new File(fname);
LOG.info("Reading from " + f);
FastqReader fqR = new FourLinesFastqReader(f);
run(fqR, out);
fqR.close();
}
out.flush();
} catch (Exception err) {
LOG.error(err);
return -1;
} finally {
CloserUtil.close(out);
}
return 0;
}
use of com.github.lindenb.jvarkit.util.picard.FourLinesFastqReader in project jvarkit by lindenb.
the class FindCorruptedFiles method testFastq.
private void testFastq(File f) {
long n = 0;
LOG.fine("Test Fastq for " + f);
FastqReader r = null;
try {
r = new FourLinesFastqReader(f);
r.setValidationStringency(this.validationStringency);
while (r.hasNext() && (NUM < 0 || n < NUM)) {
r.next();
++n;
}
if (n == 0) {
emptyFile(f);
}
} catch (Exception err) {
LOG.fine("Cannot read " + f);
stdout().println(f);
} finally {
CloserUtil.close(r);
}
}
Aggregations