Beispiel #1
0
    def setupMolSystem(self, molSysName):

        self.molSystem = self.ccpnProject.findFirstMolSystem(code=molSysName)

        if not self.molSystem:

            self.molSystem = MolSystem.MolSystem(self.ccpnProject,
                                                 code=molSysName)
Beispiel #2
0
def makeChainCopy(chain):
  """Descrn: Make a duplicate of a molSystem chain, using the same underlying molecule
     Inputs: Ccp.MolSystem.Chain
     Output: Ccp.MolSystem.Chain
  """

  code = nextChainCode(chain.molSystem)
  newChain = MolSystem.Chain(chain.molSystem, code=code, molecule=chain.molecule)
  newChain.setDetails(chain.details)
  
  return newChain
Beispiel #3
0
def deleteChainFragment(chainFragment):
    """Descrn: Remove a molSystem chain fragment by recreating the parent chain with fewer residues
     Inputs: Ccp.MolSystem.ChainFragment
     Output: None
  """

    # delete residues, molResidues, molResLinks and anything else?
    chain = chainFragment.chain
    code = chain.code
    molecule = chain.molecule
    details = chain.details
    molSystem = chain.molSystem
    molResidues = [r.molResidue for r in chainFragment.residues]
    chain.delete()

    for molResidue in molResidues:
        for linkEnd in molResidue.molResLinkEnds:
            if linkEnd.molResLink:
                linkEnd.molResLink.delete()
        molResidue.delete()

    chain = MolSystem.Chain(molSystem, code=code, molecule=molecule)
    chain.setDetails(details)
Beispiel #4
0
def makeChain(molSystem,molecule,code=None):
  """Descrn: Make a molSystem chain based upon an input molecule template
     Inputs: Ccp.MolSystem.MolSystem, Ccp.Molecule.Molecule, Word
     Output: Ccp.MolSystem.Chain
  """

  if code is None:
    code = nextChainCode(molSystem)
  
  chain = MolSystem.Chain(molSystem, code=code, molecule=molecule)
    
  if len(molecule.molResidues) == 1:
    details = molecule.findFirstMolResidue().chemComp.name
  else:
    details = molecule.seqString
  
  if details:
    if len(details) > 10:
      details = details[:10] + '...'
 
    chain.setDetails(details)
  
  return chain
Beispiel #5
0
                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
Beispiel #6
0
    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)