data=["1lghB A i 79.8 H H -24.58", "1lghB V i 79.6 H H -22.06", "1lghB H i 71.9 H H -19.94"] for line in data: print "\nlooking at", line substrs=line.strip().split() print "amino acid =", substrs[1], "and value =", substrs[-1] value = abs(float(substrs[-1])) if 9.99 < value < 22.01: print "greater than 10 and less than 22" # # And if you want to keep track of how many hits are found for each # amino, I would suggest a dictionary with the amino acid symbol # as key, containing a simple integer counter, so adding to a # dictionary the simplest way is: # (This is still under the if statement) if substrs[1] in amino_dic: amino_dic += 1 else: amino_dic[substrs[1]]=1
## what is Z_CORRED ## and you don't define z for i in Z-CORRED: if 10.0 <= z <= 22.0: matches.append([1,i])
symbol=substrs[1] ## not necessary but easier to read if symbol in amino_dic: amino_dic[symbol] += 1 else: amino_dic[symbol]=1
output will in 21 column,1st column for true false value,others r for 20 amino acids.true false value will be either 1 or -1,and within other 20 coulum one value will be n:1,others will be n:0.n=0,1,2,3..20
if symbol not in amino_dic: amino_dic[symbol]=[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,] amino_dic[symbol] = add one to proper list element
| DaniWeb Message | |
| Cancel Changes | |