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 returnLine = "" # The modified line to be returned to the caller 56 57 datamap = _data_map(peaklist.datalabels) 58 59 # Construct labels for keying into dictionary 60 originAssCol = datamap[originNuc + ".L"] + 1 61 originPPMCol = datamap[originNuc + ".P"] + 1 62 detectedPPMCol = datamap[detectedNuc + ".P"] + 1 63 64 # Make a list of the data lines involving the detected 65 if str(toResNum) in peaklist.residue_dict(detectedNuc) \ 66 and str(originResNum) in peaklist.residue_dict(detectedNuc): 67 detectedList = peaklist.residue_dict(detectedNuc)[str(toResNum)] 68 originList = peaklist.residue_dict(detectedNuc)[str(originResNum)] 69 returnLine = detectedList[0] 70 71 for line in detectedList: 72 aveDetectedPPM = _col_ave(detectedList, detectedPPMCol) 73 aveOriginPPM = _col_ave(originList, originPPMCol) 74 originAss = originList[0].split()[originAssCol] 75 76 returnLine = xpktools.replace_entry(returnLine, originAssCol + 1, originAss) 77 returnLine = xpktools.replace_entry(returnLine, originPPMCol + 1, aveOriginPPM) 78 79 return returnLine
80 81
82 -def _data_map(labelline):
83 # Generate a map between datalabels and column number 84 # based on a labelline 85 i = 0 # A counter 86 datamap = {} # The data map dictionary 87 labelList = labelline.split() # Get the label line 88 89 # Get the column number for each label 90 for i in range(len(labelList)): 91 datamap[labelList[i]] = i 92 93 return datamap
94 95
96 -def _col_ave(list, col):
97 # Compute average values from a particular column in a string list 98 total = 0.0 99 n = 0 100 for element in list: 101 total += float(element.split()[col]) 102 n += 1 103 return total / n
104