@Override public void write(final FastqRecord rec) { try { writeStream(stream, rec); } catch (IOException e) { throw new SAMException("Error in writing fastq file " + path, e); } } // TODO: refactor into FastqEncoder.write()
private void ensureAligner() throws IOException { if (aligner == null) { log.info("Starting external aligner"); log.info(commandlinestr); aligner = new ProcessBuilder(args) .redirectInput(Redirect.PIPE) .redirectOutput(Redirect.PIPE) .redirectError(Redirect.INHERIT) .start(); toExternalProgram = new NonFlushingBasicFastqWriter(new BufferedOutputStream(aligner.getOutputStream())); reader = new Thread(() -> readAllAlignments(readerFactory)); reader.setName("ExternalProcessStreamingAligner"); reader.start(); } } /* (non-Javadoc)
@Override public void close() { try { flush(); stream.close(); } catch (IOException e) { throw new SAMException("Error in writing fastq file " + path, e); } } }
protected int createSupplementaryAlignmentFastq(File input, File fq, boolean isRecursive) throws IOException { int recordsWritten = 0; try (SamReader reader = readerFactory.open(input)) { try (AsyncBufferedIterator<SAMRecord> bufferedIt = new AsyncBufferedIterator<>(reader.iterator(), input.getName())) { try (FastqWriter writer = new AsyncFastqWriter(new NonFlushingBasicFastqWriter(fq), AsyncFastqWriter.DEFAULT_QUEUE_SIZE)) { SplitReadFastqExtractionIterator fastqit = new SplitReadFastqExtractionIterator( bufferedIt, isRecursive, minSoftClipLength, minSoftClipQuality, !isRecursive && isProcessSecondaryAlignments(), isRealignExistingSplitReads(), isRealignEntireRecord(), eidgen); while (fastqit.hasNext()) { writer.write(fastqit.next()); recordsWritten++; } } } } return recordsWritten; } public boolean isRealignExistingSplitReads() {