Changeset 107 for biocomp.pscoils/trunk/src/biocomp/pscoils/__init__.py
- Timestamp:
- 10/18/09 19:27:54 (3 years ago)
- Location:
- biocomp.pscoils/trunk
- Files:
-
- 2 modified
-
. (modified) (1 prop)
-
src/biocomp/pscoils/__init__.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
biocomp.pscoils/trunk
-
Property
svn:mergeinfo set
to
/biocomp.pscoils/branches/biopython-enabled merged eligible
-
Property
svn:mergeinfo set
to
-
biocomp.pscoils/trunk/src/biocomp/pscoils/__init__.py
r6 r107 35 35 import math 36 36 import string 37 import copy 38 37 39 import Params # this must be in the sys.path. Params contains the COILS paramters 40 import utils 41 42 from Bio.SeqFeature import FeatureLocation, SeqFeature 38 43 39 44 # … … 69 74 return prof,pos 70 75 71 #---------------------------------#72 73 74 #----------- readFasta files75 def readFasta(fname):76 ''' readFasta(fname) returns a dictionary77 '''78 try:79 lines=open(fname,'r').readlines()80 except:81 sys.stderr.write('cannot open file '+fname+'\n')82 sys.exit()83 seqs={}84 name=''85 seq=''86 for line in lines:87 if line[0]=='>': # assuming fasta file88 if name != '':89 seqs[name]=seq90 seq=''91 name=line[1:].strip()92 else:93 seq+=''.join(line.split())94 if name != '':95 seqs[name]=seq96 return seqs97 76 #---------------------------------# 98 77 … … 134 113 135 114 136 #---------------------------------# 137 def pred_coil(seq,seqLen,params,fScore): 115 def pred_coil(seqr, params, fScore=None): 138 116 ''' pred_coil(seq,seqLen,params,fScore) returns the coiled coil prediction of sequence seq''' 117 seqr = copy.deepcopy(seqr) 118 if fScore == None: 119 fScore = seqScore 120 seq = seqr.seq 121 seqLen = len(seqr.seq) 139 122 hept_pos=['a','b','c','d','e','f','g'] 140 123 score=[0.0]*seqLen 141 prob=[0.0]*seqLen142 gcc=[0.0]*seqLen143 gg=[0.0]*seqLen144 124 hept_seq=['x']*seqLen 145 125 for i in range(seqLen-params.win+1): … … 160 140 hept_seq[i+j]=hept_pos[pos] 161 141 for i in range(seqLen): 162 gg[i],gcc[i],prob[i]= coilProb(score[i],params) 163 return gg,gcc,prob,hept_seq,score 164 142 gg, gcc, prob = coilProb(score[i],params) 143 seqf = SeqFeature(location=FeatureLocation(i,i), type="pscoils") 144 seqf.qualifiers = {'gg':gg, 145 'gcc': gcc, 146 'prob': prob, 147 'score': score[i], 148 'hept_seq': hept_seq[i]} 149 seqr.features.append(seqf) 150 return seqr 165 151 166 152 #---------------------------------# … … 195 181 return gg,gcc,prob,hept_seq,score 196 182 197 def printCoil(seq,seqLen,hept_seq,score,P,Gcc,Gg,labels='T',io=sys.stdout):198 ''' '''199 ccLab="C"200 loopLab="L"201 if labels !='T' :202 for i in range(seqLen):203 #print "%4d %c %c %7.3f %7.3f (%7.3f %7.3f)" % (i+1,seq[i],hept_seq[i],score[i],P[i],Gcc[i],Gg[i])204 io.write("%4d %c %c %7.3f %7.3f %7.3f %7.3f\n" % (i+1,seq[i],hept_seq[i],score[i],P[i],Gcc[i],Gg[i]))205 else:206 io.write(" Pos A Hep Score Prob Gcc Gg Pred (Loop=L Coiledcoil=C)\n")207 for i in range(seqLen):208 if P[i] > 0.5:209 clabel=ccLab210 else:211 clabel=loopLab212 io.write("%4d %c %c %7.3f %7.3f %7.3f %7.3f %s\n" % (i+1,seq[i],hept_seq[i],score[i],P[i],Gcc[i],Gg[i],clabel))213 183
