示例#1
0
    if (boolean):
      return 'yes'
    else:
      return 'no'

  def getSelectedChemComp(self):

    return self.chem_comp_var_table.currentObject

if (__name__ == '__main__'):

  from memops.api.Implementation import MemopsRoot
  from memops.gui.Button import Button
  from memops.gui.MessageReporter import showInfo

  project = MemopsRoot(name='p')

  root = Tkinter.Tk()
  root.top = root

  root.grid_rowconfigure(0, weight=1)
  root.grid_columnconfigure(0, weight=1)

  frame = ChemCompFrame(root, project, path = '/ebi/msd/nmrqual/workspace/CCPN/python/ccp/gui/local/cctest/')
  frame.grid(sticky=Tkinter.NSEW)

  def getSelected():

    chemComp = frame.getSelectedChemComp()
    if (chemComp):
      if hasattr(chemComp,'chemComp'):
示例#2
0
# - Then link the person to the citation - use the addAuthor() method
#     of the JournalCitation class.
#
# - Finally print the person's name and also the citation title starting
#     from the person object by finding the first citation for this person
#     with the relevant journal name.
#
# - Hint: use findFirstAuthorCitation to follow the person to citation link
#     in this case.
#

from memops.api.Implementation import MemopsRoot

if __name__ == '__main__':

    project = MemopsRoot(name='objTest')
    projectName = project.name

    # Create a new AffiliationStore top object.

    affStore = project.newAffiliationStore(name=projectName)

    # Create a new CitationStore top object.

    citStore = project.newCitationStore(name=projectName)

    # Create a new Person object from the AffiliationStore top object.

    person = affStore.newPerson(familyName='Smith', givenName='John')

    # Create a new JournalCitation object from the CitationStore top object.
示例#3
0
      fp.write('refpt %5.4f\n' % self.refpt[i])
      fp.write('nuc %s\n' % self.nuc[i])
      if self.pointValues[i]:
        fp.write('params')
        for value in self.pointValues[i]:
          fp.write(' %5.4f' % value)
        fp.write('\n')

    fp.close()

if (__name__ == '__main__'):

  import sys
  if (len(sys.argv) != 2):
    print 'Error: required argument: <parFile>'
    sys.exit(1)

  parFile = sys.argv[1]
  params = AzaraParams(parFile)

  from memops.api.Implementation import MemopsRoot, Url
  from ccp.util.Spectrum import createExperiment

  r = MemopsRoot()
  l = r.newDataLocationStore(name='testDLS')
  d = l.newDataUrl(name='testDataUrl', url=Url(path='/Users/wb104/edl387'))
  n = r.newNmrProject(name='testNmrProject')
  e = createExperiment(n, name='testExpt', numDim=params.ndim, sf=params.sf, isotopeCodes=params.nuc)
  s = params.createDataSource(e, name='testSpectrum', dataUrl=d)

示例#4
0
import os
import Tkinter

from memops.api.Implementation import MemopsRoot

from ccpnmr.format.converters.CnsFormat import CnsFormat

from ccpnmr.format.general.Util import (createExperiment,
                                        getRefExpFromOldExpType)

from msd.nmrStar.IO.NmrStarExport import NmrStarExport

if __name__ == '__main__':

    # Similar start to code as that found in ex6.py.
    project = MemopsRoot(name='sampleTest')
    guiRoot = Tkinter.Tk()

    cnsObj = CnsFormat(project, guiRoot)

    nmrProject = project.currentNmrProject = \
        project.newNmrProject(name = project.name)
    strucGen = nmrProject.newStructureGeneration()

    cnsDir = '../data/cns'
    cnsFile = os.path.join(cnsDir, 'cns_1.pdb')

    cnsObj.readCoordinates([cnsFile],
                           strucGen=strucGen,
                           minimalPrompts=1,
                           linkAtoms=0)
示例#5
0
import os

# This contains the application data class.
from memops.api import Implementation
from memops.api.Implementation import MemopsRoot

from ccpnmr.format.converters.FastaFormat import FastaFormat

from msd.nmrStar.IO.NmrStarExport import NmrStarExport

if __name__ == '__main__':

    project = MemopsRoot(name='alignTest')

    # Create a BMRB Entry for export to the NMR-STAR file.
    entryStore = project.newNmrEntryStore(name=project.name)
    nmrEntry = entryStore.newEntry(name=project.name)

    # Application data objects allow you to store and associate extra data
    # in the CCPN project that does not fit into the rest of the data model.

    # Format of an application data object has the application that the data
    # is derived from (e.g., XEasy, NmrStar); a keyword to describe the type
    # of data that is present (e,g., sequence, chemical shift) and the value
    # of the data.

    # For this example, we are reading a Fasta file.
    seqDir = '../data/seq'
    seqFile = os.path.join(seqDir, 'fasta.seq')

    keywds = {
示例#6
0
文件: ex2.py 项目: fenglb/ccpnmr2.4
from memops.api.Implementation import MemopsRoot

# No longer need the following package imports as can use methods
# in parent objects to create child objects like NmrEntryStore or Entry.
#from ccp.api.nmr.NmrEntry import (NmrEntryStore, Entry)

if __name__ == '__main__':

    # Still need to create the CCPN project from an import.
    project = MemopsRoot(name='entryTest2')

    # Can use methods to get object attributes.
    projectName = project.getName()
    print 'Project [%s]' % projectName

    # New way to create an NmrEntryStore instance.
    entryStore = project.newNmrEntryStore(name=projectName)
    entryStoreName = entryStore.getName()
    print 'Entry store [%s]' % entryStoreName

    # New way to create an Entry instance.
    keywds = {
        'title': 'test title',
        'bmrbProcessing': 'test submission',
        'details': 'test details'
    }
    entry = entryStore.newEntry(name=entryStoreName + 'A', **keywds)

    entryName = entry.getName()
    entryTitle = entry.getTitle()
    entryBmrbProc = entry.getBmrbProcessing()
示例#7
0
import os
import Tkinter

from memops.api.Implementation import MemopsRoot

from ccpnmr.format.converters.CnsFormat import CnsFormat

if __name__ == '__main__':

    # CCPN project.
    project = MemopsRoot(name='readCns')

    guiRoot = Tkinter.Tk()

    # CNS object.
    cnsObj = CnsFormat(project, guiRoot)

    # Read in a sequence - this will create the molecular system with
    # all the atom information.

    # Note, many of the popups can be avoided when the right information
    # is passed in (see the readSequence() function in the
    # ccpnmr.format.converters.DataFormat class.

    # 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)
示例#8
0
import Tkinter

from memops.api.Implementation import MemopsRoot

from ccpnmr.format.converters.NmrViewFormat import NmrViewFormat
from ccpnmr.format.converters.XEasyFormat import XEasyFormat

# Pre-defined functions to create an NMR experiment and data source.
from ccpnmr.format.general.Util import (createExperiment,
                                        getRefExpFromOldExpType,
                                        createPpmFreqDataSource)

if __name__ == '__main__':

    # CCPN project.
    project = MemopsRoot(name='nmrView2XEasy')

    gui = Tkinter.Tk()

    # NmrView object.
    nmrViewObj = NmrViewFormat(project, gui)

    # Location of the NmrView files.
    nmrViewDir = '../data/nmrView'

    # Read in a sequence to set molecule and molSystem objects.
    nmrViewSeq = 'nmrView.seq'
    nmrViewSeqFile = os.path.join(nmrViewDir, nmrViewSeq)

    nmrViewObj.readSequence(nmrViewSeqFile, minimalPrompts=1)
示例#9
0
from memops.api.Implementation import MemopsRoot

if __name__ == '__main__':

    # CCPN project.
    project = MemopsRoot(name='moleculeTest')

    # Create a molecule. This is a reference object - molSystem contains the
    # actual molecule. e.g., in a homodimer, you only create 1 molecule, but
    # the molSystem has 2 chains (see below).
    molecule = project.newMolecule(name='myMoleculeName')

    # Then we have to create the MolResidues. All the reference information
    # for these comes from the 'ChemComps', which must be loaded first.

    # Here is an example protein sequence.
    seq = ['Ala', 'Gly', 'Tyr', 'Glu', 'Leu', 'Gly', 'Ser', 'His', 'Ile']

    for pos in range(0, len(seq)):
        ccpCode = seq[pos]

        # Find the reference data chemComp. Note the type of residue needs to be
        # specified from: 'protein', 'DNA', 'RNA' 'carbohydrate', and 'other'.
        keywds = {'molType': 'protein', 'ccpCode': ccpCode}
        chemComp = project.findFirstChemComp(**keywds)

        # For linear biopolymers ('protein', 'DNA' and 'RNA) the 'linking'
        # needs to be set, which indicates the position in the linear chain.
        # For other types ('carbohydrate', 'other') linking indicates the
        # pattern of links to other building blocks.
        if pos == 0:
示例#10
0
#     to each other:
#
#   - from ccp.examples.workshop.session2.makeMolSystem import makeLinearLink
#
#   - makeLinearLink(molecule, molResidue, position, linking) .
#

from memops.api.Implementation import MemopsRoot

# makeLinearLink sub-routine to make the correct links between the molResidues.

from ccp.examples.workshop.session2.makeMolSystem import makeLinearLink

if __name__ == '__main__':

    project = MemopsRoot(name='dnaTest')

    # Make a new molecule top object.

    molecule = project.newMolecule(name='myDnaMoleculeName')

    # DNA sequence as a string of one-letter codes.

    seq = 'ATGGATCATTAG'

    # Iterate over this sequence.

    for pos in range(0, len(seq)):

        # Get the residue code.
示例#11
0
#     of the files that are created - use the method saveModified() .
#
# - Try and run the script twice and see what happens.
#
# - Hint: Check to see what the mandatory attributes are for these top objects.
#

# Import the MemopsRoot class from the API.

from memops.api.Implementation import MemopsRoot

if __name__ == '__main__':

  # New CCPN project - called a MemopsRoot.

  project = MemopsRoot(name = 'topObjectTest')

  # Use the new<Class> factory methods available to the MemopsRoot class.

  # NmrEntry
  entryStore = project.newNmrEntryStore(name = 'myEntry')

  # Nmr
  nmrProject = project.newNmrProject(name = 'myNmrProject')

  # Affiliation
  affStore = project.newAffiliationStore(name = 'myAffiliation')

  # Citation
  citStore = project.newCitationStore(name = 'myCitation')
示例#12
0
文件: ex1.py 项目: fenglb/ccpnmr2.4
# Package imports from CCPN API.
# These must be in the global scope.
from memops.api.Implementation import MemopsRoot
from ccp.api.nmr.NmrEntry import (NmrEntryStore, Entry)

if __name__ == '__main__':

    # Create a CCPN project (called a MemopsRoot class in the CCPN API).
    # Must specify the attribute 'name' when created.
    project = MemopsRoot(name = 'entryTest')

    # Non-API way to get object attributes.
    projectName = project.name
    print 'Project [%s]' % projectName

    # Create an NmrEntryStore that can hold multiple BMRB Entry objects.
    entryStore = NmrEntryStore(project, 
                               name = projectName)

    entryStoreName = entryStore.name
    print 'Entry store [%s]' % entryStoreName
    print 'Current store: [%s]' % project.currentNmrEntryStore

    # Create a BMRB Entry object, which can hold all the data for a BMRB
    # deposition.
    entry = Entry(entryStore, name = entryStoreName)
    entryName = entry.name
    print 'Entry [%s]\n' % entryName
示例#13
0
文件: ex3.py 项目: fenglb/ccpnmr2.4
from memops.api.Implementation import MemopsRoot

if __name__ == '__main__':

    # CCPN project.
    project = MemopsRoot(name='personTest')

    # Create a BMRB Entry.
    entryStore = project.currentNmrEntryStore = \
        project.newNmrEntryStore(name = project.name)
    entry = entryStore.newEntry(name=project.name)

    # Create an affiliationStore and alias for it.
    affStore = project.currentAffiliationStore = \
        project.newAffiliationStore(name = project.name)

    # Create an organisation and group.
    orgn = affStore.newOrganisation(name='myDepartment')
    group = orgn.newGroup(name='myGroup')

    # Create a new person.
    keywds = {'familyName': 'Smith', 'givenName': 'John'}
    person = affStore.newPerson(**keywds)

    # Set the group for this person. PersonInGroup is an intermediate
    # class to avoid many-to-many relationships.
    personInGroup = person.newPersonInGroup(group=group)

    # Print some basic information.
    personName = person.givenName + ' ' + person.familyName
    orgName = person.findFirstPersonInGroup().group.organisation.name
示例#14
0
from memops.api.Implementation import MemopsRoot

from ccpnmr.format.converters.NmrViewFormat import NmrViewFormat

from ccpnmr.format.general.Util import (
    createExperiment, getRefExpFromOldExpType, createPpmFreqDataSource)

# Specific class not in Format Converter used to export NMR-STAR files.
from msd.nmrStar.IO.NmrStarExport import NmrStarExport

if __name__ == '__main__':

    # This code follows on from ex8.py, but writes the project
    # to NMR-STAR format.
    project = MemopsRoot(name = 'nmrStarTest')
    gui = Tkinter.Tk()

    nmrViewObj = NmrViewFormat(project, gui)

    nmrViewDir = '../data/nmrView'

    nmrViewSeq     = 'nmrView.seq'
    nmrViewSeqFile = os.path.join(nmrViewDir, nmrViewSeq)

    nmrViewObj.readSequence(nmrViewSeqFile, minimalPrompts = 1)

    nmrProject = project.currentNmrProject = \
        project.newNmrProject(name = project.name)

    nmrViewChemShifts    = 'ppm.out'
示例#15
0
                                              numDim=params.ndim)

    # create spectrum

    if not spectrumName:
        n = 1
        while experiment.findFirstDataSource(name='%d' % n):
            n += 1
        spectrumName = '%d' % n

    spectrum = params.createDataSource(experiment, name=spectrumName)

    return spectrum


if __name__ == '__main__':

    import sys
    from memops.api.Implementation import MemopsRoot

    if len(sys.argv) != 2:
        print 'Need to specify file'
        sys.exit()

    fileName = sys.argv[1]

    project = MemopsRoot(name='test')
    nmrProject = project.newNmrProject(name='test')

    spectrum = openSpectrum(fileName, nmrProject=nmrProject)
示例#16
0
      residue = chain.newResidue(seqId=seqId, seqCode=molSysResidue.seqCode)

      # create MolStructure.Atoms
      for molSysAtom in molSysResidue.atoms:
        chemAtom = molSysAtom.chemAtom
        if chemAtom.elementSymbol != 'H':
          atom = residue.newAtom(name=molSysAtom.name)

          # create MolStructure.Coord
          coord = atom.newCoord(model=model)
          coord.x = random.random()
          coord.y = random.random()
          coord.z = random.random()

  #root.saveModified()

if __name__ == '__main__':

  import sys

  if len(sys.argv) == 1:
    from memops.api.Implementation import MemopsRoot
    root = MemopsRoot(name='testNmr')
  elif len(sys.argv) == 2:
    from memops.general.Io import loadProject
    repositoryPath = sys.argv[1]
    root = loadProject(path=repositoryPath)

  main(root)

示例#17
0
文件: ex12.py 项目: fenglb/ccpnmr2.4
# Sub routine to print out details of the repositories.
def printReposUrls(project):

    print '\nUrls:'

    for repos in project.sortedRepositories():
        print repos.name, repos.url.path

    print


if __name__ == '__main__':

    # This code follows on from ex7.py.
    project = MemopsRoot(name='constraintsTest')
    guiRoot = Tkinter.Tk()

    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)
示例#18
0
    # with chains is straightforward. All the residue and atom information for
    # these are taken from the reference Molecule and ChemComp information.
    keywds = {'code': molSysCode, 'name': molSysName}
    molSystem = project.newMolSystem(**keywds)

    # Now create the chains.
    for code in chainCodes:
        molSystem.newChain(code=code, molecule=molecule)

    return molSystem


if __name__ == '__main__':

    # CCPN project.
    project = MemopsRoot(name='moleculeTest')

    #           12345678901234567890
    sequence = 'ACDEFGHIKLMNPQRSTVWY'

    # Make a three-letter sequence list from a one-letter sequence string.
    tlcSeq = makeSequence(sequence)

    molecule = makeMolecule(project, tlcSeq)

    print 'Molecule: [%s]' % molecule.name, '\n'

    for molRes in molecule.sortedMolResidues():
        print 'MolResidue: [%s]' % molRes.ccpCode

    print