Exemple #1
0
def test_translate():
    dic = get_transl_table()
    codontab = CodonTable(dic)
    assert len(test_data['dna']) % 3 == 0
    protein = codontab.translate(test_data['dna']).decode('ascii')
    print(protein)
    print(test_data['protein'])
    assert protein[:-1] == test_data['protein']
    assert protein[-1] == '*'
Exemple #2
0
 def render(cls, args, outfile):
     dic = translate.get_transl_table(args.table)
     tab = CodonTable(dic)
     for fn in args.filenames:
         for rec in fasta.read(fn, args.concise):
             if len(rec.seq) % 3:
                 if not args.quiet:
                     msg = 'warning: lenth of seq not a multiple of 3\n'
                     msg += '^debug:\t{}\t{}\t{}'.format(len(rec.seq), fn, rec.cmt)
                     print(msg, file=sys.stderr)
                 if args.skip:
                     continue
                 l = len(rec.seq)
                 rec.seq = rec.seq[:int(l - l % 3)]
             rec.seq = tab.translate(rec.seq)
             fasta.write(outfile, rec)