Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Python Program Logical Error

$
0
0
The following program asks for a string. Checks the whole string for substrings AAT,AAC,AAG and then prints upto 19 chars from that substring and calculate the value as given. But I am getting same value over and over again. Maybe a Logical Problem with the nested looping.

q=[-5.23,-0.22,3.35,-3.9,0.59,5.76,-3.27,2.95,0.68,-2.65,2.6,1.87,-0.68,2.77,0,-3.92,0,0.06,4.17];
w=[15.1,1.11,-0.85,0,-0.47,-4,3.63,-2.29,-1.96,1.16,0,-4.09,-0.27,-2.14,1.86,0,2.32,-2.61];
e=[1.04,0,0,3.91,-0.53,-1.75,1.88,1.88,-0.22,2.81,0,-0.91,1.96,2.62,-2.67,0,0.06,-1.95,0.58];
r=[-6.8,0,-2.73,-1.81,1.38,1.76,0,-1.79,4.22,-1.3,-4.13,4.62,0,-0.66,6.2,-1.69,3.12,0.93];
t=['A','G','C','T']
import re
i=0;s=0;f=0;k=0;l=0;c=0;
regex = re.compile("(?=(AA[TCG].{16}))")
x=raw_input('get::')
l=regex.findall(x)
for x in range(len(l)):
    c=l[x]
    n=len(c)
    while(i<n):        
        if(c[i]==t[0]):
              s=q[i];
        elif(c[i]==t[1]):
              s=w[i];             
        elif(c[i]==t[2]):
              s=e[i];              
        elif(c[i]==t[3]):
              s=r[i];
        i+=1
        f+=s
    print c
    print f
    k+=1
    
           
h=raw_input('Enter to continue')


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>