Class BAMRecord

    • Field Detail

      • CIGAR_SIZE_MULTIPLIER

        public static final short CIGAR_SIZE_MULTIPLIER
        Constant 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:
        Constant Field Values
      • MAX_CIGAR_OPERATORS

        public static final int MAX_CIGAR_OPERATORS
        Maximal 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 placed SN

        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:
        Constant Field Values
      • MAX_CIGAR_ELEMENT_LENGTH

        public static final int MAX_CIGAR_ELEMENT_LENGTH
        See Also:
        Constant Field Values
    • Constructor Detail

      • 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 Detail

      • eagerDecode

        protected void eagerDecode()
        Force all the lazily-initialized attributes to be decoded.
        Overrides:
        eagerDecode in class SAMRecord
      • 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:
        getVariableBinaryRepresentation in class SAMRecord
      • getAttributesBinarySize

        public int getAttributesBinarySize()
        Depending on the concrete implementation, the binary file size of attributes may be known without computing them all.
        Overrides:
        getAttributesBinarySize in class SAMRecord
        Returns:
        binary file size of attribute, if known, else -1.
      • setAttribute

        protected void setAttribute​(short tag,
                                    Object value,
                                    boolean isUnsignedArray)
        Overrides:
        setAttribute in class SAMRecord
      • clearAttributes

        public void clearAttributes()
        Removes all attributes.
        Overrides:
        clearAttributes in class SAMRecord
      • getReadLength

        public int getReadLength()
        Avoids decoding binary block to get read length.
        Overrides:
        getReadLength in class SAMRecord
        Returns:
        number of bases in the read.
      • getReadNameLength

        public int getReadNameLength()
        Avoids decoding read name to get read name length. Do not include null terminator.
        Overrides:
        getReadNameLength in class SAMRecord
        Returns:
        length not including a null terminator.
      • getCigar

        public Cigar getCigar()
        Description copied from class: SAMRecord
        Do 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()
        Overrides:
        getCigar in class SAMRecord
        Returns:
        Cigar object for the read, or null if there is none.
      • getCigarLength

        public int getCigarLength()
        Avoids decoding CIGAR in order to get length.
        Overrides:
        getCigarLength in class SAMRecord
        Returns:
        number of cigar elements (number + operator) in the cigar string.
      • getReadBases

        public byte[] getReadBases()
        Description copied from class: SAMRecord
        Do 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:
        getReadBases in class SAMRecord
        Returns:
        read sequence as ASCII bytes ACGTN=.
      • getBaseQualities

        public byte[] getBaseQualities()
        Description copied from class: SAMRecord
        Do 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:
        getBaseQualities in class SAMRecord
        Returns:
        Base qualities, as binary phred scores (not ASCII).