def importFullStarProjects(starFileName, projectName, inputDir='.', outputDir='.', guiRoot=None, allowPopups=0,minimalPrompts=1,verbose=1): '''Returns a full CCPN project rooted in inputDir/projectName that will be created and saved. Input will be from inputDir/starFileName Returns False for error. ''' if not os.path.exists(inputDir): nTerror("Failed to find inputDir: %s" % inputDir) return False starFileNameFull = os.path.join(inputDir, starFileName) if not os.path.exists(starFileNameFull): nTerror("Failed to find starFileNameFull: %s" % starFileNameFull) return False if not os.path.exists(outputDir): os.mkdir(outputDir) os.chdir(outputDir) ccpnProjectPath = os.path.join(outputDir, projectName) if os.path.exists(ccpnProjectPath): shutil.rmtree(ccpnProjectPath) ccpnProject = Implementation.MemopsRoot(name=projectName) # 'linkAtoms': (True,False,'If set to False (off), unrecognized coordinate atoms will not be linked.'), keywds = {'minimalPrompts': minimalPrompts, 'allowPopups': allowPopups, 'linkAtoms':0} formatNmrStarFormat = NmrStarFormat(ccpnProject, guiRoot, verbose=verbose, **keywds) formatNmrStarFormat.version = '3.1' entryTitle = 'Project from NMR-STAR for %s' % projectName entryDetails = "Created by Wim Vranken's FormatConverter embedded in CING" formatNmrStarFormat.getFullProject( starFileNameFull, title = entryTitle, details = entryDetails, **keywds) # nmrConstraintStore = shiftList.nmrConstraintStore # structureGeneration = nmrConstraintStore.findFirstStructureGeneration() # formatNmrStarFormat.linkResonances( # forceDefaultChainMapping=1, # may be overwritten by using forceChainMappings. # globalStereoAssign=1, # setSingleProchiral=1, # setSinglePossEquiv=1, ## strucGen=structureGeneration, # allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **keywds) # Catch entries like mentioned in issue try: ccpnProject.checkAllValid() except ApiError: nTtracebackError() nTerror("Failed ccpnProject.checkAllValid") nTerror("See issue: %s%d" % (issueListUrl, 266)) return False ccpnProject.saveModified() if not os.path.exists(ccpnProjectPath): nTerror("Failed to find new CCPN project directory: %s" % ccpnProjectPath) return False tgzFileName = projectName + ".tgz" cmd = "tar -czf %s %s" % (tgzFileName, projectName) do_cmd(cmd) return ccpnProject
def importFullStarProjects(starFileName, projectName, inputDir='.', outputDir='.', guiRoot=None, allowPopups=0, minimalPrompts=1, verbose=1): '''Returns a full CCPN project rooted in inputDir/projectName that will be created and saved. Input will be from inputDir/starFileName Returns False for error. ''' if not os.path.exists(inputDir): nTerror("Failed to find inputDir: %s" % inputDir) return False starFileNameFull = os.path.join(inputDir, starFileName) if not os.path.exists(starFileNameFull): nTerror("Failed to find starFileNameFull: %s" % starFileNameFull) return False if not os.path.exists(outputDir): os.mkdir(outputDir) os.chdir(outputDir) ccpnProjectPath = os.path.join(outputDir, projectName) if os.path.exists(ccpnProjectPath): shutil.rmtree(ccpnProjectPath) ccpnProject = Implementation.MemopsRoot(name=projectName) # 'linkAtoms': (True,False,'If set to False (off), unrecognized coordinate atoms will not be linked.'), keywds = { 'minimalPrompts': minimalPrompts, 'allowPopups': allowPopups, 'linkAtoms': 0 } formatNmrStarFormat = NmrStarFormat(ccpnProject, guiRoot, verbose=verbose, **keywds) formatNmrStarFormat.version = '3.1' entryTitle = 'Project from NMR-STAR for %s' % projectName entryDetails = "Created by Wim Vranken's FormatConverter embedded in CING" formatNmrStarFormat.getFullProject(starFileNameFull, title=entryTitle, details=entryDetails, **keywds) # nmrConstraintStore = shiftList.nmrConstraintStore # structureGeneration = nmrConstraintStore.findFirstStructureGeneration() # formatNmrStarFormat.linkResonances( # forceDefaultChainMapping=1, # may be overwritten by using forceChainMappings. # globalStereoAssign=1, # setSingleProchiral=1, # setSinglePossEquiv=1, ## strucGen=structureGeneration, # allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **keywds) # Catch entries like mentioned in issue try: ccpnProject.checkAllValid() except ApiError: nTtracebackError() nTerror("Failed ccpnProject.checkAllValid") nTerror("See issue: %s%d" % (issueListUrl, 266)) return False ccpnProject.saveModified() if not os.path.exists(ccpnProjectPath): nTerror("Failed to find new CCPN project directory: %s" % ccpnProjectPath) return False tgzFileName = projectName + ".tgz" cmd = "tar -czf %s %s" % (tgzFileName, projectName) do_cmd(cmd) return ccpnProject