示例#1
0
    def test_back_transcription_of_proteins(self):
        """Test back-transcription shouldn't work on a protein!"""
        for s in protein_seqs:
            with self.assertRaises(ValueError):
                Seq.back_transcribe(s)

            if isinstance(s, Seq.Seq):
                with self.assertRaises(ValueError):
                    s.back_transcribe()
示例#2
0
    def test_back_transcription_of_proteins(self):
        """Test back-transcription shouldn't work on a protein!"""
        for s in protein_seqs:
            with self.assertRaises(ValueError):
                Seq.back_transcribe(s)

            if isinstance(s, Seq.Seq):
                with self.assertRaises(ValueError):
                    s.back_transcribe()
示例#3
0
 def test_back_transcribe_rna_into_dna(self):
     for nucleotide_seq in test_seqs:
         expected = Seq.back_transcribe(nucleotide_seq)
         self.assertEqual(
             str(nucleotide_seq).replace("u", "t").replace("U", "T"),
             str(expected),
         )
示例#4
0
 def test_seq_object_back_transcription_method(self):
     for nucleotide_seq in test_seqs:
         if isinstance(nucleotide_seq.alphabet, Alphabet.RNAAlphabet) and \
                 isinstance(nucleotide_seq, Seq.Seq):
             expected = Seq.back_transcribe(nucleotide_seq)
             self.assertEqual(repr(nucleotide_seq.back_transcribe()),
                              repr(expected))
示例#5
0
 def test_back_transcribe_rna_into_dna(self):
     for nucleotide_seq in test_seqs:
         if isinstance(nucleotide_seq.alphabet, Alphabet.RNAAlphabet):
             expected = Seq.back_transcribe(nucleotide_seq)
             self.assertEqual(
                 str(nucleotide_seq).replace("u", "t").replace("U", "T"),
                 str(expected))
示例#6
0
    def reversed_transcription(self):
        """Given the seq of type RNA transcribes it to DNA.

        :return: Seq object of type DNA.
        """
        if self.s_type != 'RNA':
            raise TypeError(
                'Sequence type {} can not be transcribed in reverse.'.format(
                    self.s_type))
        return Seq.back_transcribe(self.seq)
示例#7
0
def dna_aa():
    if session.username == None:
        redirect(URL(r=request, c='account', f='log_in'))
    form = FORM(
        TABLE(
            TR(
                'Sequence (raw format):  ',
                TEXTAREA(_type='text',
                         _name='sequence',
                         requires=IS_NOT_EMPTY())),
            #TR("Sequence Type: ",
            #  SELECT("Raw Format", "FASTA",
            #         _name="seq_type")),
            TR(
                'Action: ',
                SELECT('Complementation',
                       'Transcribe',
                       'Translate',
                       'Back Transcribe',
                       'Back Translate',
                       _name='action'), INPUT(_type='submit',
                                              _value='SUBMIT'))))
    if form.accepts(request.vars, session):
        #if form.vars.seq_type == "FASTA":
        #    session['sequence'] = \
        #        seqClean(fasta_to_raw(form.vars.sequence.upper()))
        #else:
        session['sequence'] = seqClean(form.vars.sequence.upper())
        if form.vars.action == "Complementation":
            session['action'] = "Complementation"
            session['Complement'] = Seq.reverse_complement(session['sequence'])
        if form.vars.action == "Transcribe":
            session['action'] = 'Transcribe'
            session['Transcribed RNA'] = Seq.transcribe(session['sequence'])
        if form.vars.action == "Back Transcribe":
            session['action'] = 'Back Transcribe'
            session['DNA'] = Seq.back_transcribe(session['sequence'])
        if form.vars.action == "Translate":
            session['action'] = 'Translate'
            session.update(translate(session['sequence']))
        if form.vars.action == "Back Translate":
            session['action'] = 'Back Translate'
            session.update(back_translate(session['sequence']))
        redirect(URL(r=request, f='dna_aa_output'))
    return dict(form=form)
示例#8
0
def dna_aa():
    if session.username == None:
        redirect(URL(r=request, c='account', f='log_in'))
    form = FORM(TABLE(TR('Sequence (raw format):  ', 
                        TEXTAREA(_type='text', _name='sequence',
                                 requires=IS_NOT_EMPTY())),
                      #TR("Sequence Type: ", 
                      #  SELECT("Raw Format", "FASTA",
                      #         _name="seq_type")),
                      TR('Action: ', 
                        SELECT('Complementation', 'Transcribe', 'Translate', 
                               'Back Transcribe', 'Back Translate',
                               _name='action'),
                      INPUT(_type='submit', _value='SUBMIT'))))
    if form.accepts(request.vars,session):
        #if form.vars.seq_type == "FASTA": 
        #    session['sequence'] = \
        #        seqClean(fasta_to_raw(form.vars.sequence.upper()))
        #else: 
        session['sequence'] = seqClean(form.vars.sequence.upper())
        if form.vars.action == "Complementation":
           session['action'] = "Complementation"
           session['Complement'] = Seq.reverse_complement(session['sequence'])
        if form.vars.action == "Transcribe": 
            session['action'] = 'Transcribe'
            session['Transcribed RNA'] = Seq.transcribe(session['sequence'])
        if form.vars.action == "Back Transcribe": 
            session['action'] = 'Back Transcribe'
            session['DNA'] = Seq.back_transcribe(session['sequence'])
        if form.vars.action == "Translate":
            session['action'] = 'Translate'
            session.update(translate(session['sequence']))
        if form.vars.action == "Back Translate":
            session['action'] = 'Back Translate'
            session.update(back_translate(session['sequence']))
        redirect(URL(r=request, f='dna_aa_output'))
    return dict(form=form)
示例#9
0
 def test_back_transcribe_rna_string_into_dna(self):
     seq = "AUGAAACUG"
     self.assertEqual("ATGAAACTG", Seq.back_transcribe(seq))
示例#10
0
    except ValueError:
        pass
    if not isinstance(s, Seq.Seq):
        continue  # Only Seq has this method
    try:
        print s.transcribe()
        assert False, "Transcription shouldn't work on a protein!"
    except ValueError:
        pass

print
print "Back-transcribe RNA into DNA"
print "============================"
for nucleotide_seq in test_seqs:
    try:
        expected = Seq.back_transcribe(nucleotide_seq)
        assert str(nucleotide_seq).replace("u",
                                           "t").replace("U",
                                                        "T") == str(expected)
        print "%s -> %s" \
        % (repr(nucleotide_seq) , repr(expected))
    except ValueError, e:
        expected = None
        print "%s -> %s" \
        % (repr(nucleotide_seq) , str(e))
    #Now test the Seq object's method
    if isinstance(nucleotide_seq, Seq.Seq):
        try:
            assert repr(expected) == repr(nucleotide_seq.back_transcribe())
        except ValueError:
            assert expected is None
示例#11
0
        assert False, "Transcription shouldn't work on a protein!"
    except ValueError :
        pass
    if not isinstance(s, Seq.Seq) : continue #Only Seq has this method
    try :
        print s.transcribe()
        assert False, "Transcription shouldn't work on a protein!"
    except ValueError :
        pass

print
print "Back-transcribe RNA into DNA"
print "============================"
for nucleotide_seq in test_seqs:
    try :
        expected = Seq.back_transcribe(nucleotide_seq)
        assert str(nucleotide_seq).replace("u","t").replace("U","T") == str(expected)
        print "%s -> %s" \
        % (repr(nucleotide_seq) , repr(expected))
    except ValueError, e :
        expected = None
        print "%s -> %s" \
        % (repr(nucleotide_seq) , str(e))
    #Now test the Seq object's method
    if isinstance(nucleotide_seq, Seq.Seq) :
        try :
            assert repr(expected) == repr(nucleotide_seq.back_transcribe())
        except ValueError :
            assert expected is None
            
for s in protein_seqs :
示例#12
0
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 21 12:38:35 2019

@author: kaysm
"""
from Bio import Seq

Input = open("Translate an RNA String into an Amino Acid String.txt", "r")
sequence = Input.read().split("\n")[0]

Dna = Seq.back_transcribe(sequence)
print(Seq.translate(Dna))
示例#13
0
 def test_seq_object_back_transcription_method(self):
     for nucleotide_seq in test_seqs:
         if isinstance(nucleotide_seq.alphabet, Alphabet.RNAAlphabet) and \
                 isinstance(nucleotide_seq, Seq.Seq):
             expected = Seq.back_transcribe(nucleotide_seq)
             self.assertEqual(repr(nucleotide_seq.back_transcribe()), repr(expected))
示例#14
0
 def test_back_transcribe_rna_string_into_dna(self):
     seq = "AUGAAACUG"
     self.assertEqual("ATGAAACTG", Seq.back_transcribe(seq))
示例#15
0
 def test_back_transcribe_rna_into_dna(self):
     for nucleotide_seq in test_seqs:
         if isinstance(nucleotide_seq.alphabet, Alphabet.RNAAlphabet):
             expected = Seq.back_transcribe(nucleotide_seq)
             self.assertEqual(str(nucleotide_seq).replace("u", "t").replace("U", "T"),
                              str(expected))
示例#16
0
    #print (record.description)

    all_id = record.description
    piRNA_product = all_id.split('|')[0]

    piRNA_ID = ()

    gb_search = re.search(".*\|gb\|.*", all_id)
    if gb_search:
        piRNA_ID = all_id.split('|')[2]
    else:
        piRNA_ID = "NULL"

    #print (record.seq)
    ## transcribe back
    dna_seq = Seq.back_transcribe(record.seq)

    head = ">" + all_id + "\n"
    output_FASTA.write(head)
    output_FASTA.write(str(dna_seq))
    output_FASTA.write("\n")

    ## parse and generate
    Chr = all_id.split(':')[1]
    Start = all_id.split(':')[2]
    End = all_id.split(':')[3]
    Strand = all_id.split(':')[-1]

    ## GTF example
    code_strand = ()
    if (Strand == 'Plus'):