You are here: Home V2 Software Software More ... Developer Notes Legacy Notes Version 1.0 to 1.1 code migration

Version 1.0 to 1.1 code migration

Python API coding changes 1.0 to 1.1

Ccp API separated into directories

An extra level of four sub-packages has been introduced into the ccp package, and so there are now four directories:  general/lims/molecule/ & nmr/ in the python/ccp/api directory.
This means that imports of API objects from Ccp packages require and extra part to their dot path, corresponding to the extra directory.

Examples

  • from ccp.api.nmr import Nmr
  • from ccp.api.nmr import NmrConstraint
  • from ccp.api.general import Method
  • from ccp.api.molecule import MolStructure
  • from ccp.api.molecule import MolSystem
  • from ccp.api.molecule import Molecule
  • from ccp.api.molecule import ChemComp



New Top Objects

The top-level objects AnalysisProject and NmrProject have been added to the data model. This means that there is an extra object between things like experiments and spectrum windows and the upper most parent (root), which is equivalent to the old project object.

The uppermost 'root' object can have several NmrProject and AnalysisProject objects in its respective nmrProjects and analysisProjects links. However, there will be links to current Nmr and Analysis projects, i.e. one root.currentNmrProject and one root.currentAnalysisProject.

The Nmr top-level object also has consequences for the naming of a few links. Links from root like nmrExperiments and nmrMeasurementLists are now gone and replaced with experiments and measurementLists from the NmrProject top-level object.

Examples:

  • Instead of "resonance.project.atomSets" do "resonance.nmrProject.atomSets"
  • Instead of "experiment.project" do "experiment.nmrProject.project" or "experiment.root"
  • Instead of "project.findFirstNmrExperiment(name='HSQC')" do "project.currentNmrProject.findFirstExperiment(name='HSQC')"
  • Instead of "experiment.project.spectrumWindows" do "experiment.root.currentAnalysisProject.spectrumWindows"



NmrConstraintHead is now called NmrConstraintStore

Also, the object is now under an NmrProject, rather than the uppermost root.

  • Instead of "project.nmrConstraintHead" do "nmrProject.nmrConstraintStore"

 

Package name changes


Structure is now MolStructure

  • Instread of "molSystem.structures" do "molSystem.molStructures"

NmrConstraints is now NmrConstraint

  • NmrConstraint.NmrConstraintStore()

 

Link lists replaced by sets

In general you can no longer do object.links[0], instead do object.findFirstLink()

Example

  • Substitute "atom = atomSet.atoms[0]" with "atom = atomSet.findFirstAtom()"


You can generally no longer do object.links[i], instead do object.sortedLinks()[i] if the order is important. Otherwise you can convert the link set to a list.
Example

  • Substitute "residue = chain.residues[i+1]" with "residue = chain.sortedResidues()[i+1]"
  • Also "i = list(chain.residues).index(residue)" may not give the expected result, instead do"i = chain.sortedResidues().index(residue)"


Links to watch out for, where order is often assumed:

  • peak.peakDims
  • dataSource.dataDims
  • chain.residues
  • molecule.molResidues
  • spectrumWindow.axisPanels
  • axisPanel.axisRegions