def importCnsDistance(self): if not self.project: showWarning('Failure','Please create a new CCPN project.', parent=self) return fileTypes = [ FileType('CNS', ['*.tbl']), FileType('All', ['*']) ] fileSelectPopup = FileSelectPopup(self, file_types=fileTypes, title='Import CNS distance restraints file', dismiss_text='Cancel', selected_file_must_exist=True, multiSelect=False,) fileName = fileSelectPopup.getFile() if not os.path.exists(fileName): showWarning('Failure','No such file.', parent=self) return if fileName: name = os.path.split(fileName)[1] if '.' in name: name = name.split('.')[0] cnsObj = CnsFormat(self.project, self, verbose=True) cnsObj.readDistanceConstraints(fileName, minimalPrompts=True) self.eciFrame.updateAll() return cnsObj
def importXplorCoorAndRes(ccpnProject, inputDir, guiRoot, replaceCoordinates=1, replaceRestraints=1, allowPopups=1, minimalPrompts=0, verbose=1, **presets): if replaceCoordinates: status = importPseudoPdb(ccpnProject, inputDir, guiRoot, allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **presets) if status: nTerror("Failed importXplorCoorAndRes") return True if not replaceRestraints: return formatCns = CnsFormat(ccpnProject, guiRoot, verbose=verbose, minimalPrompts=minimalPrompts, allowPopups=allowPopups) ccpnConstraintListOfList = [] # Will overwrite the settings given to formatCns.linkResonances( below globPattern = inputDir + '/*_noe.tbl' fileList = glob(globPattern) nTdebug("From %s will read files: %s" % (globPattern, fileList)) # for fn in fileList[0:1]: # TODO: for fn in fileList: fnBaseName = os.path.basename(fn).split('.')[0] ccpnConstraintList = formatCns.readDistanceConstraints(fn, minimalPrompts=minimalPrompts, verbose=verbose) ccpnConstraintList.setName(fnBaseName) ccpnConstraintListOfList.append(ccpnConstraintList) if not ccpnConstraintList: nTerror("Failed to read") return True # globPattern = inputDir + '/*_hbond.tblXXXX' # TODO: globPattern = inputDir + '/*_hbond.tbl' fileList = glob(globPattern) nTdebug("From %s will read in files: %s" % (globPattern, fileList)) for fn in fileList: fnBaseName = os.path.basename(fn).split('.')[0] ccpnConstraintList = formatCns.readDistanceConstraints(fn, minimalPrompts=minimalPrompts, verbose=verbose) ccpnConstraintList.setName(fnBaseName) ccpnConstraintListOfList.append(ccpnConstraintList) # globPattern = inputDir + '/*_dihe.tblXXXX' # TODO: globPattern = inputDir + '/*_dihe.tbl' fileList = glob(globPattern) nTdebug("From %s will read in total files: %s" % (globPattern, fileList)) for fn in fileList: fnBaseName = os.path.basename(fn).split('.')[0] ccpnConstraintList = formatCns.readDihedralConstraints(fn, minimalPrompts=minimalPrompts, verbose=verbose) ccpnConstraintList.setName(fnBaseName) ccpnConstraintListOfList.append(ccpnConstraintList) keywds = getDeepByKeysOrDefault(presets, {}, LINK_RESONANCES, KEYWORDS) nTdebug("From getDeepByKeysOrDefault keywds: %s" % repr(keywds)) ccpnConstraintList = getDeepByKeys(ccpnConstraintListOfList, 0) # no need to repeat nTdebug("First ccpnConstraintList: %s" % ccpnConstraintList) if ccpnConstraintList != None: # for i, ccpnConstraintList in enumerate(ccpnConstraintListOfList): keywds = getDeepByKeysOrDefault(presets, {}, LINK_RESONANCES, KEYWORDS) nTdebug("From getDeepByKeysOrDefault keywds: %s" % repr(keywds)) nTdebug("ccpnConstraintList: %s" % ccpnConstraintList) nmrConstraintStore = ccpnConstraintList.nmrConstraintStore structureGeneration = nmrConstraintStore.findFirstStructureGeneration() formatCns.linkResonances( forceDefaultChainMapping=1, # may be overwritten by using forceChainMappings. globalStereoAssign=1, setSingleProchiral=1, setSinglePossEquiv=1, strucGen=structureGeneration, allowPopups=allowPopups, minimalPrompts=minimalPrompts, verbose=verbose, **keywds)
cnsObj = CnsFormat(project, guiRoot) cnsDir = '../data/cns' cnsCoord = 'cns_1.pdb' cnsCoordFile = os.path.join(cnsDir, cnsCoord) # To make a molSystem object. chains = cnsObj.readSequence(cnsCoordFile) distConst = 'n15noesy.tbl' distConstFile = os.path.join(cnsDir, distConst) # To make a structureGeneration object. constList = cnsObj.readDistanceConstraints(distConstFile) nmrConstStore = constList.nmrConstraintStore strucGen = nmrConstStore.findFirstStructureGeneration() cnsObj.linkResonances(forceDefaultChainMapping=1, globalStereoAssign=1, setSingleProchiral=1, setSinglePossEquiv=1, strucGen=strucGen) # As usual, create the BMRB Entry object. entryStore = project.newNmrEntryStore(name=project.name) entry = entryStore.newEntry(name=project.name) # Get the molSystem object, and link to it.
# all the atom information. # # Note that a lot of the popups can be avoided when the right information # is passed in (see ccpnmr.format.converters.DataFormat, the readSequence # function in the DataFormat class) # coordinateFile = os.path.join(dataDir, coordinateFileName) ccpnChains = cnsFormat.readSequence(coordinateFile) # # Read in a distance constraint list # distanceConstraintFile = os.path.join(dataDir, distanceConstraintFileName) ccpnConstraintList = cnsFormat.readDistanceConstraints( distanceConstraintFile) # # Do some preliminary Data Model navigation to get input parameters for # linkResonances # # An nmrConstraintStore links a group of constraint files # A structureGeneration links an nmrConstraintStore with a set of structures # nmrConstraintStore = ccpnConstraintList.nmrConstraintStore structureGeneration = nmrConstraintStore.findFirstStructureGeneration() # # Run linkResonances (this will generate a lot of output to the shell) #
# Set the location of the CNS files. cnsDir = '../data/cns' # Read in a sequence to set molecule and molSystem objects. cnsCoord = 'cns_1.pdb' cnsCoordFile = os.path.join(cnsDir, cnsCoord) # readSequence() returns a list of chains. chains = cnsObj.readSequence(cnsCoordFile, minimalPrompts=1) # Read in a distance constraint list. distConst = 'n15noesy.tbl' distConstFile = os.path.join(cnsDir, distConst) constList = cnsObj.readDistanceConstraints(distConstFile, minimalPrompts=1) # Do some preliminary data model navigation to get input parameters for # linkResonances. # An nmrConstraintStore links a group of constraint files. # A structureGeneration links an nmrConstraintStore with a set # of structures. nmrConstStore = constList.nmrConstraintStore strucGen = nmrConstStore.findFirstStructureGeneration() # Run linkResonances (this will generate a lot of output to the shell). # The current options are the 'safest' to maintain the original # information, although bear in mind that all atoms in the original # list are considered to be stereospecifically assigned.
# all the atom information. # # Note that a lot of the popups can be avoided when the right information # is passed in (see ccpnmr.format.converters.DataFormat, the readSequence # function in the DataFormat class) # coordinateFile = os.path.join(dataDir,coordinateFileName) ccpnChains = cnsFormat.readSequence(coordinateFile) # # Read in a distance constraint list # distanceConstraintFile = os.path.join(dataDir,distanceConstraintFileName) ccpnConstraintList = cnsFormat.readDistanceConstraints(distanceConstraintFile) # # Do some preliminary Data Model navigation to get input parameters for # linkResonances # # An nmrConstraintStore links a group of constraint files # A structureGeneration links an nmrConstraintStore with a set of structures # nmrConstraintStore = ccpnConstraintList.nmrConstraintStore structureGeneration = nmrConstraintStore.findFirstStructureGeneration() # # Run linkResonances (this will generate a lot of output to the shell) #