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  __docformat__ = "restructuredtext en" 
 16   
 17   
18 -def predictNOE(peaklist, originNuc, detectedNuc, originResNum, toResNum):
19 """Predict the i->j NOE position based on self peak (diagonal) assignments 20 21 Parameters 22 ---------- 23 peaklist : xprtools.Peaklist 24 List of peaks from which to derive predictions 25 originNuc : str 26 Name of originating nucleus. 27 originResNum : int 28 Index of originating residue. 29 detectedNuc : str 30 Name of detected nucleus. 31 32 toResNum : int 33 Index of detected residue. 34 35 Returns 36 ------- 37 returnLine : str 38 The .xpk file entry for the predicted crosspeak. 39 40 Examples 41 -------- 42 Using predictNOE(peaklist,"N15","H1",10,12) 43 where peaklist is of the type xpktools.peaklist 44 would generate a .xpk file entry for a crosspeak 45 that originated on N15 of residue 10 and ended up 46 as magnetization detected on the H1 nucleus of 47 residue 12 48 49 50 Notes 51 ===== 52 The initial peaklist is assumed to be diagonal (self peaks only) 53 and currently there is no checking done to insure that this 54 assumption holds true. Check your peaklist for errors and 55 off diagonal peaks before attempting to use predictNOE. 56 """ 57 58 returnLine = "" # The modified line to be returned to the caller 59 60 datamap = _data_map(peaklist.datalabels) 61 62 # Construct labels for keying into dictionary 63 originAssCol = datamap[originNuc + ".L"] + 1 64 originPPMCol = datamap[originNuc + ".P"] + 1 65 detectedPPMCol = datamap[detectedNuc + ".P"] + 1 66 67 # Make a list of the data lines involving the detected 68 if str(toResNum) in peaklist.residue_dict(detectedNuc) \ 69 and str(originResNum) in peaklist.residue_dict(detectedNuc): 70 detectedList = peaklist.residue_dict(detectedNuc)[str(toResNum)] 71 originList = peaklist.residue_dict(detectedNuc)[str(originResNum)] 72 returnLine = detectedList[0] 73 74 for line in detectedList: 75 aveDetectedPPM = _col_ave(detectedList, detectedPPMCol) 76 aveOriginPPM = _col_ave(originList, originPPMCol) 77 originAss = originList[0].split()[originAssCol] 78 79 returnLine = xpktools.replace_entry(returnLine, originAssCol + 1, originAss) 80 returnLine = xpktools.replace_entry(returnLine, originPPMCol + 1, aveOriginPPM) 81 82 return returnLine
83 84
85 -def _data_map(labelline):
86 # Generate a map between datalabels and column number 87 # based on a labelline 88 i = 0 # A counter 89 datamap = {} # The data map dictionary 90 labelList = labelline.split() # Get the label line 91 92 # Get the column number for each label 93 for i in range(len(labelList)): 94 datamap[labelList[i]] = i 95 96 return datamap
97 98
99 -def _col_ave(list, col):
100 # Compute average values from a particular column in a string list 101 total = 0.0 102 n = 0 103 for element in list: 104 total += float(element.split()[col]) 105 n += 1 106 return total / n
107