/** * Read the next record from the input stream and convert into a java object. * * @return null if no more records. Should throw exception if EOF is encountered in the middle of * a record. */ @Override public SAMRecord decode() { final Integer recordLength = decodeRecordLength(); if (recordLength == null) { return null; } return decode(recordLength); }
@Override public SAMRecordsForCluster decode() { final SAMRecord zerothRecord = bamCodec.decode(); if (zerothRecord == null) return null; final SAMRecordsForCluster ret = new SAMRecordsForCluster(numRecords); ret.records[0] = zerothRecord; for (int i = 1; i < numRecords; ++i) { ret.records[i] = bamCodec.decode(); if (ret.records[i] == null) { throw new IllegalStateException(String.format("Expected to read %d records but read only %d", numRecords, i)); } } return ret; }
@Override public SAMRecordsForCluster decode() { final SAMRecord zerothRecord = bamCodec.decode(); if (zerothRecord == null) return null; final SAMRecordsForCluster ret = new SAMRecordsForCluster(numRecords); ret.records[0] = zerothRecord; for (int i = 1; i < numRecords; ++i) { ret.records[i] = bamCodec.decode(); if (ret.records[i] == null) { throw new IllegalStateException(String.format("Expected to read %d records but read only %d", numRecords, i)); } } return ret; }
@Override public void readFields(DataInput in) throws IOException { lazyCodec.setInputStream(new DataInputWrapper(in)); record = lazyCodec.decode(); }
@Override public void readFields(DataInput in) throws IOException { lazyCodec.setInputStream(new DataInputWrapper(in)); record = lazyCodec.decode(); }
@Override public void readFields(DataInput in) throws IOException { lazyCodec.setInputStream(new DataInputWrapper(in)); record = lazyCodec.decode(); }
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; }
SAMRecord samRecord = null; List<SAMRecord> records = new ArrayList<SAMRecord>(); while ((samRecord = codec.decode()) != null) { records.add(samRecord); refSet.add(samRecord.getReferenceIndex());
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; }
private void decode(BamRecordDecodingInfo info) { if (info.buffer == null) { // decode directly from the parent codec info.record = bamRecordCodec.decode(info.recordLength); codec.setInputStream(is, mStream.getInputFileName()); info.record = codec.decode(info.recordLength); mAvailableIdleCodec.add(codec); info.buffer = null;
/** * Read the next record from the input stream. */ SAMRecord getNextRecord() throws IOException { final long startCoordinate = mCompressedInputStream.getFilePointer(); final SAMRecord next = bamRecordCodec.decode(); final long stopCoordinate = mCompressedInputStream.getFilePointer(); if(mReader != null && next != null) next.setFileSource(new SAMFileSource(mReader,new BAMFileSpan(new Chunk(startCoordinate,stopCoordinate)))); return next; }
/** * Read the next record from the input stream. */ SAMRecord getNextRecord() throws IOException { final long startCoordinate = mCompressedInputStream.getFilePointer(); final SAMRecord next = bamRecordCodec.decode(); final long stopCoordinate = mCompressedInputStream.getFilePointer(); if(mReader != null && next != null) next.setFileSource(new SAMFileSource(mReader,new BAMFileSpan(new Chunk(startCoordinate,stopCoordinate)))); return next; }
private void advance() { final long startCoordinate = inputStream.getFilePointer(); nextRead = codec.decode(); final long stopCoordinate = inputStream.getFilePointer(); if(reader != null && nextRead != null) PicardNamespaceUtils.setFileSource(nextRead, new SAMFileSource(reader, new GATKBAMFileSpan(new GATKChunk(startCoordinate, stopCoordinate)))); } }
/** * Read the next record from the input stream. */ SAMRecord getNextRecord() throws IOException { final long startCoordinate = mCompressedInputStream.getFilePointer(); final SAMRecord next = bamRecordCodec.decode(); final long stopCoordinate = mCompressedInputStream.getFilePointer(); if(mReader != null && next != null) next.setFileSource(new SAMFileSource(mReader,new BAMFileSpan(new Chunk(startCoordinate,stopCoordinate)))); return next; }
while (b < BLOCKS_NEEDED_FOR_GUESS) SAMRecord record = bamCodec.decode(); if (record == null) { break;
while (b < BLOCKS_NEEDED_FOR_GUESS) SAMRecord record = bamCodec.decode(); if (record == null) { break;
SAMRecord record = bc.decode(); assertThat(record.getReadName(), is("readName")); assertThat(record.getFlags(), is(4));