Differences

This shows you the differences between two versions of the page.

part5 [2009/05/12 10:29]
nuin
part5 [2010/02/11 05:12] (current)
newacct
Line 108: Line 108:
    proteinseq = ''     proteinseq = ''
    for n in range(0,len(sequence),3):     for n in range(0,len(sequence),3):
-        if gencode.has_key(sequence[n:n+3]) == True:+        if sequence[n:n+3] in gencode:
            proteinseq += gencode[sequence[n:n+3]]             proteinseq += gencode[sequence[n:n+3]]
Line 119: Line 119:
means that it will loop from 0 to the size of the DNA sequence in steps of 3, so basically we start at 0 and then jumping directly to 3. This is done to obey the translation structure based on codons of three nucleotides. Sometimes the DNA sequence entered does not have a size multiple of three and that's the reason we use an error checking before accessing the dictionary means that it will loop from 0 to the size of the DNA sequence in steps of 3, so basically we start at 0 and then jumping directly to 3. This is done to obey the translation structure based on codons of three nucleotides. Sometimes the DNA sequence entered does not have a size multiple of three and that's the reason we use an error checking before accessing the dictionary
-<code python>if gencode.has_key(sequence[n:n+3]) == True:</code>+<code python>if sequence[n:n+3] in gencode:</code>
-This will test for any possible error, or codons that are smaller than three nucleotides. If the key exists it is returned and addes to our protein string. The code that will use this function is this:+This will test for any possible error, or codons that are smaller than three nucleotides. If the key exists it is returned and added to our protein string. The code that will use this function is this:
<code python>#!/usr/bin/env python <code python>#!/usr/bin/env python
 
part5.1242138582.txt.gz · Last modified: 2009/05/12 10:29 by nuin
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki