def setupMolSystem(self, molSysName): self.molSystem = self.ccpnProject.findFirstMolSystem(code=molSysName) if not self.molSystem: self.molSystem = MolSystem.MolSystem(self.ccpnProject, code=molSysName)
nextLink = prevMolRes.findFirstMolResLinkEnd(linkCode='next') if nextLink: molResLink = Molecule.MolResLink( molecule, molResLinkEnds=[nextLink, prevLink]) # # Now that the Molecule information is set, creation a molecular system with chains # is very straightforward. All the residue and atom information for these chains is # taken from the reference Molecule and ChemComp information and set automatically... # molSystem = MolSystem.MolSystem(project, code='myMolecularSystemCode', name='My molecular system name') # # Now create a homodimer - two chains referring to the same Molecule # chainA = MolSystem.Chain(molSystem, code='A', molecule=molecule) chainB = MolSystem.Chain(molSystem, code='B', molecule=molecule) # # Now we can navigate the system... you can also go back to all the reference information to # get info on bonds, angles, ... . Refer to the CCPN data model documentation to see which # attributes and links you can access from here. For example for residues, see: # # http://www.ccpn.ac.uk/ccpnmr/ccpnmr/python/ccp/api/doc/MolSystem/Residue/index.html
def selectMolSystem(self, resonanceList=None): # # If minimalPrompts, just select any available molSystem # if self.minimalPrompts and len(self.project.molSystems) == 1: self.molSystem = self.project.findFirstMolSystem() elif not hasattr(self, 'molSystem'): self.molSystem = None # # If resonance info is given, try to determine from to-atom link # if resonanceList: for resonance in resonanceList: resonanceSet = resonance.resonanceSet if resonanceSet: refAtom = resonanceSet.findFirstAtomSet().findFirstAtom() self.molSystem = refAtom.residue.chain.molSystem break # # Try to select from list # if not self.molSystem: (selectionList, selectionDict) = createSelection(self.project.sortedMolSystems()) if selectionList: while (not self.molSystem): interaction = self.multiDialog.SelectionList( self.guiParent, selectionList, selectionDict=selectionDict, title="Project '%s': " % self.project.name + 'Select molecular system', text='Existing molecular system codes:', urlFile='SelectMolSystem') if interaction.isSelected: self.molSystem = interaction.selection # # If nothing, create new # if not self.molSystem: molSysExists = 1 molSysCode = 'My_molecular_system' while (molSysExists): molSysCode = self.dataEntry.askString( "Molecular system name", "Code for new molecular system:", molSysCode, self.guiParent) if self.project.findFirstMolSystem(name=molSysCode): self.messageReporter.showError( "Error", "Name for molecular system already exists - select another.", parent=self.guiParent) elif ' ' in molSysCode: self.messageReporter.showError( "Error", "Name for molecular system cannot have spaces.", parent=self.guiParent) else: molSysExists = 0 self.molSystem = MolSystem.MolSystem(self.project, code=molSysCode, name=molSysCode)