Package htsjdk.samtools.cram.structure
Class CRAMCompressionRecord
- java.lang.Object
-
- htsjdk.samtools.cram.structure.CRAMCompressionRecord
-
public class CRAMCompressionRecord extends Object
A CRAMRecord represents a SAMRecord that has been transformed to CRAM-style representation. This includes representing read bases as reference-relative read features, and representation of quality scores, tags, and BAM and CRAM flags.
-
-
Field Summary
Fields Modifier and Type Field Description static intCF_DETACHEDstatic intCF_HAS_MATE_DOWNSTREAMstatic intCF_QS_PRESERVED_AS_ARRAYstatic intCF_UNKNOWN_BASESstatic intMF_MATE_NEG_STRANDstatic intMF_MATE_UNMAPPEDstatic byteMISSING_QUALITY_SCOREstatic intNO_READGROUP_ID
-
Constructor Summary
Constructors Constructor Description CRAMCompressionRecord(long sequentialIndex, int bamFlags, int cramFlags, String readName, int readLength, int referenceIndex, int alignmentStart, int templateSize, int mappingQuality, byte[] qualityScores, byte[] readBases, List<ReadTag> readTags, List<ReadFeature> readFeaturesList, int readGroupID, int mateFlags, int mateReferenceIndex, int mateAlignmentStart, int recordsToNextFragment)Create a CRAMRecord from a set of values retrieved from a serialized Slice's data series streams.CRAMCompressionRecord(CRAMVersion cramVersion, CRAMEncodingStrategy encodingStrategy, SAMRecord samRecord, byte[] referenceBases, long sequentialIndex, Map<String,Integer> readGroupMap)Create a CRAMRecord from a SAMRecord.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidassignReadName()booleanequals(Object o)intgetAlignmentEnd()intgetAlignmentStart()intgetBAMFlags()intgetCRAMFlags()intgetMappingQuality()intgetMateAlignmentStart()intgetMateFlags()intgetMateReferenceIndex()CRAMCompressionRecordgetNextSegment()CRAMCompressionRecordgetPreviousSegment()byte[]getQualityScores()byte[]getReadBases()List<ReadFeature>getReadFeatures()intgetReadGroupID()intgetReadLength()StringgetReadName()intgetRecordsToNextFragment()intgetReferenceIndex()longgetSequentialIndex()MutableIntgetTagIdsIndex()List<ReadTag>getTags()intgetTemplateSize()inthashCode()booleanisDetached()static booleanisDetached(int cramFlags)booleanisFirstSegment()booleanisForcePreserveQualityScores()static booleanisForcePreserveQualityScores(int cramFlags)booleanisHasMateDownStream()static booleanisHasMateDownStream(int cramFlags)booleanisLastSegment()booleanisNormalized()When a CRAM record is read from a CRAM stream, it is "raw" in that the record's read bases, quality scores, and mate graph are not stored directly as part of the record.booleanisPlaced()Determine is read is "placed".booleanisReadPaired()booleanisSecondaryAlignment()booleanisSegmentUnmapped()Does this record have the mapped flag set? This is independent of placement/alignment status.static booleanisSegmentUnmapped(int bamFlags)booleanisUnknownBases()static booleanisUnknownBases(int cramFlags)voidresolveQualityScores()Resolve the quality scores for this CRAM record based on preserved scores, read features and flags.voidrestoreMateInfo()voidrestoreReadBases(byte[] referenceBases, int zeroBasedReferenceOffset, SubstitutionMatrix substitutionMatrix)voidsetDetached(boolean detached)voidsetNextSegment(CRAMCompressionRecord nextSegment)voidsetPreviousSegment(CRAMCompressionRecord previousSegment)voidsetTagIdsIndex(MutableInt tagIdsIndex)voidsetToDetachedState()SAMRecordtoSAMRecord(SAMFileHeader samFileHeader)Create a SAMRecord from the CRAMRecord.
-
-
-
Field Detail
-
CF_QS_PRESERVED_AS_ARRAY
public static final int CF_QS_PRESERVED_AS_ARRAY
- See Also:
- Constant Field Values
-
CF_DETACHED
public static final int CF_DETACHED
- See Also:
- Constant Field Values
-
CF_HAS_MATE_DOWNSTREAM
public static final int CF_HAS_MATE_DOWNSTREAM
- See Also:
- Constant Field Values
-
CF_UNKNOWN_BASES
public static final int CF_UNKNOWN_BASES
- See Also:
- Constant Field Values
-
NO_READGROUP_ID
public static final int NO_READGROUP_ID
- See Also:
- Constant Field Values
-
MISSING_QUALITY_SCORE
public static final byte MISSING_QUALITY_SCORE
- See Also:
- Constant Field Values
-
MF_MATE_NEG_STRAND
public static final int MF_MATE_NEG_STRAND
- See Also:
- Constant Field Values
-
MF_MATE_UNMAPPED
public static final int MF_MATE_UNMAPPED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CRAMCompressionRecord
public CRAMCompressionRecord(CRAMVersion cramVersion, CRAMEncodingStrategy encodingStrategy, SAMRecord samRecord, byte[] referenceBases, long sequentialIndex, Map<String,Integer> readGroupMap)
Create a CRAMRecord from a SAMRecord.- Parameters:
cramVersion-encodingStrategy-samRecord-referenceBases-sequentialIndex-readGroupMap-
-
CRAMCompressionRecord
public CRAMCompressionRecord(long sequentialIndex, int bamFlags, int cramFlags, String readName, int readLength, int referenceIndex, int alignmentStart, int templateSize, int mappingQuality, byte[] qualityScores, byte[] readBases, List<ReadTag> readTags, List<ReadFeature> readFeaturesList, int readGroupID, int mateFlags, int mateReferenceIndex, int mateAlignmentStart, int recordsToNextFragment)Create a CRAMRecord from a set of values retrieved from a serialized Slice's data series streams.- Parameters:
sequentialIndex-bamFlags-cramFlags-readName-readLength-referenceIndex-alignmentStart-templateSize-mappingQuality-qualityScores-readBases-readTags-readFeaturesList-readGroupID-mateFlags-mateReferenceIndex-mateAlignmentStart-recordsToNextFragment-
-
-
Method Detail
-
toSAMRecord
public SAMRecord toSAMRecord(SAMFileHeader samFileHeader)
Create a SAMRecord from the CRAMRecord.- Parameters:
samFileHeader- SAMFileHeader- Returns:
- a SAMRecord
-
assignReadName
public void assignReadName()
-
isNormalized
public boolean isNormalized()
When a CRAM record is read from a CRAM stream, it is "raw" in that the record's read bases, quality scores, and mate graph are not stored directly as part of the record. These values must be resolved through the separate process of normalization, which is performed at Slice granularity (all records in a Slice are normalized at the same time). (seeSlice#normalizeCRAMRecords(List, CRAMReferenceRegion, SubstitutionMatrix)).- Returns:
- true if this record is normalized
-
resolveQualityScores
public void resolveQualityScores()
Resolve the quality scores for this CRAM record based on preserved scores, read features and flags.
-
restoreReadBases
public void restoreReadBases(byte[] referenceBases, int zeroBasedReferenceOffset, SubstitutionMatrix substitutionMatrix)- Parameters:
referenceBases- reference bases for this reference, if one is required (may be null for records with RR=false in the compression header)zeroBasedReferenceOffset- zero-based reference offset of the first base inreferenceBasessubstitutionMatrix- substitution matrix
-
restoreMateInfo
public void restoreMateInfo()
-
setToDetachedState
public void setToDetachedState()
-
isPlaced
public boolean isPlaced()
Determine is read is "placed". For consistency with the rest of htsjdk, this only consults the alignmentStart (placed reads should also have a valid reference index, and unplaced reads should be unmapped; those two abberant conditions are logged as warnings).- Returns:
- true if the record is placed
- See Also:
isSegmentUnmapped()
-
getReadName
public String getReadName()
-
getAlignmentStart
public int getAlignmentStart()
-
getReadLength
public int getReadLength()
-
getReadBases
public byte[] getReadBases()
-
getQualityScores
public byte[] getQualityScores()
-
getMappingQuality
public int getMappingQuality()
-
getReferenceIndex
public int getReferenceIndex()
-
getTemplateSize
public int getTemplateSize()
-
getRecordsToNextFragment
public int getRecordsToNextFragment()
-
getReadFeatures
public List<ReadFeature> getReadFeatures()
-
getReadGroupID
public int getReadGroupID()
- Returns:
- read group id, or
NO_READGROUP_IDif no read group assigned
-
getBAMFlags
public int getBAMFlags()
-
getMateReferenceIndex
public int getMateReferenceIndex()
-
getMateAlignmentStart
public int getMateAlignmentStart()
-
setTagIdsIndex
public void setTagIdsIndex(MutableInt tagIdsIndex)
-
getTagIdsIndex
public MutableInt getTagIdsIndex()
-
getMateFlags
public int getMateFlags()
-
getCRAMFlags
public int getCRAMFlags()
-
getAlignmentEnd
public int getAlignmentEnd()
- Returns:
- the initialized alignmentEnd
-
getSequentialIndex
public long getSequentialIndex()
-
getNextSegment
public CRAMCompressionRecord getNextSegment()
-
setNextSegment
public void setNextSegment(CRAMCompressionRecord nextSegment)
-
getPreviousSegment
public CRAMCompressionRecord getPreviousSegment()
-
setPreviousSegment
public void setPreviousSegment(CRAMCompressionRecord previousSegment)
-
isSecondaryAlignment
public boolean isSecondaryAlignment()
-
isHasMateDownStream
public boolean isHasMateDownStream()
-
isHasMateDownStream
public static boolean isHasMateDownStream(int cramFlags)
-
isDetached
public boolean isDetached()
-
isDetached
public static boolean isDetached(int cramFlags)
-
isForcePreserveQualityScores
public boolean isForcePreserveQualityScores()
-
isForcePreserveQualityScores
public static boolean isForcePreserveQualityScores(int cramFlags)
-
isUnknownBases
public boolean isUnknownBases()
-
isUnknownBases
public static boolean isUnknownBases(int cramFlags)
-
isReadPaired
public boolean isReadPaired()
-
isSegmentUnmapped
public boolean isSegmentUnmapped()
Does this record have the mapped flag set? This is independent of placement/alignment status. Unmapped records may be stored in the sameSlices andContainers as mapped records if they are placed.- Returns:
- true if the record is unmapped
- See Also:
isPlaced()
-
isSegmentUnmapped
public static boolean isSegmentUnmapped(int bamFlags)
-
isFirstSegment
public boolean isFirstSegment()
-
isLastSegment
public boolean isLastSegment()
-
setDetached
public void setDetached(boolean detached)
-
-