@Override public Chunk getChunk() { final SAMFileSource source = rec.getFileSource(); if (source == null) { throw new SAMException("No source (virtual file offsets); needed for indexing on BAM Record " + rec); } return ((BAMFileSpan) source.getFilePointer()).getSingleChunk(); } });
/** * Retrieves the id of the reader which built the given read. * @param read The read to test. * @return ID of the reader. */ public SAMReaderID getReaderID(SAMRecord read) { return resourcePool.getReaderID(read.getFileSource().getReader()); }
final long chunkStart = (container.offset << 16) | cramRecord.sliceIndex; final long chunkEnd = ((container.offset << 16) | cramRecord.sliceIndex) + 1; nextRecord.setFileSource(new SAMFileSource(mReader, new BAMFileSpan(new Chunk(chunkStart, chunkEnd))));
/** * 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; }
@Override public Chunk getChunk() { final SAMFileSource source = rec.getFileSource(); if (source == null) { throw new SAMException("No source (virtual file offsets); needed for indexing on BAM Record " + rec); } return ((BAMFileSpan) source.getFilePointer()).getSingleChunk(); } });
final long chunkStart = (container.offset << 16) | cramRecord.sliceIndex; final long chunkEnd = ((container.offset << 16) | cramRecord.sliceIndex) + 1; nextRecord.setFileSource(new SAMFileSource(mReader, new BAMFileSpan(new Chunk(chunkStart, chunkEnd))));
public MisencodedBAM(SAMRecord read, String message) { this(read.getFileSource() != null ? read.getFileSource().getReader().toString() : "(none)", message); }
@Override public Chunk getChunk() { final SAMFileSource source = rec.getFileSource(); if (source == null) { throw new SAMException("No source (virtual file offsets); needed for indexing on BAM Record " + rec); } return ((BAMFileSpan) source.getFilePointer()).getSingleChunk(); } });
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)))); } }
public MalformedBAM(SAMRecord read, String message) { this(read.getFileSource() != null ? read.getFileSource().getReader().toString() : "(none)", message); }
@Override public Chunk getChunk() { final SAMFileSource source = rec.getFileSource(); if (source == null) { throw new SAMException("No source (virtual file offsets); needed for indexing on BAM Record " + rec); } return ((BAMFileSpan) source.getFilePointer()).getSingleChunk(); } });
/** * 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; }
public MissortedBAM(SAMFileHeader.SortOrder order, SAMRecord read, String message) { super(String.format("Missorted input SAM/BAM/CRAM file %s: file sorted in %s order but %s is required. Please see " + HelpConstants.articlePost(1317) + "for more information. Error details: %s", read.getFileSource().getReader(), read.getHeader().getSortOrder(), order, message)); }
@Override public Chunk getChunk() { final SAMFileSource source = rec.getFileSource(); if (source == null) { throw new SAMException("No source (virtual file offsets); needed for indexing on BAM Record " + rec); } return ((BAMFileSpan) source.getFilePointer()).getSingleChunk(); } });
/** * 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; }
/** * Gets the reader associated with the given read. * @param readers Available readers. * @param read * @return */ private SAMReaderID getReaderID(SAMReaders readers, SAMRecord read) { for(SAMReaderID id: getReaderIDs()) { if(readers.getReader(id) == read.getFileSource().getReader()) return id; } throw new ReviewedGATKException("Unable to find id for reader associated with read " + read.getReadName()); }
/** * Process the given record for the index. * @param rec the record from the file being indexed * @throws IOException */ public void processAlignment(final SAMRecord rec) throws IOException { // write an offset for the first record and for the g-th record thereafter (where // g is the granularity), to be consistent with the index method if (count == 0 || (count + 1) % granularity == 0) { SAMFileSource fileSource = rec.getFileSource(); SAMFileSpan filePointer = fileSource.getFilePointer(); writeVirtualOffset(getPos(filePointer)); } count++; }
info.record.setFileSource(new SAMFileSource(mReader, new BAMFileSpan(new Chunk(info.start, info.stop))));
/** * Process the given record for the index. * @param rec the record from the file being indexed * @throws IOException */ public void processAlignment(final SAMRecord rec) throws IOException { // write an offset for the first record and for the g-th record thereafter (where // g is the granularity), to be consistent with the index method if (count == 0 || (count + 1) % granularity == 0) { SAMFileSource fileSource = rec.getFileSource(); SAMFileSpan filePointer = fileSource.getFilePointer(); writeVirtualOffset(getPos(filePointer)); } count++; }
@Override protected void writeAlignment(final SAMRecord alignment) { prepareToWriteAlignments(); if (bamIndexer != null) { try { final long startOffset = blockCompressedOutputStream.getFilePointer(); bamRecordCodec.encode(alignment); final long stopOffset = blockCompressedOutputStream.getFilePointer(); // set the alignment's SourceInfo and then prepare its index information alignment.setFileSource(new SAMFileSource(null, new BAMFileSpan(new Chunk(startOffset, stopOffset)))); bamIndexer.processAlignment(alignment); } catch (Exception e) { bamIndexer = null; throw new SAMException("Exception when processing alignment for BAM index " + alignment, e); } } else { bamRecordCodec.encode(alignment); } }