Hi Marco,
> We are trying to use the CCP (python) library for research here at the
> department. Do you have more documentation besides the automatically
> extracted pydocs? A tutorial, manual or even a thesis reporting this work is
> what we are looking for. Something with examples would also be helpful.
There are now some references available, see:
http://www.ccpn.ac.uk/project/publications/publications.html
Also useful is the 'quick guide', though it's a bit out of date now:
http://www.ccpn.ac.uk/documentation/Quick_Guide/quick_guide.html
There are not really any simple example scripts available - this is a good
point and we will do something about this. In the meantime I have attached
a simple example of how to create a homodimer using the Python API - we
will make this and other example scripts part of the distribution.
Some more examples for using the FormatConverter higher level code (which
is an extra layer on top of the Python API) are available from:
http://www.ebi.ac.uk/msd-srv/docs/NMR/NMRtoolkit/scripts.html
Hope that helps... if not then let us know what you want to do and we can
write a more specific example for you to start off with.
Bye,
Wim
from memops.api import Implementation
from ccp.api import Molecule, MolSystem
from ccp.general.Io import getChemCompHead
if __name__ == '__main__':
#
# First you always have to create a project (this is the root object)
#
project = Implementation.Project(name = 'test')
# Alternatively load an existing project:
#
# from memops.general.Io import loadXmlProjectFile
# project = loadXmlProjectFile(file = 'test.xml')
#
#
# Now we can create a molecule. This is a reference object: if you have
# a homodimer, for example, you only create 1 molecule, but (see below) 2 chains.
#
# Note that you have to pass in the parent object (the project in this case).
# The child object (here the Molecule) can never exist without its parent
#
molecule = Molecule.Molecule(project,name = 'myMolecule')
#
# Then we have to create the MolResidues. All the reference information
# for these comes from the 'ChemComps', and you have to load this ChemComp
# before you can create the MolResidue.
#
exampleSequence = ['ALA','GLY','TYR','GLU','LEU','GLY','SER','HIS','ILE']
for seqPosition in range(0,len(exampleSequence)):
ccpCode = exampleSequence[seqPosition]
#
# getChemCompHead() is a standard function. Note that you also have to
# specify the type of residue - available are 'protein', 'DNA', 'RNA' and 'other'
#
chemCompHead = getChemCompHead(project, 'protein', ccpCode)
#
# For biopolymers ('protein','DNA' and 'RNA) you have to set the 'linking'. This
# indicates the position in the linear chain
#
if seqPosition == 0:
linking = 'start'
elif seqPosition == len(exampleSequence) - 1:
linking = 'end'
else:
linking = 'middle'
#
# You also have to specify the 'descriptor' which defines the protonation
# state of the residue (the variant of the ChemComp: a ChemCompVar).
# Here the default state is selected using the findFirst function provided by the API
#
chemCompVar = chemCompHead.chemComp.findFirstChemCompVar(linking = linking, isDefaultVar = True)
#
# Create a molResidue. You can also set the
#
molRes = Molecule.MolResidue(molecule, chemCompHead = chemCompHead,
seqCode = seqPosition,
linking = linking,
descriptor = chemCompVar.descriptor)
#
# Finally we have to set the residue linking information...
#
if linking in ['middle','end']:
prevLink = molRes.findFirstMolResLinkEnd(linkCode = 'prev')
prevMolRes = molecule.findFirstMolResidue(seqId = seqPosition - 1)
if prevLink and prevMolRes:
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 = 'myMolecularSystem', name = 'My molecular system')
#
# 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
#
# (or even better the local html files that come with the distribution)
#
for residue in chainA.residues:
print residue.ccpCode, residue.seqCode
print " ",
for atom in residue.atoms:
print atom.name,
print
|