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

Source Code for Module Bio.NMR.NOEtools

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