def update(self, snp):
        '''update with snp.'''

        contig = snp.chromosome
        lcontig = self.mFasta.getLength(contig)

        # check for codon:
        self.mReferenceCodons = []
        self.mVariantCodons = []
        self.mReferenceAAs = []
        self.mVariantAAs = []
        self.mVariantType = []

        if snp.pos >= lcontig:
            E.warn("snp is out of range: %s:%i => %s" %
                   (contig, lcontig, ";".join(map(str, snp))))
            self.mCode = "X"
            return

        reference_base = snp.reference_base

        ######
        code = self.mAnnotations.getSequence(contig, "+", snp.pos, snp.pos + 1)
        self.mCode = code

        is_negative_strand = False

        pos = None
        # ignore non-coding SNPs
        if code in 'abcABC':

            pos = "abcABC".find(code)
            is_negative_strand = code in 'ABC'

            if is_negative_strand:
                pos -= 3
                position = lcontig - snp.pos - 1
                strand = "-"
            else:
                position = snp.pos
                strand = "+"

            # start, end are forward/negative strand coordinates
            offset = pos % 3
            start, end = position - offset, position - offset + 3

            # If a codon is split by an intron, several
            # reference codons are possible.
            self.mReferenceCodons = set()
            if self.mJunctions:
                if contig in self.mJunctions:
                    j = self.mJunctions[contig]
                    for x in xrange(start, end):
                        if x in j:
                            # found a junction within codon
                            for junction_strand, next_start, frame in j[x]:

                                # wrong strand
                                if (junction_strand == "-") != is_negative_strand:
                                    continue

                                # codon is complete, junction within frame
                                if frame == 0:
                                    self.mReferenceCodons.add(
                                        self.mFasta.getSequence(contig, strand, start, end).upper())
                                    continue

                                codon = self.mFasta.getSequence( contig, strand, start, x + 1) + \
                                    self.mFasta.getSequence(
                                        contig, strand, next_start, next_start + end - (x + 1))

                                # position within codon
                                y = x + 1 - start
                                E.debug("building a split codon for %s:%s:%i(%i) start=%i, split=%i, cont=%i, end=%i: codon=%s:%s" %
                                        (contig, strand, snp.pos, position, start, x + 1, next_start, next_start + end - (x + 1),
                                         codon[:y], codon[y:]))

                                assert len(codon) == 3
                                self.mReferenceCodons.add(codon.upper())

            # ordinary codon
            if not self.mReferenceCodons:
                self.mReferenceCodons.add(
                    self.mFasta.getSequence(contig, strand, start, end).upper())

            # fixate the order of reference codons
            self.mReferenceCodons = tuple(self.mReferenceCodons)

        # process according to variant type
        # indels need to be treated differently from SNPs as
        # they have larger effects
        if reference_base == "*":
            self.updateIndels(snp, is_negative_strand)
        else:
            self.updateSNPs(snp, is_negative_strand, pos)
dataset/ETHPy150Open CGATOxford/cgat/scripts/snp2table.py/BaseAnnotatorCodon.update/original