Package htsjdk.samtools.cram.ref
Class ReferenceSource
- java.lang.Object
-
- htsjdk.samtools.cram.ref.ReferenceSource
-
- All Implemented Interfaces:
CRAMReferenceSource
public class ReferenceSource extends Object implements 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
Constructors Constructor Description ReferenceSource(ReferenceSequenceFile rsFile)
ReferenceSource(File file)
ReferenceSource(Path path)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clearCache()
static CRAMReferenceSource
getDefaultCRAMReferenceSource()
Attempts to construct a default CRAMReferenceSource for use with CRAM files when one has not been explicitly provided.int
getDownloadTriesBeforeFailing()
byte[]
getReferenceBases(SAMSequenceRecord record, boolean tryNameVariants)
getReferenceBasesvoid
setDownloadTriesBeforeFailing(int downloadTriesBeforeFailing)
-
-
-
Constructor Detail
-
ReferenceSource
public ReferenceSource(File file)
-
ReferenceSource
public ReferenceSource(Path path)
-
ReferenceSource
public ReferenceSource(ReferenceSequenceFile rsFile)
-
-
Method Detail
-
getDefaultCRAMReferenceSource
public static CRAMReferenceSource 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:
IllegalStateException
- if no default reference source can be acquiredIllegalArgumentException
- 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
-
clearCache
public void clearCache()
-
getReferenceBases
public byte[] getReferenceBases(SAMSequenceRecord record, boolean tryNameVariants)
Description copied from interface:CRAMReferenceSource
getReferenceBases- 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
-
getDownloadTriesBeforeFailing
public int getDownloadTriesBeforeFailing()
-
setDownloadTriesBeforeFailing
public void setDownloadTriesBeforeFailing(int downloadTriesBeforeFailing)
-
-