Permalink
Browse files

input must be alignment + new seq

  • Loading branch information...
1 parent 35b0127 commit a353d5482189ec50e1ff2adb4e58e486e4bbaa56 @vreinharz vreinharz committed Oct 3, 2012
Showing with 6 additions and 10 deletions.
  1. +6 −10 src/RNAPyroEx.py
View
@@ -356,9 +356,10 @@ def energy((a,b),(a2,b2),alpha=1.0):
def isostericity(seq,ref_seq,(i,j),(a,b), alpha=1.0):
#isostericity of going from original base pair to (a,b)
- iso1 = ISO[(ref_seq[i],ref_seq[j]),(a,b)]
- iso2 = ISO[(ref_seq[i],ref_seq[j]),(seq[i],seq[j])]
- return math.exp(-((1-alpha)*(iso1-iso2))/(BOLTZMANN*T))
+ iso_mut = sum(ISO[(ref[i],ref[j]),(a,b)] for ref in ref_seq)
+ iso_start = sum(ISO[(ref[i],ref[j]),(seq[i],seq[j])] for ref in ref_seq)
+ iso = (iso_mut-iso_start)/len(ref_seq)
+ return math.exp(-((1-alpha)*iso)/(BOLTZMANN*T))
@memoize
def forward(seq,ref_seq,struct,(i,j),(a,b),m, alpha=1.0):
@@ -588,10 +589,7 @@ def parse_fasta(file_name):
seq.append(line)
if all(x in '(.)' for x in line):
struct = line
- if len(seq) == 1:
- return seq[0], seq[0], parseStruct(struct)
- else:
- return seq[0],seq[1], parseStruct(struct)
+ return seq[:-1],seq[-1], parseStruct(struct)
def all_probabilities(seq,ref_seq, stuct, m, alpha):
n = len(seq)
@@ -612,8 +610,6 @@ def help():
the nb of mutants allowed and the value of alpha, between 0 and 1"""
if __name__ == "__main__":
- test()
- sys.exit(0)
opts = sys.argv
if len(opts) < 4:
help()
@@ -638,7 +634,7 @@ def help():
- seq,ref_seq,struct = parse_fasta(file_name)
+ ref_seq,seq,struct = parse_fasta(file_name)
results = all_probabilities(seq,ref_seq,struct,m,alpha)
display_all_probabilities(results)

0 comments on commit a353d54

Please sign in to comment.