示例#1
0
 def testStopCodonsNotInCodonTable(self):
     """
     The stop codons must not be in the main table.
     """
     for stop in STOP_CODONS:
         for codons in CODONS.values():
             self.assertNotIn(stop, codons)
示例#2
0
 def testStopCodonsNotInCodonTable(self):
     """
     The stop codons must not be in the main table.
     """
     for stop in STOP_CODONS:
         for codons in CODONS.values():
             self.assertNotIn(stop, codons)
示例#3
0
 def testCodonContent(self):
     """
     Codons must only contain the letters A, T, G, C.
     """
     for codons in CODONS.values():
         for codon in codons:
             self.assertTrue(all(letter in 'ACGT' for letter in codon))
示例#4
0
 def testCodonContent(self):
     """
     Codons must only contain the letters A, T, G, C.
     """
     for codons in CODONS.values():
         for codon in codons:
             self.assertTrue(all(letter in 'ACGT' for letter in codon))
示例#5
0
 def testCodonsAreNotAbbrev3s(self):
     """
     No codon can be the same as an amino acid 3-letter abbreviation (or
     else our find function may not be unambiguous in what it returns).
     """
     for codons in CODONS.values():
         self.assertFalse(
             any(codon.title() in ABBREV3_TO_ABBREV1 for codon in codons))
示例#6
0
 def testCodonsAreNotAbbrev3s(self):
     """
     No codon can be the same as an amino acid 3-letter abbreviation (or
     else our find function may not be unambiguous in what it returns).
     """
     for codons in CODONS.values():
         self.assertFalse(
             any(codon.title() in ABBREV3_TO_ABBREV1 for codon in codons))
示例#7
0
 def testDistinct(self):
     """
     All nucleotide triples must be distinct.
     """
     seen = set()
     for codons in CODONS.values():
         for codon in codons:
             seen.add(codon)
     self.assertEqual(61, len(seen))
示例#8
0
 def testDistinct(self):
     """
     All nucleotide triples must be distinct.
     """
     seen = set()
     for codons in CODONS.values():
         for codon in codons:
             seen.add(codon)
     self.assertEqual(61, len(seen))
示例#9
0
    def testAllCodonsPresent(self):
        """
        All possible codons must be present, as either coding for an AA
        or as a stop codon.
        """
        combinations = set(''.join(x) for x in product('ACGT', 'ACGT', 'ACGT'))
        for codons in CODONS.values():
            for codon in codons:
                combinations.remove(codon)

        # Just the stop codons should be left.
        self.assertEqual(set(STOP_CODONS), combinations)
示例#10
0
    def testAllCodonsPresent(self):
        """
        All possible codons must be present, as either coding for an AA
        or as a stop codon.
        """
        combinations = set(
            ''.join(x) for x in product('ACGT', 'ACGT', 'ACGT'))
        for codons in CODONS.values():
            for codon in codons:
                combinations.remove(codon)

        # Just the stop codons should be left.
        self.assertEqual(set(STOP_CODONS), combinations)
示例#11
0
def findOrDie(s):
    """
    Look up an amino acid.

    @param s: A C{str} amino acid specifier. This may be a full name,
        a 3-letter abbreviation or a 1-letter abbreviation. Case is ignored.
    @return: An C{AminoAcid} instance, if one can be found. Else exit.
    """
    aa = find(s)
    if aa:
        return aa
    else:
        print("Unknown amino acid or codon: %s" % s, file=sys.stderr)
        print("Valid arguments are: %s." % list(CODONS.keys()), file=sys.stderr)
        sys.exit(1)
示例#12
0
def findOrDie(s):
    """
    Look up an amino acid.

    @param s: A C{str} amino acid specifier. This may be a full name,
        a 3-letter abbreviation or a 1-letter abbreviation. Case is ignored.
    @return: An C{AminoAcid} instance, if one can be found. Else exit.
    """
    aa = find(s)
    if aa:
        return aa
    else:
        print('Unknown amino acid or codon: %s' % s, file=sys.stderr)
        print('Valid arguments are: %s.' % list(CODONS.keys()),
              file=sys.stderr)
        sys.exit(1)
示例#13
0
 def testNumberCodons(self):
     """
     The table must contain the right number of codons.
     """
     self.assertEqual(44, sum(len(codons) for codons in CODONS.values()))
示例#14
0
 def testNumberCodons(self):
     """
     The table must contain the right number of codons.
     """
     self.assertEqual(44, sum(len(codons) for codons in CODONS.values()))
示例#15
0
 def testNumberCodons(self):
     """
     The table must contain 61 codons. This is 4^3 - 3. I.e., all possible
     combinations of 3 bases minus the three stop codons.
     """
     self.assertEqual(61, sum(len(codons) for codons in CODONS.values()))
示例#16
0
 def testCorrectAAs(self):
     """
     The CODONS dict must have the correct AA keys.
     """
     self.assertEqual(AA_LETTERS, sorted(CODONS.keys()))
示例#17
0
 def testCodonLength(self):
     """
     All codons must be three bases long.
     """
     for codons in CODONS.values():
         self.assertTrue(all(len(codon) == 3 for codon in codons))
示例#18
0
#!/usr/bin/env python

import sys
from Bio import SeqIO
from os.path import exists

from dark.aa import CODONS

START_CODON = 'ATG'
STOP_CODONS = {'TAA', 'TAG', 'TGA'}
CODON_TO_AA = {}

START_AA = 'M'
STOP_AA = '*'

for aa, codons in CODONS.items():
    for codon in codons:
        CODON_TO_AA[codon] = aa

for codon in STOP_CODONS:
    CODON_TO_AA[codon] = STOP_AA

_rcTable = str.maketrans('ACGT', 'TGCA')


def revcomp(s):
    """
    Reverse complement a nucleotide string.
    """
    return s.translate(_rcTable)[::-1]
示例#19
0
 def testCodonLength(self):
     """
     All codons must be three bases long.
     """
     for codons in CODONS.values():
         self.assertTrue(all(len(codon) == 3 for codon in codons))
示例#20
0
 def testNumberCodons(self):
     """
     The table must contain 61 codons. This is 4^3 - 3. I.e., all possible
     combinations of 3 bases minus the three stop codons.
     """
     self.assertEqual(61, sum(len(codons) for codons in CODONS.values()))
示例#21
0
 def testCorrectAAs(self):
     """
     The CODONS dict must have the correct AA keys.
     """
     self.assertEqual(AA_LETTERS, sorted(CODONS.keys()))