Bioinformatics: Find Genes given a Genome String
<p>Biologists use a sequence of letters A, C, T, and G to model a genome.  A gene is a substrsing of a genome that starts after a triplet ATG and ends before a triplet TAG, TAA, or TGA.  Furthermore, the length of a gene string is a multiple of 3 and the gene does not contain any of the triplets ATG, TAG, TAA, and TGA.</p>

<p>Ideally:</p>

<pre><code>Enter a genome string: TTATGTTTTAAGGATGGGGCGTTAGTT #Enter   
TTT
GGGCGT
-----------------
Enter a genome string: TGTGTGTATAT
No Genes Were Found
</code></pre>

<p>So far, I have:</p>

<pre><code>def findGene(gene):
    final = ""
    genep = gene.split("ATG")
    for part in genep:
        for chr in part:
            for i in range(0, len(chr)):
                if genePool(chr[i:i + 3]) == 1:
                    break
                else:
                    final += (chr[i+i + 3] + "\n")
    return final

def genePool(part):
    g1 = "ATG"
    g2 = "TAG"
    g3 = "TAA"
    g4 = "TGA"
    if (part.count(g1) != 0) or (part.count(g2) != 0) or (part.count(g3) != 0) or (part.count(g4) != 0):
        return 1

def main():
    geneinput = input("Enter a genome string: ")
    print(findGene(geneinput))

main()
# TTATGTTTTAAGGATGGGGCGTTAGTT
</code></pre>

<p>I keep running into errors</p>

<p>To be completely honest, this is really not working for me - I think I have hit a dead end with these lines of code -  a new approach may be helpful.</p>

<p>Thanks in advance!</p>

<p>The error that I have been getting -</p>

<pre><code>Enter a genome string: TTATGTTTTAAGGATGGGGCGTTAGTT
Traceback (most recent call last):
  File "D:\Python\Chapter 8\Bioinformatics.py", line 40, in &lt;module&gt;
    main()
  File "D:\Python\Chapter 8\Bioinformatics.py", line 38, in main
    print(findGene(geneinput))
  File "D:\Python\Chapter 8\Bioinformatics.py", line 25, in findGene
    final += (chr[i+i + 3] + "\n")
IndexError: string index out of range
</code></pre>

<p>Like I said before, I'm not really sure if I am on the right track to solve the issue with my current code - any new ideas w/ pseudo code is appreciated!</p>