def run( self, chain=None, chargeType="bcc", chargeVal=None, guessCharge=False, multiplicity="1", atomType="gaff", force=False, basename=None, debug=False, outTopol="all", engine="tleap", allhdg=False, timeTol=36000, qprog="sqm", ekFlag=None, outType="mol2", ): ccpnProject = self.project if chain: other = [chain] else: other = self.getHeteroMols() if not other: print("WARN: no molecules entitled for ACPYPE") return None acpypeDict = {} for chain in other: if chargeVal is None and not guessCharge: chargeVal = chain.molecule.formalCharge # pdbCode = ccpnProject.name res = chain.findFirstResidue() resName = res.ccpCode.upper() if chargeVal is None: print("Running ACPYPE for '%s : %s' and trying to guess net charge" % (resName, chain.molecule.name)) else: print("Running ACPYPE for '%s : %s' with charge '%s'" % (resName, chain.molecule.name, chargeVal)) random.seed() d = [random.choice(letters) for x in range(10)] randString = "".join(d) randString = "test" dirTemp = "/tmp/ccpn2acpype_%s" % randString if not os.path.exists(dirTemp): os.mkdir(dirTemp) if outType == "mol2": resTempFile = os.path.join(dirTemp, "%s.mol2" % resName) else: resTempFile = os.path.join(dirTemp, "%s.pdb" % resName) entry = ccpnProject.currentNmrEntryStore.findFirstEntry() strucGen = entry.findFirstStructureGeneration() refStructure = strucGen.structureEnsemble.sortedModels()[0] if outType == "mol2": mol2Format = Mol2Format.Mol2Format(ccpnProject) mol2Format.writeChemComp( resTempFile, chemCompVar=chain.findFirstResidue().chemCompVar, coordSystem="pdb", minimalPrompts=True, forceNamingSystemName="XPLOR", ) else: pdbFormat = PdbFormat.PdbFormat(ccpnProject) pdbFormat.writeCoordinates( resTempFile, exportChains=[chain], structures=[refStructure], minimalPrompts=True, forceNamingSystemName="XPLOR", ) origCwd = os.getcwd() os.chdir(dirTemp) t0 = time.time() print(header) try: molecule = ACTopol( resTempFile, chargeType=chargeType, chargeVal=chargeVal, debug=debug, multiplicity=multiplicity, atomType=atomType, force=force, outTopol=outTopol, engine=engine, allhdg=allhdg, basename=basename, timeTol=timeTol, qprog=qprog, ekFlag='''"%s"''' % ekFlag, ) if not molecule.acExe: molecule.printError("no 'antechamber' executable... aborting!") hint1 = "HINT1: is 'AMBERHOME' or 'ACHOME' environment variable set?" hint2 = ( "HINT2: is 'antechamber' in your $PATH?" + " What 'which antechamber' in your terminal says?" + " 'alias' doesn't work for ACPYPE." ) molecule.printMess(hint1) molecule.printMess(hint2) sys.exit(1) molecule.createACTopol() molecule.createMolTopol() acpypeFailed = False except: raise _exceptionType, exceptionValue, exceptionTraceback = sys.exc_info() print("ACPYPE FAILED: %s" % exceptionValue) if debug: traceback.print_tb(exceptionTraceback, file=sys.stdout) acpypeFailed = True execTime = int(round(time.time() - t0)) if execTime == 0: msg = "less than a second" else: msg = elapsedTime(execTime) try: rmtree(molecule.tmpDir) except: raise print("Total time of execution: %s" % msg) if not acpypeFailed: acpypeDict[resName] = [x for x in dirWalk(os.path.join(dirTemp, "%s.acpype" % resName))] else: acpypeDict[resName] = [] # sys.exit(1) os.chdir(origCwd) self.acpypeDictFiles = acpypeDict
cType = 'gas' #'gas' debug = False water = ' -water none' print('usePymol: %s, ffType: %s, cType: %s' % (usePymol, ffType, cType)) tmpDir = '/tmp/testAcpype' delList = ['topol.top', 'posre.itp'] #create Dummy PDB tpdb = '/tmp/tmp.pdb' dummyLine = 'ATOM 1 N ALA A 1 -1.188 -0.094 0.463 1.00 0.00 N\n' open(tpdb, 'w').writelines(dummyLine) tempObj = ACTopol(tpdb, chargeVal=0, verbose=False) # Binaries for ambertools acExe = tempObj.acExe tleapExe = tempObj.tleapExe sanderExe = os.path.join(os.path.dirname(acExe), 'sander') ambpdbExe = os.path.join(os.path.dirname(acExe), 'ambpdb') exePymol = '/sw/bin/pymol' # Binaries for gromacs gpath = '/sw/' gmxTopDir = gpath + "share" pdb2gmx = gpath + 'bin/pdb2gmx' grompp = gpath + 'bin/grompp' mdrun = gpath + 'bin/mdrun'