Package Bio :: Package NMR :: Module NOEtools
[hide private]
[frames] | no frames]

Source Code for Module Bio.NMR.NOEtools

 1  # NOEtools.py: A python module for predicting NOE coordinates from 
 2  #                assignment data.   
 3  # 
 4  #    The input and output are modelled on nmrview peaklists. 
 5  #    This modules is suitable for directly generating an nmrview 
 6  #    peaklist with predicted crosspeaks directly from the 
 7  #    input assignment peaklist.  
 8   
 9  import string 
10  import sys 
11  sys.path=[sys.path,"/usr/people/robert/development/xpktools/"] 
12  import xpktools 
13   
14 -def predictNOE(peaklist,originNuc,detectedNuc,originResNum,toResNum):
15 # Predict the i->j NOE position based on self peak (diagonal) assignments 16 # 17 # example predictNOE(peaklist,"N15","H1",10,12) 18 # where peaklist is of the type xpktools.peaklist 19 # would generate a .xpk file entry for a crosspeak 20 # that originated on N15 of residue 10 and ended up 21 # as magnetization detected on the H1 nucleus of 22 # residue 12. 23 # CAVEAT: The initial peaklist is assumed to be diagonal (self peaks only) 24 # and currently there is not checking done to insure that this 25 # assumption holds true. Check your peaklist for errors and 26 # off diagonal peaks before attempting to use predictNOE. 27 28 returnLine="" # The modified line to be returned to the caller 29 30 datamap=_data_map(peaklist.datalabels) 31 32 # Construct labels for keying into dictionary 33 originAssCol = datamap[originNuc+".L"]+1 34 originPPMCol = datamap[originNuc+".P"]+1 35 detectedPPMCol = datamap[detectedNuc+".P"]+1 36 37 # Make a list of the data lines involving the detected 38 if (peaklist.residue_dict(detectedNuc).has_key(str(toResNum)) and 39 peaklist.residue_dict(detectedNuc).has_key(str(originResNum))): 40 detectedList=peaklist.residue_dict(detectedNuc)[str(toResNum)] 41 originList=peaklist.residue_dict(detectedNuc)[str(originResNum)] 42 returnLine=detectedList[0] 43 44 for line in detectedList: 45 46 aveDetectedPPM =_col_ave(detectedList,detectedPPMCol) 47 aveOriginPPM =_col_ave(originList,originPPMCol) 48 originAss =string.splitfields(originList[0])[originAssCol] 49 50 returnLine=xpktools.replace_entry(returnLine,originAssCol+1,originAss) 51 returnLine=xpktools.replace_entry(returnLine,originPPMCol+1,aveOriginPPM) 52 53 return returnLine
54 55
56 -def _data_map(labelline):
57 # Generate a map between datalabels and column number 58 # based on a labelline 59 i=0 # A counter 60 datamap={} # The data map dictionary 61 labelList=string.splitfields(labelline) # Get the label line 62 63 # Get the column number for each label 64 for i in range(len(labelList)): 65 datamap[labelList[i]]=i 66 67 return datamap
68
69 -def _col_ave(list,col):
70 # Compute average values from a particular column in a string list 71 sum=0; n=0 72 for element in list: 73 sum=sum+string.atof(string.split(element)[col]) 74 n=n+1 75 return sum/n
76