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

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

            if isinstance(s, Seq.Seq):
                with self.assertRaises(ValueError):
                    s.transcribe()
示例#3
0
 def test_seq_object_transcription_method(self):
     for nucleotide_seq in test_seqs:
         if isinstance(nucleotide_seq, Seq.Seq):
             self.assertEqual(
                 repr(Seq.transcribe(nucleotide_seq)),
                 repr(nucleotide_seq.transcribe()),
             )
示例#4
0
 def test_transcription_dna_into_rna(self):
     for nucleotide_seq in test_seqs:
         expected = Seq.transcribe(nucleotide_seq)
         self.assertEqual(
             str(nucleotide_seq).replace("t", "u").replace("T", "U"),
             str(expected),
         )
示例#5
0
 def test_transcription_dna_into_rna(self):
     for nucleotide_seq in test_seqs:
         if isinstance(nucleotide_seq.alphabet, Alphabet.DNAAlphabet):
             expected = Seq.transcribe(nucleotide_seq)
             self.assertEqual(
                 str(nucleotide_seq).replace("t", "u").replace("T", "U"),
                 str(expected))
示例#6
0
def print_proteins_and_codons_using_mitocondrial_yeast_table(seq):
    dna = Seq(seq)
    mRna = dna.transcribe()
     
    #Diccionario 
    d = {}
    d["mRNA"] = [mRna]
    d["protein"] = []
    d["stop_codon"] = []

    #Revisar si tiene codon de inicio
    codon_inicio = False
    for codon in range(0,len(dna),3):
        if "ATG" in dna[codon:codon+3]:
            #Variable con la posicion del primer aa del codon de inicio
            posicion_inicio = codon
            dnaCoding = dna[codon:len(dna)]
            
            d["protein"] = dnaCoding.translate(to_stop = True, table = 3)
            #Si hay codon de inicio
            codon_inicio = True
            #Solo para encontrar un codon 
            break

        if "ATA" in dna[codon:codon+3]:
            #Variable con la posicion del primer aa del codon de inicio
            posicion_inicio = codon
            dnaCoding = dna[codon:len(dna)]
            
            d["protein"] = dnaCoding.translate(to_stop = True, table = 3)
            #Si hay codon de inicio
            codon_inicio = True
            #Solo para encontrar un codon 
            break

        if "GTG" in dna[codon:codon+3]:
            #Variable con la posicion del primer aa del codon de inicio
            posicion_inicio = codon
            dnaCoding = dna[codon:len(dna)]
            
            d["protein"] = dnaCoding.translate(to_stop = True, table = 3)
            #Si hay codon de inicio
            codon_inicio = True
            #Solo para encontrar un codon 
            break

    #Si si lo hay buscar codon de paro despues del codon de inicio  
    if codon_inicio == True:
        for codon in range(0,len(dna),3):
            #print(dna[codon:codon+3])
            if ("TAG" in dna[codon:codon+3]) & (posicion_inicio < codon):
                d["stop_codon"].append("TAG")
                break
            if ("TAA" in dna[codon:codon+3]) & (posicion_inicio < codon):
                d["stop_codon"].append("TAA")
                break
            
    return d
示例#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_transcription_dna_string_into_rna(self):
     seq = "ATGAAACTG"
     self.assertEqual("AUGAAACUG", Seq.transcribe(seq))
示例#10
0
#Sanity test on the test sequence alphabets (see also enhancement bug 2597)
for nucleotide_seq in test_seqs:
    if hasattr(nucleotide_seq, "alphabet"):
        if "U" in str(nucleotide_seq).upper():
            assert not isinstance(nucleotide_seq.alphabet,
                                  Alphabet.DNAAlphabet)
        if "T" in str(nucleotide_seq).upper():
            assert not isinstance(nucleotide_seq.alphabet,
                                  Alphabet.RNAAlphabet)

print
print "Transcribe DNA into RNA"
print "======================="
for nucleotide_seq in test_seqs:
    try:
        expected = Seq.transcribe(nucleotide_seq)
        assert str(nucleotide_seq).replace("t",
                                           "u").replace("T",
                                                        "U") == 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.transcribe())
        except ValueError:
            assert expected is None
示例#11
0
# Import the sequence from the Biopython library
from Bio.Seq import *

def complement(seq):
    comp_seq=""
    mapping =  {'A':'T', "C":"G", "G":"C", "T":"A"}
    for nucleotide in gene:
        comp_seq += mapping[nucleotide]
    return comp_seq;

def reverse(seq):
    rev_seq = seq[::-1]
    return rev_seq

if __name__ == '__main__':
    gene = "TCAGACTGGTGCCGTGGTGCTCTCGCCCGATGTGACGTCGACCGCCAGCGGCGCGATGACGCCGAGGATTTCCGTGATCGTTTCGGAGGGCACGCCGGCTGCGGTCAGCGCGTCGGCCAAGTGTCCGGCGACCAGGCTGAAGTGGTGCATGGTAATTCCGCGCCCCTGATGGACTTGCTTCATCGGCGCACCGGTATAGGGCTCGGGCCCGCCAAGCGCGGCCGCGAAAAACTCCACCTGCTTGCCCTTGAGGCGGCTCATGTTCGTACCGCTGAAGAAGGCCGATAGTTGGTCATCGGCAAGCACACGAACATAGAAGTCCTCGACGACGACTTCGATGGCCTCATGCCCGCCGATCTTGTCGTAGATGCTGATCGGCTCACGTTTGCGCAAGCGTGACAGTAGTCCCATTTTTATA"
    res = reverse(complement(gene))
    print(res)
    # Define a sequence as a DNA Seq object
    seq = Seq("CCTCAGCGAGGACAGCAAGGGACTAGCC")

    # The complement() method can act just like your complement() function.
    complement = seq.complement()
    # Similarly, we can use the reverse_complement() method.
    reverse_complement = seq.reverse_complement()
    # We can even use the transcribe() method to switch alphabets to RNA
    RNA = seq.transcribe()
    print(RNA)
示例#12
0
#Sanity test on the test sequence alphabets (see also enhancement bug 2597)
for nucleotide_seq in test_seqs :
    if hasattr(nucleotide_seq, "alphabet") :
        if "U" in str(nucleotide_seq).upper() :
            assert not isinstance(nucleotide_seq.alphabet, Alphabet.DNAAlphabet)
        if "T" in str(nucleotide_seq).upper() :
            assert not isinstance(nucleotide_seq.alphabet, Alphabet.RNAAlphabet)
            

print
print "Transcribe DNA into RNA"
print "======================="
for nucleotide_seq in test_seqs:
    try :
        expected = Seq.transcribe(nucleotide_seq)
        assert str(nucleotide_seq).replace("t","u").replace("T","U") == 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.transcribe())
        except ValueError :
            assert expected is None

for s in protein_seqs :
示例#13
0
                    print("Stop found:", seqs[temp_window:temp_window + 3])
                    temp_result.append(
                        temp_window +
                        3)  # Stores stop codon index in list with start codon.
                    break
                temp_window += 3  # Iterates by 3, codon size.

            # print(temp_result)
            # print(seqs[temp_result[0]: temp_result[1]])
            # result_seqs.append(seqs[temp_result[0]: temp_result[1]])

            # Adds protein to list from stored index locations, only if a stop codon is present at the end e.g.
            # a stop codon was found before the end of the sequence.
            try:
                dna = seqs[temp_result[0]:temp_result[1]]
                rna = Seq.transcribe(dna)
                protein = Seq.translate(rna, stop_symbol="")
                print(protein)
                if protein not in result_seqs:  # Stops the addition of duplicate peptides
                    result_seqs.append(protein)

            except IndexError:
                pass

        window += 1

print(result_seqs)

# Writes sequences to file.

file = open("result_peptides.txt", "w")
示例#14
0
def transcription(seqData):
    dnaSeq = Seq(seqData[::-1])
    return dnaSeq.transcribe()

#manipulateSeqFromFile("data/dna_chromosome_1.seq")
示例#15
0
 def test_seq_object_transcription_method(self):
     for nucleotide_seq in test_seqs:
         if isinstance(nucleotide_seq.alphabet, Alphabet.DNAAlphabet) and \
                 isinstance(nucleotide_seq, Seq.Seq):
             self.assertEqual(repr(Seq.transcribe(nucleotide_seq)),
                              repr(nucleotide_seq.transcribe()))
示例#16
0
 def test_transcription_dna_string_into_rna(self):
     seq = "ATGAAACTG"
     self.assertEqual("AUGAAACUG", Seq.transcribe(seq))
示例#17
0
 def test_transcription_dna_into_rna(self):
     for nucleotide_seq in test_seqs:
         if isinstance(nucleotide_seq.alphabet, Alphabet.DNAAlphabet):
             expected = Seq.transcribe(nucleotide_seq)
             self.assertEqual(str(nucleotide_seq).replace("t", "u").replace("T", "U"),
                              str(expected))