1 Replies - 187 Views - Last Post: 21 February 2013 - 12:57 PM Rate Topic: -----

#1 smfsher48  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 21-February 13

Python Program Logical Error

Posted 21 February 2013 - 12:07 PM

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')



Is This A Good Question/Topic? 0
  • +

Replies To: Python Program Logical Error

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3371
  • View blog
  • Posts: 11,420
  • Joined: 12-December 12

Re: Python Program Logical Error

Posted 21 February 2013 - 12:57 PM

Are you able to debug/step through your code using your editor? If not, I would throw in a load of print statements to track what happens to your lists each step of the way.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1