Class Cigar

  • All Implemented Interfaces:
    Serializable, Iterable<CigarElement>

    public class Cigar
    extends Object
    implements Serializable, Iterable<CigarElement>
    A list of CigarElements, which describes how a read aligns with the reference. E.g. the Cigar string 10M1D25M means * match or mismatch for 10 bases * deletion of 1 base * match or mismatch for 25 bases c.f. http://samtools.sourceforge.net/SAM1.pdf for complete CIGAR specification.
    See Also:
    Serialized Form
    • Constructor Detail

      • Cigar

        public Cigar()
    • Method Detail

      • getCigarElement

        public CigarElement getCigarElement​(int i)
      • numCigarElements

        public int numCigarElements()
      • isEmpty

        public boolean isEmpty()
      • getReferenceLength

        public int getReferenceLength()
        Returns:
        The number of reference bases that the read covers, excluding padding.
      • getPaddedReferenceLength

        public int getPaddedReferenceLength()
        Returns:
        The number of reference bases that the read covers, including padding.
      • getReadLength

        public int getReadLength()
        Returns:
        The number of read bases that the read covers.
      • getReadLength

        public static int getReadLength​(List<CigarElement> cigarElements)
        Returns:
        The number of read bases that the read covers.
      • isValid

        public List<SAMValidationError> isValid​(String readName,
                                                long recordNumber)
        Exhaustive validation of CIGAR. Note that this method deliberately returns null rather than Collections.emptyList() if there are no validation errors, because callers tend to assume that if a non-null list is returned, it is modifiable.
        Parameters:
        readName - For error reporting only. May be null if not known.
        recordNumber - For error reporting only. May be -1 if not known.
        Returns:
        List of validation errors, or null if no errors.
      • fromCigarOperators

        public static Cigar fromCigarOperators​(List<CigarOperator> cigarOperators)
        build a new Cigar object from a list of cigar operators. This can be used if you have the operators associated to each base in the read. e.g: read length =10 with cigar= [M,M,M,M,M,M,M,M,M,M], here fromCigarOperators would generate the cigar '10M' later the user resolved the 'M' to '=' or 'X', the array is now [=,=,=,=,=,X,X,=,=,=] fromCigarOperators would generate the cigar '5M2X3M'
      • containsOperator

        public boolean containsOperator​(CigarOperator operator)
        returns true if the cigar string contains the given operator
      • getFirstCigarElement

        public CigarElement getFirstCigarElement()
        returns the first cigar element
      • getLastCigarElement

        public CigarElement getLastCigarElement()
        returns the last cigar element
      • isLeftClipped

        public boolean isLeftClipped()
        returns true if the cigar string starts With a clipping operator
      • isRightClipped

        public boolean isRightClipped()
        returns true if the cigar string ends With a clipping operator
      • isClipped

        public boolean isClipped()
        returns true if the cigar is clipped
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object