Package htsjdk.samtools.cram.ref
Class ReferenceSource
java.lang.Object
htsjdk.samtools.cram.ref.ReferenceSource
- All Implemented Interfaces:
CRAMReferenceSource
Used to represent a CRAM reference, the backing source for which can either be
a file or the EBI ENA reference service.
NOTE: In a future release, this class will be renamed and the functionality it
contains will be refactored and distributed into one or more separate reference
source implementations, each corresponding to the type of resource backing the
reference.
-
Constructor Summary
ConstructorDescriptionReferenceSource
(ReferenceSequenceFile rsFile) ReferenceSource
(File file) ReferenceSource
(Path path) -
Method Summary
Modifier and TypeMethodDescriptionstatic CRAMReferenceSource
Attempts to construct a default CRAMReferenceSource for use with CRAM files when one has not been explicitly provided.int
byte[]
getReferenceBases
(SAMSequenceRecord record, boolean tryNameVariants) Get the reference bases for an entire reference contig.byte[]
getReferenceBasesByRegion
(SAMSequenceRecord sequenceRecord, int zeroBasedStart, int requestedRegionLength) Get the reference bases for a region of a reference contig.void
setDownloadTriesBeforeFailing
(int downloadTriesBeforeFailing)
-
Constructor Details
-
ReferenceSource
-
ReferenceSource
-
ReferenceSource
-
-
Method Details
-
getDefaultCRAMReferenceSource
Attempts to construct a default CRAMReferenceSource for use with CRAM files when one has not been explicitly provided.- Returns:
- CRAMReferenceSource if one can be acquired. Guaranteed to not be null if none of the listed exceptions is thrown.
- Throws:
IllegalArgumentException
- if the reference_fasta environment variable refers to a a file that doesn't existConstruct a default reference source to use when an explicit reference has not been provided by checking for fallback sources in this order:
- Defaults.REFERENCE_FASTA - the value of the system property "reference_fasta". If set, must refer to a valid reference file.
- ENA Reference Service if it is enabled
-
getReferenceBases
Description copied from interface:CRAMReferenceSource
Get the reference bases for an entire reference contig.- Specified by:
getReferenceBases
in interfaceCRAMReferenceSource
- Parameters:
record
- the SAMSequenceRecord identifying the reference being requestedtryNameVariants
- if true, attempt to match the requested sequence name against the reference by using common name variations, such as adding or removing a leading "chr" prefix from the requested name. if false, use exact match- Returns:
- the upper-cased, normalized (see
Utils.normalizeBase(byte)
) bases representing the requested sequence, or null if the sequence cannot be found
-
getReferenceBasesByRegion
public byte[] getReferenceBasesByRegion(SAMSequenceRecord sequenceRecord, int zeroBasedStart, int requestedRegionLength) Description copied from interface:CRAMReferenceSource
Get the reference bases for a region of a reference contig. If the sequence can be retrieved, but is not long enough to satisfy the requested length, it is permissible to return fewer bases than therequestedRegionLength
. It is the caller's responsibility to detect and handle this case.- Specified by:
getReferenceBasesByRegion
in interfaceCRAMReferenceSource
- Parameters:
sequenceRecord
- the SAMSequenceRecord for the reference contig being requestedzeroBasedStart
- the zero based offset of the starting reference base, must be >= 0requestedRegionLength
- the length of the requested reference region- Returns:
- the bases for the reference region, or null if the sequence cannot be found.
-
getDownloadTriesBeforeFailing
public int getDownloadTriesBeforeFailing() -
setDownloadTriesBeforeFailing
public void setDownloadTriesBeforeFailing(int downloadTriesBeforeFailing)
-