Package htsjdk.samtools
Class BAMRecord
java.lang.Object
htsjdk.samtools.SAMRecord
htsjdk.samtools.BAMRecord
- All Implemented Interfaces:
HtsRecord,Locatable,Serializable,Cloneable
Wrapper class for binary BAM records.
Delays unpacking all data binary until requested.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class htsjdk.samtools.SAMRecord
SAMRecord.SAMTagAndValue -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final shortConstant for converting between the number of operators in a Cigar and the length of the int[] array needed to represent it in the BAM formatstatic final intstatic final intMaximal number of cigar operators that can be represented normally in the cigar part of the bam record.Fields inherited from class htsjdk.samtools.SAMRecord
MAX_INSERT_SIZE, mMateReferenceIndex, mReferenceIndex, NO_ALIGNMENT_CIGAR, NO_ALIGNMENT_REFERENCE_INDEX, NO_ALIGNMENT_REFERENCE_NAME, NO_ALIGNMENT_START, NO_MAPPING_QUALITY, NULL_QUALS, NULL_QUALS_STRING, NULL_SEQUENCE, NULL_SEQUENCE_STRING, serialVersionUID, TAGS_TO_REVERSE, TAGS_TO_REVERSE_COMPLEMENT, UNKNOWN_MAPPING_QUALITY -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBAMRecord(SAMFileHeader header, int referenceID, int coordinate, short readNameLength, short mappingQuality, int indexingBin, int cigarLen, int flags, int readLen, int mateReferenceID, int mateCoordinate, int insertSize, byte[] restOfData) Create a new BAM Record. -
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves all attributes.protected voidForce all the lazily-initialized attributes to be decoded.getAttribute(short tag) intDepending on the concrete implementation, the binary file size of attributes may be known without computing them all.byte[]Do not modify the value returned by this method.protected SAMBinaryTagAndValuegetCigar()Do not modify the value returned by this method.intAvoids decoding CIGAR in order to get length.byte[]Do not modify the value returned by this method.intAvoids decoding binary block to get read length.intAvoids decoding read name to get read name length.byte[]If this record has a valid binary representation of the variable-length portion of a binary record stored, return that byte array, otherwise return null.protected voidsetAttribute(short tag, Object value, boolean isUnsignedArray) voidsetBaseQualities(byte[] value) voidFor setting the Cigar string when changed.voidsetCigarString(String value) voidsetReadBases(byte[] value) voidsetReadName(String value) Methods inherited from class htsjdk.samtools.SAMRecord
clone, computeIndexingBinIfAbsent, deepCopy, equals, format, getAlignmentBlocks, getAlignmentEnd, getAlignmentStart, getAttribute, getAttribute, getAttributes, getBaseQualityString, getByteArrayAttribute, getByteArrayAttribute, getByteAttribute, getByteAttribute, getCharacterAttribute, getCharacterAttribute, getCigarString, getContig, getDuplicateReadFlag, getEnd, getFileSource, getFirstOfPairFlag, getFlags, getFloatArrayAttribute, getFloatArrayAttribute, getFloatAttribute, getFloatAttribute, getHeader, getInferredInsertSize, getIntegerAttribute, getIntegerAttribute, getMappingQuality, getMateAlignmentStart, getMateNegativeStrandFlag, getMateReferenceIndex, getMateReferenceName, getMateUnmappedFlag, getNotPrimaryAlignmentFlag, getOriginalBaseQualities, getPairedReadName, getProperPairFlag, getReadFailsVendorQualityCheckFlag, getReadGroup, getReadNegativeStrandFlag, getReadPairedFlag, getReadPositionAtReferencePosition, getReadPositionAtReferencePosition, getReadPositionAtReferencePosition, getReadString, getReadUnmappedFlag, getReferenceIndex, getReferenceName, getReferencePositionAtReadPosition, getReferencePositionAtReadPosition, getSAMFlags, getSAMString, getSecondOfPairFlag, getShortAttribute, getShortAttribute, getSignedByteArrayAttribute, getSignedByteArrayAttribute, getSignedIntArrayAttribute, getSignedIntArrayAttribute, getSignedShortArrayAttribute, getSignedShortArrayAttribute, getStart, getStringAttribute, getStringAttribute, getSupplementaryAlignmentFlag, getTransientAttribute, getUnclippedEnd, getUnclippedStart, getUnsignedByteArrayAttribute, getUnsignedByteArrayAttribute, getUnsignedIntArrayAttribute, getUnsignedIntArrayAttribute, getUnsignedIntegerAttribute, getUnsignedIntegerAttribute, getUnsignedIntegerAttribute, getUnsignedShortArrayAttribute, getUnsignedShortArrayAttribute, getValidationStringency, hasAttribute, hasAttribute, hashCode, initializeCigar, isAllowedAttributeValue, isSecondaryAlignment, isSecondaryOrSupplementary, isUnsignedArrayAttribute, isValid, isValid, removeTransientAttribute, resolveIndexFromName, resolveNameFromIndex, reverseComplement, reverseComplement, reverseComplement, setAlignmentStart, setAttribute, setAttribute, setAttribute, setAttribute, setAttributes, setBaseQualityString, setDuplicateReadFlag, setFileSource, setFirstOfPairFlag, setFlags, setHeader, setHeaderStrict, setInferredInsertSize, setMappingQuality, setMateAlignmentStart, setMateNegativeStrandFlag, setMateReferenceIndex, setMateReferenceName, setMateUnmappedFlag, setNotPrimaryAlignmentFlag, setOriginalBaseQualities, setProperPairFlag, setReadFailsVendorQualityCheckFlag, setReadNegativeStrandFlag, setReadPairedFlag, setReadString, setReadUmappedFlag, setReadUnmappedFlag, setReferenceIndex, setReferenceName, setSecondaryAlignment, setSecondOfPairFlag, setSupplementaryAlignmentFlag, setTransientAttribute, setUnsignedArrayAttribute, setValidationStringency, toString, validateCigarMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface htsjdk.samtools.util.Locatable
contains, contigsMatch, getLengthOnReference, overlaps, withinDistanceOf
-
Field Details
-
CIGAR_SIZE_MULTIPLIER
public static final short CIGAR_SIZE_MULTIPLIERConstant for converting between the number of operators in a Cigar and the length of the int[] array needed to represent it in the BAM format- See Also:
-
MAX_CIGAR_OPERATORS
public static final int MAX_CIGAR_OPERATORSMaximal number of cigar operators that can be represented normally in the cigar part of the bam record. Records that have larger cigars will have their Cigars encoded to int[] and placed in the CG tag in the attributes (BAM only) This should happen upon encoding. In place of the Cigar a sentinel value will be placedS N When a BAM record is decoded, the sentinel cigar informs of the existance of the CG tag, which is decoded and removed. The sentinel value is then replaced with the actual cigar (in memory).
- See Also:
-
MAX_CIGAR_ELEMENT_LENGTH
public static final int MAX_CIGAR_ELEMENT_LENGTH- See Also:
-
-
Constructor Details
-
BAMRecord
protected BAMRecord(SAMFileHeader header, int referenceID, int coordinate, short readNameLength, short mappingQuality, int indexingBin, int cigarLen, int flags, int readLen, int mateReferenceID, int mateCoordinate, int insertSize, byte[] restOfData) Create a new BAM Record. If the reference sequence index or mate reference sequence index are any value other than NO_ALIGNMENT_REFERENCE_INDEX (-1), then the specified index values must exist in the sequence dictionary in the header argument.
-
-
Method Details
-
eagerDecode
protected void eagerDecode()Force all the lazily-initialized attributes to be decoded.- Overrides:
eagerDecodein classSAMRecord
-
getVariableBinaryRepresentation
public byte[] getVariableBinaryRepresentation()If this record has a valid binary representation of the variable-length portion of a binary record stored, return that byte array, otherwise return null. This will never be true for SAMRecords. It will be true for BAMRecords that have not been eagerDecoded(), and for which none of the data in the variable-length portion has been changed.- Overrides:
getVariableBinaryRepresentationin classSAMRecord
-
getAttributesBinarySize
public int getAttributesBinarySize()Depending on the concrete implementation, the binary file size of attributes may be known without computing them all.- Overrides:
getAttributesBinarySizein classSAMRecord- Returns:
- binary file size of attribute, if known, else -1.
-
setReadName
- Overrides:
setReadNamein classSAMRecord
-
setCigar
Description copied from class:SAMRecordFor setting the Cigar string when changed. Note that this nulls the indexing bin, which would need to be recomputed on write (if needed). To avoid clobbering the indexing bin, useSAMRecord.initializeCigar(htsjdk.samtools.Cigar) -
setCigarString
- Overrides:
setCigarStringin classSAMRecord
-
setReadBases
public void setReadBases(byte[] value) - Overrides:
setReadBasesin classSAMRecord
-
setBaseQualities
public void setBaseQualities(byte[] value) - Overrides:
setBaseQualitiesin classSAMRecord
-
setAttribute
- Overrides:
setAttributein classSAMRecord
-
clearAttributes
public void clearAttributes()Removes all attributes.- Overrides:
clearAttributesin classSAMRecord
-
getReadLength
public int getReadLength()Avoids decoding binary block to get read length.- Overrides:
getReadLengthin classSAMRecord- Returns:
- number of bases in the read.
-
getReadName
- Overrides:
getReadNamein classSAMRecord
-
getReadNameLength
public int getReadNameLength()Avoids decoding read name to get read name length. Do not include null terminator.- Overrides:
getReadNameLengthin classSAMRecord- Returns:
- length not including a null terminator.
-
getCigar
Description copied from class:SAMRecordDo not modify the value returned by this method. If you want to change the Cigar, create a new Cigar and call setCigar() or call setCigarString() -
getCigarLength
public int getCigarLength()Avoids decoding CIGAR in order to get length.- Overrides:
getCigarLengthin classSAMRecord- Returns:
- number of cigar elements (number + operator) in the cigar string.
-
getReadBases
public byte[] getReadBases()Description copied from class:SAMRecordDo not modify the value returned by this method. If you want to change the bases, create a new byte[] and call setReadBases() or call setReadString().- Overrides:
getReadBasesin classSAMRecord- Returns:
- read sequence as ASCII bytes ACGTN=.
-
getBaseQualities
public byte[] getBaseQualities()Description copied from class:SAMRecordDo not modify the value returned by this method. If you want to change the qualities, create a new byte[] and call setBaseQualities() or call setBaseQualityString().- Overrides:
getBaseQualitiesin classSAMRecord- Returns:
- Base qualities, as binary phred scores (not ASCII).
-
getAttribute
- Overrides:
getAttributein classSAMRecord- Parameters:
tag- Binary representation of a 2-char String tag as created by SAMTagUtil.- See Also:
-
getBinaryAttributes
- Overrides:
getBinaryAttributesin classSAMRecord- Returns:
- Pointer to the first of the tags. Returns null if there are no tags.
-