@Override public BAMRecordCodec clone() { // Do not clone the references to codecs, as they must be distinct for each instance. return new BAMRecordCodec(this.header, this.samRecordFactory); }
@Override public BAMRecordCodec clone() { // Do not clone the references to codecs, as they must be distinct for each instance. return new BAMRecordCodec(this.header, this.samRecordFactory); }
Codec(final int numRecords) { this(numRecords, new BAMRecordCodec(null)); }
@Override public BAMRecordCodec clone() { // Do not clone the references to codecs, as they must be distinct for each instance. return new BAMRecordCodec(this.header, this.samRecordFactory); }
public BAMRecordCodec clone() { // Do not clone the references to codecs, as they must be distinct for each instance. return new BAMRecordCodec(this.header, this.samRecordFactory); }
private void prepareToWriteAlignments() { if (bamRecordCodec == null) { bamRecordCodec = new BAMRecordCodec(getFileHeader()); bamRecordCodec.setOutputStream(outputBinaryCodec.getOutputStream(), getFilename()); } }
private void prepareToWriteAlignments() { if (bamRecordCodec == null) { bamRecordCodec = new BAMRecordCodec(getFileHeader()); bamRecordCodec.setOutputStream(outputBinaryCodec.getOutputStream(), getFilename()); } }
@Override public void write(DataOutput out) throws IOException { // In theory, it shouldn't matter whether we give a header to // BAMRecordCodec or not, since the representation of an alignment in BAM // doesn't depend on the header data at all. Only its interpretation // does, and a simple read/write codec shouldn't really have anything to // say about that. (But in practice, it already does matter for decode(), // which is why LazyBAMRecordFactory exists.) final BAMRecordCodec codec = new BAMRecordCodec(record.getHeader()); codec.setOutputStream(new DataOutputWrapper(out)); codec.encode(record); } @Override public void readFields(DataInput in) throws IOException {
private List<SAMRecord> toSAMRecord(BAMRecordView view, SAMFileHeader samHeader) { BAMRecordCodec bc = new BAMRecordCodec(samHeader); bc.setInputStream(new ByteArrayInputStream(view.buf, 0, view.start)); List<SAMRecord> records = new ArrayList<SAMRecord>(); SAMRecord record; while ((record = bc.decode()) != null) { records.add(record); } return records; }
private void init( OutputStream output, SAMFileHeader header, boolean writeHeader) throws IOException { origOutput = output; compressedOut = new BlockCompressedOutputStream(origOutput, null); binaryCodec = new BinaryCodec(compressedOut); recordCodec = new BAMRecordCodec(header); recordCodec.setOutputStream(compressedOut); if (writeHeader) this.writeHeader(header); }
@Override public void write(DataOutput out) throws IOException { // In theory, it shouldn't matter whether we give a header to // BAMRecordCodec or not, since the representation of an alignment in BAM // doesn't depend on the header data at all. Only its interpretation // does, and a simple read/write codec shouldn't really have anything to // say about that. (But in practice, it already does matter for decode(), // which is why LazyBAMRecordFactory exists.) final BAMRecordCodec codec = new BAMRecordCodec(record.getHeader()); codec.setOutputStream(new DataOutputWrapper(out)); codec.encode(record); } @Override public void readFields(DataInput in) throws IOException {
private void prepareToWriteAlignments() { if (bamRecordCodec == null) { bamRecordCodec = new BAMRecordCodec(getFileHeader()); bamRecordCodec.setOutputStream(outputBinaryCodec.getOutputStream(), getFilename()); } }
@Override public void write(DataOutput out) throws IOException { // In theory, it shouldn't matter whether we give a header to // BAMRecordCodec or not, since the representation of an alignment in BAM // doesn't depend on the header data at all. Only its interpretation // does, and a simple read/write codec shouldn't really have anything to // say about that. (But in practice, it already does matter for decode(), // which is why LazyBAMRecordFactory exists.) final BAMRecordCodec codec = new BAMRecordCodec(record.getHeader()); codec.setOutputStream(new DataOutputWrapper(out)); codec.encode(record); } @Override public void readFields(DataInput in) throws IOException {
public BAMSplitGuesser( SeekableStream ss, InputStream headerStream, Configuration conf) throws IOException { inFile = ss; header = SAMHeaderReader.readSAMHeaderFrom(headerStream, conf); referenceSequenceCount = header.getSequenceDictionary().size(); bamCodec = new BAMRecordCodec(null, new LazyBAMRecordFactory()); }
/** * @param advance Trick to enable subclass to do more setup before advancing */ BAMFileIterator(final boolean advance) { this.bamRecordCodec = new BAMRecordCodec(getFileHeader(), samRecordFactory); this.bamRecordCodec.setInputStream(BAMFileReader.this.mStream.getInputStream(), BAMFileReader.this.mStream.getInputFileName()); if (advance) { advance(); } }
/** * @param advance Trick to enable subclass to do more setup before advancing */ BAMFileIterator(final boolean advance) { this.bamRecordCodec = new BAMRecordCodec(getFileHeader(), samRecordFactory); this.bamRecordCodec.setInputStream(BAMFileReader.this.mStream.getInputStream(), BAMFileReader.this.mStream.getInputFileName()); if (advance) { advance(); } }
/** * @param advance Trick to enable subclass to do more setup before advancing */ BAMFileIterator(final boolean advance) { this.bamRecordCodec = new BAMRecordCodec(getFileHeader(), samRecordFactory); this.bamRecordCodec.setInputStream(BAMFileReader.this.mStream.getInputStream(), BAMFileReader.this.mStream.getInputFileName()); if (advance) { advance(); } }
public BAMSplitGuesser( SeekableStream ss, InputStream headerStream, Configuration conf) throws IOException { inFile = ss; header = SAMHeaderReader.readSAMHeaderFrom(headerStream, conf); referenceSequenceCount = header.getSequenceDictionary().size(); bamCodec = new BAMRecordCodec(null, new LazyBAMRecordFactory()); }
private List<SAMRecord> getRecordsAtSplits(File bam, SplittingBAMIndex index) throws IOException { List<SAMRecord> records = new ArrayList<>(); BAMRecordCodec codec = new BAMRecordCodec(samFileHeader); BlockCompressedInputStream bci = new BlockCompressedInputStream(bam); codec.setInputStream(bci); for (Long offset : index.getVirtualOffsets()) { bci.seek(offset); SAMRecord record = codec.decode(); if (record != null) { records.add(record); } } return records; }
CramToBam_OBA_Function(CramHeader header, ReferenceSource referenceSource) { this.header = header; parser = new ContainerParser(header.getSamFileHeader()); f = new Cram2SamRecordFactory(header.getSamFileHeader()); codec = new BAMRecordCodec(header.getSamFileHeader()); n = new CramNormalizer(header.getSamFileHeader(), referenceSource); log.info("converter created"); }