def __init__(self,features,mlib=None):#mlib does not need to be supplied anymore self.features=features #self.preprocess_features() self.featurelist=[] self.featurenames=[] self.mlib=mlib self.atomclasslib='atmcls-mf.lib' self.fclist=re.findall('[a-z]{1,4}[0-9\#\-\.]{1,20}',self.features) #feature code list self.ffclist=copy.deepcopy(self.fclist) self.frlist=[] # feature range list self.fdlist=[] # feature bin number list self.fslist=[] # feature start post list for i in range(len(self.fclist)): sfc=self.fclist[i] if sfc.count('#')==2: rer=re.search('([a-z]{1,5})([0-9]{1,8})\#([0-9\-\.]{1,5})\#([0-9\-\.]{1,5})',sfc) self.fclist[i]=rer.group(1) self.fdlist.append(int(rer.group(2))) self.frlist.append(float(rer.group(3))) self.fslist.append(float(rer.group(4))) if sfc.count('#')==1: rer=re.search('([a-z]{1,5})([0-9]{1,8})\#([0-9\.]{1,5})',sfc) self.fclist[i]=rer.group(1) self.fdlist.append(int(rer.group(2))) self.frlist.append(float(rer.group(3))) self.fslist.append(0) elif sfc.count('#')==0: self.frlist.append(0) rer=re.search('([a-z]{1,5})([0-9]{1,8})',sfc) self.fdlist.append(int(rer.group(2))) self.fslist.append(0) if not mlib: env = runenv.env #log.minimal() self.mlib=mdt.Library(env)
from modeller import * import os import mdt import mdt.features env = Environ() mlib = mdt.Library(env) xray = mdt.features.XRayResolution(mlib, bins=[(0.51, 2.001, 'High res(2.0A)')]) restyp = mdt.features.ResidueType(mlib) phi = mdt.features.PhiDihedral(mlib, bins=mdt.uniform_bins(72, -180, 5.0)) m = mdt.Table(mlib, file='mdt.mdt') # remove the bins corresponding to undefined values for each of the 3 variables: m = m.reshape(features=(xray, restyp, phi), offset=(0, 0, 0), shape=(-1, -2, -1)) # Let's get rid of the resolution variable from the output MDT table: m = m.integrate(features=(restyp, phi)) # Process the raw histograms to get appropriate pdf 1D splines for restraints: # Start by smoothing with a uniform prior (equal weight when 10 points per bin), # producing a normalized distribution that sums to 1 (not a pdf when dx != 1): m = m.smooth(dimensions=1, weight=10) # Normalize it to get the true pdf (Integral p(x) dx = 1): # (the scaling actually does not matter, because I am eventually taking the # log and subtracting the smallest element of the final pdf, so this command
def get_mdt_library(self, **vars): """Read in MDT library and bin definitions""" env = self.get_environ() return mdt.Library(env, **vars)