static synchronized String getSAMString(final SAMRecord alignment) { if (stringWriter == null) stringWriter = new StringWriter(); if (textWriter == null) textWriter = new SAMTextWriter(stringWriter); stringWriter.getBuffer().setLength(0); textWriter.writeAlignment(alignment); return stringWriter.toString(); }
static synchronized String getSAMString(final SAMRecord alignment) { if (stringWriter == null) stringWriter = new StringWriter(); if (textWriter == null) textWriter = new SAMTextWriter(stringWriter); stringWriter.getBuffer().setLength(0); textWriter.writeAlignment(alignment); return stringWriter.toString(); }
static synchronized String getSAMString(final SAMRecord alignment) { if (stringWriter == null) stringWriter = new StringWriter(); if (textWriter == null) textWriter = new SAMTextWriter(stringWriter); stringWriter.getBuffer().setLength(0); textWriter.writeAlignment(alignment); return stringWriter.toString(); }
/** * Create a SAMTextWriter for writing to a stream that is ready to receive SAMRecords. * This method does not support the creation of an MD5 file * * @param header entire header. Sort order is determined by the sortOrder property of this arg. * @param presorted if true, SAMRecords must be added to the SAMFileWriter in order that agrees with header.sortOrder. * @param stream the stream to write records to. Note that this method does not buffer the stream, so the * caller must buffer if desired. Note that PrintStream is buffered. */ public SAMFileWriter makeSAMWriter(final SAMFileHeader header, final boolean presorted, final OutputStream stream) { return initWriter(header, presorted, false, new SAMTextWriter(stream)); }
@Override public boolean open() { if(!input.toFile().exists()){ return false; } this.writer = new SAMTextWriter(input.toFile()); try { this.adaptor.open(); } catch (IOException e) { e.printStackTrace(); return false; } return true; }
/** * Create a SAMTextWriter for writing to a stream that is ready to receive SAMRecords. * This method does not support the creation of an MD5 file * * @param header entire header. Sort order is determined by the sortOrder property of this arg. * @param presorted if true, SAMRecords must be added to the SAMFileWriter in order that agrees with header.sortOrder. * @param stream the stream to write records to. Note that this method does not buffer the stream, so the * caller must buffer if desired. Note that PrintStream is buffered. */ public SAMFileWriter makeSAMWriter(final SAMFileHeader header, final boolean presorted, final OutputStream stream) { /** * Use the value specified from Defaults.SAM_FLAG_FIELD_FORMAT when samFlagFieldOutput value has not been set. This should * be samFlagFieldOutput.DECIMAL when the user has not set Defaults.SAM_FLAG_FIELD_FORMAT. */ if (samFlagFieldOutput == SamFlagField.NONE) { samFlagFieldOutput = Defaults.SAM_FLAG_FIELD_FORMAT; } return initWriter(header, presorted, new SAMTextWriter(stream, samFlagFieldOutput)); }
/** * Create a SAMTextWriter for writing to a stream that is ready to receive SAMRecords. * This method does not support the creation of an MD5 file * * @param header entire header. Sort order is determined by the sortOrder property of this arg. * @param presorted if true, SAMRecords must be added to the SAMFileWriter in order that agrees with header.sortOrder. * @param stream the stream to write records to. Note that this method does not buffer the stream, so the * caller must buffer if desired. Note that PrintStream is buffered. */ public SAMFileWriter makeSAMWriter(final SAMFileHeader header, final boolean presorted, final OutputStream stream) { /** * Use the value specified from Defaults.SAM_FLAG_FIELD_FORMAT when samFlagFieldOutput value has not been set. This should * be samFlagFieldOutput.DECIMAL when the user has not set Defaults.SAM_FLAG_FIELD_FORMAT. */ if (samFlagFieldOutput == SamFlagField.NONE) { samFlagFieldOutput = Defaults.SAM_FLAG_FIELD_FORMAT; } return initWriter(header, presorted, new SAMTextWriter(stream, samFlagFieldOutput)); }
public int writeToStream(OutputStream stream, Iterator<PicardAlignment> alignments, boolean bam) { SAMFileWriterImpl writer; // if (bam) { // return 0; // Don't know how to output bams // //writer = new BAMFileWriter(stream, null); // } else { writer = new SAMTextWriter(stream); writer.setHeader(header); return writeAlignments(writer, alignments); // } }
private void init( OutputStream output, SAMFileHeader header, boolean writeHeader) throws IOException { this.header = header; writer = new SAMTextWriter(output); writer.setSortOrder(header.getSortOrder(), false); if (writeHeader) writer.setHeader(header); }
private void init( OutputStream output, SAMFileHeader header, boolean writeHeader) throws IOException { this.header = header; writer = new SAMTextWriter(output); writer.setSortOrder(header.getSortOrder(), false); if (writeHeader) writer.setHeader(header); }
private void init( OutputStream output, SAMFileHeader header, boolean writeHeader) throws IOException { this.header = header; writer = new SAMTextWriter(output); writer.setSortOrder(header.getSortOrder(), false); if (writeHeader) writer.setHeader(header); }
/** * Create a SAMTextWriter that is ready to receive SAMRecords. * * @param header entire header. Sort order is determined by the sortOrder property of this arg. * @param presorted if true, SAMRecords must be added to the SAMFileWriter in order that agrees with header.sortOrder. * @param outputPath where to write the output. */ public SAMFileWriter makeSAMWriter(final SAMFileHeader header, final boolean presorted, final Path outputPath) { /** * Use the value specified from Defaults.SAM_FLAG_FIELD_FORMAT when samFlagFieldOutput value has not been set. This should * be SamFlagField.DECIMAL when the user has not set Defaults.SAM_FLAG_FIELD_FORMAT. */ if (samFlagFieldOutput == SamFlagField.NONE) { samFlagFieldOutput = Defaults.SAM_FLAG_FIELD_FORMAT; } try { final SAMTextWriter ret = this.createMd5File ? new SAMTextWriter(new Md5CalculatingOutputStream(Files.newOutputStream(outputPath), IOUtil.addExtension(outputPath, ".md5")), samFlagFieldOutput) : new SAMTextWriter(null == outputPath ? null : Files.newOutputStream(outputPath), samFlagFieldOutput); return initWriter(header, presorted, ret); } catch (final IOException ioe) { throw new RuntimeIOException("Error opening file: " + outputPath.toUri(), ioe); } }
/** * Create a SAMTextWriter that is ready to receive SAMRecords. * * @param header entire header. Sort order is determined by the sortOrder property of this arg. * @param presorted if true, SAMRecords must be added to the SAMFileWriter in order that agrees with header.sortOrder. * @param outputPath where to write the output. */ public SAMFileWriter makeSAMWriter(final SAMFileHeader header, final boolean presorted, final Path outputPath) { /** * Use the value specified from Defaults.SAM_FLAG_FIELD_FORMAT when samFlagFieldOutput value has not been set. This should * be SamFlagField.DECIMAL when the user has not set Defaults.SAM_FLAG_FIELD_FORMAT. */ if (samFlagFieldOutput == SamFlagField.NONE) { samFlagFieldOutput = Defaults.SAM_FLAG_FIELD_FORMAT; } try { final SAMTextWriter ret = this.createMd5File ? new SAMTextWriter(new Md5CalculatingOutputStream(Files.newOutputStream(outputPath), IOUtil.addExtension(outputPath, ".md5")), samFlagFieldOutput) : new SAMTextWriter(null == outputPath ? null : Files.newOutputStream(outputPath), samFlagFieldOutput); return initWriter(header, presorted, ret); } catch (final IOException ioe) { throw new RuntimeIOException("Error opening file: " + outputPath.toUri(), ioe); } }
/** * Create a SAMTextWriter that is ready to receive SAMRecords. * @param header entire header. Sort order is determined by the sortOrder property of this arg. * @param presorted if true, SAMRecords must be added to the SAMFileWriter in order that agrees with header.sortOrder. * @param outputFile where to write the output. */ public SAMFileWriter makeSAMWriter(final SAMFileHeader header, final boolean presorted, final File outputFile) { try { final SAMTextWriter ret = this.createMd5File ? new SAMTextWriter(new Md5CalculatingOutputStream(new FileOutputStream(outputFile, false), new File(outputFile.getAbsolutePath() + ".md5"))) : new SAMTextWriter(outputFile); ret.setSortOrder(header.getSortOrder(), presorted); if (maxRecordsInRam != null) { ret.setMaxRecordsInRam(maxRecordsInRam); } ret.setHeader(header); if (this.useAsyncIo) return new AsyncSAMFileWriter(ret, this.asyncOutputBufferSize); else return ret; } catch (final IOException ioe) { throw new RuntimeIOException("Error opening file: " + outputFile.getAbsolutePath()); } }
public static SAMFileWriter createSAMTextWriter(SAMFileWriterFactory factoryOrNull, OutputStream os, SAMFileHeader header, boolean printHeader) throws IOException { SAMFileWriter writer = null; if (printHeader) { if (factoryOrNull == null) factoryOrNull = new SAMFileWriterFactory(); writer = factoryOrNull.makeSAMWriter(header, true, os); } else { SwapOutputStream sos = new SwapOutputStream(); final SAMTextWriter ret = new SAMTextWriter(sos); ret.setSortOrder(header.getSortOrder(), true); ret.setHeader(header); ret.getWriter().flush(); writer = ret; sos.delegate = os; } return writer; }