Exercise

Write an ORF class. To help you along the way here is a template for such a class:


from orfs import translateSequence, splitCodons


class ORF:
    """

    """
    def __init__(self, seq):
        """
        The __init__ method ...
        """
        # make sure that this is an open reading frame
        assert len(seq) % 3 == 0 and seq[:3] == "ATG" and seq[-3:] in ['TAG', 'TGA', 'TAA']

        # make an orf attribute for the class that holds the orf sequence
        self.orf = seq




    def __len__(self):
        """
        The __len__ method ...
        """
        return len(self.orf)/3







    def __str__(self):
        """
        The __str__ method ...
        """
        aaSymbolString = ''
        for aa in translateSequence(self.orf):
            aaSymbolString += ' %s ' % (aa)
        return "%s\n%s" % (aaSymbolString, self.orf)

    def aaSequence(self):
        """
        Returns a string of symbols for the amino acids coded by the ORF
        """
        return translateSequence(self.orf)[:-1]

    def __iter__(self):
        """
        The __iter_ method ...
        """
        for aa in splitCodons(self.orf):
            yield aa




    def __eq__(self, other):
        """
        The __eq__ method ...
        """
        return translateSequence(self.orf) == translateSequence(other.orf)




if __name__ == "__main__":

    orf = ORF("ATGCTCTAA")

    print len(orf)

    print orf

    for aa in orf:
        print aa

    print orf.aaSequence()


    orf2 = ORF("ATGCTCTGA")

    print orf2

    print orf == orf2


Index

Contact info

Office address:
Bioinformatics Research Centre (BiRC)
Aarhus University
C.F. Møllers Allé 8
DK-8000 Aarhus C
Denmark
Office phone:
+45 871 55558
Mobile phone:
3013 8342
Email:
kaspermunch@birc.au.dk