471,325 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,325 software developers and data experts.

Plz help..urgent!

111 100+
I have a code here which is finding a log vaue.
its input will be a sequence file and another matrix file..it reads both and computes the results.there seems to be some problem .. and it gives an indendation error as a problem and i dont think that could be..
my input files examples
Expand|Select|Wrap|Line Numbers
  1. matrix file:
  2. PO         A          C          G          T       
  3. 01         0.00       3.67       0.00       0.00    
  4. 02         0.00       0.00       3.67       0.00    
  5. 03         0.00       0.00       0.00       3.67    
  6. 04         0.00       3.67       0.00       0.00    
  7. 05         3.67       0.00       0.00       0.00    
  8. 06         3.46       0.00       0.22       0.00    
  9. 07         0.00       0.00       3.67       0.00    
  10. 08         0.00       0.00       0.00       3.67    
  11. 09         0.00       0.00       0.00       3.67    
  12. 10         0.00       3.67       0.00       0.00    
  13. 11         3.67       0.00       0.00       0.00    
  14. 12         3.67       0.00       0.00       0.00    
  15. 13         0.00       0.00       3.67       0.00    
  16. 14         0.00       0.00       0.00       3.67    
  17. 15         0.00       0.00       3.67       0.00    
  18. 16         0.00       3.67       0.00       0.00    
  19. sequence file:
  20. >Scer_YAL001C SGDID:S0000001 5' untranslated region, Chr I 151168 - 152167 (revcom), 1000 bp
  21. ACTTGTAAATATATCTTTTATTTTCCGAGAGGAAAAAGTTTCAAAAAAAAAAAAAAAAAAAGAAGAAAAATAACTTTCTCATGTAATAAAAGGTAACTAATGTAGACAAAAAAGTATACATTTAGCTTTTCTTTTTTTGATGATTTTTGAGTTTCATGTTACTAATCAGAACAATTAACGACACCTTCATTATGAAAAAATTAATTAGCTATAAGTCTTCGAAGTAGAACATGATATTTGGCAATCACTCGAATAACTATCTTAATTTACCTGCTGAAATAATTTGAAAAAACACCCGAGGCAGCAGACGAAAGGTGTTTTTGCTAAACAATGATTGATTTCTGGCGCCATTTCTACATTCTGAACAGTTCATCTCATTTCAGTAACAGTACTTCAATGGAATATTTATTAAAGAAAGTGCTTAAAAAAGTATTATAAAACGATACATGGACTGACTCAAGATTGAGCTAATAAGGTCCACCGCCTAGTGCTTAAGAGTTCTGTACCACTATAATAATTTATCTTGATCGTATTATGTGTAAAAAAAAGGCGCTTGAAATGAAAGCTCCGAAAATTAAAATACTTTGACTGCTTCGGAAAACAAAAACATATAAATAAATTTAAAAAATAAACTGTAAAATATTTAAAAACTATTAAAAATATTTTATATTTTTAAAATTATTTATTATTATGTCATGTGACAAGACTTAAATCATTACATAAAAGGTTTTGAAGTTCAATGTCAAAGTCAATATAATAAGCATACTAAGGCACACTTATGCAAATCGAGTTATTGAAGCTGGTAAAATTATAAGATTTTTATTTTTATTTCTTTTATTTCTGCAAATCTGCATTTTCAAATACCGCTTGGTTTTTTGCATCATAAAGGGCGGCGCTTTCAGTCGCGAAAGTGAAATAAACAACCAGTCACACATATAACTTTCTTCTTGCCATAAGAGAGAAGAGGACGTTTGGTTGAAGCCAACTAGCCACAAGAAAA
  22. >Spar YAL001C c218:24375..25375
  23. TCAAGAGGGTTATTATATACCGATATTTGAATCCACACATGATCGAACTAATATAATTCACTACTTAGCTGCTTAACCATTCTTTGCCATTATAATAAATGTATCTCGATCGAATGCTGCATAGAGAAAAGCGCTTAAAAAAGTGTTCCGAAATATAACATATTTTAAACGTTTCGGAAACCAAAAACATATATTTATTATCTTAAAGTAATCTAAAAAATGAAAGAAACTTTGATATATTTAAAACATAATATAATTATTTTATAAAAGTAACATGTGATTAAACTCACAAAGCCTAAAAATGTTTTTAATCATTATGTTAAGCTGAATATAGTATATCTAATAATTGTTTATTTAAGCAGATTGAACTGTGAATGCTAGTAAATTTTTAAGGGTTTTTTGTTGTTCTGCTTTTCTCTAGTTTTGTAGTGTCAAATACAACTAACTGGATTTTTTGCATCAGAAGGGGCGCTTTAACTCGCGAAAGTAAAAATAAACAATTAATCACACATATCTTTTCCTCTTGCAGAAGCAAAGAAGAGGACGGTTGATTGAAGCAAACCAGCCACAGAAAATATGGCGTTGACAATTTATCCTGATGAACTGGTTAAAATAGTGTCTGATGAAATTGCATCAAATAAAGGAAGTATGTATATGCCTCATTCTTCTATTCCATGTTCTTTTCAGGTGAGAAACGTGATATATTGTAAGATTATTTACTAACGACTTATTAAAGAAATTACGTTAAATCAGCTTTGGGATATATCTCGTAAATATTTTGATTTGTCTGACGAGAAAGTTAAACAATTTGTGCTTTCATGCGTGATGTTGAAAAAGGACATCGAGGTGTACTGTGATAGCGTTATAACAACTAAAAACGTGACAAATATTATAGACGACACTAGTCATTCATACTCAGTAGGGATTACTGAGGACAGCCTGTGGACGTTATTAACTGGATACACAAAGAAGGAGTCAACTATCGGGAATTCAGCATTTGA
  24.  well my code is here
  25.     Expand|Select|Wrap|Line Numbers
  •  
  •     
  •  
  • from math import *
  • import random
  • f=open("half.txt","r")
  • line=f.next()
  • while not line.startswith('PO'):
  •     line=f.next()
  •  
  • headerlist=line.strip().split()[1:]
  • linelist=[]
  •  
  •  
  • line=f.next().strip()
  • while not line.startswith('/'):
  •     if line !='':
  •         linelist.append(line.strip().split())
  •     line=f.next().strip()
  •  
  • keys=[i[0] for i in linelist]
  • values=[[float(s) for s in item] for item in [j[1:] for j in linelist]]
  •  
  • array={}
  • linedict=dict(zip(keys,values))
  • keys=linedict.keys()
  • keys.sort()
  • for key in keys:
  •     array=[key,linedict[key]]
  •  
  • datadict={}
  • datadict1={}
  • for i,item in enumerate(headerlist):
  •     datadict[item]={}
  •     for key_ in linedict:
  •         datadict[item][key_]=linedict[key_][i]
  •  
  •  
  • for keymain in datadict:
  •     for keysub in datadict[keymain]:
  •         datadict[keymain][keysub]+=1.0
  •  
  • datadict1=datadict.copy()
  • for keysub in datadict:
  •     for keysub in datadict[keymain]:
  •         #print "::::::::::::::::"
  • datadict1[keymain][keysub]=datadict[keymain][keysub]/(sum(values[int(keysub)-1])+4)
  •  
  •  
  • def readfasta():
  •     file1=open("YAL001C.txt",'r')
  •     file_content=file1.readlines()
  •     first=1
  •     list1=""
  •     for line in file_content:
  •         if line[0]==">":
  •             if first==0:
  •                 print "***************"
  •                 list1+=sequence
  •                 print "***********"
  •             else:
  •                 first=0
  •                 sequence=""
  •                 seq=""
  •                 for i in range(0,len(line)-1):
  •                     seq+=line[i]
  •         else:
  •                for i in range(0,len(line)-1):
  •             sequence+=line[i]
  •     list1+=sequence
  •     return list1
  • p=readfasta()
  • res=1
  • part=""
  • q=len(p)
  • seqq=""
  •  
  • value={"A"=0.3,"T":0.3,"C":0.2,"G":0.2}
  • for i in range(q-16):
  •     part=p[i:i+16]
  •     seqq=part
  •     res=1
  •     score=1
  •     for j in range(16):
  •         key=seqq[j]
  •         res=res*datadict1[key]["%02d"%(j+1)]
  •     for key in seqq:
  •         score=score*value[key]
  •     log_ratio=log10(res/score)
  •     print i,log_ratio
  •  
  •  
  •     
  •  
  •  
  • can you see the problem?
    plz help!!
    Dec 9 '07 #1
    0 923

    Post your reply

    Sign in to post your reply or Sign up for a free account.

    Similar topics

    8 posts views Thread by Tim::.. | last post: by
    7 posts views Thread by zeyais | last post: by
    17 posts views Thread by Saps | last post: by
    3 posts views Thread by N. Spiker | last post: by

    By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

    To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.