/** * Get all reference bases in this context. The results are cached in this object for future * queries. Will always return an empty array if there is no backing data source and/or interval * to query. * * <p>Call {@link #setWindow} before calling this method if you want to configure the amount of * extra reference context to include around the current interval * * @return reference bases in this context, as a byte array */ public byte[] getBases() { if (dataSource == null || window == null) { return new byte[0]; } // Only perform a query if we haven't fetched the bases in this context previously if (cachedSequence == null) { cachedSequence = dataSource.queryAndPrefetch(window); } return cachedSequence.getBases(); }
/** * Determines the stop of the expanded reference window, bounded if necessary by the contig. * * @param locus The locus to expand. * @param windowTrailingBases number of bases to attempt to expand relative to the locus end (>= * 0) * @return The end of the expanded window. */ private int calculateWindowStop(final SimpleInterval locus, final int windowTrailingBases) { final int sequenceLength = dataSource.getSequenceDictionary().getSequence(locus.getContig()).getSequenceLength(); return Math.min(locus.getEnd() + windowTrailingBases, sequenceLength); }
/** * Get an iterator over the reference bases in this context. Will return an empty iterator if this * context has no backing data source and/or interval. * * <p>Call {@link #setWindow} before calling this method if you want to configure the amount of * extra reference context to include around the current interval * * @return iterator over the reference bases in this context */ @Override public Iterator<Byte> iterator() { return dataSource != null && window != null ? dataSource.query(window) : new ByteArrayIterator(new byte[0]); }