Show
Ignore:
Timestamp:
06/10/08 23:46:02 (4 years ago)
Author:
mauro
Message:
 
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • biocomp.pscoils/branches/biopython-enabled/src/biocomp/pscoils/__init__.py

    r6 r27  
    3535import math 
    3636import string 
     37 
    3738import Params # this must be in the sys.path. Params contains the COILS paramters 
     39import utils 
     40 
     41from Bio.SeqFeature import FeatureLocation, SeqFeature 
    3842 
    3943# 
     
    6973    return prof,pos 
    7074     
    71 #---------------------------------# 
    72  
    73  
    74 #----------- readFasta files  
    75 def readFasta(fname): 
    76     ''' readFasta(fname) returns a dictionary  
    77     ''' 
    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 file 
    88            if name != '': 
    89                seqs[name]=seq 
    90                seq='' 
    91            name=line[1:].strip() 
    92         else: 
    93            seq+=''.join(line.split()) 
    94     if name != '': 
    95         seqs[name]=seq 
    96     return seqs 
    9775#---------------------------------# 
    9876 
     
    134112 
    135113     
    136 #---------------------------------# 
    137 def pred_coil(seq,seqLen,params,fScore): 
     114def pred_coil(seqr, params, fScore=None): 
    138115    ''' pred_coil(seq,seqLen,params,fScore) returns the coiled coil prediction of sequence seq''' 
     116    if fScore == None: 
     117        fScore = seqScore 
     118    seq = seqr.seq 
     119    seqLen = len(seqr.seq) 
    139120    hept_pos=['a','b','c','d','e','f','g'] 
    140121    score=[0.0]*seqLen 
    141     prob=[0.0]*seqLen 
    142     gcc=[0.0]*seqLen 
    143     gg=[0.0]*seqLen 
    144122    hept_seq=['x']*seqLen 
    145123    for i in range(seqLen-params.win+1): 
     
    160138                hept_seq[i+j]=hept_pos[pos] 
    161139    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    
     140        gg, gcc, prob = coilProb(score[i],params) 
     141        seqf = SeqFeature(location=FeatureLocation(i,i), type="pscoils") 
     142        seqf.qualifiers = {'gg':gg,  
     143            'gcc': gcc,  
     144            'prob': prob,  
     145            'score': score[i], 
     146            'hept_seq': hept_seq[i]} 
     147        seqr.features.append(seqf) 
     148    return seqr   
    165149     
    166150#---------------------------------# 
     
    195179    return gg,gcc,prob,hept_seq,score 
    196180   
    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=ccLab 
    210             else: 
    211                clabel=loopLab 
    212             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)) 
    213181