def annotateEntry(entryCodeNew, *extraArgList): nTmessage(header) nTmessage(getStartMessage()) expectedArgumentList = [] expectedNumberOfArguments = len(expectedArgumentList) if len(extraArgList) != expectedNumberOfArguments: nTerror("Got arguments: " + repr(extraArgList)) nTerror("Failed to get expected number of arguments: %d got %d" % ( expectedNumberOfArguments, len(extraArgList))) nTerror("Expected arguments: %s" % expectedArgumentList) return True # entryCode, city = entryCodePlusCity.split('_') # Adjust the parameters below isInteractive = False sourceIsOrgProject = True checkOrgProject = False replaceCoordinates = True # From all *.pdb files in inputDir. replaceRestraints = True doSwapCheck = True doSaveProject = True doExport = True minimalPrompts = True verbose = True if isInteractive: allowPopups = True minimalPrompts = False # verbose = True else: allowPopups = False # minimalPrompts = True # verbose = False print 'allowPopups ', allowPopups print 'isInteractive ', isInteractive print 'minimalPrompts ', minimalPrompts print 'verbose ', verbose print 'sourceIsOrgProject (or new CCPN file) ', sourceIsOrgProject print 'checkOrgProject ', checkOrgProject print 'replaceCoordinates ', replaceCoordinates print 'replaceRestraints ', replaceRestraints print 'doSwapCheck ', doSwapCheck print 'doSaveProject ', doSaveProject print 'doExport ', doExport guiRoot = None if allowPopups: guiRoot = Tkinter.Tk() entryCode,city = mapEntrycodeNew2EntrycodeAndCity[entryCodeNew] ch23 = entryCode[1:3] entryCodeOrg = entryCode + 'Org' dataOrgEntryDir = os.path.join(dataDir, ch23, entryCodeOrg) ccpnFile = os.path.join(dataOrgEntryDir, entryCodeOrg + ".tgz") # entryCodeNew = entryCode + city programId = getDeepByKeys(programHoH, entryCode, city) if not (city == 'Test' or programId): # nTdebug("Skipping %s" % entryCodeNew) nTerror("Neither City is 'Test' or programId given") return else: nTdebug("Looking at %s" % entryCodeNew) # continue # TODO disable premature stop. dataDividedXDir = os.path.join(dataDir, ch23) entryDir = os.path.join(dataDividedXDir, entryCodeNew) inputAuthorDir = os.path.join(entryDir, 'Author') outputNijmegenDir = os.path.join(entryDir, 'Nijmegen') if not os.path.exists(inputAuthorDir): mkdirs(inputAuthorDir) if not os.path.exists(outputNijmegenDir): mkdirs(outputNijmegenDir) os.chdir(outputNijmegenDir) presets = getDeepByKeysOrDefault(presetDict, {}, entryCodeNew) if presets: nTmessage("In annotateLoop using preset values...") # end if if sourceIsOrgProject: if os.path.exists(entryCodeOrg): nTmessage("Removing previous Org directory: %s" % entryCodeOrg) rmtree(entryCodeOrg) do_cmd("tar -xzf " + ccpnFile) if os.path.exists(entryCodeNew): nTmessage("Removing previous directory: %s" % entryCodeNew) rmtree(entryCodeNew) copytree(entryCodeOrg, entryCodeNew) if checkOrgProject: # By reading the ccpn tgz into cing it is also untarred/tested. project = Project.open(entryCodeOrg, status='new') if not project.initCcpn(ccpnFolder=ccpnFile, modelCount=1): nTerror("Failed check of original project") return project.removeFromDisk() project.close(save=False) ccpnProject = loadProject(entryCodeNew) if not ccpnProject: nTerror("Failed to read project: %s" % entryCodeNew) return # nmrProject = ccpnProject.currentNmrProject # ccpnMolSystem = ccpnProject.findFirstMolSystem() # nTmessage('found ccpnMolSystem: %s' % ccpnMolSystem) # print 'status: %s' % ccpnMolSystem.setCode(projectName) # impossible; reported to ccpn team. if replaceCoordinates or replaceRestraints: if programId == CYANA: importCyanaCoorAndRes(ccpnProject, inputAuthorDir, guiRoot, replaceCoordinates=replaceCoordinates, replaceRestraints=replaceRestraints, allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **presets) elif programId == XPLOR: importXplorCoorAndRes(ccpnProject, inputAuthorDir, guiRoot, replaceCoordinates=replaceCoordinates, replaceRestraints=replaceRestraints, allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **presets) elif programId == PDB: importPseudoPdb(ccpnProject, inputAuthorDir, guiRoot, allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **presets) else: nTerror("Failed to doImportCoordinatesAndRestraints because action for program Id not coded for: %s" % programId) nTerror("Skipping entry") return if doSwapCheck: # constraintsHandler = ConstraintsHandler() nmrConstraintStore = ccpnProject.findFirstNmrConstraintStore() structureEnsemble = ccpnProject.findFirstStructureEnsemble() numSwapCheckRuns = 3 if nmrConstraintStore: if structureEnsemble: swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns) else: nTmessage("Failed to find structureEnsemble; skipping swapCheck") else: nTmessage("Failed to find nmrConstraintStore; skipping swapCheck") # constraintsHandler.swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns) if doSaveProject: # nTmessage('Checking validity and saving to new path') nTmessage('Saving to new path: %s' % entryCodeNew) # checkValid=True, saveProject(ccpnProject, newPath=entryCodeNew, removeExisting=True) if doExport: tarPath = os.path.join(entryDir, entryCodeNew + ".tgz") if os.path.exists(tarPath): nTmessage("Overwriting: " + tarPath) myTar = tarfile.open(tarPath, mode='w:gz') # overwrites myTar.add(entryCodeNew) myTar.close() if guiRoot: guiRoot.destroy()
def annotateEntry(entry_code, bmrb_id, *extraArgList): 'Return True on error' nTmessage(header) nTmessage(getStartMessage()) expectedArgumentList = [] expectedNumberOfArguments = len(expectedArgumentList) if len(extraArgList) != expectedNumberOfArguments: nTerror("Got arguments: " + repr(extraArgList)) nTerror("Failed to get expected number of arguments: %d got %d" % (expectedNumberOfArguments, len(extraArgList))) nTerror("Expected arguments: %s" % expectedArgumentList) return True # entry_code, city = entryCodePlusCity.split('_') # Adjust the parameters below isInteractive = False checkOrgProject = False doSwapCheck = False doSaveProject = True doExport = True minimalPrompts = True verbose = True allowPopups = False if isInteractive: allowPopups = True minimalPrompts = False # verbose = True else: pass # minimalPrompts = True # verbose = False print 'entry_code ', entry_code print 'bmrb_id ', bmrb_id print 'allowPopups ', allowPopups print 'isInteractive ', isInteractive print 'minimalPrompts ', minimalPrompts print 'verbose ', verbose print 'checkOrgProject ', checkOrgProject print 'doSwapCheck ', doSwapCheck print 'doSaveProject ', doSaveProject print 'doExport ', doExport guiRoot = None if allowPopups: guiRoot = Tkinter.Tk() ch23 = entry_code[1:3] dataOrgEntryDir = os.path.join(results_dir, 'recoordSync', entry_code) ccpnFile = os.path.join(dataOrgEntryDir, entry_code + ".tgz") if not os.path.exists(ccpnFile): nTerror("Input file not found: %s" % ccpnFile) return True nTdebug("Looking at %s" % entry_code) # continue # TODO disable premature stop. bmrb_code = 'bmr' + bmrb_id digits12 = "%02d" % (bmrb_id % 100) inputStarDir = os.path.join(bmrbDir, digits12) if not os.path.exists(inputStarDir): nTerror("Input star dir not found: %s" % inputStarDir) return True inputStarFile = os.path.join(inputStarDir, '%s.str' % bmrb_code) if not os.path.exists(inputStarFile): nTerror("inputStarFile not found: %s" % inputStarFile) return True dataDividedXDir = os.path.join(nrgPlusDir, ch23) entryDir = os.path.join(dataDividedXDir, entry_code) outputNijmegenDir = os.path.join(entryDir, 'Nijmegen') if not os.path.exists(outputNijmegenDir): mkdirs(outputNijmegenDir) os.chdir(outputNijmegenDir) presets = getDeepByKeysOrDefault(presetDict, {}, bmrb_code) if presets: nTmessage("In annotateLoop using preset values...") nTdebug(str(presets)) if os.path.exists(entry_code): nTmessage("Removing previous directory: %s" % entry_code) rmtree(entry_code) do_cmd("tar -xzf " + ccpnFile) if os.path.exists('linkNmrStarData'): nTmessage("Renaming standard directory linkNmrStarData to entry: %s" % entry_code) os.rename('linkNmrStarData', entry_code) if checkOrgProject: # By reading the ccpn tgz into cing it is also untarred/tested. project = Project.open(entry_code, status='new') if not project.initCcpn(ccpnFolder=ccpnFile, modelCount=1): nTerror("Failed check of original project") return True project.removeFromDisk() project.close(save=False) ccpnProject = loadProject(entry_code) if not ccpnProject: nTerror("Failed to read project: %s" % entry_code) return True # nmrProject = ccpnProject.currentNmrProject # ccpnMolSystem = ccpnProject.findFirstMolSystem() # nTmessage('found ccpnMolSystem: %s' % ccpnMolSystem) # print 'status: %s' % ccpnMolSystem.setCode(projectName) # impossible; reported to ccpn team. importStarChemicalShifts(ccpnProject, inputStarDir, guiRoot, allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **presets) if doSwapCheck: # constraintsHandler = ConstraintsHandler() nmrConstraintStore = ccpnProject.findFirstNmrConstraintStore() structureEnsemble = ccpnProject.findFirstStructureEnsemble() numSwapCheckRuns = 3 if nmrConstraintStore: if structureEnsemble: swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns) else: nTmessage( "Failed to find structureEnsemble; skipping swapCheck") else: nTmessage("Failed to find nmrConstraintStore; skipping swapCheck") # constraintsHandler.swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns) if doSaveProject: # nTmessage('Checking validity and saving to new path') nTmessage('Saving to new path') # checkValid=True, saveProject(ccpnProject, newPath=entry_code, removeExisting=True) if doExport: tarPath = os.path.join(entryDir, entry_code + ".tgz") if os.path.exists(tarPath): nTmessage("Overwriting: " + tarPath) myTar = tarfile.open(tarPath, mode='w:gz') # overwrites myTar.add(entry_code) myTar.close() if guiRoot: guiRoot.destroy()
def main(entryId, *extraArgList): """inputDir may be a directory or a url. A url needs to start with http://. """ fastestTest = False # default: False htmlOnly = False # default: False but enable it for faster runs without some actual data. doWhatif = True # disables whatif actual run doProcheck = True doWattos = True doQueeny = True doTalos = True tgzCing = True # default: True # Create a tgz for the cing project. In case of a CING project input it will be overwritten. # NB leave this set to True or modify code below. removeCcpnDirectory = 1 # perhaps not so in the future. modelCount = None # default setting is None # ranges = None if fastestTest: modelCount = 2 # if this is more and there is only one model present it leads to an error message. htmlOnly = True doWhatif = False doProcheck = False doWattos = False doQueeny = False doTalos = False forceRedo = True forceRetrieveInput = True nTmessage(header) nTmessage(getStartMessage()) # Sync below code with nrgCing#createToposTokens expectedArgumentList = """ verbosity inputDir outputDir pdbConvention restraintsConvention archiveType projectType storeCING2db ranges filterTopViolations filterVasco singleCoreOperation """.split() expectedNumberOfArguments = len(expectedArgumentList) if len(extraArgList) != expectedNumberOfArguments: nTmessage("consider updating code to include all sequential parameters: %s" % str(expectedArgumentList)) if len(extraArgList) > expectedNumberOfArguments: nTerror("Got arguments: " + str(extraArgList)) nTerror("Failed to get expected number of arguments: %d got %d" % ( expectedNumberOfArguments, len(extraArgList))) nTerror("Expected arguments: %s" % expectedArgumentList) return True # end if # end if entryCodeChar2and3 = entryId[1:3] cing.verbosity = int( extraArgList[IDX_VERBOSITY] ) inputDir = extraArgList[IDX_INPUT] outputDir = os.path.join(extraArgList[IDX_OUTPUT], DATA_STR, entryCodeChar2and3, entryId) pdbConvention = extraArgList[IDX_PDB] #@UnusedVariable restraintsConvention = extraArgList[IDX_RESTRAINTS] archiveType = extraArgList[IDX_ARCHIVE] # Only used for deriving the input location not the output. projectType = extraArgList[IDX_PROJECT_TYPE] storeCING2db = stringMeansBooleanTrue( getDeepByKeysOrAttributes(extraArgList, IDX_STORE_DB)) ranges = getDeepByKeysOrAttributes(extraArgList, IDX_RANGES) filterTopViolations = getDeepByKeysOrAttributes(extraArgList, IDX_FILTER_TOP) if filterTopViolations: filterTopViolations = int(filterTopViolations) # change '0' to 0 filterVasco = getDeepByKeysOrAttributes(extraArgList, IDX_FILTER_VASCO) if filterVasco: filterVasco = int(filterVasco) else: filterVasco = 1 # Default should be True # end if singleCoreOperation = getDeepByKeysOrAttributes(extraArgList, IDX_SINGLE_CORE_OPERATION ) if singleCoreOperation: singleCoreOperation = int(singleCoreOperation) else: singleCoreOperation = 0 # Default should be True # end if if archiveType == ARCHIVE_TYPE_FLAT: pass # default elif archiveType == ARCHIVE_TYPE_BY_ENTRY: inputDir = os.path.join(inputDir, entryId) elif archiveType == ARCHIVE_TYPE_BY_CH23: inputDir = os.path.join(inputDir, entryCodeChar2and3) elif archiveType == ARCHIVE_TYPE_BY_CH23_BY_ENTRY: inputDir = os.path.join(inputDir, entryCodeChar2and3, entryId) isRemoteOutputDir = False if '@' in outputDir: isRemoteOutputDir = True # end if # vc = vCing('.') # argument is a fake master_ssh_url not needed here. archive_id = getArchiveIdFromDirectoryName( outputDir ) nTdebug("Using program arguments:") nTdebug("inputDir: %s" % inputDir) nTdebug("outputDir: %s" % outputDir) nTdebug("pdbConvention: %s" % pdbConvention) nTdebug("restraintsConvention: %s" % restraintsConvention) nTdebug("archiveType: %s" % archiveType) nTdebug("projectType: %s" % projectType) nTdebug("storeCING2db: %s" % storeCING2db) nTdebug("ranges: %s" % ranges) nTdebug("filterTopViolations: %s" % filterTopViolations) nTdebug("filterVasco: %s" % filterVasco) nTdebug("singleCoreOperation: %s" % singleCoreOperation) nTdebug("") nTdebug("Using derived settings:") nTdebug("modelCount: %s" % modelCount) nTdebug("isRemoteOutputDir: %s" % isRemoteOutputDir) nTdebug("archive_id: %s" % archive_id) # For NMR_REDO required as most efficient. if singleCoreOperation: setToSingleCoreOperation() # presume the directory still needs to be created. cingEntryDir = entryId + ".cing" if os.path.isdir(cingEntryDir): if forceRedo: nTmessage("Enforcing a redo") rmtree(cingEntryDir) else: mainIndexFile = os.path.join(cingEntryDir, "index.html") isDone = os.path.isfile(mainIndexFile) if isDone: nTmessage("SKIPPING ENTRY ALREADY DONE") return nTmessage("REDOING BECAUSE VALIDATION CONSIDERED NOT DONE.") rmtree(cingEntryDir) # end if. # end if. if isRemoteOutputDir: os.chdir(cingDirTmp) else: os.chdir(outputDir) project = Project(entryId) if project.removeFromDisk(): nTerror("Failed to remove existing project (if present)") return True # end if. formatFileName = '%s.tgz' if projectType == PROJECT_TYPE_CING: formatFileName = '%s.cing.tgz' elif projectType == PROJECT_TYPE_PDB: formatFileName = 'pdb%s.ent.gz' fileNameTgz = formatFileName % entryId # nTdebug("fileNameTgz: %s" % fileNameTgz) allowedInputProtocolList = 'http file ssh'.split() inputProtocal = string.split( inputDir, ':' )[0] if inputProtocal in allowedInputProtocolList: stillToRetrieve = False if os.path.exists(fileNameTgz): if forceRetrieveInput: os.unlink(fileNameTgz) stillToRetrieve = True # end if else: stillToRetrieve = True # end if if stillToRetrieve: retrieveTgzFromUrl(entryId, inputDir, archiveType=archiveType, formatFileName=formatFileName) # end if if not os.path.exists(fileNameTgz): nTerror("Tgz should already have been present skipping entry") return # end if else: nTdebug("Entry not retrieved which might be normal in some situations.") # end if. if projectType == PROJECT_TYPE_CING: # Needs to be copied because the open method doesn't take a directory argument.. # fullFileNameTgz = os.path.join(inputDir, fileNameTgz) # shutil.copy(fullFileNameTgz, '.') project = Project.open(entryId, status='old') if not project: nTerror("Failed to init old project") return True elif projectType == PROJECT_TYPE_CCPN: project = Project.open(entryId, status='new') if not project.initCcpn(ccpnFolder=fileNameTgz, modelCount=modelCount): nTerror("Failed to init project from ccpn") return True elif projectType == PROJECT_TYPE_PDB: project = Project.open(entryId, status='new') pdbFilePath = entryId + ".pdb" gunzip(fileNameTgz, outputFileName=pdbFilePath, removeOriginal=True) project.initPDB(pdbFile=pdbFilePath, convention=IUPAC, nmodels=modelCount) # if tmpPdbFile: if True: nTdebug("Removing tmp: %s" % pdbFilePath) os.unlink(pdbFilePath) # end if if ranges is not None: project.molecule.setRanges(ranges) # end if if archive_id: project.molecule.setArchiveId(archive_id) # end if project.molecule.superpose(ranges=ranges) if filterTopViolations and not project.filterHighRestraintViol(): nTerror("Failed to filterHighRestraintViol") ####> MAIN UTILITY HERE if 0: # DEFAULT 0 project.save() if project.validate(htmlOnly=htmlOnly, ranges=ranges, doProcheck=doProcheck, doWhatif=doWhatif, doWattos=doWattos, doQueeny = doQueeny, doTalos=doTalos, filterVasco = filterVasco ): nTerror("Failed to validate project read") return True # end if filterVasco # Write a single PDB file containing all models # according to IUPAC conventions project.export2PDB() project.save() if storeCING2db and archive_id: # Does require: #from cing.PluginCode.sqlAlchemy import csqlAlchemy # and should never crash run. # archive_id = ARCHIVE_DEV_NRG_ID # if isProduction: # archive_id = ARCHIVE_NRG_ID try: if doStoreCING2db( entryId, archive_id, project=project): nTerror("Failed to store CING project's data to DB but continuing.") except: nTtracebackError() nTerror("Failed to store CING project's data due to above traceback error.") if projectType == PROJECT_TYPE_CCPN: # fileNameTgz = entryId + '.tgz' os.unlink(fileNameTgz) # temporary ccpn tgz if removeCcpnDirectory: rmdir(entryId) # ccpn dir may contain vasco info. if tgzCing: directoryNameCing = entryId + ".cing" tgzFileNameCing = directoryNameCing + ".tgz" if os.path.exists(tgzFileNameCing): nTwarning("Overwriting: " + tgzFileNameCing) cmd = "tar -czf %s %s" % (tgzFileNameCing, directoryNameCing) nTdebug("cmd: %s" % cmd) # do_cmd(cmd) status, result = commands.getstatusoutput(cmd) if status: nTerror("Failed to tar status: %s with result %s" % (status, result)) return True if isRemoteOutputDir: if putFileBySsh(tgzFileNameCing, outputDir, ntriesMax = 2): nTerror("Failed to send File By Scp status: %s with result %s" % (status, result)) nTerror("Maintaining results.") return True # end if nTmessage("Removing tgz result: %s" % tgzFileNameCing) os.remove(tgzFileNameCing) nTmessage("Removing cing dir itself: %s" % directoryNameCing) rmdir(directoryNameCing) else: # do NOT remove local copy pass
job = job_list[id] _do_cmd, cmdTuple = job cmd = cmdTuple[0] nTerror("In runSlave Failed forked: %s" % cmd) # end for # end def # end class if __name__ == "__main__": cing.verbosity = verbosityDebug nTmessage(header) nTmessage(getStartMessage()) vc = Vcing(cmdDict=cmdDict) nTmessage("Starting with %r" % vc) destination = sys.argv[1] startArgListOther = 2 argListOther = [] if len(sys.argv) > startArgListOther: argListOther = sys.argv[startArgListOther:] # end if nTmessage('\nGoing to destination: %s with(out) arguments %s' % (destination, str(argListOther))) try: if destination == 'runSlaveThread': if vc.runSlaveThread():
def annotateEntry(entry_code, bmrb_id, *extraArgList): 'Return True on error' nTmessage(header) nTmessage(getStartMessage()) expectedArgumentList = [] expectedNumberOfArguments = len(expectedArgumentList) if len(extraArgList) != expectedNumberOfArguments: nTerror("Got arguments: " + repr(extraArgList)) nTerror("Failed to get expected number of arguments: %d got %d" % ( expectedNumberOfArguments, len(extraArgList))) nTerror("Expected arguments: %s" % expectedArgumentList) return True # entry_code, city = entryCodePlusCity.split('_') # Adjust the parameters below isInteractive = False checkOrgProject = False doSwapCheck = False doSaveProject = True doExport = True minimalPrompts = True verbose = True allowPopups = False if isInteractive: allowPopups = True minimalPrompts = False # verbose = True else: pass # minimalPrompts = True # verbose = False print 'entry_code ', entry_code print 'bmrb_id ', bmrb_id print 'allowPopups ', allowPopups print 'isInteractive ', isInteractive print 'minimalPrompts ', minimalPrompts print 'verbose ', verbose print 'checkOrgProject ', checkOrgProject print 'doSwapCheck ', doSwapCheck print 'doSaveProject ', doSaveProject print 'doExport ', doExport guiRoot = None if allowPopups: guiRoot = Tkinter.Tk() ch23 = entry_code[1:3] dataOrgEntryDir = os.path.join(results_dir, 'recoordSync', entry_code) ccpnFile = os.path.join(dataOrgEntryDir, entry_code + ".tgz") if not os.path.exists(ccpnFile): nTerror("Input file not found: %s" % ccpnFile) return True nTdebug("Looking at %s" % entry_code) # continue # TODO disable premature stop. bmrb_code = 'bmr'+bmrb_id digits12 ="%02d" % ( bmrb_id % 100 ) inputStarDir = os.path.join(bmrbDir, digits12) if not os.path.exists(inputStarDir): nTerror("Input star dir not found: %s" % inputStarDir) return True inputStarFile = os.path.join(inputStarDir, '%s.str'%bmrb_code) if not os.path.exists(inputStarFile): nTerror("inputStarFile not found: %s" % inputStarFile) return True dataDividedXDir = os.path.join(nrgPlusDir, ch23) entryDir = os.path.join(dataDividedXDir, entry_code) outputNijmegenDir = os.path.join(entryDir, 'Nijmegen') if not os.path.exists(outputNijmegenDir): mkdirs(outputNijmegenDir) os.chdir(outputNijmegenDir) presets = getDeepByKeysOrDefault(presetDict, {}, bmrb_code) if presets: nTmessage("In annotateLoop using preset values...") nTdebug(str(presets)) if os.path.exists(entry_code): nTmessage("Removing previous directory: %s" % entry_code) rmtree(entry_code) do_cmd("tar -xzf " + ccpnFile) if os.path.exists('linkNmrStarData'): nTmessage("Renaming standard directory linkNmrStarData to entry: %s" % entry_code) os.rename('linkNmrStarData', entry_code) if checkOrgProject: # By reading the ccpn tgz into cing it is also untarred/tested. project = Project.open(entry_code, status='new') if not project.initCcpn(ccpnFolder=ccpnFile, modelCount=1): nTerror("Failed check of original project") return True project.removeFromDisk() project.close(save=False) ccpnProject = loadProject(entry_code) if not ccpnProject: nTerror("Failed to read project: %s" % entry_code) return True # nmrProject = ccpnProject.currentNmrProject # ccpnMolSystem = ccpnProject.findFirstMolSystem() # nTmessage('found ccpnMolSystem: %s' % ccpnMolSystem) # print 'status: %s' % ccpnMolSystem.setCode(projectName) # impossible; reported to ccpn team. importStarChemicalShifts(ccpnProject, inputStarDir, guiRoot, allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **presets) if doSwapCheck: # constraintsHandler = ConstraintsHandler() nmrConstraintStore = ccpnProject.findFirstNmrConstraintStore() structureEnsemble = ccpnProject.findFirstStructureEnsemble() numSwapCheckRuns = 3 if nmrConstraintStore: if structureEnsemble: swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns) else: nTmessage("Failed to find structureEnsemble; skipping swapCheck") else: nTmessage("Failed to find nmrConstraintStore; skipping swapCheck") # constraintsHandler.swapCheck(nmrConstraintStore, structureEnsemble, numSwapCheckRuns) if doSaveProject: # nTmessage('Checking validity and saving to new path') nTmessage('Saving to new path') # checkValid=True, saveProject(ccpnProject, newPath=entry_code, removeExisting=True) if doExport: tarPath = os.path.join(entryDir, entry_code + ".tgz") if os.path.exists(tarPath): nTmessage("Overwriting: " + tarPath) myTar = tarfile.open(tarPath, mode='w:gz') # overwrites myTar.add(entry_code) myTar.close() if guiRoot: guiRoot.destroy()
#!/usr/bin/env python # Execute like: # $CINGROOT/python/cing/Scripts/vCing/test/cingByVCtest.py a b from cing import header from cing.Libs.NTutils import * #@UnusedWildImport from cing.main import getStartMessage from cing.main import getStopMessage if __name__ == "__main__": cing.verbosity = verbosityDebug nTmessage(header) nTmessage(getStartMessage()) nTmessage("Starting program: %s" % sys.argv[0]) nTdebug("Argument retrieved: %s" % str(sys.argv[1:] )) nTmessage(getStopMessage(cing.starttime))
def main(entryId, *extraArgList): """inputDir may be a directory or a url. A url needs to start with http://. """ fastestTest = False # default: False htmlOnly = False # default: False but enable it for faster runs without some actual data. doWhatif = True # disables whatif actual run doProcheck = True doWattos = True doQueeny = True doTalos = True tgzCing = True # default: True # Create a tgz for the cing project. In case of a CING project input it will be overwritten. # NB leave this set to True or modify code below. removeCcpnDirectory = 1 # perhaps not so in the future. modelCount = None # default setting is None # ranges = None if fastestTest: modelCount = 2 # if this is more and there is only one model present it leads to an error message. htmlOnly = True doWhatif = False doProcheck = False doWattos = False doQueeny = False doTalos = False forceRedo = True forceRetrieveInput = True nTmessage(header) nTmessage(getStartMessage()) # Sync below code with nrgCing#createToposTokens expectedArgumentList = """ verbosity inputDir outputDir pdbConvention restraintsConvention archiveType projectType storeCING2db ranges filterTopViolations filterVasco singleCoreOperation """.split() expectedNumberOfArguments = len(expectedArgumentList) if len(extraArgList) != expectedNumberOfArguments: nTmessage( "consider updating code to include all sequential parameters: %s" % str(expectedArgumentList)) if len(extraArgList) > expectedNumberOfArguments: nTerror("Got arguments: " + str(extraArgList)) nTerror("Failed to get expected number of arguments: %d got %d" % (expectedNumberOfArguments, len(extraArgList))) nTerror("Expected arguments: %s" % expectedArgumentList) return True # end if # end if entryCodeChar2and3 = entryId[1:3] cing.verbosity = int(extraArgList[IDX_VERBOSITY]) inputDir = extraArgList[IDX_INPUT] outputDir = os.path.join(extraArgList[IDX_OUTPUT], DATA_STR, entryCodeChar2and3, entryId) pdbConvention = extraArgList[IDX_PDB] #@UnusedVariable restraintsConvention = extraArgList[IDX_RESTRAINTS] archiveType = extraArgList[ IDX_ARCHIVE] # Only used for deriving the input location not the output. projectType = extraArgList[IDX_PROJECT_TYPE] storeCING2db = stringMeansBooleanTrue( getDeepByKeysOrAttributes(extraArgList, IDX_STORE_DB)) ranges = getDeepByKeysOrAttributes(extraArgList, IDX_RANGES) filterTopViolations = getDeepByKeysOrAttributes(extraArgList, IDX_FILTER_TOP) if filterTopViolations: filterTopViolations = int(filterTopViolations) # change '0' to 0 filterVasco = getDeepByKeysOrAttributes(extraArgList, IDX_FILTER_VASCO) if filterVasco: filterVasco = int(filterVasco) else: filterVasco = 1 # Default should be True # end if singleCoreOperation = getDeepByKeysOrAttributes(extraArgList, IDX_SINGLE_CORE_OPERATION) if singleCoreOperation: singleCoreOperation = int(singleCoreOperation) else: singleCoreOperation = 0 # Default should be True # end if if archiveType == ARCHIVE_TYPE_FLAT: pass # default elif archiveType == ARCHIVE_TYPE_BY_ENTRY: inputDir = os.path.join(inputDir, entryId) elif archiveType == ARCHIVE_TYPE_BY_CH23: inputDir = os.path.join(inputDir, entryCodeChar2and3) elif archiveType == ARCHIVE_TYPE_BY_CH23_BY_ENTRY: inputDir = os.path.join(inputDir, entryCodeChar2and3, entryId) isRemoteOutputDir = False if '@' in outputDir: isRemoteOutputDir = True # end if # vc = vCing('.') # argument is a fake master_ssh_url not needed here. archive_id = getArchiveIdFromDirectoryName(outputDir) nTdebug("Using program arguments:") nTdebug("inputDir: %s" % inputDir) nTdebug("outputDir: %s" % outputDir) nTdebug("pdbConvention: %s" % pdbConvention) nTdebug("restraintsConvention: %s" % restraintsConvention) nTdebug("archiveType: %s" % archiveType) nTdebug("projectType: %s" % projectType) nTdebug("storeCING2db: %s" % storeCING2db) nTdebug("ranges: %s" % ranges) nTdebug("filterTopViolations: %s" % filterTopViolations) nTdebug("filterVasco: %s" % filterVasco) nTdebug("singleCoreOperation: %s" % singleCoreOperation) nTdebug("") nTdebug("Using derived settings:") nTdebug("modelCount: %s" % modelCount) nTdebug("isRemoteOutputDir: %s" % isRemoteOutputDir) nTdebug("archive_id: %s" % archive_id) # For NMR_REDO required as most efficient. if singleCoreOperation: setToSingleCoreOperation() # presume the directory still needs to be created. cingEntryDir = entryId + ".cing" if os.path.isdir(cingEntryDir): if forceRedo: nTmessage("Enforcing a redo") rmtree(cingEntryDir) else: mainIndexFile = os.path.join(cingEntryDir, "index.html") isDone = os.path.isfile(mainIndexFile) if isDone: nTmessage("SKIPPING ENTRY ALREADY DONE") return nTmessage("REDOING BECAUSE VALIDATION CONSIDERED NOT DONE.") rmtree(cingEntryDir) # end if. # end if. if isRemoteOutputDir: os.chdir(cingDirTmp) else: os.chdir(outputDir) project = Project(entryId) if project.removeFromDisk(): nTerror("Failed to remove existing project (if present)") return True # end if. formatFileName = '%s.tgz' if projectType == PROJECT_TYPE_CING: formatFileName = '%s.cing.tgz' elif projectType == PROJECT_TYPE_PDB: formatFileName = 'pdb%s.ent.gz' fileNameTgz = formatFileName % entryId # nTdebug("fileNameTgz: %s" % fileNameTgz) allowedInputProtocolList = 'http file ssh'.split() inputProtocal = string.split(inputDir, ':')[0] if inputProtocal in allowedInputProtocolList: stillToRetrieve = False if os.path.exists(fileNameTgz): if forceRetrieveInput: os.unlink(fileNameTgz) stillToRetrieve = True # end if else: stillToRetrieve = True # end if if stillToRetrieve: retrieveTgzFromUrl(entryId, inputDir, archiveType=archiveType, formatFileName=formatFileName) # end if if not os.path.exists(fileNameTgz): nTerror("Tgz should already have been present skipping entry") return # end if else: nTdebug( "Entry not retrieved which might be normal in some situations.") # end if. if projectType == PROJECT_TYPE_CING: # Needs to be copied because the open method doesn't take a directory argument.. # fullFileNameTgz = os.path.join(inputDir, fileNameTgz) # shutil.copy(fullFileNameTgz, '.') project = Project.open(entryId, status='old') if not project: nTerror("Failed to init old project") return True elif projectType == PROJECT_TYPE_CCPN: project = Project.open(entryId, status='new') if not project.initCcpn(ccpnFolder=fileNameTgz, modelCount=modelCount): nTerror("Failed to init project from ccpn") return True elif projectType == PROJECT_TYPE_PDB: project = Project.open(entryId, status='new') pdbFilePath = entryId + ".pdb" gunzip(fileNameTgz, outputFileName=pdbFilePath, removeOriginal=True) project.initPDB(pdbFile=pdbFilePath, convention=IUPAC, nmodels=modelCount) # if tmpPdbFile: if True: nTdebug("Removing tmp: %s" % pdbFilePath) os.unlink(pdbFilePath) # end if if ranges is not None: project.molecule.setRanges(ranges) # end if if archive_id: project.molecule.setArchiveId(archive_id) # end if project.molecule.superpose(ranges=ranges) if filterTopViolations and not project.filterHighRestraintViol(): nTerror("Failed to filterHighRestraintViol") ####> MAIN UTILITY HERE if 0: # DEFAULT 0 project.save() if project.validate(htmlOnly=htmlOnly, ranges=ranges, doProcheck=doProcheck, doWhatif=doWhatif, doWattos=doWattos, doQueeny=doQueeny, doTalos=doTalos, filterVasco=filterVasco): nTerror("Failed to validate project read") return True # end if filterVasco # Write a single PDB file containing all models # according to IUPAC conventions project.export2PDB() project.save() if storeCING2db and archive_id: # Does require: #from cing.PluginCode.sqlAlchemy import csqlAlchemy # and should never crash run. # archive_id = ARCHIVE_DEV_NRG_ID # if isProduction: # archive_id = ARCHIVE_NRG_ID try: if doStoreCING2db(entryId, archive_id, project=project): nTerror( "Failed to store CING project's data to DB but continuing." ) except: nTtracebackError() nTerror( "Failed to store CING project's data due to above traceback error." ) if projectType == PROJECT_TYPE_CCPN: # fileNameTgz = entryId + '.tgz' os.unlink(fileNameTgz) # temporary ccpn tgz if removeCcpnDirectory: rmdir(entryId) # ccpn dir may contain vasco info. if tgzCing: directoryNameCing = entryId + ".cing" tgzFileNameCing = directoryNameCing + ".tgz" if os.path.exists(tgzFileNameCing): nTwarning("Overwriting: " + tgzFileNameCing) cmd = "tar -czf %s %s" % (tgzFileNameCing, directoryNameCing) nTdebug("cmd: %s" % cmd) # do_cmd(cmd) status, result = commands.getstatusoutput(cmd) if status: nTerror("Failed to tar status: %s with result %s" % (status, result)) return True if isRemoteOutputDir: if putFileBySsh(tgzFileNameCing, outputDir, ntriesMax=2): nTerror( "Failed to send File By Scp status: %s with result %s" % (status, result)) nTerror("Maintaining results.") return True # end if nTmessage("Removing tgz result: %s" % tgzFileNameCing) os.remove(tgzFileNameCing) nTmessage("Removing cing dir itself: %s" % directoryNameCing) rmdir(directoryNameCing) else: # do NOT remove local copy pass
from cing.main import getStartMessage try: import yasaramodule as yasara #@UnresolvedImport except: pass # nTdebug("Yasara is not available for interactive work in CING; no problem have a homebrew") MolmolColorDict = dict(green = '0 1 0', orange = '1 0.647 0', red = '1 0 0') loadTestingFile = True originatingProgramDeclaration = """Created by: %s %s""" % (header, getStartMessage()) originatingProgramDeclaration = toPoundedComment(originatingProgramDeclaration) molmolMacroFileHeader = """# Execute by issuing command (without pound sign): # molmol -f THIS_FILE_NAME """ + originatingProgramDeclaration pyMolMacroFileHeader = """# Execute by issuing command (without pound sign): # pymol THIS_FILE_NAME """ + originatingProgramDeclaration yasaraMacroFileHeader = """# Execute by issuing command (without pound sign): # Inside YASARA having the molecule in the soup. # E.g. sequence: # Read the PDB file. # LoadPDB /home/i/2kq3/2kq3.pdb
def main(entryId, *extraArgList): """inputDir may be a directory or a url. A url needs to start with http://. """ fastestTest = True # default: False # ranges=AUTO_STR # default is None retrieved from DBMS csv files. htmlOnly = False # default: False but enable it for faster runs without some actual data. doWhatif = True # disables whatif actual run doProcheck = True doWattos = True doTalos = True tgzCing = True # default: True # Create a tgz for the cing project. In case of a CING project input it will be overwritten. modelCount = None # default setting is None if fastestTest: modelCount = 3 htmlOnly = True doWhatif = False doProcheck = False doWattos = False doTalos = False force_redo = True force_retrieve_input = True nTmessage(header) nTmessage(getStartMessage()) expectedArgumentList = [ 'inputDir', 'outputDir', 'pdbConvention', 'restraintsConvention', 'archiveType','projectType','storeCING2db'] expectedNumberOfArguments = len(expectedArgumentList) if len(extraArgList) != expectedNumberOfArguments: nTerror("Got arguments: " + repr(extraArgList)) nTerror("Failed to get expected number of arguments: %d got %d" % ( expectedNumberOfArguments, len(extraArgList))) nTerror("Expected arguments: %s" % expectedArgumentList) return True entryCodeChar2and3 = entryId[1:3] inputDir = extraArgList[0] outputDir = os.path.join(extraArgList[1], DATA_STR, entryCodeChar2and3, entryId) pdbConvention = extraArgList[2] #@UnusedVariable restraintsConvention = extraArgList[3] archiveType = extraArgList[4] projectType = extraArgList[5] storeCING2db = False if len(extraArgList) >= expectedNumberOfArguments: storeCING2db = extraArgList[6] if archiveType == ARCHIVE_TYPE_FLAT: pass # default elif archiveType == ARCHIVE_TYPE_BY_ENTRY: inputDir = os.path.join(inputDir, entryId) elif archiveType == ARCHIVE_TYPE_BY_CH23: inputDir = os.path.join(inputDir, entryCodeChar2and3) elif archiveType == ARCHIVE_TYPE_BY_CH23_BY_ENTRY: inputDir = os.path.join(inputDir, entryCodeChar2and3, entryId) ranges = None # targetId = getTargetForFullEntryName(entryId) # if not targetId: # nTerror("Failed to getTargetForFullEntryName for entryId: %s" % entryId) # return True # ranges = getRangesForTarget(targetId) # if ranges == None: # nTerror("Failed to getRangesForTarget for targetId: %s" % targetId) # return True nTdebug("Using:") nTdebug("inputDir: %s" % inputDir) nTdebug("outputDir: %s" % outputDir) nTdebug("pdbConvention: %s" % pdbConvention) nTdebug("restraintsConvention: %s" % restraintsConvention) nTdebug("archiveType: %s" % archiveType) nTdebug("projectType: %s" % projectType) nTdebug("modelCount: %s" % modelCount) nTdebug("storeCING2db: %s" % storeCING2db) nTdebug("ranges: %s" % ranges) # presume the directory still needs to be created. cingEntryDir = entryId + ".cing" if os.path.isdir(cingEntryDir): if force_redo: nTmessage("Enforcing a redo") rmtree(cingEntryDir) else: mainIndexFile = os.path.join(cingEntryDir, "index.html") isDone = os.path.isfile(mainIndexFile) if isDone: nTmessage("SKIPPING ENTRY ALREADY DONE") return nTmessage("REDOING BECAUSE VALIDATION CONSIDERED NOT DONE.") rmtree(cingEntryDir) # end if. # end if. os.chdir(outputDir) project = Project(entryId) if project.removeFromDisk(): nTerror("Failed to remove existing project (if present)") return True # end if. # extension = '.tgz' formatFileName = '%s.tgz' # fileNameTgz = entryId + '.tgz' if projectType == PROJECT_TYPE_CING: # fileNameTgz = entryId + '.cing.tgz' formatFileName = '%s.cing.tgz' elif projectType == PROJECT_TYPE_PDB: formatFileName = 'pdb%s.ent.gz' fileNameTgz = formatFileName % entryId # nTdebug("fileNameTgz: %s" % fileNameTgz) # if true will do retrieveTgzFromUrl. if inputDir.startswith("http") or inputDir.startswith("file"): stillToRetrieve = False if os.path.exists(fileNameTgz): if force_retrieve_input: os.unlink(fileNameTgz) stillToRetrieve = True # end if else: stillToRetrieve = True # end if if stillToRetrieve: retrieveTgzFromUrl(entryId, inputDir, archiveType=archiveType, formatFileName=formatFileName) # end if if not os.path.exists(fileNameTgz): nTerror("Tgz should already have been present skipping entry") return # end if # end if. # retrieveTgzFromUrl(entryId, inputDir) if projectType == PROJECT_TYPE_CING: # Needs to be copied because the open method doesn't take a directory argument.. fullFileNameTgz = os.path.join(inputDir, fileNameTgz) shutil.copy(fullFileNameTgz, '.') project = Project.open(entryId, status='old') if not project: nTerror("Failed to init old project") return True elif projectType == PROJECT_TYPE_CCPN: project = Project.open(entryId, status='new') if not project.initCcpn(ccpnFolder=fileNameTgz, modelCount=modelCount): nTerror("Failed to init project from ccpn") return True elif projectType == PROJECT_TYPE_PDB: project = Project.open(entryId, status='new') # pdbFileFormats = [ entryId + ".pdb", "pdb" + entryId + ".ent.gz" ] # for pdbFileName in pdbFileFormats: # pdbFileName = "pdb" + entryId + ".ent.gz" # # pdbFilePath = os.path.join( inputDir, pdbFileName) # pdbFilePath = os.path.join(inputDir, pdbFileName) # if os.path.exists(pdbFilePath): # break # tmpPdbFile = None # if pdbFileName.endswith('.gz'): pdbFilePath = entryId + ".pdb" # tmpPdbFile = pdbFilePath # if os.path.exists(pdbFilePath): # os.unlink(pdbFilePath) gunzip(fileNameTgz, outputFileName=pdbFilePath, removeOriginal=True) project.initPDB(pdbFile=pdbFilePath, convention=IUPAC, nmodels=modelCount) # if tmpPdbFile: if True: nTdebug("Removing tmp: %s" % pdbFilePath) os.unlink(pdbFilePath) # if inputDirOrg == inputDirCASD_NMR: # if True: # Default is False for this is specific to CASD-NMR # nTmessage("Renaming molecule name to entry id: %s" % entryId) # project.molecule.name = entryId # insufficient since all data is already initialized to disk. # project.updateProject() # project.molecule.rename( entryId ) # project.save() # project.molecule.ranges = ranges # JFD: this doesn't seem to be set there exactly. project.molecule.superpose(ranges=ranges) if True: if project.validate(htmlOnly=htmlOnly, ranges=ranges, doProcheck=doProcheck, doWhatif=doWhatif, doWattos=doWattos, doTalos=doTalos): nTerror("Failed to validate project read") return True if storeCING2db: # Does require: #from cing.PluginCode.sqlAlchemy import csqlAlchemy # and should never crash run. try: if doStoreCING2db( entryId, ARCHIVE_CASP_ID, project=project): nTerror("Failed to store CING project's data to DB but continuing.") except: nTtracebackError() nTerror("Failed to store CING project's data due to above traceback error.") project.save() if projectType == PROJECT_TYPE_CCPN: # fileNameTgz = entryId + '.tgz' # os.unlink(fileNameTgz) # temporary ccpn tgz rmdir(entryId) # temporary ccpn dir if tgzCing: directoryNameCing = entryId + ".cing" tgzFileNameCing = directoryNameCing + ".tgz" if os.path.exists(tgzFileNameCing): nTwarning("Overwriting: " + tgzFileNameCing) cmd = "tar -czf %s %s" % (tgzFileNameCing, directoryNameCing) do_cmd(cmd)
def main(entryId, *extraArgList): """inputDir may be a directory or a url. A url needs to start with http://. """ fastestTest = True # default: False # ranges=AUTO_STR # default is None retrieved from DBMS csv files. htmlOnly = False # default: False but enable it for faster runs without some actual data. doWhatif = True # disables whatif actual run doProcheck = True doWattos = True doTalos = True tgzCing = True # default: True # Create a tgz for the cing project. In case of a CING project input it will be overwritten. modelCount = None # default setting is None if fastestTest: modelCount = 3 htmlOnly = True doWhatif = False doProcheck = False doWattos = False doTalos = False force_redo = True force_retrieve_input = True nTmessage(header) nTmessage(getStartMessage()) expectedArgumentList = [ 'inputDir', 'outputDir', 'pdbConvention', 'restraintsConvention', 'archiveType', 'projectType', 'storeCING2db' ] expectedNumberOfArguments = len(expectedArgumentList) if len(extraArgList) != expectedNumberOfArguments: nTerror("Got arguments: " + repr(extraArgList)) nTerror("Failed to get expected number of arguments: %d got %d" % (expectedNumberOfArguments, len(extraArgList))) nTerror("Expected arguments: %s" % expectedArgumentList) return True entryCodeChar2and3 = entryId[1:3] inputDir = extraArgList[0] outputDir = os.path.join(extraArgList[1], DATA_STR, entryCodeChar2and3, entryId) pdbConvention = extraArgList[2] #@UnusedVariable restraintsConvention = extraArgList[3] archiveType = extraArgList[4] projectType = extraArgList[5] storeCING2db = False if len(extraArgList) >= expectedNumberOfArguments: storeCING2db = extraArgList[6] if archiveType == ARCHIVE_TYPE_FLAT: pass # default elif archiveType == ARCHIVE_TYPE_BY_ENTRY: inputDir = os.path.join(inputDir, entryId) elif archiveType == ARCHIVE_TYPE_BY_CH23: inputDir = os.path.join(inputDir, entryCodeChar2and3) elif archiveType == ARCHIVE_TYPE_BY_CH23_BY_ENTRY: inputDir = os.path.join(inputDir, entryCodeChar2and3, entryId) ranges = None # targetId = getTargetForFullEntryName(entryId) # if not targetId: # nTerror("Failed to getTargetForFullEntryName for entryId: %s" % entryId) # return True # ranges = getRangesForTarget(targetId) # if ranges == None: # nTerror("Failed to getRangesForTarget for targetId: %s" % targetId) # return True nTdebug("Using:") nTdebug("inputDir: %s" % inputDir) nTdebug("outputDir: %s" % outputDir) nTdebug("pdbConvention: %s" % pdbConvention) nTdebug("restraintsConvention: %s" % restraintsConvention) nTdebug("archiveType: %s" % archiveType) nTdebug("projectType: %s" % projectType) nTdebug("modelCount: %s" % modelCount) nTdebug("storeCING2db: %s" % storeCING2db) nTdebug("ranges: %s" % ranges) # presume the directory still needs to be created. cingEntryDir = entryId + ".cing" if os.path.isdir(cingEntryDir): if force_redo: nTmessage("Enforcing a redo") rmtree(cingEntryDir) else: mainIndexFile = os.path.join(cingEntryDir, "index.html") isDone = os.path.isfile(mainIndexFile) if isDone: nTmessage("SKIPPING ENTRY ALREADY DONE") return nTmessage("REDOING BECAUSE VALIDATION CONSIDERED NOT DONE.") rmtree(cingEntryDir) # end if. # end if. os.chdir(outputDir) project = Project(entryId) if project.removeFromDisk(): nTerror("Failed to remove existing project (if present)") return True # end if. # extension = '.tgz' formatFileName = '%s.tgz' # fileNameTgz = entryId + '.tgz' if projectType == PROJECT_TYPE_CING: # fileNameTgz = entryId + '.cing.tgz' formatFileName = '%s.cing.tgz' elif projectType == PROJECT_TYPE_PDB: formatFileName = 'pdb%s.ent.gz' fileNameTgz = formatFileName % entryId # nTdebug("fileNameTgz: %s" % fileNameTgz) # if true will do retrieveTgzFromUrl. if inputDir.startswith("http") or inputDir.startswith("file"): stillToRetrieve = False if os.path.exists(fileNameTgz): if force_retrieve_input: os.unlink(fileNameTgz) stillToRetrieve = True # end if else: stillToRetrieve = True # end if if stillToRetrieve: retrieveTgzFromUrl(entryId, inputDir, archiveType=archiveType, formatFileName=formatFileName) # end if if not os.path.exists(fileNameTgz): nTerror("Tgz should already have been present skipping entry") return # end if # end if. # retrieveTgzFromUrl(entryId, inputDir) if projectType == PROJECT_TYPE_CING: # Needs to be copied because the open method doesn't take a directory argument.. fullFileNameTgz = os.path.join(inputDir, fileNameTgz) shutil.copy(fullFileNameTgz, '.') project = Project.open(entryId, status='old') if not project: nTerror("Failed to init old project") return True elif projectType == PROJECT_TYPE_CCPN: project = Project.open(entryId, status='new') if not project.initCcpn(ccpnFolder=fileNameTgz, modelCount=modelCount): nTerror("Failed to init project from ccpn") return True elif projectType == PROJECT_TYPE_PDB: project = Project.open(entryId, status='new') # pdbFileFormats = [ entryId + ".pdb", "pdb" + entryId + ".ent.gz" ] # for pdbFileName in pdbFileFormats: # pdbFileName = "pdb" + entryId + ".ent.gz" # # pdbFilePath = os.path.join( inputDir, pdbFileName) # pdbFilePath = os.path.join(inputDir, pdbFileName) # if os.path.exists(pdbFilePath): # break # tmpPdbFile = None # if pdbFileName.endswith('.gz'): pdbFilePath = entryId + ".pdb" # tmpPdbFile = pdbFilePath # if os.path.exists(pdbFilePath): # os.unlink(pdbFilePath) gunzip(fileNameTgz, outputFileName=pdbFilePath, removeOriginal=True) project.initPDB(pdbFile=pdbFilePath, convention=IUPAC, nmodels=modelCount) # if tmpPdbFile: if True: nTdebug("Removing tmp: %s" % pdbFilePath) os.unlink(pdbFilePath) # if inputDirOrg == inputDirCASD_NMR: # if True: # Default is False for this is specific to CASD-NMR # nTmessage("Renaming molecule name to entry id: %s" % entryId) # project.molecule.name = entryId # insufficient since all data is already initialized to disk. # project.updateProject() # project.molecule.rename( entryId ) # project.save() # project.molecule.ranges = ranges # JFD: this doesn't seem to be set there exactly. project.molecule.superpose(ranges=ranges) if True: if project.validate(htmlOnly=htmlOnly, ranges=ranges, doProcheck=doProcheck, doWhatif=doWhatif, doWattos=doWattos, doTalos=doTalos): nTerror("Failed to validate project read") return True if storeCING2db: # Does require: #from cing.PluginCode.sqlAlchemy import csqlAlchemy # and should never crash run. try: if doStoreCING2db(entryId, ARCHIVE_CASP_ID, project=project): nTerror( "Failed to store CING project's data to DB but continuing." ) except: nTtracebackError() nTerror( "Failed to store CING project's data due to above traceback error." ) project.save() if projectType == PROJECT_TYPE_CCPN: # fileNameTgz = entryId + '.tgz' # os.unlink(fileNameTgz) # temporary ccpn tgz rmdir(entryId) # temporary ccpn dir if tgzCing: directoryNameCing = entryId + ".cing" tgzFileNameCing = directoryNameCing + ".tgz" if os.path.exists(tgzFileNameCing): nTwarning("Overwriting: " + tgzFileNameCing) cmd = "tar -czf %s %s" % (tgzFileNameCing, directoryNameCing) do_cmd(cmd)