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  from . import xpktools 
10   
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 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
67 -def _col_ave(list, col):
68 # Compute average values from a particular column in a string list 69 total = 0 70 n = 0 71 for element in list: 72 total += float(element.split()[col]) 73 n += 1 74 return total / n
75