mgltools-sff-1.5.7~rc1~cvs.20130519/0000755000175000017500000000000012146213435016010 5ustar debiandebianmgltools-sff-1.5.7~rc1~cvs.20130519/sff/0000755000175000017500000000000012146213437016570 5ustar debiandebianmgltools-sff-1.5.7~rc1~cvs.20130519/sff/amber.py0000644000175000017500000003523710653444130020237 0ustar debiandebian## Automatically adapted for numpy.oldnumeric Jul 30, 2007 by # # Copyright_notice # import _prmlib as prmlib import re import os import numpy.oldnumeric as Numeric from types import StringType realType = Numeric.Float intType = Numeric.Int pyArrayInt = prmlib.PyArray_INT pyArrayDouble = prmlib.PyArray_DOUBLE getpat = re.compile( 'parmstruct_(\w+)_get') parmattrs = {} for x in dir( prmlib): match = getpat.match( x) if match: parmattrs[ match.group( 1) ] = None parmbuffers = { 'AtomNames': (StringType, lambda x: x.Natom * 4 + 81, None), 'Charges': (realType, lambda x: x.Natom, pyArrayDouble ), 'Masses': (realType, lambda x: x.Natom, pyArrayDouble), 'Iac': (intType, lambda x: x.Natom, pyArrayInt), 'Iblo': (intType, lambda x: x.Natom, pyArrayInt), 'Cno': (intType, lambda x: x.Ntype2d, pyArrayInt), 'ResNames': (StringType, lambda x: x.Nres * 4 + 81, None), 'Ipres': (intType, lambda x: x.Nres + 1, pyArrayInt), 'Rk': (realType, lambda x: x.Numbnd, pyArrayDouble), 'Req': (realType, lambda x: x.Numbnd, pyArrayDouble), 'Tk': (realType, lambda x: x.Numang, pyArrayDouble), 'Teq': (realType, lambda x: x.Numang, pyArrayDouble), 'Pk': (realType, lambda x: x.Nptra, pyArrayDouble), 'Pn': (realType, lambda x: x.Nptra, pyArrayDouble), 'Phase': (realType, lambda x: x.Nptra, pyArrayDouble), 'Solty': (realType, lambda x: x.Natyp, pyArrayDouble), 'Cn1': (realType, lambda x: x.Nttyp, pyArrayDouble), 'Cn2': (realType, lambda x: x.Nttyp, pyArrayDouble), 'Boundary': (intType, lambda x: x.Nspm, pyArrayInt), 'BondHAt1': (intType, lambda x: x.Nbonh, pyArrayInt), 'BondHAt2': (intType, lambda x: x.Nbonh, pyArrayInt), 'BondHNum': (intType, lambda x: x.Nbonh, pyArrayInt), 'BondAt1': (intType, lambda x: x.Nbona, pyArrayInt), 'BondAt2': (intType, lambda x: x.Nbona, pyArrayInt), 'BondNum': (intType, lambda x: x.Nbona, pyArrayInt), 'AngleHAt1': (intType, lambda x: x.Ntheth, pyArrayInt), 'AngleHAt2': (intType, lambda x: x.Ntheth, pyArrayInt), 'AngleHAt3': (intType, lambda x: x.Ntheth, pyArrayInt), 'AngleHNum': (intType, lambda x: x.Ntheth, pyArrayInt), 'AngleAt1': (intType, lambda x: x.Ntheta, pyArrayInt), 'AngleAt2': (intType, lambda x: x.Ntheta, pyArrayInt), 'AngleAt3': (intType, lambda x: x.Ntheta, pyArrayInt), 'AngleNum': (intType, lambda x: x.Ntheta, pyArrayInt), 'DihHAt1': (intType, lambda x: x.Nphih, pyArrayInt), 'DihHAt2': (intType, lambda x: x.Nphih, pyArrayInt), 'DihHAt3': (intType, lambda x: x.Nphih, pyArrayInt), 'DihHAt4': (intType, lambda x: x.Nphih, pyArrayInt), 'DihHNum': (intType, lambda x: x.Nphih, pyArrayInt), 'DihAt1': (intType, lambda x: x.Nphia, pyArrayInt), 'DihAt2': (intType, lambda x: x.Nphia, pyArrayInt), 'DihAt3': (intType, lambda x: x.Nphia, pyArrayInt), 'DihAt4': (intType, lambda x: x.Nphia, pyArrayInt), 'DihNum': (intType, lambda x: x.Nphia, pyArrayInt), 'ExclAt': (intType, lambda x: x.Nnb, pyArrayInt), 'HB12': (realType, lambda x: x.Nphb, pyArrayDouble), 'HB10': (realType, lambda x: x.Nphb, pyArrayDouble), 'Box': (realType, lambda x: 3, pyArrayDouble), 'AtomSym': (StringType, lambda x: x.Natom * 4 + 81, None), 'AtomTree': (StringType, lambda x: x.Natom * 4 + 81, None), 'TreeJoin': (intType, lambda x: x.Natom, pyArrayInt), 'AtomRes': (intType, lambda x: x.Natom, pyArrayInt), 'N14pairs': (intType, lambda x: x.Natom, pyArrayInt), 'N14pairlist': (intType, lambda x: 10*x.Natom, pyArrayInt), } def checkbuffersize( parmobj, attr, value): attrlen = parmbuffers[ attr][ 1]( parmobj) if attr in ['AtomNames', 'AtomSym', 'AtomTree']: attrlen = parmobj.Natom * 4 elif attr == 'ResNames': attrlen = parmobj.Nres * 4 elif attr == 'Ipres': attrlen = parmobj.Nres elif attr == 'N14pairlist': from operator import add sum = reduce( add, parmobj.N14pairs ) attrlen = sum if sum!=len(value): print 'WARNING: N14pairlist length' attrlen = len(value) if len( value) < attrlen: raise ValueError( attr, attrlen, len( value)) class AmberParm: def __init__( self, name, parmdict=None): """ name - string parmdict - map """ import types self.name = name if parmdict: parmptr = self._parmptr_ = prmlib.parmcalloc() for name in parmattrs.keys(): value = parmdict[ name] try: bufdesc = parmbuffers[ name] except KeyError: pass else: if bufdesc[ 0] != StringType\ and not isinstance( value, StringType): value = Numeric.array( value).astype(bufdesc[ 0]) self.__dict__[ name] = value if name == 'Box': self.Box[:] = value else: getattr( prmlib, 'parmstruct_%s_set' % name)( parmptr, value) else: assert os.path.exists( name ) self._parmptr_ = parmptr = prmlib.readparm( name) for attr in filter( lambda x: not parmbuffers.has_key( x), parmattrs.keys()): value = getattr( prmlib, 'parmstruct_%s_get' % attr)( parmptr) self.__dict__[ attr] = value for attr in filter( lambda x: parmbuffers.has_key( x), parmattrs.keys()): # these _get() functions must not be called from anywhere else #print "attr:", attr, value = getattr( prmlib, 'parmstruct_%s_get' % attr)( parmptr) #print "value: ", value if value is None: value = () else: bufdesc = parmbuffers[ attr] if bufdesc[ 0] != StringType: value = prmlib.createNumArr(value, bufdesc[ 1]( self), bufdesc[2]) self.__dict__[ attr] = value if __debug__: for attr in parmbuffers.keys(): val = getattr(self, attr) if isinstance(val, Numeric.ArrayType) or isinstance(val, StringType): checkbuffersize(self, attr, val) def __setattr__( self, name, value): if parmattrs.has_key( name): raise AttributeError( 'constant parm attribute') self.__dict__[ name] = value def __del__( self): prmlib.parmfree( self._parmptr_) delattr( self, '_parmptr_') def asDict(self): # return the content of the parm structure as a python dict d = {} for k in self.__dict__.keys(): if k[0]=='_': continue if parmbuffers.has_key(k): value = list(getattr(self, k)) else: value = getattr(self, k) d[k] = value return d import threading amberlock = threading.RLock() import struct class BinTrajectory: ## WARNING nothing is done about byte order def __init__(self, filename): import os assert os.path.isfile(filename) self.filename = filename self.typecode = 'f' if prmlib.UseDouble: self.typecode = 'd' self.coordSize = struct.calcsize(self.typecode) self.intSize = struct.calcsize('i') self.fileHandle = None def getNumberOfAtoms(self, filename): f = open(filename, 'rb') lenstr = f.read(struct.calcsize('i')) f.close() return struct.unpack('i', lenstr)[0] def closeFile(self): self.fileHandle.close() self.fileHandle = None def getNextConFormation(self): # open file if necessary if self.fileHandle is None: self.fileHandle = open(self.filename) # read the number of atoms as an integer lenstr = self.fileHandle.read(self.intSize) if len(lenstr) < self.intSize: #EOF reached self.closeFile() return None nba = struct.unpack('i', lenstr)[0] size = 3 * nba * self.coordSize # read the coordinates for nba atoms crdstr = self.fileHandle.read( size ) if len(crdstr) != size: #EOF reached self.closeFile() return None c = Numeric.array( struct.unpack( '%dd'%3*nba, crdstr), self.typecode ) c.shape = (-1, 3) return c class Amber94: from MolKit import parm94_dat def __init__(self, atoms, parmtop=None, prmfile=None, dataDict={}): from MolKit.amberPrmTop import Parm self.atoms = atoms self.parmtop = parmtop if prmfile: self.oprm = AmberParm( prmfile ) else: if self.parmtop is None: # create parmtop info if not len(dataDict): self.parmtop = Parm() else: #dataDict is a dictionary with possible keys: #allDictList, ntDictList, ctDictList #whose values are lists of python files such as #found in MolKit/data...which end in dat.py #dataDict['allDictList']=[all_amino94_dat] #if len(list)>1, the first is updated by the rest self.parmtop = apply(Parm, (), dataDict) self.parmtop.processAtoms(atoms, self.parm94_dat) #this read is broken #self.parmtop.loadFromFile(prmfile) else: assert isinstance(parmtop, Parm) # create the C-data structure self.oprm = AmberParm( 'test', self.parmtop.prmDict ) from operator import add coords = self.atoms.coords[:] lcoords = reduce( add, coords) self.coords = Numeric.array( lcoords).astype(realType ) # create Numeric array for frozen self.frozen = Numeric.zeros( self.oprm.Natom).astype(intType) # create Numeric array for constrained self.constrained = Numeric.zeros( self.oprm.Natom). astype(intType) # create Numeric array for anchor self.anchor = Numeric.zeros( 3*self.oprm.Natom).astype(realType) # create Numeric array for minv (md) self.minv = Numeric.zeros( 3*self.oprm.Natom).astype(realType ) # create Numeric array for v (md) self.mdv = Numeric.zeros( 3*self.oprm.Natom).astype(realType) # create Numeric array for f (md) self.mdf = Numeric.zeros( 3*self.oprm.Natom).astype( realType ) # is the number of variables self.nbVar = Numeric.array([3*self.oprm.Natom]).astype(intType) # will contain the value of the objective function at the end self.objFunc = Numeric.zeros( 1).astype(realType ) # return when sum of squares of gradient is less than dgrad drms = 0.1 self.dgrad = Numeric.array([drms*3*self.oprm.Natom]).astype(realType) # expected decrease in the function on the first iteration self.dfpred = Numeric.array( [10.0,]).astype( realType ) # self.maxIter = Numeric.array([500,]).astype(intType) # self.energies = Numeric.zeros(20).astype(realType ) # filename used to save trajectory self.filename = None self.sff_opts = prmlib.init_sff_options() def setMinimizeOptions(self, **kw): # WARNING when cut it set mme_init needs to be called to allocate a # list of non-bonded paires of the proper size for k,v in kw.items(): assert k in ['cut', 'nsnb', 'ntpr', 'scnb', 'scee', 'mme_init_first', 'dield', 'verbosemm', 'wcons'] #prmlib.mm_options(k, v) #setattr(prmlib.cvar, k, v) prmlib.mm_options(k, v, self.sff_opts) def setMdOptions(self, **kw): #nb: for the moment set verbosemm for verbosemd for k,v in kw.items(): assert k in ['t', 'dt', 'tautp', 'temp0', 'boltz2', 'verbosemd', 'ntwx','vlimit', 'ntpr_md', 'zerov', 'tempi', 'idum' ] #prmlib.md_options(k, v) #setattr(prmlib.cvar, k, v) prmlib.md_options(k, v, self.sff_opts) def setCallback(self, func, frequency): assert callable(func) prmlib.set_callback(func, frequency, 0) def freezeAtoms(self, atomIndices): assert len(atomIndices)==len(self.atoms), 'atomIndices wrong length' self.frozen = Numeric.array(atomIndices).astype(intType) def constrainAtoms(self, atomIndices, anchor): atlen = len(self.atoms) assert len(atomIndices)==atlen, 'atomIndices wrong length' #this is not right: #constNum = Numeric.add.reduce(atomIndices) #anchors have garbage for non-constrained atoms assert len(anchor)==atlen*3, 'anchor wrong length' self.constrained = Numeric.array(atomIndices).astype(intType) self.anchor = Numeric.array(anchor).astype(realType) def minimize(self, drms=None, maxIter=None, dfpred=None): if drms is not None: self.dgrad[0] = drms*3*self.oprm.Natom if maxIter is not None: self.maxIter[0] = maxIter if dfpred is not None: self.dfpred[0] = dfpred prmlib.mme_init(self.frozen, self.constrained, self.anchor, None, self.oprm._parmptr_, self.sff_opts) amberlock.acquire() result_code = -6 try: # add new thread here result_code = prmlib.conjgrad( self.coords, self.nbVar, self.objFunc, prmlib.mme_fun, self.dgrad, self.dfpred, self.maxIter, self.oprm._parmptr_, self.energies, self.sff_opts ) finally: amberlock.release() return result_code def md(self, maxStep, filename=None): self.filename = filename if filename is not None: f = open(filename, 'w') else: f = None prmlib.mme_init(self.frozen, self.constrained, self.anchor, f, self.oprm._parmptr_, self.sff_opts) amberlock.acquire() result_code = -6 try: # add new thread here result_code = prmlib.md( 3*self.oprm.Natom, maxStep, self.coords, self.minv, self.mdv, self.mdf, prmlib.mme_fun, self.energies, self.oprm._parmptr_ , self.sff_opts) finally: amberlock.release() if filename is not None: f.close() return result_code mgltools-sff-1.5.7~rc1~cvs.20130519/sff/prmlib.i0000644000175000017500000001145311214561046020230 0ustar debiandebian/* * Copyright_notice */ %module prmlib %init %{ PyEval_InitThreads(); mme_initCallbacks(); import_array(); /* load the Numeric PyCObjects */ %} %{ #ifdef _MSC_VER #include #define WinVerMajor() LOBYTE(LOWORD(GetVersion())) #endif #include #include "numpy/oldnumeric.h" #include "prm.h" static parmstruct* parmcalloc( void) { return (parmstruct*)calloc( 1, sizeof (parmstruct)); } static void parmfree( parmstruct* parm) { free( parm); } static PyThreadState* s_pythread = NULL; void foo (int *obj) { printf ("foo: got int *\n"); } %} void foo (int *obj); //void foo1(void *obj); %include typemaps.i // Note: these typemaps require that the memory be held in Python %typemap(in) _REAL*, int* { long buffer_len; if (PyObject_AsWriteBuffer( $input, (void**)&$1, &buffer_len)) return NULL; } /*********************************** %typemap( python, in) char* { int buffer_len; if (PyObject_AsReadBuffer( $input, (const void**)&$1, &buffer_len)) return NULL; } ************************************/ /* must be called once and only once (see wrapper) */ /****** %typemap( python, out) _REAL*, int*, char* { if ($1) $result = PyCObject_FromVoidPtr( $1, free); else { Py_INCREF( Py_None); $result = Py_None; } } ********/ /******** %typemap( python, out) _REAL[3] { $result = PyCObject_FromVoidPtr( $1, NULL); } *********/ %typemap(in) FILE * { if ($input == Py_None) { $1=NULL; } else if (!PyFile_Check($input)) { PyErr_SetString(PyExc_TypeError, "Need a file!"); return NULL; } else { $1 = PyFile_AsFile($input); } } %exception { assert( !s_pythread); s_pythread = PyThreadState_Get(); PyEval_ReleaseThread( s_pythread); $function PyEval_RestoreThread( s_pythread); s_pythread = NULL; } %typemap(out) char* { if ($1) $result = PyString_FromString( $1); else { Py_INCREF( Py_None); $result = Py_None; } } enum PyArray_TYPES { PyArray_CHAR, PyArray_UBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_INT, PyArray_LONG, PyArray_FLOAT, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_NTYPES, PyArray_NOTYPE}; %native(createNumArr)PyObject *Py_createNumArr(PyObject *self, PyObject *args); %{ static PyObject *Py_createNumArr(PyObject *self, PyObject *args) { PyObject * swigPt = 0 ; int dim[1]; npy_intp lDim[1]; int type; void * data; PyArrayObject *out; if(!PyArg_ParseTuple(args, (char *)"Oii", &swigPt, &dim[0], &type)) return NULL; if (swigPt) { /**swig_type_info *ty = SWIG_TypeQuery("void *"); if ((SWIG_ConvertPtr(swigPt, (void **) &data, ty, 1 )) == -1) **/ if ((SWIG_ConvertPtr(swigPt, (void**)&data, 0, 0 )) == -1) { printf("createNumArr: failed to convert pointer\n"); return NULL; } } lDim[0] = dim[0]; out = (PyArrayObject *)PyArray_SimpleNewFromData(1, lDim, type, (char *)data); if (!out) { PyErr_SetString(PyExc_RuntimeError, "Failed to allocate memory for normals"); return NULL; } #ifdef _MSC_VER switch ( WinVerMajor() ) { case 6: break; // Vista default: out->flags |= NPY_OWNDATA; } #else // so we'll free this memory when this // array will be garbage collected out->flags |= NPY_OWNDATA; #endif return Py_BuildValue("O", (PyObject *)out); } %} %include src/prm.h parmstruct* parmcalloc( void); void parmfree( parmstruct* parm); %{ static PyObject *Py_mme_callback_func[2] = {NULL, NULL}; void sffC_PyCallback(int cbNum, int nbat, _REAL *coords, _REAL *energies, int iter) { PyObject *arglist, *result; PyObject * obj0 = 0 ; PyObject * obj1 = 0 ; assert( s_pythread); PyEval_RestoreThread( s_pythread); s_pythread = NULL; obj0 = PyCObject_FromVoidPtr( coords, NULL); obj1 = PyCObject_FromVoidPtr( energies, NULL); arglist = Py_BuildValue("iiOOi", cbNum, nbat, obj0, obj1, iter); result = PyObject_CallObject(Py_mme_callback_func[cbNum], arglist); if (!result) PyErr_Print(); Py_XDECREF( result); Py_DECREF(obj0); Py_DECREF(obj1); Py_DECREF(arglist); assert( !s_pythread); s_pythread = PyThreadState_Get(); PyEval_ReleaseThread( s_pythread); } static PyObject *set_callback(PyObject *self, PyObject *args) { PyObject *ofunc; int n, freq=1, which; char *name; if (!PyArg_ParseTuple(args, "Oii", &ofunc, &freq, &which )) return NULL; if (which<0 || which > NCBFUNC ) { PyErr_SetString(PyExc_ValueError,"third argument not valid"); return NULL; } mme_callback[which].fun = sffC_PyCallback; Py_INCREF(ofunc); Py_XDECREF(Py_mme_callback_func[which]); Py_mme_callback_func[which] = ofunc; mme_callback[which].freq = freq; Py_INCREF(Py_None); return Py_None; } %} %native (set_callback) set_callback; %constant mme_f mme_fun = mme; mgltools-sff-1.5.7~rc1~cvs.20130519/sff/Tests/0000755000175000017500000000000012146213435017670 5ustar debiandebianmgltools-sff-1.5.7~rc1~cvs.20130519/sff/Tests/tripeptide.prm0000644000175000017500000003721610063626610022571 0ustar debiandebian 42 11 21 20 45 27 75 41 0 0 218 3 20 27 41 16 31 17 14 0 0 0 0 0 0 0 0 0 16 0 N H1 H2 H3 CA HA CB HB CG2 HG21HG22HG23OG1 HG1 C O N H CA HA CB HB CG2 HG21HG22HG23OG1 HG1 C O N H CA HA CB HB2 HB3 SG HSG C O OXT 3.30188076E+00 3.52419282E+00 3.52419282E+00 3.52419282E+00 6.19558200E-02 1.98076401E+00 8.22554622E+00 -5.88580290E-01 -4.65397542E+00 1.14253821E+00 1.14253821E+00 1.14253821E+00 -1.23255637E+01 7.41647610E+00 1.12304035E+01 -1.04268001E+01 -7.57501011E+00 4.95464337E+00 -7.08847470E-01 1.83498561E+00 6.65842842E+00 7.83558900E-02 -4.44259674E+00 1.16987166E+00 1.16987166E+00 1.16987166E+00 -1.23200970E+01 7.47478746E+00 1.08841798E+01 -1.03484442E+01 -6.96274083E+00 4.88539863E+00 -2.97934605E+00 2.54383308E+00 -3.63717108E+00 2.61854451E+00 2.61854451E+00 -5.65255746E+00 3.76837164E+00 1.36612583E+01 -1.45432176E+01 -1.45432176E+01 1.40100000E+01 1.00800000E+00 1.00800000E+00 1.00800000E+00 1.20100000E+01 1.00800000E+00 1.20100000E+01 1.00800000E+00 1.20100000E+01 1.00800000E+00 1.00800000E+00 1.00800000E+00 1.60000000E+01 1.00800000E+00 1.20100000E+01 1.60000000E+01 1.40100000E+01 1.00800000E+00 1.20100000E+01 1.00800000E+00 1.20100000E+01 1.00800000E+00 1.20100000E+01 1.00800000E+00 1.00800000E+00 1.00800000E+00 1.60000000E+01 1.00800000E+00 1.20100000E+01 1.60000000E+01 1.40100000E+01 1.00800000E+00 1.20100000E+01 1.00800000E+00 1.20100000E+01 1.00800000E+00 1.00800000E+00 3.20600000E+01 1.00800000E+00 1.20100000E+01 1.60000000E+01 1.60000000E+01 1 2 2 2 3 4 3 5 3 6 6 6 7 8 9 10 1 2 3 5 3 5 3 6 6 6 7 8 9 10 1 2 3 5 3 5 5 11 2 9 10 10 12 6 5 4 14 7 10 7 6 3 2 1 2 1 7 3 10 4 14 7 10 7 6 3 2 1 2 1 7 3 10 4 9 7 7 4 3 2 1 2 1 1 1 2 4 7 11 16 22 29 37 46 56 2 3 5 8 12 17 23 30 38 47 57 4 5 6 9 13 18 24 31 39 48 58 7 8 9 10 14 19 25 32 40 49 59 11 12 13 14 15 20 26 33 41 50 60 16 17 18 19 20 21 27 34 42 51 61 22 23 24 25 26 27 28 35 43 52 62 29 30 31 32 33 34 35 36 44 53 63 37 38 39 40 41 42 43 44 45 54 64 46 47 48 49 50 51 52 53 54 55 65 56 57 58 59 60 61 62 63 64 65 66 THR THR CYS 1 17 31 5.70000000E+02 4.90000000E+02 5.53000000E+02 3.40000000E+02 3.40000000E+02 3.10000000E+02 3.20000000E+02 3.40000000E+02 3.17000000E+02 4.34000000E+02 3.67000000E+02 4.34000000E+02 3.37000000E+02 6.56000000E+02 2.74000000E+02 2.37000000E+02 1.22900000E+00 1.33500000E+00 9.60000000E-01 1.09000000E+00 1.09000000E+00 1.52600000E+00 1.41000000E+00 1.09000000E+00 1.52200000E+00 1.01000000E+00 1.47100000E+00 1.01000000E+00 1.44900000E+00 1.25000000E+00 1.33600000E+00 1.81000000E+00 8.00000000E+01 3.00000000E+01 5.00000000E+01 3.50000000E+01 5.00000000E+01 5.00000000E+01 5.00000000E+01 6.30000000E+01 5.00000000E+01 5.50000000E+01 5.00000000E+01 5.00000000E+01 4.00000000E+01 8.00000000E+01 7.00000000E+01 5.00000000E+01 3.50000000E+01 5.00000000E+01 8.00000000E+01 8.00000000E+01 5.00000000E+01 3.00000000E+01 5.00000000E+01 8.00000000E+01 6.30000000E+01 8.00000000E+01 5.00000000E+01 3.50000000E+01 4.30000000E+01 5.00000000E+01 7.00000000E+01 2.14501057E+00 2.09439600E+00 2.12755727E+00 1.91113635E+00 1.91113635E+00 1.91113635E+00 1.91113635E+00 1.93906163E+00 1.91113635E+00 1.89368305E+00 1.91113635E+00 1.91113635E+00 1.91113635E+00 2.10137732E+00 2.03505478E+00 1.91113635E+00 1.91113635E+00 1.91113635E+00 1.94080696E+00 1.94080696E+00 1.91113635E+00 2.06018753E+00 1.91113635E+00 1.91462701E+00 1.92160833E+00 2.19911580E+00 1.91113635E+00 1.91113635E+00 1.67551680E+00 1.89542838E+00 2.04203610E+00 2.00000000E+00 2.50000000E+00 0.00000000E+00 5.30000000E-01 1.50000000E-01 5.00000000E-01 2.00000000E-01 1.55555556E-01 1.66666667E-01 7.00000000E-02 1.00000000E-01 7.50000000E-01 1.35000000E+00 4.00000000E-01 2.50000000E-01 1.05000000E+01 1.00000000E+00 1.00000000E+00 2.00000000E+00 2.00000000E+00 1.00000000E+00 3.00000000E+00 4.00000000E+00 2.00000000E+00 3.00000000E+00 3.00000000E+00 2.00000000E+00 4.00000000E+00 1.00000000E+00 2.00000000E+00 4.00000000E+00 3.00000000E+00 2.00000000E+00 2.00000000E+00 0.00000000E+00 3.14159400E+00 0.00000000E+00 0.00000000E+00 3.14159400E+00 3.14159400E+00 3.14159400E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 3.14159400E+00 3.14159400E+00 3.14159400E+00 0.00000000E+00 3.14159400E+00 3.14159400E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 9.44293233E+05 2.12601181E+03 1.39982777E-01 9.95480466E+05 2.56678134E+03 1.04308023E+06 2.01791425E+04 9.14716912E+00 2.27401052E+04 2.01823541E+02 6.20665997E+04 5.94667300E+01 6.78771368E+04 8.79040886E+02 3.25969625E+03 8.96776989E+04 1.07193646E+02 9.71708117E+04 1.41077189E+03 4.98586848E+03 7.51607703E+03 7.44975864E+05 1.40467023E+03 7.91544157E+05 1.45985502E+04 4.66922514E+04 6.82786631E+04 5.81803229E+05 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 8.82619071E+05 2.27577561E+03 9.24822270E+05 2.01619733E+04 6.01816484E+04 8.61541883E+04 7.01803794E+05 0.00000000E+00 8.19971662E+05 6.06829342E+05 1.02595236E+03 6.47841731E+05 1.12780457E+04 3.69471530E+04 5.44261042E+04 4.71003287E+05 0.00000000E+00 5.74393458E+05 3.79876399E+05 2.01562190E+06 5.97860700E+03 2.09861767E+06 4.93469320E+04 1.42791446E+05 2.02461849E+05 1.61587928E+06 0.00000000E+00 1.86068943E+06 1.32911052E+06 4.19430400E+06 8.01323529E+02 2.09604198E+01 9.37598976E-02 7.36907417E+02 2.06278363E+01 6.75612247E+02 6.45756063E+01 7.57919667E-01 6.13981767E+01 3.56012899E+00 1.13252061E+02 1.93248820E+00 1.06076943E+02 7.42992380E+00 1.43076527E+01 1.36131731E+02 2.59456373E+00 1.26919150E+02 9.41257003E+00 1.76949863E+01 2.17257828E+01 7.50714425E+02 1.79702257E+01 6.93079947E+02 5.79323581E+01 1.03606917E+02 1.25287818E+02 6.99746810E+02 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 0.00000000E+00 6.53361429E+02 1.82891803E+01 5.99015525E+02 5.44372326E+01 9.40505980E+01 1.12529845E+02 6.14502845E+02 0.00000000E+00 5.31102864E+02 6.77220874E+02 1.53505284E+01 6.26720080E+02 5.08951803E+01 9.21192136E+01 1.11805549E+02 6.29300710E+02 0.00000000E+00 5.55666448E+02 5.64885984E+02 1.28923404E+03 3.87070358E+01 1.17824605E+03 1.11203892E+02 1.89165096E+02 2.25248294E+02 1.21753341E+03 0.00000000E+00 1.04466382E+03 1.10369829E+03 2.04800000E+03 36 39 3 24 27 4 24 30 4 24 33 4 18 21 5 12 15 8 0 3 10 0 6 10 0 9 10 78 81 3 66 69 4 66 72 4 66 75 4 60 63 5 54 57 5 48 51 12 111 114 15 102 105 5 102 108 5 96 99 5 90 93 12 42 45 1 42 48 2 18 24 6 18 36 7 12 18 6 12 42 9 0 12 11 84 87 1 84 90 2 60 66 6 60 78 7 54 60 6 54 84 9 48 54 13 117 120 14 117 123 14 102 111 16 96 102 6 96 117 9 90 96 13 42 48 51 2 30 24 33 4 27 24 30 4 27 24 33 4 21 18 24 6 21 18 36 7 18 24 27 9 18 24 30 9 18 24 33 9 18 36 39 10 15 12 18 11 15 12 42 12 12 18 21 6 9 0 12 16 6 0 9 17 6 0 12 16 3 0 6 17 3 0 9 17 3 0 12 16 0 12 15 18 84 90 93 2 72 66 75 4 69 66 72 4 69 66 75 4 63 60 66 6 63 60 78 7 60 66 69 9 60 66 72 9 60 66 75 9 60 78 81 10 57 54 60 6 57 54 84 21 54 60 63 6 51 48 54 22 48 54 57 23 108 102 111 27 105 102 108 28 105 102 111 27 102 111 114 29 99 96 102 6 99 96 117 21 96 102 105 6 96 102 108 6 93 90 96 22 90 96 99 23 45 42 48 1 42 48 54 3 24 18 36 5 18 12 42 8 12 18 24 13 12 18 36 5 12 42 45 14 12 42 48 15 0 12 18 19 0 12 42 20 87 84 90 1 84 90 96 3 66 60 78 5 60 54 84 8 54 60 66 13 54 60 78 5 54 84 87 14 54 84 90 15 48 54 60 24 48 54 84 25 120 117 123 26 102 96 117 8 96 102 111 30 96 117 120 31 96 117 123 31 90 96 102 24 90 96 117 25 45 42 48 51 1 45 42 -48 51 2 42 48 54 57 3 33 24 18 36 8 30 24 18 36 8 27 24 18 36 8 24 18 36 39 9 21 18 12 42 8 21 18 24 27 8 21 18 24 30 8 21 18 24 33 8 21 18 36 39 9 15 12 18 21 8 15 12 18 24 8 15 12 18 36 8 15 12 42 45 3 15 12 42 48 3 12 18 24 27 8 12 18 24 30 8 12 18 24 33 8 12 18 36 39 9 12 42 48 51 2 9 0 12 15 8 9 0 12 18 8 9 0 12 42 8 6 0 12 15 8 6 0 12 18 8 6 0 12 42 8 3 0 12 15 8 3 0 12 18 8 3 0 12 42 8 0 12 18 21 8 87 84 90 93 1 87 84 -90 93 2 84 90 96 99 3 75 66 60 78 8 72 66 60 78 8 69 66 60 78 8 66 60 78 81 9 63 60 54 84 8 63 60 66 69 8 63 60 66 72 8 63 60 66 75 8 63 60 78 81 9 57 54 60 63 8 57 54 60 66 8 57 54 60 78 8 57 54 84 87 3 57 54 84 90 3 54 60 66 69 8 54 60 66 72 8 54 60 66 75 8 54 60 78 81 9 54 84 90 93 2 51 48 54 57 3 51 48 54 60 3 51 48 54 84 3 48 54 60 63 8 108 102 96 117 8 108 102 111 114 15 105 102 96 117 8 105 102 111 114 15 99 96 102 105 8 99 96 102 108 8 99 96 102 111 8 99 96 117 120 3 99 96 117 123 3 96 102 111 114 15 93 90 96 99 3 93 90 96 102 3 93 90 96 117 3 90 96 102 105 8 90 96 102 108 8 42 54 -48 -51 17 84 96 -90 -93 17 45 42 48 54 2 42 48 54 60 4 42 48 -54 60 5 42 48 -54 60 6 42 48 54 84 7 36 18 12 42 8 24 18 12 42 8 18 12 42 45 3 18 12 42 48 10 18 12 -42 48 11 12 42 48 54 2 0 12 18 24 8 0 12 18 36 8 0 12 42 45 3 0 12 42 48 3 87 84 90 96 2 84 90 96 102 4 84 90 -96 102 5 84 90 -96 102 6 84 90 96 117 7 78 60 54 84 8 66 60 54 84 8 60 54 84 87 3 60 54 84 90 10 60 54 -84 90 11 54 84 90 96 2 48 54 60 66 8 48 54 60 78 8 48 54 84 87 3 48 54 84 90 12 48 54 -84 90 13 48 54 -84 90 14 111 102 96 117 8 102 96 117 120 3 102 96 117 123 3 90 96 102 111 8 90 96 117 120 3 90 96 117 123 3 12 48 -42 -45 16 54 90 -84 -87 16 96 120 -117 -123 16 2 3 4 5 6 7 8 9 13 15 16 17 3 4 5 6 7 15 4 5 6 7 15 5 6 7 15 6 7 8 9 10 11 12 13 14 15 16 17 18 19 7 8 9 13 15 16 17 8 9 10 11 12 13 14 15 16 17 9 10 11 12 13 14 15 10 11 12 13 14 15 11 12 13 12 13 13 14 15 0 16 17 18 19 20 21 29 17 18 19 18 19 20 21 22 23 27 29 30 31 19 20 21 29 20 21 22 23 24 25 26 27 28 29 30 31 32 33 21 22 23 27 29 30 31 22 23 24 25 26 27 28 29 30 31 23 24 25 26 27 28 29 24 25 26 27 28 29 25 26 27 26 27 27 28 29 0 30 31 32 33 34 35 40 31 32 33 32 33 34 35 36 37 38 40 41 42 33 34 35 40 34 35 36 37 38 39 40 41 42 35 36 37 38 40 41 42 36 37 38 39 40 41 42 37 38 39 40 38 39 40 39 40 0 41 42 42 0 N3 H H H CT HP CT H1 CT HC HC HC OH HO C O N H CT H1 CT H1 CT HC HC HC OH HO C O N H CT H1 CT H1 H1 SH HS C O2 O2 BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA M E M E 3 E 3 E E E S E M E BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA BLA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 mgltools-sff-1.5.7~rc1~cvs.20130519/sff/Tests/p1H.pdb0000644000175000017500000000671610063626610021020 0ustar debiandebianREMARK 4 XXXX COMPLIES WITH FORMAT V. 2.0, 15-APR-1996 ATOM 1 N THR 1 17.047 14.099 3.625 1.00 13.79 1CRN N ATOM 2 H1 THR 1 17.914 14.119 3.088 1.00 0.00 1CRN H ATOM 3 H2 THR 1 16.958 14.895 4.257 1.00 0.00 1CRN H ATOM 4 H3 THR 1 16.224 14.286 3.051 1.00 0.00 1CRN H ATOM 5 CA THR 1 16.967 12.784 4.338 1.00 10.80 1CRN C ATOM 6 HA THR 1 17.000 11.939 3.612 1.00 0.00 1CRN H ATOM 7 CB THR 1 18.170 12.703 5.337 1.00 13.02 1CRN C ATOM 8 HB THR 1 18.134 13.632 5.953 1.00 0.00 1CRN H ATOM 9 CG2 THR 1 18.150 11.546 6.304 1.00 14.23 1CRN C ATOM 10 1HG2 THR 1 19.007 11.488 7.015 1.00 0.00 1CRN H ATOM 11 2HG2 THR 1 18.058 10.586 5.744 1.00 0.00 1CRN H ATOM 12 3HG2 THR 1 17.188 11.541 6.869 1.00 0.00 1CRN H ATOM 13 OG1 THR 1 19.334 12.829 4.463 1.00 15.06 1CRN O ATOM 14 HG1 THR 1 20.064 12.780 5.069 1.00 0.00 1CRN H ATOM 15 C THR 1 15.685 12.755 5.133 1.00 9.19 1CRN C ATOM 16 O THR 1 15.268 13.825 5.594 1.00 9.85 1CRN O ATOM 17 N THR 2 15.115 11.555 5.265 1.00 7.81 1CRN N ATOM 18 H THR 2 15.524 10.726 4.834 1.00 0.00 1CRN H ATOM 19 CA THR 2 13.856 11.469 6.066 1.00 8.31 1CRN C ATOM 20 HA THR 2 13.501 12.504 6.280 1.00 0.00 1CRN H ATOM 21 CB THR 2 12.732 10.711 5.261 1.00 10.32 1CRN C ATOM 22 HB THR 2 11.794 10.602 5.854 1.00 0.00 1CRN H ATOM 23 CG2 THR 2 12.484 11.442 3.895 1.00 11.90 1CRN C ATOM 24 1HG2 THR 2 11.689 10.906 3.326 1.00 0.00 1CRN H ATOM 25 2HG2 THR 2 13.421 11.558 3.303 1.00 0.00 1CRN H ATOM 26 3HG2 THR 2 12.248 12.523 4.032 1.00 0.00 1CRN H ATOM 27 OG1 THR 2 13.308 9.439 4.926 1.00 12.81 1CRN O ATOM 28 HG1 THR 2 12.631 8.982 4.441 1.00 0.00 1CRN H ATOM 29 C THR 2 14.164 10.785 7.379 1.00 5.80 1CRN C ATOM 30 O THR 2 14.993 9.862 7.443 1.00 6.94 1CRN O ATOM 31 N CYS 3 13.488 11.241 8.417 1.00 5.24 1CRN N ATOM 32 H CYS 3 12.817 11.995 8.269 1.00 0.00 1CRN H ATOM 33 CA CYS 3 13.660 10.707 9.787 1.00 5.39 1CRN C ATOM 34 HA CYS 3 14.252 9.762 9.757 1.00 0.00 1CRN H ATOM 35 CB CYS 3 14.368 11.748 10.691 1.00 5.99 1CRN C ATOM 36 HB2 CYS 3 14.555 11.317 11.702 1.00 0.00 1CRN H ATOM 37 HB3 CYS 3 13.663 12.570 10.958 1.00 0.00 1CRN H ATOM 38 SG CYS 3 15.885 12.426 10.016 1.00 7.01 1CRN S ATOM 39 HSG CYS 3 16.149 13.226 11.045 1.00 0.00 1CRN H ATOM 40 C CYS 3 12.269 10.431 10.323 1.00 4.45 1CRN C ATOM 41 O CYS 3 11.393 11.308 10.185 1.00 6.54 1CRN O ATOM 42 OXT CYS 3 12.026 9.383 10.917 1.00 6.54 1CRN O MASTER 1 0 0 0 0 0 0 0 41 0 0 0 END mgltools-sff-1.5.7~rc1~cvs.20130519/sff/Tests/tripepparmdict.py0000644000175000017500000003574310063626610023304 0ustar debiandebianp = { 'ititl': 'test', 'Ntype2d':121, 'Cn1': [ 1., 2., 4., 7., 11., 16., 22., 29., 37., 46., 56., 2., 3., 5., 8., 12., 17., 23., 30., 38., 47., 57., 4., 5., 6., 9., 13., 18., 24., 31., 39., 48., 58., 7., 8., 9., 10., 14., 19., 25., 32., 40., 49., 59., 11., 12., 13., 14., 15., 20., 26., 33., 41., 50., 60., 16., 17., 18., 19., 20., 21., 27., 34., 42., 51., 61., 22., 23., 24., 25., 26., 27., 28., 35., 43., 52., 62., 29., 30., 31., 32., 33., 34., 35., 36., 44., 53., 63., 37., 38., 39., 40., 41., 42., 43., 44., 45., 54., 64., 46., 47., 48., 49., 50., 51., 52., 53., 54., 55., 65., 56., 57., 58., 59., 60., 61., 62., 63., 64., 65., 66.], 'Cn2': [ 1., 2., 4., 7., 11., 16., 22., 29., 37., 46., 56., 2., 3., 5., 8., 12., 17., 23., 30., 38., 47., 57., 4., 5., 6., 9., 13., 18., 24., 31., 39., 48., 58., 7., 8., 9., 10., 14., 19., 25., 32., 40., 49., 59., 11., 12., 13., 14., 15., 20., 26., 33., 41., 50., 60., 16., 17., 18., 19., 20., 21., 27., 34., 42., 51., 61., 22., 23., 24., 25., 26., 27., 28., 35., 43., 52., 62., 29., 30., 31., 32., 33., 34., 35., 36., 44., 53., 63., 37., 38., 39., 40., 41., 42., 43., 44., 45., 54., 64., 46., 47., 48., 49., 50., 51., 52., 53., 54., 55., 65., 56., 57., 58., 59., 60., 61., 62., 63., 64., 65., 66.], 'Nat3':0, 'Nspm':1, 'Ntypes': 11, 'Iblo': [12, 6, 5, 4, 14, 7, 10, 7, 6, 3, 2, 1, 2, 1, 7, 3, 10, 4, 14, 7, 10, 7, 6, 3, 2, 1, 2, 1, 7, 3, 10, 4, 9, 7, 7, 4, 3, 2, 1, 2, 1, 1], 'BondAt1': [0.0, 12.0, 12.0, 18.0, 18.0, 42.0, 42.0, 48.0, 54.0, 54.0, 60.0, 60.0, 84.0, 84.0, 90.0, 96.0, 96.0, 102.0, 117.0, 117.0], 'BondAt2': [12.0, 18.0, 42.0, 24.0, 36.0, 45.0, 48.0, 54.0, 60.0, 84.0, 66.0, 78.0, 87.0, 90.0, 96.0, 102.0, 117.0, 111.0, 120.0, 123.0], 'Nptra': 15, 'AngleAt1': [18.0, 42.0, 12.0, 12.0, 12.0, 12.0, 42.0, 24.0, 42.0, 48.0, 60.0, 84.0, 54.0, 54.0, 54.0, 54.0, 84.0, 66.0, 84.0, 90.0, 102.0, 117.0, 96.0, 96.0, 96.0, 117.0, 120.0], 'AngleAt3': [0.0, 0.0, 24.0, 36.0, 45.0, 48.0, 18.0, 36.0, 54.0, 45.0, 48.0, 48.0, 66.0, 78.0, 87.0, 90.0, 60.0, 78.0, 96.0, 87.0, 90.0, 90.0, 111.0, 120.0, 123.0, 102.0, 123.0], 'Nttyp': 0, 'Cno': [ 1., 2., 4., 7., 11., 16., 22., 29., 37., 46., 56., 2., 3., 5., 8., 12., 17., 23., 30., 38., 47., 57., 4., 5., 6., 9., 13., 18., 24., 31., 39., 48., 58., 7., 8., 9., 10., 14., 19., 25., 32., 40., 49., 59., 11., 12., 13., 14., 15., 20., 26., 33., 41., 50., 60., 16., 17., 18., 19., 20., 21., 27., 34., 42., 51., 61., 22., 23., 24., 25., 26., 27., 28., 35., 43., 52., 62., 29., 30., 31., 32., 33., 34., 35., 36., 44., 53., 63., 37., 38., 39., 40., 41., 42., 43., 44., 45., 54., 64., 46., 47., 48., 49., 50., 51., 52., 53., 54., 55., 65., 56., 57., 58., 59., 60., 61., 62., 63., 64., 65., 66.], 'Ifpert': 0, 'AngleAt2': [12.0, 12.0, 18.0, 18.0, 42.0, 42.0, 12.0, 18.0, 48.0, 42.0, 54.0, 54.0, 60.0, 60.0, 84.0, 84.0, 54.0, 60.0, 90.0, 84.0, 96.0, 96.0, 102.0, 117.0, 117.0, 96.0, 117.0], 'Natom': 42, 'Nbonh': 21, 'Charges': [3.30188076, 3.5241928200000001, 3.5241928200000001, 3.5241928200000001, 0.061955820000000002, 1.9807640100000001, 8.22554622, -0.58858029000000012, -4.6539754200000001, 1.1425382100000001, 1.1425382100000001, 1.1425382100000001, -12.32556372, 7.4164760999999997, 11.23040349, -10.426800060000001, -7.5750101100000009, 4.9546433699999994, -0.70884746999999992, 1.8349856099999999, 6.6584284199999999, 0.078355889999999997, -4.4425967399999999, 1.1698716599999999, 1.1698716599999999, 1.1698716599999999, -12.320097030000001, 7.4747874600000008, 10.884179790000001, -10.34844417, -6.9627408300000004, 4.8853986300000001, -2.9793460500000002, 2.5438330800000002, -3.6371710800000003, 2.61854451, 2.61854451, -5.6525574599999997, 3.7683716400000002, 13.661258310000001, -14.543217630000001, -14.543217630000001], 'Zcap': 0, 'Nbona': 20, 'ExclAt': [2, 3, 4, 5, 6, 7, 8, 9, 13, 15, 16, 17, 3, 4, 5, 6, 7, 15, 4, 5, 6, 7, 15, 5, 6, 7, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 7, 8, 9, 13, 15, 16, 17, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 9, 10, 11, 12, 13, 14, 15, 10, 11, 12, 13, 14, 15, 11, 12, 13, 12, 13, 13, 14, 15, 0, 16, 17, 18, 19, 20, 21, 29, 17, 18, 19, 18, 19, 20, 21, 22, 23, 27, 29, 30, 31, 19, 20, 21, 29, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 21, 22, 23, 27, 29, 30, 31, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 23, 24, 25, 26, 27, 28, 29, 24, 25, 26, 27, 28, 29, 25, 26, 27, 26, 27, 27, 28, 29, 0, 30, 31, 32, 33, 34, 35, 40, 31, 32, 33, 32, 33, 34, 35, 36, 37, 38, 40, 41, 42, 33, 34, 35, 40, 34, 35, 36, 37, 38, 39, 40, 41, 42, 35, 36, 37, 38, 40, 41, 42, 36, 37, 38, 39, 40, 41, 42, 37, 38, 39, 40, 38, 39, 40, 39, 40, 0, 41, 42, 42, 0], 'Box': [0., 0., 0.], 'Mbper': 0, 'Phase': [0.0, 0.0, 0.0, 0.0, 3.1415926535897931, 0.0, 0.0, 0.0, 3.1415926535897931, 0.0, 3.1415926535897931, 0.0, 3.1415926535897931, 3.1415926535897931, 3.1415926535897931], 'Nres': 3, 'IfBox': 0, 'Nmxrs': 16, 'CN1': [944293.23256797146, 2126.0118106070863, 0.13998277703761916, 995480.4663629391, 2566.7813383041557, 1043080.2307033287, 20179.142458282517, 9.1471691245072577, 22740.105239497425, 201.82354130747285, 62066.599749628745, 59.466729982673158, 67877.136766213604, 879.04088635443543, 3259.6962529686762, 89677.698908466016, 107.1936455734686, 97170.811711368719, 1410.7718879131319, 4985.8684768914336, 7516.0770340909585, 744975.86419548525, 1404.6702337355946, 791544.1565721808, 14598.55020685001, 46692.251433316342, 68278.663143236481, 581803.22917952423, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 882619.07113852445, 2275.775605027035, 924822.26970255352, 20161.973280508293, 60181.648388363021, 86154.188326580377, 701803.79409288475, 0.0, 819971.66216166609, 606829.34249013837, 1025.9523604899639, 647841.7314394908, 11278.045702527517, 36947.152957469938, 54426.104170034348, 471003.28656053549, 0.0, 574393.45780133759, 379876.39852344815, 2015621.8995230631, 5978.6069987442397, 2098617.6732316222, 49346.931964304531, 142791.44557463724, 202461.84913546019, 1615879.2807305618, 0.0, 1860689.4298890929, 1329110.5215164199, 4194304.0], 'CN2': [801.32352901073648, 20.96041975062256, 0.093759897599999989, 736.90741710863813, 20.627836280013653, 675.6122474879927, 64.57560627319944, 0.75791966660000043, 61.398176700122868, 3.5601289856000014, 113.25206145881647, 1.9324881999411727, 106.07694324680888, 7.4299237992767155, 14.307652661650437, 136.13173106000798, 2.5945637286476178, 126.91914990510502, 9.4125700295373456, 17.694986305413803, 21.72578278775962, 750.71442548492928, 17.970225725194219, 693.07994715021232, 57.932358100075021, 103.60691691848741, 125.2878184638575, 699.74680969439771, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 653.36142895885314, 18.289180262453637, 599.015525142667, 54.437232592471624, 94.050597958772798, 112.52984461685405, 614.50284545857767, 0.0, 531.10286365600882, 677.22087396384438, 15.350528417410029, 626.72008039321361, 50.895180336189838, 92.119213572969684, 111.80554855078391, 629.30071037696848, 0.0, 555.66644842516325, 564.88598385842113, 1289.2340356228342, 38.707035789225856, 1178.2460467213175, 111.20389249248535, 189.165096403034, 225.24829404375737, 1217.5334113014796, 0.0, 1044.6638246246193, 1103.6982895530125, 2048.0], 'Numang': 31, 'AngleNum': [2, 3, 7, 8, 9, 10, 13, 8, 19, 20, 22, 23, 7, 8, 9, 10, 13, 8, 19, 20, 22, 23, 26, 27, 27, 13, 31], 'AngleHAt3': [0.0, 6.0, 9.0, 3.0, 9.0, 6.0, 9.0, 21.0, 15.0, 15.0, 27.0, 30.0, 33.0, 39.0, 21.0, 36.0, 30.0, 33.0, 33.0, 51.0, 48.0, 51.0, 63.0, 57.0, 57.0, 69.0, 72.0, 75.0, 81.0, 63.0, 78.0, 72.0, 75.0, 75.0, 93.0, 90.0, 93.0, 105.0, 108.0, 99.0, 99.0, 114.0, 108.0, 111.0, 111.0], 'Mdper': 0, 'Pn': [3.0, 2.0, 3.0, 3.0, 2.0, 2.0, 2.0, 1.0, 2.0, 1.0, 1.0, 3.0, 2.0, 2.0, 2.0], 'Cutcap': 0, 'Nhparm': 0, 'Pk': [0.15555555555555556, 0.0, 0.15555555555555556, 0.16666666666666666, 2.5, 0.070000000000000007, 0.0, 0.53000000000000003, 0.20000000000000001, 2.0, 0.75, 0.25, 10.5, 1.0, 10.5], 'Tk': [50.0, 80.0, 80.0, 35.0, 50.0, 50.0, 40.0, 50.0, 80.0, 70.0, 50.0, 50.0, 63.0, 50.0, 55.0, 50.0, 35.0, 30.0, 50.0, 80.0, 50.0, 80.0, 63.0, 30.0, 50.0, 50.0, 70.0, 43.0, 35.0, 50.0, 80.0], 'Mbona': 20, 'Req': [1.01, 1.4710000000000001, 1.0900000000000001, 1.526, 1.522, 1.0900000000000001, 1.4099999999999999, 1.0900000000000001, 0.95999999999999996, 1.2290000000000001, 1.335, 1.01, 1.4490000000000001, 1.8100000000000001, 1.3360000000000001, 1.25], 'Masses': [14.01, 1.008, 1.008, 1.008, 12.01, 1.008, 12.01, 1.008, 12.01, 1.008, 1.008, 1.008, 16.0, 1.008, 12.01, 16.0, 14.01, 1.008, 12.01, 1.008, 12.01, 1.008, 12.01, 1.008, 1.008, 1.008, 16.0, 1.008, 12.01, 16.0, 14.01, 1.008, 12.01, 1.008, 12.01, 1.008, 1.008, 32.060000000000002, 1.008, 12.01, 16.0, 16.0], 'AtomRes': range(42), 'Ipres': [1, 15, 27, -1], 'BondHNum': [1, 1, 1, 3, 6, 8, 8, 8, 9, 12, 6, 6, 8, 8, 8, 9, 12, 6, 6, 6, 15], 'Ycap': 0, 'Teq': [1.911135530933791, 1.9408061282176943, 1.9408061282176943, 1.911135530933791, 1.911135530933791, 1.911135530933791, 1.911135530933791, 1.911135530933791, 2.101376419401173, 2.0350539078253882, 1.911135530933791, 1.911135530933791, 1.9390607989657, 1.911135530933791, 1.8936822384138474, 1.911135530933791, 1.911135530933791, 2.0943951023931953, 2.1275563581810877, 2.1450096507010312, 1.911135530933791, 1.9146261894377794, 1.9216075064457567, 2.0601866490541068, 1.911135530933791, 1.8954275676658416, 2.0420352248333655, 1.6755160819145563, 1.911135530933791, 1.911135530933791, 2.1991148575128552], 'Ndper': 0, 'Nnb': 218, 'Ntheth': 45, 'Mgper': 0, 'Natyp': 14, 'Ntheta': 27, 'Ngper': 0, 'Xcap': 0, 'Iptres': 0, 'BondNum': [2, 4, 5, 4, 7, 10, 11, 13, 4, 5, 4, 7, 10, 11, 13, 4, 5, 14, 16, 16], 'Nspsol': 0, 'Solty': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], 'N14pairs': range(42), 'AngleHNum': [1, 4, 4, 5, 4, 5, 5, 6, 11, 12, 14, 14, 14, 15, 6, 16, 17, 17, 17, 18, 21, 24, 6, 6, 25, 14, 14, 14, 15, 6, 16, 17, 17, 17, 18, 21, 24, 6, 6, 6, 25, 28, 29, 30, 30], 'N14pairlist': range(420), 'BondHAt1': [0.0, 0.0, 0.0, 12.0, 18.0, 24.0, 24.0, 24.0, 36.0, 48.0, 54.0, 60.0, 66.0, 66.0, 66.0, 78.0, 90.0, 96.0, 102.0, 102.0, 111.0], 'IfCap': 0, 'Nparm': 0, 'Nphih': 73, 'DihHNum': [1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 4, 5, 1, 1, 1, 2, 2, 1, 1, 1, 1, 4, 4, 1, 1, 1, 7, 10, 1, 7, 7, 7, 1, 1, 1, 4, 5, 1, 1, 1, 2, 2, 1, 1, 1, 1, 4, 4, 1, 1, 1, 7, 10, 1, 1, 7, 7, 7, 12, 1, 1, 1, 2, 2, 1, 12, 1, 12, 13, 13], 'DihHAt1': [21, 3, 18, 42, 6, 18, 42, 9, 18, 42, 12, 12, 12, 12, 12, 21, 24, 15, 15, 15, 42, 21, 21, 21, 21, 24, 27, 30, 33, 42, 51, 63, 51, 60, 84, 54, 54, 54, 54, 54, 57, 66, 57, 57, 57, 84, 63, 63, 63, 63, 66, 69, 72, 75, 84, 93, 105, 108, 93, 102, 117, 96, 99, 99, 99, 99, 99, 117, 105, 117, 108, 60, 99], 'DihHAt2': [18, 0, 12, 12, 0, 12, 12, 0, 12, 12, 18, 18, 18, 18, 42, 18, 18, 12, 12, 12, 12, 18, 18, 18, 18, 18, 24, 24, 24, 48, 48, 60, 48, 54, 54, 60, 60, 60, 60, 84, 54, 60, 54, 54, 54, 54, 60, 60, 60, 60, 60, 66, 66, 66, 90, 90, 102, 102, 90, 96, 96, 102, 96, 96, 96, 96, 96, 96, 102, 96, 102, 96, 126], 'DihHAt3': [12, 12, 0, 0, 12, 0, 0, 12, 0, 0, 24, 24, 24, 36, 48, 12, 12, 18, 42, 42, 18, 24, 24, 24, 36, 36, 18, 18, 18, 54, 42, 54, 54, 48, 48, 66, 66, 66, 78, 90, 60, 54, 60, 84, 84, 60, 66, 66, 66, 78, 78, 60, 60, 60, 96, 84, 96, 96, 96, 90, 90, 111, 102, 102, 102, 117, 117, 102, 111, 102, 111, -87, -120], 'DihHAt4': [0, 15, 3, 3, 15, 6, 6, 15, 9, 9, 27, 30, 33, 39, 51, 15, 15, 36, 45, 48, 21, 27, 30, 33, 39, 39, 36, 36, 36, 57, 45, 48, 57, 51, 51, 69, 72, 75, 81, 93, 63, 57, 78, 87, 90, 63, 69, 72, 75, 81, 81, 78, 78, 78, 99, 87, 90, 90, 99, 93, 93, 114, 105, 108, 111, 120, 123, 105, 114, 108, 114, -99, -129], 'Mphia': 38, 'Nphia': 38, 'DihNum': [1, 1, 2, 2, 5, 2, 6, 1, 1, 8, 9, 5, 1, 1, 2, 11, 5, 5, 2, 2, 1, 1, 9, 8, 8, 5, 11, 1, 2, 2, 5, 2, 2, 1, 9, 12, 12, 14], 'DihAt1': [24, 0, 0, 48, 12, 18, 18, 42, 42, 42, 42, 54, 66, 48, 48, 48, 54, 54, 60, 60, 84, 84, 84, 84, 84, 96, 90, 90, 90, 90, 96, 102, 102, 117, 117, 75, 96, 126], 'DihAt2': [18, 12, 12, 42, 42, 12, 12, 12, 12, 48, 48, 48, 60, 54, 54, 54, 48, 84, 54, 54, 54, 54, 54, 90, 90, 90, 84, 96, 96, 96, 90, 96, 96, 96, 96, 87, 108, -132], 'DihAt3': [12, 18, 42, 12, 48, 42, 42, 18, 18, 54, 54, 42, 54, 60, 84, 84, 42, 90, 84, 84, 60, 60, 48, 96, 96, 84, 54, 102, 117, 117, 84, 117, 117, 102, 90, -84, -105, -138], 'DihAt4': [0, 36, 45, 0, 54, 45, 48, 24, 36, 60, 84, 45, 48, 78, 87, 90, 12, 96, 87, 90, 66, 78, 42, 102, 117, 87, 48, 111, 120, 123, 54, 120, 123, 111, 84, -66, -102, -117], 'BondHAt2': [3, 6, 9, 15, 21, 27, 30, 33, 39, 51, 57, 63, 69, 72, 75, 81, 93, 99, 105, 108, 114], 'Natcap': 0, 'Nbper': 0, 'Rk': [434.0, 367.0, 340.0, 310.0, 317.0, 340.0, 320.0, 340.0, 553.0, 570.0, 490.0, 434.0, 337.0, 237.0, 274.0, 656.0], 'Ipatm': 0, 'Boundary': [42], 'Nphb': 1, # because we cannot handle o size arrays 'Iac': [1, 2, 2, 2, 3, 4, 3, 5, 3, 6, 6, 6, 7, 8, 9, 10, 1, 2, 3, 5, 3, 5, 3, 6, 6, 6, 7, 8, 9, 10, 1, 2, 3, 5, 3, 5, 5, 11, 2, 9, 10, 10], 'HB12': [0.0], 'Numbnd': 16, 'HB10': [0.0], 'AngleHAt2': [12.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 18.0, 12.0, 12.0, 24.0, 24.0, 24.0, 36.0, 18.0, 18.0, 24.0, 24.0, 24.0, 48.0, 54.0, 48.0, 60.0, 54.0, 54.0, 66.0, 66.0, 66.0, 78.0, 60.0, 60.0, 66.0, 66.0, 66.0, 90.0, 96.0, 90.0, 102.0, 102.0, 96.0, 96.0, 111.0, 102.0, 102.0, 102.0], 'Mtheta': 27, 'AngleHAt1': [15.0, 3.0, 3.0, 12.0, 6.0, 12.0, 12.0, 12.0, 18.0, 42.0, 18.0, 18.0, 18.0, 18.0, 24.0, 21.0, 27.0, 27.0, 30.0, 42.0, 57.0, 54.0, 54.0, 60.0, 84.0, 60.0, 60.0, 60.0, 60.0, 66.0, 63.0, 69.0, 69.0, 72.0, 84.0, 99.0, 96.0, 96.0, 96.0, 102.0, 117.0, 102.0, 105.0, 105.0, 108.0], 'AtomTree': 'M E E E M E 3 E 3 E E E S E M E M E M E 3 E 3 E E E S E M E M E M E 3 E E S E M E E', 'AtomSym': 'N3 H H H CT HP CT H1 CT HC HC HC OH HO C O N H CT H1 CT H1 CT HC HC HC OH HO C O N H CT H1 CT H1 H1 SH HS C O2 O2', 'ResNames': 'THR CYS THR', 'AtomNames': 'N H1 H2 H3 CA HA CB HB CG2 HG21 HG22 HG23 OG1 HG1 C O N H CA HA CB HB CG2 HG21 HG22 HG23 OG1 HG1 C O N H CA HA CB HB2 HB3 SG HSG C O OXT', 'TreeJoin': range(42)} for key in ('AtomTree','AtomSym', 'AtomNames'): p[key] = p[key] + ' '*((4*p['Natom'] + 81) - len(p[key])) p['ResNames'] = p['ResNames'] + ' '*((4*p['Nres'] + 81) - len(p['ResNames'])) parmDict = p mgltools-sff-1.5.7~rc1~cvs.20130519/sff/Tests/__init__.py0000644000175000017500000000000110063626610021767 0ustar debiandebian mgltools-sff-1.5.7~rc1~cvs.20130519/sff/Tests/test_dependencies.py0000644000175000017500000000150610406105334023724 0ustar debiandebian# ################################################################# # Author: Sowjanya Karnati ################################################################# # #Purpose:To update dependencies list # # $Id: test_dependencies.py,v 1.2 2006/03/15 21:45:00 sowjanya Exp $ from mglutil.TestUtil.Tests.dependenciestest import DependencyTester import unittest d = DependencyTester() result_expected =[] class test_dep(unittest.TestCase): def test_dep_1(self): result = d.rundeptester('sff') if result !=[]: print "\nThe Following Packages are not present in CRITICAL or NONCRITICAL DEPENDENCIES of sff :\n %s" %result self.assertEqual(result,result_expected) else: self.assertEqual(result,result_expected) if __name__ == '__main__': unittest.main() mgltools-sff-1.5.7~rc1~cvs.20130519/sff/Tests/p1H_crd.py0000644000175000017500000000203710063626610021523 0ustar debiandebiancoords = [[17.047, 14.099, 3.625], [17.914, 14.119, 3.088], [16.958, 14.895, 4.257], [16.224, 14.286, 3.051], [16.967, 12.784, 4.338], [17.0, 11.939, 3.612], [18.17, 12.703, 5.337], [18.134, 13.632, 5.953], [18.15, 11.546, 6.304], [19.007, 11.488, 7.015], [18.058, 10.586, 5.744], [17.188, 11.541, 6.869], [19.334, 12.829, 4.463], [20.064, 12.78, 5.069], [15.685, 12.755, 5.133], [15.268, 13.825, 5.594], [15.115, 11.555, 5.265], [15.524, 10.726, 4.834], [13.856, 11.469, 6.066], [13.501, 12.504, 6.28], [12.732, 10.711, 5.261], [11.794, 10.602, 5.854], [12.484, 11.442, 3.895], [11.689, 10.906, 3.326], [13.421, 11.558, 3.303], [12.248, 12.523, 4.032], [13.308, 9.439, 4.926], [12.631, 8.982, 4.441], [14.164, 10.785, 7.379], [14.993, 9.862, 7.443], [13.488, 11.241, 8.417], [12.817, 11.995, 8.269], [13.66, 10.707, 9.787], [14.252, 9.762, 9.757], [14.368, 11.748, 10.691], [14.555, 11.317, 11.702], [13.663, 12.57, 10.958], [15.885, 12.426, 10.016], [16.149, 13.226, 11.045], [12.269, 10.431, 10.323], [11.393, 11.308, 10.185], [12.026, 9.383, 10.917]] mgltools-sff-1.5.7~rc1~cvs.20130519/sff/Tests/test.py0000644000175000017500000001153310653444130021223 0ustar debiandebian## Automatically adapted for numpy.oldnumeric Jul 30, 2007 by import os from mglutil.regression import testplus import numpy.oldnumeric as Numeric def test_0010( ): print "##### test_0010: import amber ######" from sff import amber print "amber imported from: ", amber.__file__ def test_0015( ): print "##### test_0015: create AmberParm instance from .prm file #####" from sff import amber oprm = amber.AmberParm( 'tripeptide.prm') def test_0020( ): print "##### test_0020: create AmberParm instance from parameters dict #### " from sff import amber from tripepparmdict import parmDict oprm = amber.AmberParm( 'sampletest', parmDict) def test_0025(): print "##### test_0025: #####" from sff import amber oprm = amber.AmberParm( 'tripeptide.prm') print list(oprm.DihHAt1) def test_0030( ): print "##### test_0030: amber minimization #####" # try an amber minimization from sff import amber from tripepparmdict import parmDict from operator import add oprm = amber.AmberParm( 'tripeptide.prm') from p1H_crd import coords lcoords = reduce( add, coords) coords = Numeric.array( lcoords).astype(amber.realType ) ar = Numeric.zeros( oprm.Natom).astype(amber.intType) anchor = Numeric.zeros( 3*oprm.Natom).astype( amber.realType ) f = None sff_opts = amber.prmlib.init_sff_options() amber.prmlib.mme_init(ar, ar, anchor, f, oprm._parmptr_, sff_opts) nbVar = Numeric.array( [3*oprm.Natom,]).astype(amber.intType ) objFunc = Numeric.zeros( 1).astype(amber.realType ) # return when sum of squares of gradient is less than dgrad drms = 0.1 dgrad = Numeric.array([drms*3*oprm.Natom]).astype(amber.realType) # expected decrease in the function on the first iteration dfpred = Numeric.array( [10.0,]).astype( amber.realType ) maxIter = Numeric.array([500,]).astype(amber.intType) energies = Numeric.zeros(20).astype(amber.realType ) amber.prmlib.mm_options('ntpr', 10, sff_opts) amber.prmlib.mm_options('verbose', 1, sff_opts) #amber.prmlib.setccallback(amber.prmlib.sanityCb, 50, 0) i = amber.prmlib.conjgrad( coords, nbVar, objFunc, amber.prmlib.mme_fun, dgrad, dfpred, maxIter, oprm._parmptr_, energies, sff_opts ) print 'DONE RUNNING in main thread', i def test_0035(): print "##### test_0035: amber minimization in a different thread" # try an amber minimization in a different thread from sff import amber from thread import start_new_thread from tripepparmdict import parmDict from operator import add oprm = amber.AmberParm( 'tripeptide.prm') from p1H_crd import coords lcoords = reduce( add, coords) coords = Numeric.array( lcoords).astype(amber.realType ) ar = Numeric.zeros( oprm.Natom).astype(amber.intType) anchor = Numeric.zeros( 3*oprm.Natom).astype( amber.realType ) sff_opts = amber.prmlib.init_sff_options() f = None amber.prmlib.mme_init(ar, ar, anchor, f, oprm._parmptr_, sff_opts) nbVar = Numeric.array( [3*oprm.Natom,]).astype(amber.intType ) # will contain the value of the objective function at the end objFunc = Numeric.zeros( 1).astype(amber.realType ) # return when sum of squares of gradient is less than dgrad drms = 0.1 dgrad = Numeric.array([drms*3*oprm.Natom]).astype(amber.realType) # expected decrease in the function on the first iteration dfpred = Numeric.array( [10.0,]).astype( amber.realType ) maxIter = Numeric.array([500,]).astype(amber.intType) energies = Numeric.zeros(20).astype(amber.realType ) amber.prmlib.mm_options('ntpr', 10, sff_opts) amber.prmlib.mm_options('verbose', 1, sff_opts) start_new_thread( amber.prmlib.conjgrad, ( coords, nbVar, objFunc, amber.prmlib.mme_fun, dgrad, dfpred, maxIter, oprm._parmptr_, energies, sff_opts) ) print "minimization thread started" import time time.sleep(2) def test_0040( ): print "##### test_0040: create two instances of Amber94 class #####" # test Amber94 class try: from MolKit import Read except: print "could not import MolKit - unable to do test_0040" return mol = Read("p1H.pdb")[0] atoms = mol.allAtoms from sff.amber import Amber94 amber1 = Amber94(atoms, prmfile="tripeptide.prm") amber2 = Amber94(atoms, prmfile="tripeptide.prm") amber1.setMinimizeOptions(ntpr =10, verbosemm = 1) amber2.setMinimizeOptions(ntpr = 20, cut = 3.0, verbosemm =1) c1 = amber1.minimize() c2 = amber2.minimize() print "result_code: ", c1, c2 harness = testplus.TestHarness( __name__, funs = testplus.testcollect( globals()),) if __name__ == '__main__': print harness sys.exit( len( harness)) mgltools-sff-1.5.7~rc1~cvs.20130519/sff/__init__.py0000644000175000017500000000022010404123117020661 0ustar debiandebian# # copyright_notice # __MGLTOOLSVersion__ = '1-4alpha3' CRITICAL_DEPENDENCIES = ['Numeric', 'mglutil'] NONCRITICAL_DEPENDENCIES = ['MolKit'] mgltools-sff-1.5.7~rc1~cvs.20130519/src/0000755000175000017500000000000012146213437016601 5ustar debiandebianmgltools-sff-1.5.7~rc1~cvs.20130519/src/binpos.c0000644000175000017500000000225410124346147020241 0ustar debiandebian#include #include "prm.h" int openbinpos( fp ) FILE *fp; { char magic[ 10 ]; if( fread( magic, 1, 4, fp ) != 4 ){ fprintf( stderr, "Couldn't read magic number from BINPOS\n" ); return( -1 ); } magic[ 4 ] = '\0'; if( strcmp( magic, "fxyz" ) != 0 ){ fprintf( stderr, "bad magic number \"%s\"\n", magic ); return( -1 ); } return( 0 ); } int readbinpos( n_atom, apos, fp ) int n_atom; _REAL apos[]; FILE *fp; { int count, *n_atomf, size = sizeof(_REAL); if( fread( n_atomf, sizeof( int ), 1, fp ) != 1 ) { return( 1 ); } if( 0 == strncmp( n_atomf,"fxyz",4 ) ) { fread( n_atomf, size, 1, fp ); } if( ( count = fread( apos, size, 3 * n_atom, fp ) ) != 3 * n_atom ){ fprintf( stderr, "Could only read %d of %d atoms requested\n", count / 3, n_atom ); return( -1 ); } return( 0 ); } int startbinpos( fp ) FILE *fp; { /* write magic number */ fwrite( "fxyz", 4, 1, fp ); return( 0 ); } int writebinpos( n_atom, apos, fp ) int n_atom; _REAL apos[]; FILE *fp; { int size = sizeof(_REAL); if (fp == NULL) return 0; fwrite( &n_atom, sizeof( int ), 1, fp ) ; fwrite( apos, size, 3 * n_atom, fp ); fflush( fp ); return( 0 ); } mgltools-sff-1.5.7~rc1~cvs.20130519/src/prm.c0000644000175000017500000005525310124346147017554 0ustar debiandebian /* * COPYRIGHT 1992, REGENTS OF THE UNIVERSITY OF CALIFORNIA * * prm.c - read information from an amber PARM topology file: * atom/residue/bond/charge info, plus force field data. * This file and the accompanying prm.h may be distributed * provided this notice is retained unmodified and provided * that any modifications to the rest of the file are noted * in comments. * * Bill Ross, UCSF 1994 */ /* MS modified to work with sff.c */ #include #include #include #include #include #include #include #include "prm.h" #ifdef WIN32 #define popen _popen #define pclose _pclose #endif extern int errno; static int debug = 0; /* set it if you want */ static int compressed = 0; /* fortran formats * 9118 FORMAT(12I6) * 9128 FORMAT(5E16.8) */ char *f9118 = "%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d\n"; /*********************************************************************** SKIPEOLN() ************************************************************************/ /* * skip to end of line; exit if eof encountered */ skipeoln(file) FILE *file; { int i; while((i=getc(file)) != 10) { if (i==EOF) { printf("unexpected end in parm file\n"); exit(1); } } } /*********************************************************************** ISCOMPRESSED() ************************************************************************/ /* * iscompressed() - look for .Z at end of name */ int iscompressed(name) char *name; { int i = strlen(name) - 1; /* last char in name */ if (i < 0) { fprintf(stderr, "programming error: name w/ length %d\n", i); exit(1); } if (i < 3) return(0); if (name[i] == 'Z' && name[i-1] == '.') return(1); return(0); } /*********************************************************************** GENOPEN() ************************************************************************/ /* * genopen() - fopen regular or popen compressed file for reading */ FILE * genopen(name) char *name; { struct stat buf; char cbuf[120]; int length; FILE *fp; length = strlen(name); compressed = iscompressed(name); strcpy(cbuf, name); /* * if file doesn't exist, maybe it has been compressed/decompressed */ if (stat(cbuf, &buf) == -1) { switch (errno) { case ENOENT: { if (!compressed) { strcat(cbuf, ".Z"); if (stat(cbuf, &buf) == -1) { printf("%s, %s: does not exist\n", name, cbuf); return(NULL); } compressed++; strcat(name, ".Z"); /* TODO: add protection */ } else { cbuf[length-2] = '\0'; if (stat(cbuf, &buf) == -1) { printf("%s, %s: does not exist\n", name, cbuf); return(NULL); } compressed = 0; } break; } default: printf("%s: sys err", name); return(NULL); } } /* * open the file */ if (compressed) { char pcmd[120]; sprintf(pcmd, "zcat %s", cbuf); if ((fp = popen(pcmd, "r")) == NULL) { perror(pcmd); exit(1); } } else { if ((fp = fopen(cbuf, "r")) == NULL) { perror(cbuf); exit(1); } } return(fp); } /*********************************************************************** GENCLOSE() ************************************************************************/ /* * genclose() - close fopened or popened file */ genclose(fileptr, popn) FILE *fileptr; { if (popn) { if (pclose(fileptr) == -1) perror("pclose"); } else { if (fclose(fileptr) == -1) perror("fclose"); } } /*********************************************************************** GET() ************************************************************************/ char * get(size) { char *ptr; #ifdef DEBUG printf("malloc %d\n", size); fflush(stdout); #endif if (size ==0) return((char *) NULL); if ((ptr = (char *) malloc((unsigned)size)) == NULL) { printf("malloc %d", size); fflush(stdout); perror("malloc err:"); exit(1); } return(ptr); } /*********************************************************************** PREADLN() ************************************************************************/ int preadln(file, name, string) FILE *file; char *name, *string; { int i, j; for (i=0; i<81; i++) { if ((j = getc(file)) == EOF) { printf("Error: unexpected EOF in %s\n", name); exit(1); } string[i] = (char) j; if (string[i] == '\n') { break; } } if (i == 80 && string[i] != '\n') { printf("Error: line too long in %s:\n%.80s", name, string); exit(1); } } /*************************************************************************** READPARM() ****************************************************************************/ /* like strtok but one specifies the number of caracters to be read */ int get_int(char *buf, int nc) { static char *line; char rec[1024]; rec[0] = '\0'; if (buf) line = buf; strncpy(rec, line, nc); rec[nc] = '\0'; line += nc; return atoi(rec); } static void parreadmalloc( struct parm* prm) { /* * get most of the indirect stuff; some extra allowed for char arrays */ /* see out typemap and python wrapper for memory deallocation */ prm->AtomNames = (char *) get(4*prm->Natom+81); prm->Charges = (_REAL *) get(sizeof(_REAL)*prm->Natom); prm->Masses = (_REAL *) get(sizeof(_REAL)*prm->Natom); prm->Iac = (int *) get(sizeof(int)*prm->Natom); prm->Iblo = (int *) get(sizeof(int)*prm->Natom); prm->Cno = (int *) get(sizeof(int)* prm->Ntype2d); prm->ResNames = (char *) get(4* prm->Nres+81); prm->Ipres = (int *) get(sizeof(int)*( prm->Nres+1)); prm->Rk = (_REAL *) get(sizeof(_REAL)* prm->Numbnd); prm->Req = (_REAL *) get(sizeof(_REAL)* prm->Numbnd); prm->Tk = (_REAL *) get(sizeof(_REAL)* prm->Numang); prm->Teq = (_REAL *) get(sizeof(_REAL)* prm->Numang); prm->Pk = (_REAL *) get(sizeof(_REAL)* prm->Nptra); prm->Pn = (_REAL *) get(sizeof(_REAL)* prm->Nptra); prm->Phase = (_REAL *) get(sizeof(_REAL)* prm->Nptra); prm->Solty = (_REAL *) get(sizeof(_REAL)* prm->Natyp); prm->Cn1 = (_REAL *) get(sizeof(_REAL)* prm->Nttyp); prm->Cn2 = (_REAL *) get(sizeof(_REAL)* prm->Nttyp); prm->BondHAt1 = (int *) get(sizeof(int)* prm->Nbonh); prm->BondHAt2 = (int *) get(sizeof(int)* prm->Nbonh); prm->BondHNum = (int *) get(sizeof(int)* prm->Nbonh); prm->BondAt1 = (int *) get(sizeof(int)* prm->Nbona); prm->BondAt2 = (int *) get(sizeof(int)* prm->Nbona); prm->BondNum = (int *) get(sizeof(int)* prm->Nbona); prm->AngleHAt1 = (int *) get(sizeof(int)* prm->Ntheth); prm->AngleHAt2 = (int *) get(sizeof(int)* prm->Ntheth); prm->AngleHAt3 = (int *) get(sizeof(int)* prm->Ntheth); prm->AngleHNum = (int *) get(sizeof(int)* prm->Ntheth); prm->AngleAt1 = (int *) get(sizeof(int)* prm->Ntheta); prm->AngleAt2 = (int *) get(sizeof(int)*prm->Ntheta); prm->AngleAt3 = (int *) get(sizeof(int)*prm->Ntheta); prm->AngleNum = (int *) get(sizeof(int)*prm->Ntheta); prm->DihHAt1 = (int *) get(sizeof(int)*prm->Nphih); prm->DihHAt2 = (int *) get(sizeof(int)*prm->Nphih); prm->DihHAt3 = (int *) get(sizeof(int)*prm->Nphih); prm->DihHAt4 = (int *) get(sizeof(int)*prm->Nphih); prm->DihHNum = (int *) get(sizeof(int)*prm->Nphih); prm->DihAt1 = (int *) get(sizeof(int)*prm->Nphia); prm->DihAt2 = (int *) get(sizeof(int)*prm->Nphia); prm->DihAt3 = (int *) get(sizeof(int)*prm->Nphia); prm->DihAt4 = (int *) get(sizeof(int)*prm->Nphia); prm->DihNum = (int *) get(sizeof(int)*prm->Nphia); prm->ExclAt = (int *) get(sizeof(int)*prm->Nnb); prm->HB12 = (_REAL *) get(sizeof(_REAL)*prm->Nphb); prm->HB10 = (_REAL *) get(sizeof(_REAL)*prm->Nphb); prm->AtomSym = (char *) get(4*prm->Natom+81); prm->AtomTree = (char *) get(4*prm->Natom+81); prm->TreeJoin = (int *) get(sizeof(int)*prm->Natom); prm->AtomRes = (int *) get(sizeof(int)*prm->Natom); prm->N14pairs = (int *) get(sizeof(int)*prm->Natom); prm->N14pairlist = (int *) get(sizeof(int)*10*prm->Natom); } /* * readparm() - instantiate a given PARMSTRUCT */ parmstruct * readparm(name) char *name; { _REAL *H; int i, k, idum, res, ifpert, iat, kat, lat, atype; int *iptmp; FILE *file; parmstruct *prm; char buf[132], fld[20]; printf("Reading parm file (%s)\n", name); if ((file = genopen(name, "parm")) == NULL) { fprintf( stderr, "Cannot open parm file %s\n", name ); return(NULL); } prm = (parmstruct *) get(sizeof(parmstruct)); /* READ TITLE */ { char ititl[ 81]; preadln(file, name, ititl); ititl[ sizeof ititl - 1] = '\0'; prm->ititl = strdup( ititl); } /* READ CONTROL INTEGERS */ fgets(buf, 80, file); prm->Natom = get_int(buf, 6); prm->Ntypes = get_int(NULL, 6); prm->Nbonh = get_int(NULL, 6); prm->Mbona = get_int(NULL, 6); prm->Ntheth = get_int(NULL, 6); prm->Mtheta = get_int(NULL, 6); prm->Nphih = get_int(NULL, 6); prm->Mphia = get_int(NULL, 6); prm->Nhparm = get_int(NULL, 6); prm->Nparm = get_int(NULL, 6); prm->Nnb = get_int(NULL, 6); prm->Nres = get_int(NULL, 6); fgets(buf, 80, file); prm->Nbona = get_int(buf, 6); prm->Ntheta = get_int(NULL, 6); prm->Nphia = get_int(NULL, 6); prm->Numbnd = get_int(NULL, 6); prm->Numang = get_int(NULL, 6); prm->Nptra = get_int(NULL, 6); prm->Natyp = get_int(NULL, 6); prm->Nphb = get_int(NULL, 6); ifpert = get_int(NULL, 6); idum = get_int(NULL, 6); idum = get_int(NULL, 6); idum = get_int(NULL, 6); /* MS June 25 because in 2tmv9 Nnb=119232 ==> breaks reading scheme fscanf(file, f9118, &prm->Natom, &prm->Ntypes, &prm->Nbonh, &prm->Mbona, &prm->Ntheth, &prm->Mtheta, &prm->Nphih, &prm->Mphia, &prm->Nhparm, &prm->Nparm, &prm->Nnb, &prm->Nres); fscanf(file, f9118, &prm->Nbona, &prm->Ntheta, &prm->Nphia, &prm->Numbnd, &prm->Numang, &prm->Nptra, &prm->Natyp, &prm->Nphb, &ifpert, &idum, &idum, &idum); */ if (ifpert) { printf("not equipped to read perturbation prmtop\n"); free(prm); return(NULL); } fscanf(file, " %d %d %d %d %d %d", &idum, &idum,&idum,&prm->IfBox,&prm->Nmxrs,&prm->IfCap); skipeoln(file); /* ALLOCATE MEMORY */ prm->Nat3 = 3 * prm->Natom; prm->Ntype2d = prm->Ntypes * prm->Ntypes; prm->Nttyp = prm->Ntypes*(prm->Ntypes+1)/2; parreadmalloc( prm); iptmp = (int *) get(sizeof(int)*12*prm->Natom); /* * READ ATOM NAMES -IH(M04) */ for (i=0; i<(prm->Natom/20 + (prm->Natom%20 ? 1 : 0)); i++) preadln(file, "", &prm->AtomNames[i*80]); /* * READ ATOM CHARGES -X(L15) * (pre-multiplied by an energy factor of 18.2223 == sqrt(332) * for faster force field calculations) */ for (i=0; iNatom; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Charges[i]); #else fscanf(file, " %f", &prm->Charges[i]); #endif skipeoln(file); /* * READ ATOM MASSES -X(L20) */ for (i=0; iNatom; i++) #ifdef DOUBLE fscanf(file, " %le", &prm->Masses[i]); #else fscanf(file, " %e", &prm->Masses[i]); #endif skipeoln(file); /* * READ ATOM L-J TYPES -IX(I04) */ for (i=0; iNatom; i++) fscanf(file, " %d", &prm->Iac[i]); skipeoln(file); /* * READ ATOM INDEX TO 1st IN EXCLUDED ATOM LIST "NATEX" -IX(I08) */ for (i=0; iNatom; i++) fscanf(file, " %d", &prm->Iblo[i]); skipeoln(file); /* * READ TYPE INDEX TO N-B TYPE -IX(I06) */ for (i=0; iNtype2d; i++){ fscanf(file, " %d", &prm->Cno[i]); #ifdef CHECK_10_12 /* add check that this is positive, since current routines in sff.c do not support 10-12 potential terms */ if( prm->Cno[i] < 0 ){ fprintf( stderr, "parameter topology requires 10-12 terms\n" ); fprintf( stderr, " these are not currently supported\n" ); exit( 1 ); } #endif } skipeoln(file); /* * READ RES NAMES (4 chars each, 4th blank) -IH(M02) */ for (i=0; i<(prm->Nres/20 + (prm->Nres%20 ? 1 : 0)); i++) preadln(file, "", &prm->ResNames[i*80]); /* * READ RES POINTERS TO 1st ATOM -IX(I02) */ for (i=0; iNres; i++) fscanf(file, " %d", &prm->Ipres[i]); prm->Ipres[prm->Nres] = prm->Natom + 1; skipeoln(file); /* * READ BOND FORCE CONSTANTS -RK() */ for (i=0; i< prm->Numbnd; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Rk[i]); #else fscanf(file, " %f", &prm->Rk[i]); #endif skipeoln(file); /* * READ BOND LENGTH OF MINIMUM ENERGY -REQ() */ for (i=0; i< prm->Numbnd; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Req[i]); #else fscanf(file, " %f", &prm->Req[i]); #endif skipeoln(file); /* * READ BOND ANGLE FORCE CONSTANTS (following Rk nomen) -TK() */ for (i=0; i< prm->Numang; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Tk[i]); #else fscanf(file, " %f", &prm->Tk[i]); #endif skipeoln(file); /* * READ BOND ANGLE OF MINIMUM ENERGY (following Req nomen) -TEQ() */ for (i=0; i< prm->Numang; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Teq[i]); #else fscanf(file, " %f", &prm->Teq[i]); #endif skipeoln(file); /* * READ DIHEDRAL PEAK MAGNITUDE -PK() */ for (i=0; i< prm->Nptra; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Pk[i]); #else fscanf(file, " %f", &prm->Pk[i]); #endif skipeoln(file); /* * READ DIHEDRAL PERIODICITY -PN() */ for (i=0; i< prm->Nptra; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Pn[i]); #else fscanf(file, " %f", &prm->Pn[i]); #endif skipeoln(file); /* * READ DIHEDRAL PHASE -PHASE() */ for (i=0; i< prm->Nptra; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Phase[i]); #else fscanf(file, " %f", &prm->Phase[i]); #endif skipeoln(file); /* * ?? "RESERVED" -SOLTY() */ for (i=0; i< prm->Natyp; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Solty[i]); #else fscanf(file, " %f", &prm->Solty[i]); #endif skipeoln(file); /* * READ L-J R**12 FOR ALL PAIRS OF ATOM TYPES -CN1() * (SHOULD BE 0 WHERE H-BONDS) */ for (i=0; i< prm->Nttyp; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Cn1[i]); #else fscanf(file, " %f", &prm->Cn1[i]); #endif skipeoln(file); /* * READ L-J R**6 FOR ALL PAIRS OF ATOM TYPES -CN2() * (SHOULD BE 0 WHERE H-BONDS) */ for (i=0; i< prm->Nttyp; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->Cn2[i]); #else fscanf(file, " %f", &prm->Cn2[i]); #endif skipeoln(file); /* * READ COVALENT BOND W/ HYDROGEN (3*(atnum-1)): * IBH = ATOM1 -IX(I12) * JBH = ATOM2 -IX(I14) * ICBH = BOND ARRAY PTR -IX(I16) */ for (i=0; iNbonh; i++) fscanf(file, " %d %d %d", &prm->BondHAt1[i], &prm->BondHAt2[i], &prm->BondHNum[i]); skipeoln(file); /* * READ COVALENT BOND W/OUT HYDROGEN (3*(atnum-1)): * IB = ATOM1 -IX(I18) * JB = ATOM2 -IX(I20) * ICB = BOND ARRAY PTR -IX(I22) */ for (i=0; iNbona; i++) fscanf(file, " %d %d %d", &prm->BondAt1[i], &prm->BondAt2[i], &prm->BondNum[i]); skipeoln(file); /* * READ ANGLE W/ HYDROGEN: * ITH = ATOM1 -IX(I24) * JTH = ATOM2 -IX(I26) * KTH = ATOM3 -IX(I28) * ICTH = ANGLE ARRAY PTR -IX(I30) */ for (i=0; iNtheth; i++) fscanf(file, " %d %d %d %d", &prm->AngleHAt1[i], &prm->AngleHAt2[i], &prm->AngleHAt3[i], &prm->AngleHNum[i]); skipeoln(file); /* * READ ANGLE W/OUT HYDROGEN: * IT = ATOM1 -IX(I32) * JT = ATOM2 -IX(I34) * KT = ATOM3 -IX(I36) * ICT = ANGLE ARRAY PTR -IX(I38) */ for (i=0; iNtheta; i++) fscanf(file, " %d %d %d %d", &prm->AngleAt1[i], &prm->AngleAt2[i], &prm->AngleAt3[i], &prm->AngleNum[i]); skipeoln(file); /* * READ DIHEDRAL W/ HYDROGEN: * ITH = ATOM1 -IX(40) * JTH = ATOM2 -IX(42) * KTH = ATOM3 -IX(44) * LTH = ATOM4 -IX(46) * ICTH = DIHEDRAL ARRAY PTR -IX(48) */ for (i=0; iNphih; i++) fscanf(file, " %d %d %d %d %d", &prm->DihHAt1[i], &prm->DihHAt2[i], &prm->DihHAt3[i], &prm->DihHAt4[i], &prm->DihHNum[i]); skipeoln(file); /* * READ DIHEDRAL W/OUT HYDROGEN: * IT = ATOM1 * JT = ATOM2 * KT = ATOM3 * LT = ATOM4 * ICT = DIHEDRAL ARRAY PTR */ for (i=0; iNphia; i++) { fscanf(file, " %d %d %d %d %d", &prm->DihAt1[i], &prm->DihAt2[i], &prm->DihAt3[i], &prm->DihAt4[i], &prm->DihNum[i]); } skipeoln(file); /* * READ EXCLUDED ATOM LIST -IX(I10) */ for (i=0; iNnb; i++) fscanf(file, " %d", &prm->ExclAt[i]); skipeoln(file); /* * READ H-BOND R**12 TERM FOR ALL N-B TYPES -ASOL() */ for (i=0; iNphb; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->HB12[i]); #else fscanf(file, " %f", &prm->HB12[i]); #endif skipeoln(file); /* * READ H-BOND R**10 TERM FOR ALL N-B TYPES -BSOL() */ for (i=0; iNphb; i++) #ifdef DOUBLE fscanf(file, " %lf", &prm->HB10[i]); #else fscanf(file, " %f", &prm->HB10[i]); #endif skipeoln(file); /* * READ H-BOND CUTOFF (NOT USED) ?? -HBCUT() */ H = (_REAL *) get(prm->Nphb * sizeof(_REAL)); for (i=0; iNphb; i++) #ifdef DOUBLE fscanf(file, " %lf", &H[i]); #else fscanf(file, " %f", &H[i]); #endif free((char *)H); skipeoln(file); /* * READ ATOM SYMBOLS (FOR ANALYSIS PROGS) -IH(M06) */ for (i=0; i<(prm->Natom/20 + (prm->Natom%20 ? 1 : 0)); i++) preadln(file, "", &prm->AtomSym[i*80]); /* * READ TREE SYMBOLS (FOR ANALYSIS PROGS) -IH(M08) */ for (i=0; i<(prm->Natom/20 + (prm->Natom%20 ? 1 : 0)); i++) preadln(file, "", &prm->AtomTree[i*80]); /* * READ TREE JOIN INFO (FOR ANALYSIS PROGS) -IX(I64) */ for (i=0; iNatom; i++) fscanf(file, " %d", &prm->TreeJoin[i]); skipeoln(file); /* * READ PER-ATOM RES NUMBER -IX(I66) * NOTE: this appears to be something entirely different * NOTE: overwriting this with correct PER-ATOM RES NUMBERs */ for (i=0; iNatom; i++) fscanf(file, " %d", &prm->AtomRes[i]); res = 0; for (i=0; iNatom; i++) { if (i+1 == prm->Ipres[res+1]) /* atom is 1st of next res */ res++; prm->AtomRes[i] = res; } /* * BOUNDARY CONDITION STUFF */ if (!prm->IfBox) { prm->Nspm = 1; prm->Boundary = (int *) get(sizeof(int)*prm->Nspm); prm->Boundary[0] = prm->Natom; } else { skipeoln(file); fscanf(file, " %d %d %d", &prm->Iptres, &prm->Nspm, &prm->Nspsol); skipeoln(file); prm->Boundary = (int *) get(sizeof(int)*prm->Nspm); for (i=0; iNspm; i++) fscanf(file, " %d", &prm->Boundary[i]); skipeoln(file); #ifdef DOUBLE fscanf(file, " %lf %lf %lf", #else fscanf(file, " %f %f %f", #endif &prm->Box[0], &prm->Box[1], &prm->Box[2]); skipeoln(file); if (prm->Iptres) prm->Ipatm = prm->Ipres[prm->Iptres] - 1; /* IF(IPTRES.GT.0) IPTATM = IX(I02+IPTRES-1+1)-1 */ } /* * ----- LOAD THE CAP INFORMATION IF NEEDED ----- */ if (prm->IfCap) { /* if (prm->IfBox) skipeoln(file); */ #ifdef DOUBLE fscanf(file, " %d %lf %lf %lf %lf", #else fscanf(file, " %d %f %f %f %f", #endif &prm->Natcap, &prm->Cutcap, &prm->Xcap, &prm->Ycap, &prm->Zcap); } genclose(file, compressed); if (debug) { printf("rdprm done\n"); fflush(stdout); } /* * -------CONSTRUCT A 1-4 LIST ------- */ for( i=0; iNatom; i++ ) prm->N14pairs[i] = 0; for( i=0; iNphih; i++ ){ iat = prm->DihHAt1[i]/3; kat = prm->DihHAt3[i]/3; lat = prm->DihHAt4[i]/3; atype = prm->DihHNum[ i ] - 1; if( kat >= 0 && lat >= 0 ) iptmp[12*iat + prm->N14pairs[iat]++] = lat; } for( i=0; iMphia; i++ ){ iat = prm->DihAt1[i]/3; kat = prm->DihAt3[i]/3; lat = prm->DihAt4[i]/3; atype = prm->DihNum[ i ] - 1; if( kat >= 0 && lat >= 0 ) iptmp[12*iat + prm->N14pairs[iat]++] = lat; } idum = 0; for( i=0; iNatom; i++ ){ for( k=0; kN14pairs[i]; k++ ) prm->N14pairlist[idum++] = iptmp[12*i + k]; } #ifdef PRINT_14PAIRS printf( "npairs:\n" ); for( k=0; kNatom; k++ ){ printf( "%4d", prm->N14pairs[k] ); if( (k+1)%20 == 0 ) printf( "\n" ); } printf( "\npairlist:\n" ); for( k=0; kN14pairlist[k] ); if( (k+1)%20 == 0 ) printf( "\n" ); } printf( "\n" ); #endif free( iptmp ); return(prm); } int firstwat(prm) parmstruct *prm; { char *restr = prm->ResNames; char *lastres = prm->ResNames + prm->Nres * 4 + 1; int res = 0; /* * find 1st water residue */ for (; restrIpres[res], &prm->AtomNames[prm->Ipres[res]]); fflush(stdout); return(prm->Ipres[res]-1); } res++; } return(0); } int readcrd(char *name, _REAL ***coord, parmstruct *parm) { FILE *file; _REAL **c; int i, j, nat; char ititl[81]; printf("Reading crd file (%s)\n", name); (*coord) = NULL; if ((file = genopen(name, "parm")) == NULL) return(0); preadln(file, name, ititl); ititl[80] = '\0'; if (strcmp(ititl, parm->ititl)!=0) { printf("WARNING: crd file title different from top file title\n"); } /* READ NUMBER OF ATOMS */ i = fscanf(file, "%d", &nat); if (i!=1) { printf("Error on line 2 of %s (wrong number of atoms)\n",name); genclose(file, name); return(0); } if (nat != parm->Natom) { printf("ERROR: number of atoms in crd file doesn't match\n"); genclose(file, name); return(0); } /* ALLOCATE MEMORY */ c = (_REAL **) get(nat*sizeof(_REAL *)); for (i=0; iititl)!=0) { printf("WARNING: crd file title different from top file title\n"); } /* READ NUMBER OF ATOMS */ i = fscanf(file, "%d", nat); if (i!=1) { printf("Error on line 2 of %s (wrong number of atoms)\n",name); genclose(file, name); return(0); } if (*nat != parm->Natom) { printf("ERROR: number of atoms in crd file doesn't match\n"); genclose(file, name); return(0); } /* ALLOCATE MEMORY */ c = (_REAL **) get((*nat)*sizeof(_REAL *)); /* READ THE COORDINATES */ for (i=0; i<(*nat); i++) { c[i] = (_REAL *) get(3*sizeof(_REAL)); #ifdef DOUBLE j = fscanf(file, " %lf %lf %lf", &c[i][0], &c[i][1], &c[i][2]); #else j = fscanf(file, " %f %f %f", &c[i][0], &c[i][1], &c[i][2]); #endif if (j != 3) { for (j=0; j #include #include #include #include "prm.h" #include "memutil.h" #include "assert.h" #include "bhtree.h" #ifdef GRAPHICS static int update_display=0; #endif static int nhbpair; static FILE *tmp; int verbosemm=0, verbosemd=0; /*int debres=-1, endres=-1; residue to monitor */ /* _REAL enbrtmp, ehbrtmp, eelrtmp, etorrtmp; */ /* general force field variables */ #ifdef flex static char *mmoinputptr; static int mmoinputlim; #endif #ifdef __APPLE__ #include _REAL second() { struct timeval t; struct timezone tz; gettimeofday(&t,&tz); return (double)t.tv_sec + (double)t.tv_usec; } #else #include _REAL second() { struct timeb t; ftime(&t); return (double)t.time + (double)t.millitm * (double)0.001; } #endif static _REAL t1, t2, tnonb, tpair, tbond, tangl, tphi, tcons; /* timer variables */ /* _REAL *resRad=NULL; residue radii array, used in nblist */ float gauss(); /* never double -bsd- */ #ifdef WIN32 #define strncasecmp strncmp #endif /* bsd mods 11 Jun */ /* signals */ #define SFF_OK 0 #define SFF_ERROR -1 int stop_flag = 0; #include #define DOT(a,b,c,d,e,f) a*d + b*e + c*f void sff_catcher(int signo) { /* reset the signal */ signal(signo,sff_catcher); if(verbosemm)fprintf(stderr,"sff_catcher: caught signal %d\n",signo); switch(signo){ case SIGINT: stop_flag = 1; break; #ifndef WIN32 case SIGUSR1: break; case SIGHUP: break; case SIGQUIT: break; #endif default: break; } fflush(stdout); fflush(stderr); } int sff_init_signals(void){ assert(sff_catcher); signal(SIGINT,sff_catcher); return(SFF_OK); } int sff_reset_signals(void) { signal(SIGINT,SIG_DFL); return(SFF_OK); } SFFoptions *init_sff_options(void) { SFFoptions * opts; opts = (SFFoptions *)malloc(sizeof(SFFoptions)); if( !opts ) nrerror( "allocation failure in init_sff_options()" ); opts->cut = 8.0; opts->scnb = 2.0; opts->scee = 1.2; opts->ntpr = 10; opts->nsnb = 25; opts->mme_init_first = 1; opts->frozen = NULL; opts->nfrozen = 0; opts->constrained = NULL; opts->nconstrained = 0; opts->x0 = NULL; opts->wcons = 0.0; opts->dield = 0; opts->w4d = 0.0; /* MD variables: */ opts->t = 0.; opts->dt = 0.001; opts->tautp = 0.2; opts->temp0 = 300.; opts->boltz2 = 9.93595e-4; opts->vlimit = 10.0; opts->ntpr_md = 10; opts-> ntwx = 0; opts->zerov = 0; opts->tempi = 0.0; opts->idum = -1; return opts; } void sffC_list_options(SFFoptions *opts) { fprintf(stdout, "non-bonded cutoff (cut), %f\n", opts->cut); fprintf(stdout, "scale factor for 1-4 nonbond (scnb), %f\n", opts->scnb); fprintf(stdout, "scale factor for 1-4 electro. (scee), %f\n", opts->scee); fprintf(stdout, "weight of constraints (wcons), %f\n", opts->wcons); fprintf(stdout, " (mme_init_first), %d\n", opts->mme_init_first); fprintf(stdout, "dielectric function to be used (dield), %d\n", opts->dield); fprintf(stdout, "output level (verbose), %d\n", verbosemm); fprintf(stdout, "print frequency (ntpr), %d\n", opts->ntpr); fprintf(stdout, "non-bonded update frequency (nsnb), %d\n", opts->nsnb); fprintf(stdout, "\nMD options -------------------------------------------\n"); fprintf(stdout, "initial time (t), %f\n", opts->t); fprintf(stdout, "time step, ps. (dt), %f\n", opts->dt); fprintf(stdout, "temp. coupling parm., ps (tautp), %f\n", opts->tautp); fprintf(stdout, "target temperature, K (temp0), %f\n", opts->temp0); fprintf(stdout, " (boltz2), %f\n", opts->boltz2); fprintf(stdout, "maximum velocity component (vlimit), %f\n", opts->vlimit); fprintf(stdout, "print frequency (ntpr_md), %d\n", opts->ntpr_md); fprintf(stdout, "trajectory snapshot frequency (ntwx), %d\n", opts->ntwx); fprintf(stdout, "if true, use zero initial velocities (zerov), %d\n", opts->zerov); fprintf(stdout, "initial temperature (tempi), %f\n", opts->tempi); fprintf(stdout, "random number seed (idum), %d\n", opts->idum); } int mm_options( char *c, float val, SFFoptions *opts ) { if (!c) return; if (strncasecmp(c,"cut",strlen(c))==0) opts->cut = val; else if (strncasecmp(c,"ntpr",strlen(c))==0) {/* print frequency */ assert(val != 0); opts->ntpr = (int)val; } else if (strncasecmp(c,"nsnb",strlen(c))==0) /* non-bonded update frequency */ opts->nsnb = (int)val; else if (strncasecmp(c,"scnb",strlen(c))==0) /* scale factor for 1-4 nonbond*/ opts->scnb = val; else if (strncasecmp(c,"scee",strlen(c))==0)/* scale factor for 1-4 electro */ opts->scee = val; else if (strncasecmp(c,"mme_init_first",strlen(c))==0) opts->mme_init_first = (int)val; else if (strncasecmp(c,"dield",strlen(c))==0) /* dielectric function */ opts->dield = (int)val; else if (strncasecmp(c,"verbose",strlen("verbose"))==0) /* */ verbosemm = (int)val; else if (strncasecmp(c,"stop_flag",strlen(c))==0) /* bsd */ stop_flag = (int)val; #ifdef MONITOR_RESIDUE } else if (strncasecmp(c,"residue",strlen(c))==0) { /* residue to monitor */ i = get_intArg(c,verbosemm); if (i==-1) { debres = endres = -1; } else { debres = prm->Ipres[i]-1; endres = prm->Ipres[i+1]-1; } } #endif else printf("ERROR: %s unknown parameter\n", c); } int md_options( char *c, float val, SFFoptions *opts ) { if (!c) return; if (strncasecmp(c,"t",strlen(c))==0) /* initial time */ opts->t = val; else if (strncasecmp(c,"dt",strlen(c))==0) /* time step, ps. */ opts->dt = val; else if (strncasecmp(c,"tautp",strlen(c))==0) /* temp. coupling parm., ps */ opts->tautp = val; else if (strncasecmp(c,"temp0",strlen(c))==0) /* target temperature, K */ opts->temp0 = val; else if (strncasecmp(c,"boltz2",strlen(c))==0)/* boltz2 */ opts->boltz2 = val; else if (strncasecmp(c,"vlimit",strlen(c))==0) /* maximum velocity component */ opts->vlimit = val; else if (strncasecmp(c,"ntpr_md",strlen(c))==0) {/* print frequency */ assert(val != 0); opts->ntpr_md = (int)val; } else if (strncasecmp(c,"zerov",strlen(c))==0) /* if true, use zero initial velocities */ opts->zerov = (int)val; else if (strncasecmp(c,"tempi",strlen(c))==0) /* initial temperature */ opts->tempi = (int)val; else if (strncasecmp(c,"idum",strlen(c))==0) /* random number seed */ opts->idum = (int)val; else if (strncasecmp(c,"ntwx",strlen(c))==0) /* random number seed */ opts->ntwx = (int)val; else if (strncasecmp(c,"verbose",strlen("verbose"))==0) /* random number seed */ verbosemd = (int)val; else printf("ERROR: %s unknown parameter\n", c); } void mme_cleanup(SFFoptions *opts) { free(opts->frozen); opts->nfrozen = 0; free(opts->constrained); opts->nconstrained = 0; free(opts->npairs); free (opts); } void mme_initCallbacks() { int i; for (i=0; idim = 3; opts->x0 = x0i; opts->binposfp = bfpi; /* resRad = Rvector( 0, prm->Natom ); */ /* for (i=0; iNres; i++) { */ /* if (strncmp(&prm->ResNames[i*4], "ARG", 3)==0) rrad= 10.0; */ /* else if (strncmp(&prm->ResNames[i*4], "TRP", 3)==0) rrad= 10.0; */ /* else if (strncmp(&prm->ResNames[i*4], "TYR", 3)==0) rrad= 9.5; */ /* else if (strncmp(&prm->ResNames[i*4], "GLU", 3)==0) rrad= 9.5; */ /* else if (strncmp(&prm->ResNames[i*4], "GLH", 3)==0) rrad= 9.5; */ /* else if (strncmp(&prm->ResNames[i*4], "GLN", 3)==0) rrad= 9.5; */ /* else if (strncmp(&prm->ResNames[i*4], "LYS", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "LYN", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "HIE", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "HID", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "HIP", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "ASP", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "ASH", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "ASN", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "PHE", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "MET", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "LEU", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "ILE", 3)==0) rrad= 9.0; */ /* else if (strncmp(&prm->ResNames[i*4], "CYS", 3)==0) rrad= 8.0; */ /* else if (strncmp(&prm->ResNames[i*4], "CYM", 3)==0) rrad= 8.0; */ /* else if (strncmp(&prm->ResNames[i*4], "THR", 3)==0) rrad= 8.0; */ /* else if (strncmp(&prm->ResNames[i*4], "SER", 3)==0) rrad= 8.0; */ /* else if (strncmp(&prm->ResNames[i*4], "VAL", 3)==0) rrad= 8.0; */ /* else if (strncmp(&prm->ResNames[i*4], "PRO", 3)==0) rrad= 8.0; */ /* else if (strncmp(&prm->ResNames[i*4], "ALA", 3)==0) rrad= 7.0; */ /* else if (strncmp(&prm->ResNames[i*4], "GLY", 3)==0) rrad= 6.0; */ /* else { */ /* printf("WARNING: residue %4s has no radius\n", &prm->ResNames[i*4]); */ /* rrad = 100.; */ /* } */ /* ip1 = prm->Ipres[i]; */ /* ip2 = prm->Ipres[i+1] - 1; */ /* for (j=ip1-1; jNatom ); */ if( opts->mme_init_first ){ opts->frozen = ivector( 0, prm->Natom ); opts->constrained = ivector( 0, prm->Natom ); opts->npairs = ivector( 0, prm->Natom ); /* crude estimate for the number of non-bonded pairs */ opts->maxnb = prm->Natom * opts->cut * opts->cut * opts->cut / 1.25; nblimit = prm->Natom*prm->Natom/2 - prm->Natom; if (opts->maxnb > nblimit) opts->maxnb = nblimit; #ifdef DEBUG printf( "allocating space for %d non-bonded pairs\n", opts->maxnb ); #endif opts->pairlist = ivector( 0, opts->maxnb ); opts->mme_init_first = 0; opts->nfrozen = 0; opts->nconstrained = 0; for (i=0; iNatom; i++) { opts->frozen[i] = opts->constrained[i] = 0; } } if (froz) { opts->nfrozen = 0; for (i=0; iNatom; i++) { if (froz[i]) { opts->frozen[i] = 1; opts->nfrozen++; } else opts->frozen[i] = 0; } printf( "froze %d atoms\n", opts->nfrozen ); } else { for (i=0; iNatom; i++) { opts->frozen[i] = 0; } } if (constr) { opts->nconstrained = 0; for (i=0; iNatom; i++) { if (constr[i]) { opts->constrained[i] = 1; opts->nconstrained++; } else opts->constrained[i] = 0; } printf( "constrained %d atoms\n", opts->nconstrained ); } else { for (i=0; iNatom; i++) { opts->constrained[i] = 0; } } #ifdef ORIG opts->nfrozen = set_belly_mask( m, aexp, opts->frozen ); opts->nconstrained = set_cons_mask( m, aexp2, opts->constrained ); #endif return( 0 ); } _REAL econs( x, f, prm, opts ) _REAL *x, *f; parmstruct *prm; SFFoptions *opts; { int i; _REAL e_cons,rx,ry,rz; e_cons = 0.0; for( i=0; iNatom; i++ ){ if( opts->constrained[i] ){ rx = x[3*i ] - opts->x0[3*i ]; ry = x[3*i + 1] - opts->x0[3*i + 1]; rz = x[3*i + 2] - opts->x0[3*i + 2]; e_cons += opts->wcons*(rx*rx + ry*ry + rz*rz); f[3*i ] += 2.*opts->wcons*rx; f[3*i + 1] += 2.*opts->wcons*ry; f[3*i + 2] += 2.*opts->wcons*rz; } } return( e_cons ); } _REAL ebond( nbond, a1, a2, atype, Rk, Req, x, f ) int nbond, *a1, *a2, *atype; _REAL *Rk, *Req, *x, *f; { int i,at1,at2,atyp; _REAL e_bond,r,rx,ry,rz,r2,s,db,df,e; e_bond = 0.0; for( i=0; i 1.0) cst = 1.0; if (cst < -1.0) cst = -1.0; at=acos(cst); da=at - Teq[atyp]; df=da * Tk[atyp]; e = df*da; e_theta = e_theta + e; df = df+df; at = sin(at); if (at > 0 && at < 1.e-3) at = 1.e-3; else if (at < 0 && at > -1.e-3) at = -1.e-3; df=-df/at; xtmp=df*rir*(dxjr-cst*dxir); dxtmp=df*rjr*(dxir-cst*dxjr); ytmp=df*rir*(dyjr-cst*dyir); dytmp=df*rjr*(dyir-cst*dyjr); ztmp=df*rir*(dzjr-cst*dzir); dztmp=df*rjr*(dzir-cst*dzjr); f[at1 + 0 ] += xtmp; f[at3 + 0 ] += dxtmp; f[at2 + 0 ] -= xtmp + dxtmp; f[at1 + 1 ] += ytmp; f[at3 + 1 ] += dytmp; f[at2 + 1 ] -= ytmp + dytmp; f[at1 + 2 ] += ztmp; f[at3 + 2 ] += dztmp; f[at2 + 2 ] -= ztmp + dztmp; } return( e_theta ); } /* compute only for one residue */ _REAL ephiRes( nphi, a1, a2, a3, a4, atype, Pk, Pn, Phase, x, start, end ) int nphi, *a1, *a2, *a3, *a4, *atype, start, end; _REAL *Pk, *Pn, *Phase, *x; { _REAL e,co,den,co1,uu,vv,uv,ax,bx,cx,ay,by,cy,az,bz,cz; _REAL a0x,b0x,c0x,a0y,b0y,c0y,a0z,b0z,c0z,a1x,b1x; _REAL a1y,b1y,a1z,b1z,a2x,b2x,a2y,b2y,a2z,b2z; _REAL dd1x,dd2x,dd3x,dd4x,dd1y,dd2y,dd3y,dd4y,dd1z,dd2z,dd3z,dd4z; _REAL df,aa,bb,cc,ab,bc,ac,d1,d2,d3,e1,e2,e3,ktot; _REAL ktors1,ktors2,ktors3,ktors4,phase,e_tors; int i,at1,at2,at3,at4,atyp; int rat, iin, jin; e_tors = 0.0; for (i=0; i=end) ? 0:1; rat = at4/3; jin = (rat=end) ? 0:1; if ( !iin && !jin ) continue; atyp = atype[i] - 1; ax = x[at2 + 0] - x[at1 + 0]; ay = x[at2 + 1] - x[at1 + 1]; az = x[at2 + 2] - x[at1 + 2]; bx = x[at3 + 0] - x[at2 + 0]; by = x[at3 + 1] - x[at2 + 1]; bz = x[at3 + 2] - x[at2 + 2]; cx = x[at4 + 0] - x[at3 + 0]; cy = x[at4 + 1] - x[at3 + 1]; cz = x[at4 + 2] - x[at3 + 2]; ab = DOT(ax,ay,az,bx,by,bz); bc = DOT(bx,by,bz,cx,cy,cz); ac = DOT(ax,ay,az,cx,cy,cz); aa = DOT(ax,ay,az,ax,ay,az); bb = DOT(bx,by,bz,bx,by,bz); cc = DOT(cx,cy,cz,cx,cy,cz); uu = (aa * bb) - (ab*ab); vv = (bb * cc ) - (bc * bc); uv = (ab * bc) - (ac * bb); den= 1.0/sqrt(fabs(uu*vv)); co = uv * den; co1 = 0.5*co*den; a0x = -bc*bx + bb*cx; a0y = -bc*by + bb*cy; a0z = -bc*bz + bb*cz; b0x = ab*cx + bc*ax -2.*ac*bx; b0y = ab*cy + bc*ay -2.*ac*by; b0z = ab*cz + bc*az -2.*ac*bz; c0x = ab*bx - bb*ax; c0y = ab*by - bb*ay; c0z = ab*bz - bb*az; a1x = 2.*uu*(-cc*bx + bc*cx); a1y = 2.*uu*(-cc*by + bc*cy); a1z = 2.*uu*(-cc*bz + bc*cz); b1x = 2.*uu*(bb*cx - bc*bx); b1y = 2.*uu*(bb*cy - bc*by); b1z = 2.*uu*(bb*cz - bc*bz); a2x = -2.*vv*(bb*ax - ab*bx); a2y = -2.*vv*(bb*ay - ab*by); a2z = -2.*vv*(bb*az - ab*bz); b2x = 2.*vv*(aa*bx - ab*ax); b2y = 2.*vv*(aa*by - ab*ay); b2z = 2.*vv*(aa*bz - ab*az); dd1x = (a0x - a2x*co1)*den; dd1y = (a0y - a2y*co1)*den; dd1z = (a0z - a2z*co1)*den; dd2x = (-a0x - b0x - (a1x - a2x - b2x)*co1)*den; dd2y = (-a0y - b0y - (a1y - a2y - b2y)*co1)*den; dd2z = (-a0z - b0z - (a1z - a2z - b2z)*co1)*den; dd3x = (b0x - c0x - (-a1x - b1x + b2x)*co1)*den; dd3y = (b0y - c0y - (-a1y - b1y + b2y)*co1)*den; dd3z = (b0z - c0z - (-a1z - b1z + b2z)*co1)*den; dd4x = (c0x - b1x*co1)*den; dd4y = (c0y - b1y*co1)*den; dd4z = (c0z - b1z*co1)*den; multi_term: ktors1 = 0.; ktors2 = 0.; ktors3 = 0.; ktors4 = 0.; switch( (int)fabs(Pn[atyp]) ){ case 1: ktors1 = Pk[atyp]; break; case 2: ktors2 = Pk[atyp]; break; case 3: ktors3 = Pk[atyp]; break; case 4: ktors4 = Pk[atyp]; break; default: fprintf( stderr, "bad value for Pn: %d %d %d %d %8.3f\n", at1,at2,at3,at4,Pn[atyp] ); exit(1); } if( fabs(Phase[atyp]-3.142) < 0.01 ) phase = -1.0; else phase = 1.0; e = 4.*ktors3*co*co + 2.*ktors2*co + ktors1 - 3.*ktors3 + 8.*ktors4*co*(co*co - 1.); e = e*co - ktors2 + ktors4; ktot = ktors1+ktors2+ktors3+ktors4; e = ktot + phase*e; e_tors += e; if( Pn[atyp] < 0 ){ atyp++; goto multi_term; } } return( e_tors ); } _REAL ephi( nphi, a1, a2, a3, a4, atype, Pk, Pn, Phase, x, f ) int nphi, *a1, *a2, *a3, *a4, *atype; _REAL *Pk, *Pn, *Phase, *x, *f; { _REAL e,co,den,co1,uu,vv,uv,ax,bx,cx,ay,by,cy,az,bz,cz; _REAL a0x,b0x,c0x,a0y,b0y,c0y,a0z,b0z,c0z,a1x,b1x; _REAL a1y,b1y,a1z,b1z,a2x,b2x,a2y,b2y,a2z,b2z; _REAL dd1x,dd2x,dd3x,dd4x,dd1y,dd2y,dd3y,dd4y,dd1z,dd2z,dd3z,dd4z; _REAL df,aa,bb,cc,ab,bc,ac,d1,d2,d3,e1,e2,e3,ktot; _REAL ktors1,ktors2,ktors3,ktors4,phase,e_tors; int i,at1,at2,at3,at4,atyp; int rat, in1,in4; /* FILE *tmp=fopen("mmetor.list","w"); */ /* etorrtmp = */ e_tors = 0.0; for (i=0; i=debres && rat=debres && ratNres ); iexw = ivector( -1, prm->Natom ); /* loop over all pairs of residues: */ tot_pair = 0; kpr = 0; cut2 = cut*cut; ji = 0; for( i=0; iNatom; i++ ){ iexw[i] = -1; } for( ires=0; iresNres; ires++ ){ ip1 = prm->Ipres[ires]; ip2 = prm->Ipres[ires+1] - 1; jrp = 0; ires_pairlist[0] = ires; /* irescut = cut+resRad[ires]; */ for( jres=ires+1; jresNres; jres++ ){ jp1 = prm->Ipres[jres]; jp2 = prm->Ipres[jres+1] - 1; /* jrescut = resRad[jres]; */ for( i=ip1-1; i (irescut+jrescut)*(irescut+jrescut)) break;*/ if( rrw > uppercut) break; } } continue; includit: ires_pairlist[++jrp] = jres; } /* ---- End of generating the resdue pair list for residue ires ---- Now take care of exclusions and sort the lists: */ for( i=ip1-1; iIblo[i]; for( k=0; kExclAt[ji+k]-1 ] = i; } ji += nx; for( jrp2=0; jrp2<=jrp; jrp2++ ){ jres = ires_pairlist[jrp2]; if( ires==jres ) jp1 = i+2; else jp1 = prm->Ipres[jres]; jp2 = prm->Ipres[jres+1] - 1; for( j=jp1-1; j (*maxnb) ) { printf( "reallocating space for %d non-bonded pairs\n", *maxnb + 100000 ); npairlist = ivector( 0, *maxnb + (*maxnb)/10 ); if ( !npairlist ) { fprintf( stderr, "failed to reallocate NB list \n"); exit(-1); } memcpy( npairlist, (*pairlist), (*maxnb)*sizeof(int)); free_ivector( (*pairlist), 0, *maxnb ); (*pairlist) = npairlist; *maxnb += (*maxnb)/10; } #endif } } } tot_pair += ipair; npairs[i] = ipair; #ifndef REALLOCNB if( tot_pair > (*maxnb) ){ fprintf( stderr, "maxnb (%d) is too small needed %d\n", *maxnb, tot_pair ); exit(1); } #endif } } /* printf( "nbdist:%d\n",nbdist ); */ #ifdef PRINT_NB_LIST printf( "npairs:\n" ); for( k=0; kNatom; k++ ){ printf( "%4d", npairs[k] ); if( (k+1)%20 == 0 ) printf( "\n" ); } printf( "\npairlist:\n" ); for( k=0; kNres ); free_ivector( iexw, -1, prm->Natom ); /* printf( " " ); printf( " " ); printf( " %d\n", tot_pair ); */ return( tot_pair ); } /* MS December 01 modified to use BHtree */ int nblistBH( x, npairs, pairlist, prm, cut, maxnb, frozen ) _REAL *x, cut; int *npairs, **pairlist, *maxnb, *frozen; parmstruct *prm; { _REAL dx,dy,dz,rrw; int tot_pair,nx,ipair,ji,ires,jres,ip1,jp1,ip2,jp2,i,j,k,jrp,jrp2,kpr; int *ires_pairlist; int *iexw; int *npairlist; BHtree *bht; BHpoint **BHat; int res, close[2001], nbcl, *close_res, *atres; float pt[3]; /* build a BHtree with all atoms */ BHat = (BHpoint **)malloc(prm->Natom*sizeof(BHpoint *)); res = 0; atres = ivector( 0, prm->Natom ); /* atomnum->resnum lookup table */ for (i=0;iNatom;i++) { BHat[i] = (BHpoint *)malloc(sizeof(BHpoint)); j = i*3; BHat[i]->x[0]=x[j]; BHat[i]->x[1]=x[j+1]; BHat[i]->x[2]=x[j+2]; BHat[i]->r=0.0; BHat[i]->at=i; /* atom number 0-based */ if (i>=prm->Ipres[res+1]-1) res++; atres[i] = res; } bht = generateBHtree(BHat,prm->Natom,10); ires_pairlist = ivector( 0, prm->Nres ); /* buffer list of residue pairs */ close_res = ivector( 0, prm->Nres ); /* buffer for list of residue pair */ iexw = ivector( -1, prm->Natom ); /* loop over all pairs of residues: */ tot_pair = 0; kpr = 0; ji = 0; for( i=0; iNatom; i++ ){ iexw[i] = -1; } /* for every residue */ for( ires=0; iresNres; ires++ ){ ip1 = prm->Ipres[ires]; /* index of first atom in residue ires */ ip2 = prm->Ipres[ires+1] - 1; /* index of last atom in residue ires */ jrp = 0; ires_pairlist[0] = ires; memset(close_res, 0, prm->Nres*sizeof(int)); /* loop over all atoms in residue ires */ for( i=ip1-1; iNres; i++) if (close_res[i]) { ires_pairlist[++jrp] = i; } /* ---- End of generating the resdue pair list for residue ires ---- Now take care of exclusions and sort the lists: */ for( i=ip1-1; iIblo[i]; for( k=0; kExclAt[ji+k]-1 ] = i; } ji += nx; for( jrp2=0; jrp2<=jrp; jrp2++ ){ jres = ires_pairlist[jrp2]; if( ires==jres ) jp1 = i+2; else jp1 = prm->Ipres[jres]; jp2 = prm->Ipres[jres+1] - 1; for( j=jp1-1; j (*maxnb) ) { printf( "reallocating space for %d non-bonded pairs\n", *maxnb + 100000 ); npairlist = ivector( 0, *maxnb + (*maxnb)/10 ); if ( !npairlist ) { fprintf( stderr, "failed to reallocate NB list \n"); exit(-1); } memcpy( npairlist, (*pairlist), *maxnb*sizeof(int)); free_ivector( (*pairlist), 0, *maxnb ); (*pairlist) = npairlist; *maxnb += (*maxnb)/10; } #endif } } } tot_pair += ipair; npairs[i] = ipair; #ifndef REALLOCNB if( tot_pair > (*maxnb) ){ fprintf( stderr, "maxnb (%d) is too small\n", (*maxnb) ); exit(1); } #endif } } #ifdef PRINT_NB_LIST printf( "npairs:\n" ); for( k=0; kNatom; k++ ){ printf( "%4d", npairs[k] ); if( (k+1)%20 == 0 ) printf( "\n" ); } printf( "\npairlist:\n" ); for( k=0; kNres ); free_ivector( iexw, -1, prm->Natom ); free_ivector( close_res, 0, prm->Nres ); free_ivector( atres, 0, prm->Natom ); freeBHtree(bht); /* printf( " " ); printf( " " ); printf( " %d\n", tot_pair ); */ return( tot_pair ); } int nbond( npairs, pairlist, x, f, enb, eel, ehb, enbfac, eelfac, prm, dield ) int *npairs, *pairlist, dield; _REAL *x, *f; _REAL *enb,*eel,*ehb; _REAL enbfac, eelfac; parmstruct *prm; { int i,j,jn,ic,npr,lpair,iaci; _REAL dumx,dumy,dumz,cgi,xw1,xw2,xw3,r2inv,df2,eelt,r6,r10,f1,f2; _REAL df,fw1,fw2,fw3,enbfaci,eelfaci; _REAL rinv, rs, rssq, eps1, epsi, cgijr, pow; int ibig,isml; /* _REAL hbener, nb14; */ /* nhbpair = 0; hbener = 0.0; nb14 = 0.0; */ /* enbrtmp = ehbrtmp = eelrtmp = 0.0; */ nhbpair = 0; #define SIG 0.3 #define DIW 78.0 #define C1 38.5 lpair = 0; *enb = 0.; *eel = 0.; *ehb = 0.; enbfaci = 1./enbfac; eelfaci = 1./eelfac; for( i=0; iNatom-1; i++ ){ npr = npairs[i]; if( npr > 0 ){ iaci = prm->Ntypes*(prm->Iac[i] - 1); dumx = 0.; dumy = 0.; dumz = 0.; cgi = eelfaci*prm->Charges[i]; if( dield == -3 ){ /* special code RL dielectric, 94 force field */ for( jn=0; jnCharges[j]*rinv*epsi; *eel += cgijr; df2 = -cgijr*(1.0 + C1*pow*rs*rssq*epsi); ic = prm->Cno[iaci + prm->Iac[j] - 1] - 1; r6 = r2inv*r2inv*r2inv; f2 = prm->Cn2[ic]*r6; f1 = prm->Cn1[ic]*r6*r6; /* if( f1 > 5000. ) fprintf( stderr, "close contact: %d %d %8.2f\n", i,j,f1 ); */ *enb += (f1-f2)*enbfaci; df = (df2+6.*(f2-f1-f1)*enbfaci)*r2inv; fw1 = xw1*df; fw2 = xw2*df; fw3 = xw3*df; dumx = dumx + fw1; dumy = dumy + fw2; dumz = dumz + fw3; f[3*j + 0] -= fw1; f[3*j + 1] -= fw2; f[3*j + 2] -= fw3; } } else if( dield == -4 ) { /* distance-dependent dielectric code, 94 ff */ for( jn=0; jnCharges[j]*r2inv; df2 = -rs - rs; *eel += rs; ic = prm->Cno[iaci + prm->Iac[j] - 1] - 1; r6 = r2inv*r2inv*r2inv; f2 = prm->Cn2[ic]*r6; f1 = prm->Cn1[ic]*r6*r6; *enb += (f1-f2)*enbfaci; df = (df2+6.*(f2-f1-f1)*enbfaci)*r2inv; fw1 = xw1*df; fw2 = xw2*df; fw3 = xw3*df; dumx = dumx + fw1; dumy = dumy + fw2; dumz = dumz + fw3; f[3*j + 0] -= fw1; f[3*j + 1] -= fw2; f[3*j + 2] -= fw3; } } else { /* standard code with all options */ for( jn=0; jnCharges[j]*r2inv; df2 = -rs - rs; *eel += rs; /* if ( (i>=debres && i=debres && j < endres)) eelrtmp += rs; */ /* if (tmp) { if ( (i>=debres && i=debres && j < endres)) fprintf(tmp, "%4d %4d %6.3f %13.6f\n",i,j,sqrt(xw1*xw1 + xw2*xw2 + xw3*xw3),rs); } */ } else if( dield == 1 ){ /* epsilon = 1 */ rinv = sqrt( r2inv ); df2 = -cgi*prm->Charges[j]*rinv; *eel -= df2; } else if( dield == -2 ){ /* Ramstein & Lavery dielectric, PNAS 85, 7231 (1988). */ rinv = sqrt( r2inv ); rs = SIG/rinv; rssq = rs*rs; pow = exp( -rs ); eps1 = rssq + rs + rs + 2.0; epsi = 1.0/(DIW - C1*pow*eps1); cgijr = cgi*prm->Charges[j]*rinv*epsi; *eel += cgijr; df2 = -cgijr*(1.0 + C1*pow*rs*rssq*epsi); } ic = prm->Cno[iaci + prm->Iac[j] - 1]; if( ic > 0 || enbfac != 1.0 ){ if( ic > 0 ) { ic--; } else { ibig = prm->Iac[i] > prm->Iac[j] ? prm->Iac[i] : prm->Iac[j]; isml = prm->Iac[i] > prm->Iac[j] ? prm->Iac[j] : prm->Iac[i]; ic = ibig*(ibig-1)/2 + isml -1; } r6 = r2inv*r2inv*r2inv; f2 = prm->Cn2[ic]*r6; f1 = prm->Cn1[ic]*r6*r6; /* if( f1 > 5000. ) ** fprintf( stderr, "close contact: %d %d %8.2f\n", ** i,j,f1 ); */ *enb += (f1-f2)*enbfaci; /* if ( (i>=debres && i=debres && j < endres)) enbrtmp += (f1-f2)*enbfaci; */ /* if (tmp) { fprintf(tmp, "%4d %4d %6.3f %13.6f\n",i,j,sqrt(xw1*xw1 + xw2*xw2 + xw3*xw3),(f1-f2)*enbfaci); }*/ df = (df2+6.*(f2-f1-f1)*enbfaci)*r2inv; /* if( enbfac != 1.0 ) nb14 += (f1-f2)*enbfaci; */ } else { ic = -ic - 1; r10 = r2inv*r2inv*r2inv*r2inv*r2inv; f2 = prm->HB10[ic]*r10; f1 = prm->HB12[ic]*r10*r2inv; *ehb += (f1-f2)*enbfaci; /* if ( (i>=debres && i=debres && j < endres)) ehbrtmp += (f1-f2)*enbfaci; */ df = (df2+(10.*f2-12.*f1)*enbfaci)*r2inv; nhbpair++; /* hbener += (f1-f2)*enbfaci; */ } fw1 = xw1*df; fw2 = xw2*df; fw3 = xw3*df; dumx = dumx + fw1; dumy = dumy + fw2; dumz = dumz + fw3; f[3*j + 0] -= fw1; f[3*j + 1] -= fw2; f[3*j + 2] -= fw3; } } f[3*i + 0] += dumx; f[3*i + 1] += dumy; f[3*i + 2] += dumz; lpair += npr; } } /* printf( "found %d hydrogen-bond pairs with energy %.3f\n", nhbpair, hbener ); printf( "1-4 nonbon = %.3f\n", nb14 ); */ return( 0 ); } _REAL getTor( parmstruct *prm, _REAL *c, _REAL *f ) { _REAL eth, eta, dum; eth = ephi( prm->Nphih, prm->DihHAt1, prm->DihHAt2, prm->DihHAt3, prm->DihHAt4, prm->DihHNum, prm->Pk, prm->Pn, prm->Phase, c, f); eta = ephi( prm->Mphia, prm->DihAt1, prm->DihAt2, prm->DihAt3, prm->DihAt4, prm->DihNum, prm->Pk, prm->Pn, prm->Phase, c, f); return(eth + eta); } void sanityCb(int cbNum, int nbat, _REAL *coords, _REAL *energies, int step) { int i; printf("got there %d\n", step); for (i=0; i<10; i++) printf("x: %f y:%f z:%f\n", coords[i*3], coords[i*3+1], coords[i*3+2]); printf("\nenergies"); for (i=0; i<10; i++) printf(" %f,", energies[i]); printf("\n===========================================\n"); } cbFunc_t mme_callback[NCBFUNC]; void setccallback( sffcb_f cbfun, int frequency, int callbacknum) { assert( callbacknum < NCBFUNC); mme_callback[callbacknum].fun = cbfun; mme_callback[callbacknum].freq = frequency; } _REAL mme( x, f, iter, ene, prm, opts) _REAL *x, *f, *ene; int *iter; parmstruct *prm; SFFoptions *opts; { _REAL ebh, eba, eth, eta, eph, epa, enb, ehb, eel, enb14, eel14, ecn, frms, dum; int nb_pairs; int i,k; t1 = second(); opts->enbr = opts->ehbr = opts->eelr = opts->etorr = opts->enb14r = opts->eel14r = 0.0; if( verbosemm && *iter<=1 ){ printf( " iter bad vdW elect. cons. Total grms\n" ); tnonb = tpair = tbond = tangl = tphi = tcons = 0.0; } if( *iter==1 || (*iter%opts->nsnb==0 && *iter!=0 ) ) { /***************************************************************** Using BHtrees ends up being slower than n2 method on 4sgbEI npairs with BHtree: 765186 in 0.401000 npairs: 765186 in 0.232000 ff: 1 2298.85 10082.88 -2463.31 0.00 9918.42 745.20 765186 ff: 10 2243.14 590.83 -2459.11 0.00 374.86 51.92 765186 ff: 20 1676.61 -777.55 -2603.81 0.00 -1704.74 4.00 765186 npairs with BHtree: 763404 in 0.375000 npairs: 763404 in 0.232000 ff: 30 1637.41 -957.61 -2747.24 0.00 -2067.44 2.91 763404 ff: 40 1621.13 -1044.20 -2839.55 0.00 -2262.63 2.32 763404 npairs with BHtree: 764524 in 0.378000 npairs: 764524 in 0.261000 ff: 50 1588.62 -1080.65 -2897.73 0.00 -2389.76 1.97 764524 ff: 60 1582.25 -1090.80 -2964.33 0.00 -2472.88 1.58 764524 ff: 70 1578.40 -1091.46 -3016.13 0.00 -2529.19 1.24 764524 npairs with BHtree: 762654 in 0.376000 npairs: 762654 in 0.232000 nb_pairs = nblistBH( x, opts->npairs, &(opts->pairlist), prm, opts->cut, &(opts->maxnb), opts->frozen ); t2 = second(); printf( "npairs: %d in %f\n", nb_pairs, t2-t1); ***************************************************************************/ t1 = second(); nb_pairs = nblist( x, opts->npairs, &(opts->pairlist), prm, opts->cut, &(opts->maxnb), opts->frozen); t2 = second(); /*printf( "npairs: %d in %f\n", nb_pairs, t2-t1); */ tpair += t2-t1; t1 = t2; /* printf( "npairs:\n" ); for( k=0; kNatom; k++ ){ printf( "%4d |", npairs[k] ); if( (k+1)%20 == 0 ) printf( "\n" ); } printf( "\npairlist: %p\n", pairlist ); for( k=0; kNatom; i++ ) f[i] = 0.0; #ifdef WITH_CALLBACKS if (sffC_mme_callback_func[0] && (*iter%sffC_mme_callback_freq[0]==0 && *iter!=0) ) sffC_callback_before(*iter); #endif /* tmp = fopen("mme.list","w"); */ nbond( opts->npairs, opts->pairlist, x, f, &enb, &eel, &ehb, 1.0, 1.0, prm, opts->dield ); /* fclose(tmp); */ tmp = NULL; /* enbr = enbrtmp; eelr = eelrtmp; ehbr = ehbrtmp; */ ene[1] = enb; ene[2] = eel; ene[10] = ehb; t2 = second(); tnonb += t2-t1; t1 = t2; ebh = ebond( prm->Nbonh, prm->BondHAt1, prm->BondHAt2, prm->BondHNum, prm->Rk, prm->Req, x, f ); eba = ebond( prm->Mbona, prm->BondAt1, prm->BondAt2, prm->BondNum, prm->Rk, prm->Req, x, f ); ene[3] = ebh + eba; t2 = second(); tbond += t2-t1; t1 = t2; eth = eangl( prm->Ntheth, prm->AngleHAt1, prm->AngleHAt2, prm->AngleHAt3, prm->AngleHNum, prm->Tk, prm->Teq, x, f ); eta = eangl( prm->Ntheta, prm->AngleAt1, prm->AngleAt2, prm->AngleAt3, prm->AngleNum, prm->Tk, prm->Teq, x, f ); ene[4] = eth + eta; t2 = second(); tangl += t2-t1; t1 = t2; eph = ephi( prm->Nphih, prm->DihHAt1, prm->DihHAt2, prm->DihHAt3, prm->DihHAt4, prm->DihHNum, prm->Pk, prm->Pn, prm->Phase, x, f ); /* etorr = etorrtmp; */ epa = ephi( prm->Mphia, prm->DihAt1, prm->DihAt2, prm->DihAt3, prm->DihAt4, prm->DihNum, prm->Pk, prm->Pn, prm->Phase, x, f ); /* etorr += etorrtmp; */ ene[5] = eph + epa; ene[6] = 0.0; /* hbond226 term not in Amber-94 force field */ dum= 0.0; nbond( prm->N14pairs, prm->N14pairlist, x, f, &enb14, &eel14, &ehb, opts->scnb, opts->scee, prm, opts->dield ); /* enb14r = enbrtmp; eel14r = eelrtmp; */ ene[7] = enb14 + ehb; ene[8] = eel14; t2 = second(); tphi += t2-t1; t1 = t2; if( opts->nconstrained ){ ecn = econs( x, f, prm, opts ); t2 = second(); tcons += t2-t1; t1 = t2; } else ecn = 0.0; ene[9] = ecn; ene[0] = 0.0; for( k=1; k<=10; k++ ) ene[0] += ene[k]; for( k=0; kNatom; k++ ){ /* zero out frozen forces */ if( opts->frozen[k] ){ f[3*k + 0] = 0.0; f[3*k + 1] = 0.0; f[3*k + 2] = 0.0; } } #ifdef PRINT_DERIV k=0; for(i=0; i<105; i++ ){ k++; printf( "%10.5f", f[i] ); if( k%8 == 0 ) printf( "\n" ); } printf( "\n" ); #endif frms = 0.0; for( i=0; i<3*prm->Natom; i++) frms += f[i]*f[i]; frms = sqrt( frms/(3*prm->Natom) ); if (mme_callback[0].fun && ( *iter!=0 && ( (*iter) % mme_callback[0].freq)==0 ) ) mme_callback[0].fun(0, prm->Natom, x, ene, *iter); if( verbosemm && (*iter==1 || *iter%opts->ntpr==0) ){ if (verbosemm > 1) { printf("1 nb : %12.6f\n", ene[1]); printf("2 eel : %12.6f\n", ene[2]); printf("3 bonds : %12.6f\n", ene[3]); printf("4 angles: %12.6f\n", ene[4]); printf("5 dihed.: %12.6f\n", ene[5]); printf("6 NA : %12.6f\n", ene[6]); printf("7 14nb : %12.6f\n", ene[7]); printf("8 14eel : %12.6f\n", ene[8]); printf("total : %12.6f\n", ene[0]); } printf( "ff:%4d %9.2f %9.2f %9.2f %9.2f %9.2f %9.2f %d\n", *iter, ene[3]+ene[4]+ene[5],ene[1]+ene[7]+ene[10],ene[2]+ene[8],ene[9], ene[0],frms,nb_pairs ); fflush( stdout ); } return ( ene[0] ); } _REAL ebond4( nbond, a1, a2, atype, Rk, Req, x, f ) int nbond, *a1, *a2, *atype; _REAL *Rk, *Req, *x, *f; { int i,at1,at2,atyp; _REAL e_bond,r,rx,ry,rz,rw,r2,s,db,df,e; e_bond = 0.0; for( i=0; i 1.0) cst = 1.0; if (cst < -1.0) cst = -1.0; at=acos(cst); da=at - Teq[atyp]; df=da * Tk[atyp]; e = df*da; e_theta = e_theta + e; df = df+df; at = sin(at); if (at > 0 && at < 1.e-3) at = 1.e-3; else if (at < 0 && at > -1.e-3) at = -1.e-3; df=-df/at; xtmp=df*rir*(dxjr-cst*dxir); dxtmp=df*rjr*(dxir-cst*dxjr); ytmp=df*rir*(dyjr-cst*dyir); dytmp=df*rjr*(dyir-cst*dyjr); ztmp=df*rir*(dzjr-cst*dzir); dztmp=df*rjr*(dzir-cst*dzjr); wtmp=df*rir*(dwjr-cst*dwir); dwtmp=df*rjr*(dwir-cst*dwjr); f[at1 + 0 ] += xtmp; f[at3 + 0 ] += dxtmp; f[at2 + 0 ] -= xtmp + dxtmp; f[at1 + 1 ] += ytmp; f[at3 + 1 ] += dytmp; f[at2 + 1 ] -= ytmp + dytmp; f[at1 + 2 ] += ztmp; f[at3 + 2 ] += dztmp; f[at2 + 2 ] -= ztmp + dztmp; f[at1 + 3 ] += wtmp; f[at3 + 3 ] += dwtmp; f[at2 + 3 ] -= wtmp + dwtmp; } return( e_theta ); } _REAL ephi4( nphi, a1, a2, a3, a4, atype, Pk, Pn, Phase, x, f ) int nphi, *a1, *a2, *a3, *a4, *atype; _REAL *Pk, *Pn, *Phase, *x, *f; { _REAL e,co,den,co1,uu,vv,uv,ax,bx,cx,ay,by,cy,az,bz,cz,aw,bw,cw; _REAL a0x,b0x,c0x,a0y,b0y,c0y,a0z,b0z,c0z,a0w,b0w,c0w,a1x,b1x; _REAL a1y,b1y,a1z,b1z,a1w,b1w,a2x,b2x,a2y,b2y,a2z,b2z,a2w,b2w; _REAL dd1x,dd2x,dd3x,dd4x,dd1y,dd2y,dd3y,dd4y,dd1z,dd2z,dd3z,dd4z; _REAL dd1w,dd2w,dd3w,dd4w; _REAL df,aa,bb,cc,ab,bc,ac,d1,d2,d3,e1,e2,e3,ktot; _REAL ktors1,ktors2,ktors3,ktors4,phase,e_tors; int i,at1,at2,at3,at4,atyp; e_tors = 0.0; for (i=0; iNres ); iexw = ivector( -1, prm->Natom ); /* loop over all pairs of residues: */ tot_pair = 0; kpr = 0; cut2 = cut*cut; ji = 0; for( i=0; iNatom; i++ ){ iexw[i] = -1; } for( ires=0; iresNres; ires++ ){ ip1 = prm->Ipres[ires]; ip2 = prm->Ipres[ires+1] - 1; jrp = 0; ires_pairlist[0] = ires; for( jres=ires+1; jresNres; jres++ ){ jp1 = prm->Ipres[jres]; jp2 = prm->Ipres[jres+1] - 1; for( i=ip1-1; iIblo[i]; for( k=0; kExclAt[ji+k]-1] = i; } ji += nx; for( jrp2=0; jrp2<=jrp; jrp2++ ){ jres = ires_pairlist[jrp2]; if( ires==jres ) jp1 = i+2; else jp1 = prm->Ipres[jres]; jp2 = prm->Ipres[jres+1] - 1; for( j=jp1-1; j maxnb ){ fprintf( stderr, "maxnb (%d) is too small (%d needed)\n", maxnb, tot_pair ); exit(1); } } } #ifdef PRINT_NB_LIST printf( "npairs:\n" ); for( k=0; kNatom; k++ ){ printf( "%4d", npairs[k] ); if( (k+1)%20 == 0 ) printf( "\n" ); } printf( "\npairlist:\n" ); for( k=0; kNres ); free_ivector( iexw, -1, prm->Natom ); printf( " " ); printf( " " ); printf( " %d\n", tot_pair ); return( tot_pair ); } int nbond4( npairs, pairlist, x, f, enb, eel, enbfac, eelfac, prm ) int *npairs, *pairlist; _REAL *x, *f; _REAL *enb,*eel; _REAL enbfac, eelfac; parmstruct *prm; { int i,j,jn,ic,npr,lpair,iaci; _REAL dumx,dumy,dumz,dumw,cgi,xw1,xw2,xw3,xw4,r2inv,df2,eelt,r6,f1,f2; _REAL df,fw1,fw2,fw3,fw4,enbfaci,eelfaci,r10; int ibig,isml; lpair = 0; *enb = 0.; *eel = 0.; enbfaci = 1./enbfac; eelfaci = 1./eelfac; for( i=0; iNatom-1; i++ ){ npr = npairs[i]; if( npr > 0 ){ iaci = prm->Ntypes*(prm->Iac[i] - 1); dumx = 0.; dumy = 0.; dumz = 0.; dumw = 0.; cgi = -2.*prm->Charges[i]; for( jn=0; jnCharges[j]*r2inv; *eel -= df2; ic = prm->Cno[iaci + prm->Iac[j] - 1]; if( ic > 0 || enbfac != 1.0 ){ if( ic > 0 ) { ic--; } else { ibig = prm->Iac[i] > prm->Iac[j] ? prm->Iac[i] : prm->Iac[j]; isml = prm->Iac[i] > prm->Iac[j] ? prm->Iac[j] : prm->Iac[i]; ic = ibig*(ibig-1)/2 + isml -1; } r6 = r2inv*r2inv*r2inv; f2 = prm->Cn2[ic]*r6; f1 = prm->Cn1[ic]*r6*r6; *enb += (f1-f2)*enbfaci; df = (df2+6.*(f2-f1-f1)*enbfaci)*r2inv; } else { ic = -ic - 1; r10 = r2inv*r2inv*r2inv*r2inv*r2inv; f2 = prm->HB10[ic]*r10; f1 = prm->HB12[ic]*r10*r2inv; *enb += (f1-f2)*enbfaci; df = (df2+(10.*f2-12.*f1)*enbfaci)*r2inv; } fw1 = xw1*df; fw2 = xw2*df; fw3 = xw3*df; fw4 = xw4*df; dumx += fw1; dumy += fw2; dumz += fw3; dumw += fw4; f[4*j + 0] -= fw1; f[4*j + 1] -= fw2; f[4*j + 2] -= fw3; f[4*j + 3] -= fw4; } f[4*i + 0] += dumx; f[4*i + 1] += dumy; f[4*i + 2] += dumz; f[4*i + 3] += dumw; lpair += npr; } } *eel *= 0.5; return( 0 ); } _REAL mme4( x, f, iter, prm, opts ) _REAL *x, *f; int *iter; parmstruct *prm; SFFoptions *opts; { _REAL ebh, eba, eth, eta, eph, epa, enb, eel, enb14, eel14, frms; _REAL ene[20]; int nb_pairs; int i,k; _REAL err; if( *iter<=1 ){ printf( " iter bond angle dihed. vdW elect." ); printf( " e4d Total grms\n" ); } if( *iter==1 || (*iter%opts->nsnb==0 && *iter!=0 ) ){ nb_pairs = nblist4( x, opts->npairs, opts->pairlist, prm, opts->cut, opts->maxnb, opts->frozen ); /* printf( "nb_pairs = %d\n", nb_pairs ); */ } for( i=0; i<4*prm->Natom; i++ ) f[i] = 0.0; nbond4( opts->npairs, opts->pairlist, x, f, &enb, &eel, 1.0, 1.0, prm ); ene[1] = enb; ene[2] = eel; ebh = ebond4( prm->Nbonh, prm->BondHAt1, prm->BondHAt2, prm->BondHNum, prm->Rk, prm->Req, x, f ); eba = ebond4( prm->Mbona, prm->BondAt1, prm->BondAt2, prm->BondNum, prm->Rk, prm->Req, x, f ); ene[3] = ebh + eba; eth = eangl4( prm->Ntheth, prm->AngleHAt1, prm->AngleHAt2, prm->AngleHAt3, prm->AngleHNum, prm->Tk, prm->Teq, x, f ); eta = eangl4( prm->Ntheta, prm->AngleAt1, prm->AngleAt2, prm->AngleAt3, prm->AngleNum, prm->Tk, prm->Teq, x, f ); ene[4] = eth + eta; eph = ephi4( prm->Nphih, prm->DihHAt1, prm->DihHAt2, prm->DihHAt3, prm->DihHAt4, prm->DihHNum, prm->Pk, prm->Pn, prm->Phase, x, f ); epa = ephi4( prm->Mphia, prm->DihAt1, prm->DihAt2, prm->DihAt3, prm->DihAt4, prm->DihNum, prm->Pk, prm->Pn, prm->Phase, x, f ); ene[5] = eph + epa; ene[6] = 0.0; /* hbond term not in Amber-94 force field */ nbond4( prm->N14pairs, prm->N14pairlist, x, f, &enb14, &eel14, opts->scnb, opts->scee, prm ); ene[7] = enb14; ene[8] = eel14; ene[9] = 0.0; if ( opts->w4d != 0.0 ) { for( i = 0; i < prm->Natom; i++ ) { err = x[ 4*i + 3 ]; f[ 4*i + 3 ] = opts->w4d*err; ene[9] += 0.5*opts->w4d*err*err; } } ene[0] = 0.0; for( k=1; k<=9; k++ ) ene[0] += ene[k]; for( k=0; kNatom; k++ ){ /* zero out frozen forces */ if( opts->frozen[k] ){ f[4*k + 0] = 0.0; f[4*k + 1] = 0.0; f[4*k + 2] = 0.0; f[4*k + 3] = 0.0; } } frms = 0.0; for( i=0; i<4*prm->Natom; i++) frms += f[i]*f[i]; frms = sqrt( frms/(4*prm->Natom) ); /* for( i=0; i<4*prm->Natom; i+=4 ) * printf( "%10.5f%10.5f%10.5f%10.5f\n", f[i],f[i+1],f[i+2],f[i+3] ); */ if( verbosemm && (*iter==1 || *iter%opts->ntpr==0 )){ printf( "ff:%4d%9.2f%9.2f%9.2f%9.2f%9.2f%9.2f%9.2f%9.2f\n", *iter, ene[3],ene[4],ene[5],ene[1]+ene[7],ene[2]+ene[8],ene[9], ene[0],frms ); } return ( ene[0] ); } int get_masses( minv, prm , dim) /* dim = 3 or 4, for 3D or 4D problem */ _REAL *minv; parmstruct *prm; int dim; { int i,k; _REAL am; for( k=0, i=0; iNatom; i++ ){ am = 1./prm->Masses[ i ]; minv[ k + 0 ] = am; minv[ k + 1 ] = am; minv[ k + 2 ] = am; if( dim == 4 ) minv[ k + 3 ] = am; k += dim; } return( 0 ); } int md( n, maxstep, x, minv, f, v, mme, ene, prm, opts ) _REAL ( *mme )(); int n, maxstep; _REAL *x, *minv, *f, *v, *ene; parmstruct *prm; SFFoptions *opts; { _REAL dtx, dt5, rndf, dttp, ekin0, ekin, epot, etot, tscal, temp, sd; int nstep, i, k; _REAL zero; assert(opts->temp0 >= 0.0); assert(opts->tempi >= 0.0); assert(opts->nfrozen >= 0); dtx = opts->dt*20.455; dt5 = 0.5*dtx; rndf = n - 6 -3*opts->nfrozen; ekin0 = opts->boltz2*rndf*opts->temp0; /* target kinetic energy */ dttp = opts->dt/opts->tautp; zero = 0.0; assert(rndf >= 0.0); assert(ekin0 >= 0.0); #ifdef USE_REAL_MASSES if (prm) get_masses( minv, prm, opts->dim); /* if no prmtop file is present, set all masses to 10 amu */ else for( i=0; izerov ){ for( i=0; itempi > 0.0 ){ ekin = 0.0; for( i=0; ifrozen[ i/opts->dim ]) ){ v[ i ] = 0.0; } else { sd = sqrt(2.*opts->boltz2*opts->tempi*minv[i]); v[ i ] = gauss( &zero, &sd, &(opts->idum) ); assert(minv[i] > 0.001); ekin += v[i]*v[i]/minv[i]; } } ekin *= 0.5; temp = ekin/(opts->boltz2*rndf); assert(temp >= 0.0); } else { for( ekin=0., i=0; i 0.01 ) tscal = sqrt(1. + dttp*(ekin0/ekin - 1.)); else tscal = 1.0; ekin = 0.0; for( i=0; i opts->vlimit ? opts->vlimit : v[i]; v[ i ] = v[i] < -(opts->vlimit) ? -(opts->vlimit) : v[i]; ekin += v[i]*v[i]/minv[i]; x[ i ] += v[ i ]*dtx; } ekin *= 0.5; etot = ekin + epot; temp = ekin/(opts->boltz2*rndf); opts->t += opts->dt; assert(temp >= 0.0); assert(ekin >= 0.0); if(verbosemd && (nstep%opts->ntpr_md == 0 || nstep == 1 )){ printf( "md: %5d %10.3f %10.2f %10.2f %10.2f\n", nstep, opts->t, ekin, epot, temp ); fflush( stdout ); } if( opts->ntwx > 0 && nstep%opts->ntwx == 0 && opts->binposfp){ writebinpos( n/3, x, opts->binposfp ); } } sff_reset_signals(); stop_flag = 0; return SFF_OK; } int mme_timer() { printf("\nTiming summary:\n" ); printf(" bonds %8.1f\n", tbond ); printf(" angles %8.1f\n", tangl ); printf(" torsions %8.1f\n", tphi ); printf(" pairlist %8.1f\n", tpair ); printf(" nonbonds %8.1f\n", tnonb ); printf(" constraints %8.1f\n", tcons ); printf(" Total %8.1f\n\n", tbond+tangl+tphi+tpair+tnonb+tcons ); return( 0 ); } mgltools-sff-1.5.7~rc1~cvs.20130519/src/bhtree.c0000644000175000017500000002374110124346147020224 0ustar debiandebian/* $Header: /opt/cvs/sffDIST/src/bhtree.c,v 1.1 2004/09/22 19:03:03 annao Exp $ * * $Id: bhtree.c,v 1.1 2004/09/22 19:03:03 annao Exp $ * * $Log: bhtree.c,v $ * Revision 1.1 2004/09/22 19:03:03 annao * -moved files from sffDIST/sff/src into sffDIST/src. * * Revision 1.1.1.1 2004/06/15 17:10:32 annao * Imported sources * * Revision 1.1.1.1 2002/06/26 23:29:27 gillet * Imported sources version1.0 * * Revision 1.1 2001/12/28 01:25:50 sanner * - added BHtree-based nblist calculation (turns out to be slower for 4sgb=300AA) * - added upper-cutoff in orginial nblist to speedup list genenration * - added md_options function * - split verbose variable into verbosemm and verbosemd * - renamed class Amber94Minimizer Amber94. The run method is now called * minimize and an md method has been added. * * Revision 0.2 2000/08/14 18:00:34 sanner * removed copyright text * * Revision 0.1 2000/08/14 17:45:19 sanner * added copyright text * * Revision 0.0 1999/10/27 17:51:28 sanner * *** empty log message *** * * Revision 1.3 1998/03/19 22:10:14 sanner * fixed the RCS Header Id and Log in source files * */ /* provided by Armin Widmer */ #include #include #include "bhtree.h" /* Barnes - Hut Trees ? */ #define NSTEPS 128 static int findBHcloseAtomsInNode(BHnode *node,float *x,float cutoff, int *atom,int maxn); static int findBHcloseAtomsInNodedist(BHnode *node,float *x,float cutoff, int *atom,float *dist,int maxn); /*-------------------- generateBHtree --------------------*/ BHtree *generateBHtree(BHpoint **atoms,int nbat,int granularity) { /* 3D space-sort atoms into Barnes-Hut tree with given granularity */ /* (max number of atoms per leaf-node) */ BHtree *r; BHpoint **p; int i,k; /* allocate tree data structure */ r=(BHtree *)malloc(sizeof(BHtree)); if (r==NULL) return(r); r->atom=(BHpoint **)NULL; r->bfl=0; r->rm=0.0; for (i=0;irmr) r->rm = atoms[i]->r; r->rm += 0.1; #ifdef STATBHTREE r->tot=0; /* total number of neighbors returned by findBHclose */ r->max=0; r->min=9999999; /* min and max of these numbers */ r->nbr=0; /* number of calls to findBHclose */ #endif /* allocate root node data structure */ r->root=(BHnode *)malloc(sizeof(BHnode)); if (r->root==NULL) { freeBHtree(r); return((BHtree *)NULL); } /* initialize root node data structure */ r->root->atom=(BHpoint **)NULL; r->root->n=0; r->root->dim= -1; r->root->left=(BHnode *)NULL; r->root->right=(BHnode *)NULL; /* count atoms in chain */ if (nbat==0) { freeBHtree(r); return((BHtree *)NULL); } /* allocate atom pointer array */ r->atom=atoms; if (r->atom == NULL) { freeBHtree(r); return((BHtree *)NULL); } r->root->atom=r->atom; /* fill atom pointer array */ p=r->root->atom; r->root->n=nbat; /* determine box dimension */ p=r->root->atom; for (k=0;k<3;k++) { r->xmin[k]=p[0]->x[k]; r->xmax[k]=r->xmin[k]; } for (i=1;iroot->n;i++) { for (k=0;k<3;k++) { if (r->xmin[k] > p[i]->x[k]) r->xmin[k] = p[i]->x[k]; if (r->xmax[k] < p[i]->x[k]) r->xmax[k] = p[i]->x[k]; } } /* start recursive 3D space sort */ divideBHnode(r->root,r->xmin,r->xmax,granularity); /* done... */ return(r); } /*-------------------- find_BHnode --------------------*/ BHnode *findBHnode(BHtree *tree,float *x) { /* find leaf in BH tree that contains 3D point x */ BHnode *r; int k; if (tree==NULL) return((BHnode *)NULL); /* first check if point is in tree */ for (k=0;k<3;k++) { if (x[k]xmin[k]) return((BHnode *)NULL); if (x[k]>tree->xmax[k]) return((BHnode *)NULL); } /* if point is in tree, locate the leaf */ r=tree->root; while (r!=NULL) { if (r->dim<0) break; if (x[r->dim]cut) r=r->left; else r=r->right; } return(r); } /*-------------------- freeBHtree --------------------*/ void freeBHtree(BHtree *tree) { int i; if (tree->atom!=NULL) { for (i=0;iroot->n;i++) free(tree->atom[i]); free(tree->atom); } freeBHnode(tree->root); free(tree); } /*-------------------- freeBHnode --------------------*/ void freeBHnode(BHnode *node) { if (node!=NULL) { freeBHnode(node->left); freeBHnode(node->right); free(node); } } /*-------------------- divideBHtree --------------------*/ void divideBHnode(BHnode *node,float *xmin,float *xmax,int granularity) { float cut,dx,xminl[3],xmaxl[3],xminr[3],xmaxr[3]; int dim,i,j,k,n[NSTEPS],lm,rm; BHpoint *a; /* if nothing left to divide just return */ if (node==NULL) return; if (granularity<1 || node->n <= granularity) return; if (node->atom==NULL) return; /* determine dimension along which to cut */ dim=0; if (xmax[1]-xmin[1] > xmax[dim]-xmin[dim]) dim=1; if (xmax[2]-xmin[2] > xmax[dim]-xmin[dim]) dim=2; /* determine position of cutting plane */ dx=(xmax[dim]-xmin[dim])/NSTEPS; if (dx<0.0001) return; for (i=0;in;j++) { i=(node->atom[j]->x[dim]-xmin[dim])/dx; if (i>=0 && inode->n/2) break; } cut=xmin[dim]+i*dx; if (n[i]>=node->n) return; /* create left/right descendants */ node->left=(BHnode *)malloc(sizeof(BHnode)); if (node->left==NULL) return; node->left->dim= -1; node->left->left=(BHnode *)NULL; node->left->right=(BHnode *)NULL; node->right=(BHnode *)malloc(sizeof(BHnode)); if (node->right==NULL) { freeBHnode(node->left); return; } node->right->dim= -1; node->right->left=(BHnode *)NULL; node->right->right=(BHnode *)NULL; node->cut=cut; node->dim=dim; /* sort atoms into left/right descendants */ lm=0; rm=node->n-1; while (lmn;lm++) if (node->atom[lm]->x[dim]>=cut) break; for(;rm>=0;rm--) if (node->atom[rm]->x[dim]atom[rm]; node->atom[rm]=node->atom[lm]; node->atom[lm]=a; rm--; lm++; } } if (lm==rm) { if (node->atom[rm]->x[dim]left->n=rm+1; node->left->atom=node->atom; node->right->n=node->n-(rm+1); node->right->atom=node->atom+lm; /* if descendants are coarse, cut them up... */ if (node->left->n > granularity) { for (k=0;k<3;k++) { xminl[k]=xmin[k]; xmaxl[k]=xmax[k]; } xmaxl[dim]=cut; divideBHnode(node->left,xminl,xmaxl,granularity); } if (node->right->n > granularity) { for (k=0;k<3;k++) { xminr[k]=xmin[k]; xmaxr[k]=xmax[k]; } xminr[dim]=cut; divideBHnode(node->right,xminr,xmaxr,granularity); } /* done... */ return; } /*-------------------- findBHcloseAtoms --------------------*/ int findBHcloseAtomsdist(BHtree *tree,float *x,float cutoff, int *atom,float *dist,int maxn) { int i; if (maxn<1 || tree==NULL || cutoff <=0.0) return(0); if (tree->root==NULL) return(0); for (i=0;i<3;i++) { if (x[i] < tree->xmin[i] - cutoff) break; if (x[i] > tree->xmax[i] + cutoff) break; } if (i<3) return(0); return(findBHcloseAtomsInNodedist(tree->root,x,cutoff,atom,dist,maxn)); } /*-------------------- findBHcloseAtomsInNode --------------------*/ static int findBHcloseAtomsInNodedist(BHnode *node,float *x,float cutoff, int *atom,float *dist,int maxn) { int j,n; float d[3],D,C; if (node==NULL) return(0); if (maxn<=0) return(0); if (node->n < 1) return(0); if (node->dim<0) { n=0; C=cutoff*cutoff; for (j=0;jn;j++) { d[0]=x[0]-node->atom[j]->x[0]; if (d[0]>cutoff || d[0]< -cutoff) continue; d[1]=x[1]-node->atom[j]->x[1]; if (d[1]>cutoff || d[1]< -cutoff) continue; d[2]=x[2]-node->atom[j]->x[2]; if (d[2]>cutoff || d[2]< -cutoff) continue; D=d[0]*d[0]+d[1]*d[1]+d[2]*d[2]; if (D>C) continue; if (natom[j]->at; dist[n]=sqrt(D); n++; }else{ n++; break; } } }else{ n=0; if (x[node->dim]cut+cutoff) { n+=findBHcloseAtomsInNodedist(node->left,x,cutoff,atom,dist,maxn); } if (x[node->dim]>=node->cut-cutoff) { n+=findBHcloseAtomsInNodedist(node->right,x,cutoff,atom+n,dist+n,maxn-n); } } return(n); } /*-------------------- findBHcloseAtoms --------------------*/ int findBHcloseAtoms(BHtree *tree,float *x,float cutoff, int *atom,int maxn) { int i,n; if (maxn<1 || tree==NULL || cutoff <=0.0) return(0); if (tree->root==NULL) return(0); for (i=0;i<3;i++) { if (x[i] < tree->xmin[i] - cutoff) break; if (x[i] > tree->xmax[i] + cutoff) break; } if (i<3) return(0); #ifdef STATBHTREE n = findBHcloseAtomsInNode(tree->root,x,cutoff,atom,maxn); tree->nbr++; tree->tot += n; if (n>tree->max) tree->max=n; if (nmin) tree->min=n; return(n); #else return(findBHcloseAtomsInNode(tree->root,x,cutoff,atom,maxn)); #endif } /*-------------------- findBHcloseAtomsInNode --------------------*/ static int findBHcloseAtomsInNode(BHnode *node,float *x,float cutoff, int *atom, int maxn) { int j,n; float C,D; double d1,d2,d3; BHpoint *p; /* if (node==NULL) return(0); if (maxn<=0) return(0); if (node->n < 1) return(0); */ if (node->dim<0) { C=cutoff*cutoff; for (n=j=0;jn;j++) { p = node->atom[j]; d1 = x[0] - p->x[0]; if (d1 > cutoff || d1 < -cutoff) continue; d2 = x[1] - p->x[1]; if (d2 > cutoff || d2 < -cutoff) continue; d3 = x[2] - p->x[2]; if (d3 > cutoff || d3 < -cutoff) continue; D=d1*d1 + d2*d2 + d3*d3; if (D>C) continue; if (nat; n++; }else{ printf("ERROR: findBHcloseAtomsInNode: result array too small\n"); break; } } } else { n=0; if (x[node->dim]cut+cutoff) { n+=findBHcloseAtomsInNode(node->left,x,cutoff,atom,maxn); } if (x[node->dim]>=node->cut-cutoff) { n+=findBHcloseAtomsInNode(node->right,x,cutoff,atom+n,maxn-n); } } return(n); } mgltools-sff-1.5.7~rc1~cvs.20130519/src/bhtree.h0000644000175000017500000000436410124346163020227 0ustar debiandebian/* $Header: /opt/cvs/sffDIST/src/bhtree.h,v 1.1 2004/09/22 19:03:15 annao Exp $ * * $Id: bhtree.h,v 1.1 2004/09/22 19:03:15 annao Exp $ * * $Log: bhtree.h,v $ * Revision 1.1 2004/09/22 19:03:15 annao * -moved files from sffDIST/sff/src into sffDIST/src. * * Revision 1.1.1.1 2004/06/15 17:10:32 annao * Imported sources * * Revision 1.1.1.1 2002/06/26 23:29:27 gillet * Imported sources version1.0 * * Revision 1.1 2001/12/28 01:25:50 sanner * - added BHtree-based nblist calculation (turns out to be slower for 4sgb=300AA) * - added upper-cutoff in orginial nblist to speedup list genenration * - added md_options function * - split verbose variable into verbosemm and verbosemd * - renamed class Amber94Minimizer Amber94. The run method is now called * minimize and an md method has been added. * * Revision 0.2 2000/08/14 18:00:28 sanner * removed copyright text * * Revision 0.1 2000/08/14 17:45:35 sanner * added copyright text * * Revision 0.0 1999/10/27 17:51:28 sanner * *** empty log message *** * * Revision 1.3 1998/03/19 22:10:14 sanner * fixed the RCS Header Id and Log in source files * */ /* provided by Armin Widmer */ #ifndef BHTREEDEF #define BHTREEDEF #include typedef struct BHpoint { float x[3]; float r; int at; } BHpoint; typedef struct BHnode { struct BHnode *left,*right; struct BHpoint **atom; float cut; int dim,n; } BHnode; typedef struct BHtree { struct BHnode *root; struct BHpoint **atom; float xmin[3]; float xmax[3]; float rm; #ifdef STATBHTREE long tot; /* total number of neighbors returned by findBHclose */ int max,min; /* min and max of these numbers */ int nbr; /* number of calls to findBHclose */ #endif short bfl; } BHtree; BHtree *generateBHtree(BHpoint **atoms, int nbat, int granularity); BHnode *findBHnode(BHtree *tree,float *x); int findBHcloseAtoms(BHtree *tree,float *x,float cutoff, int *atom,int maxn); int findBHcloseAtomsdist(BHtree *tree,float *x,float cutoff, int *atom,float *d,int maxn); void freeBHtree(BHtree *tree); void divideBHnode(BHnode *node,float *xmin,float *xmax,int granularity); void freeBHnode(BHnode *node); extern BHtree *bht; extern BHpoint **BHat; #endif mgltools-sff-1.5.7~rc1~cvs.20130519/src/main.c0000644000175000017500000000305110124346147017667 0ustar debiandebian#include #include #include "prm.h" /* cc -g main.c binpos.c conjgrad.c memutil.c prm.c rand2.c sff.c -lm -o main*/ int main(int argc, char **argv) { int status, size, maxiter=500; struct parm *prm; _REAL f, ene[20], dgrad=0.1, dfpred=10.0; _REAL x[] = {17.047, 14.099, 3.625, 17.914, 14.119, 3.088, 16.958, 14.895, 4.257, 16.224, 14.286, 3.051, 16.967, 12.784, 4.338, 17.0, 11.939, 3.612, 18.17, 12.703, 5.337, 18.134, 13.632, 5.953, 18.15, 11.546, 6.304, 19.007, 11.488, 7.015, 18.058, 10.586, 5.744, 17.188, 11.541, 6.869, 19.334, 12.829, 4.463, 20.064, 12.78, 5.069, 15.685, 12.755, 5.133, 15.268, 13.825, 5.594, 15.115, 11.555, 5.265, 15.524, 10.726, 4.834, 13.856, 11.469, 6.066, 13.501, 12.504, 6.28, 12.732, 10.711, 5.261, 11.794, 10.602, 5.854, 12.484, 11.442, 3.895, 11.689, 10.906, 3.326, 13.421, 11.558, 3.303, 12.248, 12.523, 4.032, 13.308, 9.439, 4.926, 12.631, 8.982, 4.441, 14.164, 10.785, 7.379, 14.993, 9.862, 7.443, 13.488, 11.241, 8.417, 12.817, 11.995, 8.269, 13.66, 10.707, 9.787, 14.252, 9.762, 9.757, 14.368, 11.748, 10.691, 14.555, 11.317, 11.702, 13.663, 12.57, 10.958, 15.885, 12.426, 10.016, 16.149, 13.226, 11.045, 12.269, 10.431, 10.323, 11.393, 11.308, 10.185, 12.026, 9.383, 10.917 }; /* assert (argc>=2); */ mme_callback[0].fun = NULL; mme_callback[0].fun = sanityCb; mme_callback[0].freq = 50; prm = readparm("NEWTRIP.prmtop"); size = sizeof x / sizeof *x; mme_init(NULL, NULL, NULL, NULL, prm); status = conjgrad( x, &size, &f, mme, &dgrad, &dfpred, &maxiter, prm, ene); return status <= 0; } mgltools-sff-1.5.7~rc1~cvs.20130519/src/memutil.c0000644000175000017500000001001310124346147020413 0ustar debiandebian/* * * This software is copyrighted, 1995, by Tom Macke and David A. Case. * The following terms apply to all files associated with the software * unless explicitly disclaimed in individual files. * * The authors hereby grant permission to use, copy, modify, and re-distribute * this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be distributed provided that * the nature of the modifications are clearly indicated. * * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY * DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE * IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE * NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR * MODIFICATIONS. * */ #include #include #include "prm.h" void nrerror( msg ) char msg[]; { fprintf( stderr, "FATAL: %s\n", msg ); exit( 1 ); } float *vector( nl, nh ) int nl, nh; { float *v; v = ( float * )malloc( ( nh - nl + 1 ) * sizeof( float ) ); if( !v ) nrerror( "allocation failure in vector()" ); return( v - nl ); } int *ivector( nl, nh ) int nl, nh; { int *v; v = ( int * )malloc( ( nh - nl + 1 ) * sizeof( int ) ); if( !v ) nrerror( "allocation failure in ivector()" ); return( v - nl ); } int *ipvector( nl, nh ) int nl, nh; { int *v; v = ( int * )malloc( ( nh - nl + 1 ) * sizeof( int * ) ); if( !v ) nrerror( "allocation failure in ivector()" ); return( v - nl ); } #define NR_END 1 float **matrix( nrl, nrh, ncl, nch ) int nrl, nrh, ncl, nch; { int i; int nrow, ncol; float **m; nrow = nrh - nrl + 1; ncol = nch - ncl + 1; m = ( float ** )malloc( ( nrow + NR_END ) * sizeof( float * ) ); if( !m ) nrerror( "allocation failure 1 in matrix()" ); m += NR_END; m -= nrl; m[ nrl ] = ( float * ) malloc( ( nrow * ncol + NR_END ) * sizeof( float ) ); if( !m[ nrl ] ) nrerror( "allocation failure 2 in matrix()" ); m[ nrl ] += NR_END; m[ nrl ] -= ncl; for( i = nrl + 1; i <= nrh; i++ ) m[ i ] = m[ i - 1 ] + ncol; return( m ); } int **imatrix( nrl, nrh, ncl, nch ) int nrl, nrh, ncl, nch; { int i; int nrow, ncol; int **m; nrow = nrh - nrl + 1; ncol = nch - ncl + 1; m = ( int ** )malloc( ( nrow + NR_END ) * sizeof( int * ) ); if( !m ) nrerror( "allocation failure 1 in matrix()" ); m += NR_END; m -= nrl; m[ nrl ] = ( int * ) malloc( ( nrow * ncol + NR_END ) * sizeof( int ) ); if( !m[ nrl ] ) nrerror( "allocation failure 2 in matrix()" ); m[ nrl ] += NR_END; m[ nrl ] -= ncl; for( i = nrl + 1; i <= nrh; i++ ) m[ i ] = m[ i - 1 ] + ncol; return( m ); } void free_vector( v, nl, nh ) float *v; int nl, nh; { free( ( char * )( v + nl ) ); } void free_ivector( v, nl, nh ) int *v; int nl, nh; { free( ( char * )( v + nl ) ); } #ifdef ORIG void free_matrix( m, nrl, nrh, ncl, nch ) float **m; int nrl, nrh, ncl, nch; { free( ( char * )( m[ nrl ] + ncl - NR_END ) ); free( ( char * )( m + nrl - NR_END ) ); } #endif void free_imatrix( m, nrl, nrh, ncl, nch ) int **m; int nrl, nrh, ncl, nch; { free( ( char * )( m[ nrl ] + ncl - NR_END ) ); free( ( char * )( m + nrl - NR_END ) ); } /* MS */ _REAL *Rvector( nl, nh ) int nl, nh; { _REAL *v; v = ( _REAL * )malloc( ( nh - nl + 1 ) * sizeof( _REAL ) ); if( !v ) nrerror( "allocation failure in Rvector()" ); return( v - nl ); } void free_Rvector( v, nl, nh ) _REAL *v; int nl, nh; { free( ( char * )( v + nl ) ); } mgltools-sff-1.5.7~rc1~cvs.20130519/src/rand2.c0000644000175000017500000000566010124346147017761 0ustar debiandebian/* * * This software is copyrighted, 1995, by Tom Macke and David A. Case. * The following terms apply to all files associated with the software * unless explicitly disclaimed in individual files. * * The authors hereby grant permission to use, copy, modify, and re-distribute * this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be distributed provided that * the nature of the modifications are clearly indicated. * * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY * DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE * IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE * NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR * MODIFICATIONS. * */ #include #include #define IM1 2147483563 #define IM2 2147483399 #define AM ( 1.0 / IM1 ) #define IMM1 ( IM1 - 1 ) #define IA1 40014 #define IA2 40692 #define IQ1 53668 #define IQ2 52774 #define IR1 12211 #define IR2 3791 #define NTAB 32 #define NDIV ( 1 + IMM1 / NTAB ) #define EPS 1.2e-7 #define RNMX ( 1.0 - EPS ) static int idum2 = 1234566789; static long iy = 0; static long iv[ NTAB ]; static int igset = 0; static float gdev1; float rand2( idum ) int *idum; { int j, k; float temp; if( *idum <= 0 ){ if( -*idum < 1 ) *idum = 1; else *idum = -*idum; idum2 = *idum; for( j = NTAB + 7; j >= 0; j-- ){ k = *idum / IQ1; *idum = IA1 * ( *idum - k * IQ1 ) - k * IR1; if( *idum < 0 ) *idum += IM1; if( j < NTAB ) iv[ j ] = *idum; } iy = iv[ 0 ]; } k = *idum / IQ1; *idum = IA1 * ( *idum - k * IQ1 ) - k * IR1; if( *idum < 0 ) *idum += IM1; k = idum2 / IQ2; idum2 = IA2 * ( idum2 - k * IQ2 ) - k * IR2; if( idum2 < 0 ) idum2 += IM2; j = iy / NDIV; iy = iv[ j ] - idum2; iv[ j ] = *idum; if( iy < 1 ) iy += IMM1; if( ( temp = AM * iy ) > RNMX ) return( RNMX ); else return( temp ); } float gauss( mean, sd, idum) float *mean,*sd; int *idum; { float fac,gdev2,rsq,s1,s2; if( igset ){ igset = 0; return( *sd*gdev1 + *mean ); } else { repeat: s1 = 2.*rand2(idum) - 1.; s2 = 2.*rand2(idum) - 1.; rsq = s1*s1 + s2*s2; if( rsq >= 1. || rsq == 0.0 ) goto repeat; fac = sqrt(-2.*log(rsq)/rsq); gdev1 = s1*fac; gdev2 = s2*fac; igset = 1; return( *sd*gdev2 + *mean ); } } mgltools-sff-1.5.7~rc1~cvs.20130519/src/memutil.h0000644000175000017500000000325110124346163020424 0ustar debiandebian/* * * This software is copyrighted, 1995, by Tom Macke and David A. Case. * The following terms apply to all files associated with the software * unless explicitly disclaimed in individual files. * * The authors hereby grant permission to use, copy, modify, and re-distribute * this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be distributed provided that * the nature of the modifications are clearly indicated. * * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY * DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE * IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE * NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR * MODIFICATIONS. * */ void nrerror(); float *vector(); int *ivector(); int *ipvector(); float **matrix(); int **imatrix(); void free_vector(); void free_ivector(); void free_matrix(); void free_imatrix(); /* MS */ extern _REAL *Rvector( int nl, int nh ); extern void free_Rvector( _REAL *v, int nl, int nh ); mgltools-sff-1.5.7~rc1~cvs.20130519/src/conjgrad.c0000644000175000017500000001774610124346147020552 0ustar debiandebian/* * * This software is copyrighted, 1995, by Tom Macke and David A. Case. * The following terms apply to all files associated with the software * unless explicitly disclaimed in individual files. * * The authors hereby grant permission to use, copy, modify, and re-distribute * this software and its documentation for any purpose, provided * that existing copyright notices are retained in all copies and that this * notice is included verbatim in any distributions. No written agreement, * license, or royalty fee is required for any of the authorized uses. * Modifications to this software may be distributed provided that * the nature of the modifications are clearly indicated. * * IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES * ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY * DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE * IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE * NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR * MODIFICATIONS. * */ #include #include "prm.h" #include "memutil.h" /* bsd mods */ /* extern int stop_flag; */ /* int sff_reset_signals(void); */ /* int sff_init_signals(void); */ int conjgrad( x, n, f, func, dgrad, dfpred, maxiter, prm, ene, opts ) _REAL x[]; int *n; int *maxiter; _REAL *f; _REAL ( *func )(); _REAL *dgrad; _REAL *dfpred; parmstruct *prm; _REAL *ene; SFFoptions * opts; /* ** ---routine carry out conjugate gradient optimization ** ** x(n) contains the variables to be updated ** n is the number of variables ** f will contain the value of the objective function at the end ** func is the name of the function that computes the objective ** function and its gradient ** dgrad return when sum of squares of gradient is less than dgrad ** dfpred expected decrease in the function on the first iteration ** ** return codes: ** >0 converged, final iteration number ** -1 bad line search, probably an error in the relation ** of the funtion to its gradient (perhaps from ** round-off if you push too hard on the minimization). ** -2 search direction was uphill ** -3 exceeded the maximum number of iterations ** -4 could not further reduce function value ** -5 stoped via signal (bsd) ** */ { _REAL *w, *g; int maxlin = 5; int mxfcon = 2; int ret_val; _REAL r__1, r__2, r__3; _REAL calc, gama, beta, fmin, gmin, dfpr, drho, gnew; _REAL step, work, z, finit, ginit, gsqrd, gspln; _REAL stmin, gamden, ddspln, stepch, sbound; _REAL fch, rho, sum; int niter, iobs, ivar, i, nfbeg, iterc, irsdg, igopt; int nfopt, irsdx, ixopt, iginit; int iterfm, iterrs, iretry, ier; int ncopy; /* initialize signals */ /* stop_flag = 0; */ /* sff_init_signals(); */ /* bsd */ --x; ncopy = *n; w = Rvector( 1, 6*ncopy ); g = Rvector( 1, ncopy ); ier = 0; irsdx = *n; irsdg = irsdx + *n; iginit = irsdg + *n; ixopt = iginit + *n; igopt = ixopt + *n; iterc = 0; niter = 0; iterfm = iterc; L10: ++niter; /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ /* ** Compute the function value in "f" and its ** gradient (with respect to x) in "g". */ *f = ( *func )( &x[ 1 ], &g[ 1 ], &niter, ene, prm, opts ); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% */ if (niter >= 2) { goto L30; } L20: for (i = 1; i <= *n; ++i) w[i] = -g[i]; iterrs = 0; if (iterc > 0) goto L40; L30: gnew = (_REAL)0.; sum = (_REAL)0.; for (i = 1; i <= *n; ++i) { gnew += w[i] * g[i]; r__1 = g[i]; sum += r__1 * r__1; } if (niter == 1) { fmin = *f; gsqrd = sum; nfopt = niter; for (i = 1; i <= *n; ++i) { w[ixopt + i] = x[i]; w[igopt + i] = g[i]; } if (sum <= *dgrad) goto L100; } else { fch = *f - fmin; if (fch < (_REAL)0. || fch == (_REAL)0. && gnew / gmin >= (_REAL)-1.) { fmin = *f; gsqrd = sum; nfopt = niter; for (i = 1; i <= *n; ++i) { w[ixopt + i] = x[i]; w[igopt + i] = g[i]; } if (sum <= *dgrad) goto L100; } } /* if (stop_flag) { */ /* bsd */ /* fprintf(stdout,"conjgrad: STOP at iteration %d\n", niter); */ /* ier = -5; goto L100; */ /* } */ if (niter >= *maxiter) { ier = -3; goto L100; } if (niter > 1) goto L60; dfpr = *dfpred; stmin = *dfpred / gsqrd; L40: ++iterc; finit = *f; ginit = (_REAL)0.; for (i = 1; i <= *n; ++i) { w[iginit + i] = g[i]; ginit += w[i] * g[i]; } if (ginit >= (_REAL)0.) { ier = -2; goto L90; } gmin = ginit; sbound = (_REAL)-1.; nfbeg = niter; iretry = -1; r__2 = stmin, r__3 = (r__1 = dfpr / ginit, ((r__1) >= 0 ? (r__1) : -(r__1))); stepch = (r__2) <= (r__3) ? (r__2) : (r__3); stmin = (_REAL)0.; L50: step = stmin + stepch; work = (_REAL)0.; for (i = 1; i <= *n; ++i) { x[i] = w[ixopt + i] + stepch * w[i]; r__2 = work, r__3 = (r__1 = x[i] - w[ixopt + i], ((r__1) >= 0 ? (r__1) : -(r__1))); work = ((r__2) >= (r__3) ? (r__2) : (r__3)); } if (work > (_REAL)0.) goto L10; if (niter > nfbeg + 1) ier = -1; if ((r__1 = gmin / ginit, ((r__1) >= 0 ? (r__1) : -(r__1))) > (_REAL).2) ier = -1; goto L90; L60: work = (fch + fch) / stepch - gnew - gmin; ddspln = (gnew - gmin) / stepch; if (niter > nfopt) { sbound = step; } if (niter <= nfopt) { if (gmin * gnew <= (_REAL)0.) sbound = stmin; stmin = step; gmin = gnew; stepch = -stepch; } if (fch != (_REAL)0.) ddspln += (work + work) / stepch; if (gmin == (_REAL)0.) goto L90; if (niter > nfbeg + 1) { if ((r__1 = gmin / ginit, ((r__1) >= 0 ? (r__1) : -(r__1))) <= (_REAL).2) { goto L90; } if (niter >= nfopt + maxlin) { ier = -1; goto L90; } } L70: stepch = (sbound - stmin) * (_REAL).5; if (sbound < (_REAL)-.5) { stepch = stmin * (_REAL)9.; } gspln = gmin + stepch * ddspln; if (gmin * gspln < (_REAL)0.) stepch = stepch * gmin / (gmin - gspln); goto L50; L80: sum = (_REAL)0.; for (i = 1; i <= *n; ++i) sum += g[i] * w[iginit + i]; beta = (gsqrd - sum) / (gmin - ginit); if ((r__1 = beta * gmin, ((r__1) >= 0 ? (r__1) : -(r__1))) > gsqrd * (_REAL).2) { ++iretry; if (iretry <= 0) { if (niter >= nfopt + maxlin) { ier = -1; goto L90; } else goto L70; } } if (*f < finit) iterfm = iterc; if (iterc >= iterfm + mxfcon) { ier = -4; goto L100; } dfpr = stmin * ginit; if (iretry > 0) { goto L20; } if (iterrs != 0 && iterc - iterrs < *n && (sum >= 0 ? sum : -sum) < gsqrd * (_REAL).2) { gama = (_REAL)0.; sum = (_REAL)0.; for (i = 1; i <= *n; ++i) { gama += g[i] * w[irsdg + i]; sum += g[i] * w[irsdx + i]; } gama /= gamden; if ((r__1 = beta * gmin + gama * sum, ((r__1) >= 0 ? (r__1) : -(r__1))) < gsqrd * (_REAL).2) { for (i = 1; i <= *n; ++i) w[i] = -g[i] + beta * w[i] + gama * w[irsdx + i]; goto L40; } } gamden = gmin - ginit; for (i = 1; i <= *n; ++i) { w[irsdx + i] = w[i]; w[irsdg + i] = g[i] - w[iginit + i]; w[i] = -g[i] + beta * w[i]; } iterrs = iterc; goto L40; L90: if (niter != nfopt) { *f = fmin; for (i = 1; i <= *n; ++i) { x[i] = w[ixopt + i]; g[i] = w[igopt + i]; } } if (ier == 0) goto L80; L100: /* stop_flag = 0; */ /* sff_reset_signals(); */ free_Rvector( w, 1, 6*ncopy ); free_Rvector( g, 1, ncopy ); if( ier == 0 ) ret_val = niter; else ret_val = ier; return ret_val; } mgltools-sff-1.5.7~rc1~cvs.20130519/src/prm.h0000644000175000017500000001133310124346163017546 0ustar debiandebian/* MS modified to work with sff.c */ #ifndef NO_DOUBLE #define DOUBLE #endif #ifdef DOUBLE typedef double _REAL; #define UseDouble 1 #else typedef float _REAL; #define UseDouble 0 #endif typedef struct parm { int IfBox, Nmxrs, IfCap, Natom, Ntypes, Nbonh, Mbona, Ntheth, Mtheta, Nphih, Mphia, Nhparm, Nparm, Nnb, Nres, Nbona, Ntheta, Nphia, Numbnd, Numang, Nptra, Natyp, Nphb, Nat3, Ntype2d, Nttyp, Nspm, Iptres, Nspsol, Ipatm, Natcap; char *ititl, *AtomNames, *ResNames, *AtomSym, *AtomTree; _REAL *Charges, *Masses, *Rk, *Req, *Tk, *Teq, *Pk, *Pn, *Phase, *Solty, *Cn1, *Cn2, *HB12, *HB10; _REAL Box[3], Cutcap, Xcap, Ycap, Zcap; int *Iac, *Iblo, *Cno, *Ipres, *ExclAt, *TreeJoin, *AtomRes, *BondHAt1, *BondHAt2, *BondHNum, *BondAt1, *BondAt2, *BondNum, *AngleHAt1, *AngleHAt2, *AngleHAt3, *AngleHNum, *AngleAt1, *AngleAt2, *AngleAt3, *AngleNum, *DihHAt1, *DihHAt2, *DihHAt3, *DihHAt4, *DihHNum, *DihAt1, *DihAt2, *DihAt3, *DihAt4, *DihNum, *Boundary; int *N14pairs, *N14pairlist; } parmstruct; typedef struct SFFoptions { _REAL cut; /* non-bonded cutoff (8.0)*/ _REAL scnb; /* scale factor for 1-4 nonbonds (2.0) */ _REAL scee; /* scale factor for 1-4 electrostatics (1.2) */ int ntpr; /* print frequency (10)*/ int nsnb; /* non-bonded update frequency (25) */ int mme_init_first; /* 1 */ int *frozen; int nfrozen; int *constrained ; int nconstrained ; _REAL *x0 ; /* will hold coordinates to be constrained */ _REAL wcons ; /* weight of constraints */ int *npairs; int *pairlist; int maxnb; int dield; /* dielectric function to be used */ _REAL w4d ; int dim; /* dimension: 3 or 4 */ /* MD variables: */ _REAL t; /* initial time (0)*/ _REAL dt; /* time step, ps.(0.001) */ _REAL tautp; /* temp. coupling parm., ps (0.02) */ _REAL temp0; /* target temperature, K (300.0)*/ _REAL boltz2; /* 9.93595e-4 */ _REAL vlimit; /* maximum velocity component (10.0)*/ int ntpr_md ; /* print frequency (10)*/ int ntwx; /* trajectory snapshot frequency (0) */ FILE *binposfp; /* file pointer for trajectories */ int zerov; /* if true, use zero initial velocities (0)*/ _REAL tempi; /* initial temperature (0.0)*/ int idum; /* random number seed (-1)*/ _REAL enbr, ehbr, eelr, etorr, enb14r, eel14r; /* energies of monitors residue */ int nhbpair; } SFFoptions; SFFoptions *init_sff_options(void); parmstruct *readparm(char *name); int readcrd(char *name, _REAL ***c, parmstruct *parm); _REAL **readcrdvec(char *name, parmstruct *parm, int *nat); void mme_initCallbacks(); int mme_init(int *froz, int *constr, _REAL *x0i, FILE *bfpi, parmstruct *prm, SFFoptions * opts); void mme_cleanup(); typedef _REAL (*mme_f)( _REAL *x, _REAL *f, int *iter, _REAL *ene, parmstruct *prm , SFFoptions *opts); _REAL mme( _REAL *x, _REAL *f, int *iter, _REAL *ene, parmstruct *prm, SFFoptions *opts ); int conjgrad( _REAL *x, int *n, _REAL *f, mme_f func, _REAL *dgrad, _REAL *dfpred, int *maxiter, parmstruct *prm, _REAL *ene, SFFoptions *opts); int md( int n, int maxstep, _REAL *x, _REAL *minv, _REAL *f, _REAL *v, mme_f func, _REAL *ene, parmstruct *prm, SFFoptions *opts ); int mm_options( char *c, float val, SFFoptions *opts ); int md_options( char *c, float val, SFFoptions *opts ); void sffC_list_options(SFFoptions *opts); int startbinpos( FILE *fp ); int openbinpos( FILE * fp ); int readbinpos( int n_atom, _REAL *apos, FILE *fp ); int writebinpos(int n_atom, _REAL *apos, FILE *fp ); /* mme options */ /* extern _REAL cut, scnb, scee, wcons; */ /* extern int nsnb, ntpr, mme_init_first, dield, verbosemm, stop_flag; */ /* md options */ /* extern _REAL t, dt, tautp, temp0, boltz2, vlimit, tempi; */ /* extern int ntpr_md, ntwx, zerov, idum, verbosemd; */ extern int verbosemd, verbosemm; extern int stop_flag; extern void sanityCb(int nbat, int cbNum, _REAL *coords, _REAL *energies, int step); /* extern int *frozen, nfrozen; */ /* extern int *constrained, nconstrained; */ /* extern _REAL *x0; */ /* will hold coordinates to be constrained */ typedef void (*sffcb_f)(int cbNum, int nbat, _REAL *coords, _REAL *energies, int step); struct cbFunc { sffcb_f fun; int freq; }; typedef struct cbFunc cbFunc_t; /* number of callback calling point in mme inner loop */ #define NCBFUNC 2 /* array of C function call at callback calling points */ extern cbFunc_t mme_callback[NCBFUNC]; void setccallback( sffcb_f cbfun, int frequency, int callbacknum); mgltools-sff-1.5.7~rc1~cvs.20130519/src/Notes0000644000175000017500000000517710124346213017617 0ustar debiandebianModified in: prm.h, sff.c , conjgrad.c: - Put global variables from sff.c in a structure: typedef struct SFFoptions { _REAL cut; /* non-bonded cutoff (8.0)*/ _REAL scnb; /* scale factor for 1-4 nonbonds (2.0) */ _REAL scee; /* scale factor for 1-4 electrostatics (1.2) */ int ntpr; /* print frequency (10)*/ int nsnb; /* non-bonded update frequency (25) */ int mme_init_first; /* 1 */ int *frozen; int nfrozen; int *constrained ; int nconstrained ; _REAL *x0 ; /* will hold coordinates to be constrained */ _REAL wcons ; /* weight of constraints */ int *npairs; int *pairlist; int maxnb; int dield; /* dielectric function to be used */ _REAL w4d ; int dim; /* dimension: 3 or 4 */ /* MD variables: */ _REAL t; /* initial time (0)*/ _REAL dt; /* time step, ps.(0.001) */ _REAL tautp; /* temp. coupling parm., ps (0.02) */ _REAL temp0; /* target temperature, K (300.0)*/ _REAL boltz2; /* 9.93595e-4 */ _REAL vlimit; /* maximum velocity component (10.0)*/ int ntpr_md ; /* print frequency (10)*/ int ntwx; /* trajectory snapshot frequency (0) */ FILE *binposfp; /* file pointer for trajectories */ int zerov; /* if true, use zero initial velocities (0)*/ _REAL tempi; /* initial temperature (0.0)*/ int idum; /* random number seed (-1)*/ _REAL enbr, ehbr, eelr, etorr, enb14r, eel14r; /* energies of monitors residue */ int nhbpair; } SFFoptions; - added a function to allocate memory for the SFFoptions structure and initialize its members : SFFoptions *init_sff_options(void); - mofified the following functions to accept a pointer to SFFoptions structure as an argument: int mme_init(int *froz, int *constr, _REAL *x0i, FILE *bfpi, parmstruct *prm, SFFoptions * opts); _REAL mme( _REAL *x, _REAL *f, int *iter, _REAL *ene, parmstruct *prm, SFFoptions *opts ); int conjgrad(_REAL *x, int *n, _REAL *f, mme_f func, _REAL *dgrad, _REAL *dfpred, int *maxiter, parmstruct *prm, _REAL *ene, SFFoptions *opts); int md(int n, int maxstep, _REAL *x, _REAL *minv, _REAL *f, _REAL *v, mme_f func, _REAL *ene, parmstruct *prm, SFFoptions *opts ); int mm_options( char *c, float val, SFFoptions *opts ); int md_options( char *c, float val, SFFoptions *opts ); void sffC_list_options(SFFoptions *opts); void mme_cleanup(SFFoptions *opts); mgltools-sff-1.5.7~rc1~cvs.20130519/setup.py0000644000175000017500000000732710675045301017533 0ustar debiandebianimport sys, os from os import path from distutils.core import setup, Extension from distutils.command.build_clib import build_clib from distutils.command.install_data import install_data from distutils.command.sdist import sdist from os import path from glob import glob pack_name = "sff" ext_name = "_prmlib" platform = sys.platform # Lists of include dirs, pre-processor macros, libraries at link-time # (build_ext). libs = {'nt':[], 'posix':["m"]}.get(os.name, []) import numpy numpy_include = numpy.get_include() incl_dir = ["src", numpy_include] if platform == 'win32': macros = [("WIN32", None),] elif platform == 'darwin': macros = [("__APPLE__", None),] else: #macros = [("UNIX", None),] macros = [] comp_args = [] if platform == "sunos5": comp_args.extend(['-Kpic', '-mt']) #source files list: src_files = [ "bhtree.c", "binpos.c", "memutil.c", "rand2.c", "conjgrad.c", "prm.c", "sff.c"] for i in range(len(src_files)): src_files[i] = path.join("src", src_files[i]) src_files.append(path.join("sff", "prmlib.i")) #data files: data_files = [] for dir in ["sff/Tests"]: files = [] for f in glob(os.path.join(dir, '*')): if f[-3:] != '.py' and f[-4:-1] != '.py' and os.path.isfile(f): files.append(f) data_files.append((dir, files)) #print "data_files: ", data_files # Overwrite the run method of the install_data to install the data files # in the package instead of a particular data directory class modified_install_data(install_data): def run(self): install_cmd = self.get_finalized_command('install') self.install_dir = getattr(install_cmd, 'install_lib') return install_data.run(self) # Overwrite the prune_file_list method of sdist to not # remove automatically the CVS directories from the distribution. class modified_sdist(sdist): def prune_file_list(self): build = self.get_finalized_command('build') base_dir = self.distribution.get_fullname() self.filelist.exclude_pattern(None, prefix=build.build_base) self.filelist.exclude_pattern(None, prefix=base_dir) try: from version import VERSION except: VERSION = "1.0" dist = setup(name = pack_name, version=VERSION, description = "SFF python extension", author = 'Molecular Graphics Laboratory', author_email = 'mgltools@scripps.edu', download_url = 'http://www.scripps.edu/~sanner/software/packager.html', url = 'http://www.scripps.edu/~sanner/software/index.html', py_modules = ['sff.__init__', 'sff.amber'], packages = ["sff.Tests"], ext_package = pack_name, cmdclass = {'install_data': modified_install_data, 'sdist': modified_sdist}, data_files = data_files, ext_modules = [Extension (ext_name, src_files, include_dirs = incl_dir, define_macros = macros, #library_dirs = [lib_dir], libraries = libs, extra_compile_args = comp_args, ) ] ,) # cp built .so from ./build/lib.platform to ./pack_name/ - for testing. ## from distutils.util import get_platform ## from distutils.file_util import copy_file ## plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3]) ## orig_ext = path.join(".", "build", "lib"+plat_specifier , pack_name, ext_name+".so") ## cp_ext = path.join(pack_name, ext_name+".so") ## if path.isfile(orig_ext): ## copy_file(orig_ext, cp_ext, update=1) mgltools-sff-1.5.7~rc1~cvs.20130519/LICENSE0000644000175000017500000000436411033241705017017 0ustar debiandebianThis software is copyrighted by Michel F. Sanner (sanner@scripps.edu) and TSRI. The following terms apply to all files associated with the software unless explicitly disclaimed in individual files. MGLTOOLS SOFTWARE LICENSE AGREEMENT. 1. Grant Of Limited License; Software Use Restrictions. The programs received by you will be used only for NON COMMERCIAL purposes. This license is issued to you as an individual. For COMMERCIAL use done with the software please contact Michel F. Sanner for details about commercial usage license agreements. For any question regarding license agreements, please contact Michel Sanner: TSRI, Molecular Biology Department, TCP 26, 10550 North Torrey Pines Road, La Jolla, CA 92037 sanner@scripps.edu tel (858) 784-7742 fax (858) 784-2341 2. COMMERCIAL USAGE is defined as revenues generating activities. These include using this software for consulting activities and selling applications built on top of, or using this software. Scientific research in an academic environment and teaching are considered NON COMMERCIAL. 3. Copying Restrictions. You will not sell or otherwise distribute commercially these programs or derivatives to any other party, whether with or without consideration. 4. Ownership of Software. You will not obtain, and will not attempt to obtain copyright coverage thereon without the express purpose written consent of The Scripps Research Institute and Dr. Sanner. 5. IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6. THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. mgltools-sff-1.5.7~rc1~cvs.20130519/version.py0000644000175000017500000000002011475262476020054 0ustar debiandebianVERSION="1.5.6" mgltools-sff-1.5.7~rc1~cvs.20130519/README0000644000175000017500000000166710260336557016710 0ustar debiandebian sff version 0.1 SFF stands for simple force field. It is a C implementation of the amber force field made by Tom Macke and David Case. This package exposes a wrapped version of the prm structure which holds the Amber parameters needed for an Amber calculation. It also exposes the mme and md functions to perform molecular mechanics and dynamics respectively. BUILDING: building this package requires SWIG v1.3.20 and python2.4 python2.4 setup.py install this will build SFF python extension in build/lib./sff and install the sff package into sys.exec_prefix/lib/python2.4/site-packages. To specify the install directory use --install-platlib option: python2.4 setup.py install --install-platlib=INSTALL_DIR To build the extension only: python2.4 setup.py build this will build SFF python extension in build/lib./sff. To build the distribution: python2.4 setup.py sdist mgltools-sff-1.5.7~rc1~cvs.20130519/MANIFEST.in0000644000175000017500000000044111033242713017540 0ustar debiandebianinclude MANIFEST.in include version.py include src/* include sff/*.i include sff/Tests/p1H.pdb include sff/Tests/tripeptide.prm include sff/doc.tar.gz #include CVS directories include CVS/* include sff/CVS/* include sff/Tests/CVS/* include sff/src/CVS/* include src/CVS/* include LICENSE