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