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