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