ccpn.core package

CCPN core package. High level interface for normal data access

Projects are saved by myProject.save(path, …)

Within the CcpNmr suite there is always a project open, assigned to the variable ‘project’.

Module Organisation

Class Hierarchy

Classes are organised in a hierarchy, with all data objects ultimately contained within the Project: The diagram shows the hierarchy, with child objects displaced to the right of the containing parent object. E.g. Spectrum, SpectrumGroup, and StructureData are all children of Project; PeakList and IntegralList are both children of Spectrum; and Peak is a child of PeakList.

Project
\-------Spectrum
        \-------SpectrumReference
        \-------PeakList
                \-------Peak
        \-------IntegralList
                \-------Integral
        \-------PseudoDimension
        \-------SpectrumHit
\-------SpectrumGroup
\-------Sample
        \-------SampleComponent
\-------Substance
\-------Chain
        \-------Residue
                \-------Atom
\-------Complex
\-------NmrChain
        \-------NmrResidue
                \-------NmrAtom
\-------ChemicalShiftList
        \-------ChemicalShift
\-------StructureData
        \-------RestraintTable
                \-------Restraint
                        \-------RestraintContribution
        \-------CalculationStep
        \-------Data
\-------StructureEnsemble
        \-------Model
\-------Note
\-------Collection
\-------DataTable

The Project object serves as container for all other data objects and the starting point for navigation.

A Spectrum object contains all the stored properties of a spectrum, as well as the path to the stored NMR data file.

A SpectrumReference holds detailed information about axes and referencing needed for e.g. multple-quantum, projection, and reduced-dimensionality experiments.

A PeakList serves as a container for Peak objects, which contain Peak position, intensity and assignment information.

An IntegralList serves as a container for Integral objects, which contain Integral intervals and values.

A PseudoDimension object is used to describe sampled-value axes, such as the time delay axis for T1 experiments.

A SpectrumHis object is used in screening and metabolomics implementations to describe that a Substance has been found to be present (metabolomics) or active (screening) in a given spectrum.

A SpectrumGroup combines multiple Spectrum objects, so they can be treated as a single object.

A Sample corresponds to an NMR sample. It is made up of SampleComponents, which indicate which individual chemical entities make up that Sample, (e.g. protein, buffer, salt), and their concentrations.

A Substance object represents a defined chemical entity, e.g. Lysozyme, ATP, NaCl, or (less commonly) a composite material like fetal calf serum or standard lysis buffer.

A Chain object corresponds to a molecular chain. It is made up of Residue objects, which in turn are made up of Atom objects.

A Complex is a group of chain objects, combined so that they can be treated as a single object.

Assignment is done through a hierarchy of NmrChain, NmrResidue, and NmrAtom objects. that parallels the hierarchy of molecular chains. An NmrChain (NmrResidue, Atom) is considered assigned to the Chain (Residue, Atom) with the same ID. NmrAtom objects serve as a way of connecting a named nucleus to an observed chemical shift, and peaks are assigned to NmrAtoms.

A ChemicalShiftList object is a container for ChemicalShift objects, which represent observed chemical shifts.

StructureData objects serve to group RestraintTables/ViolationTables and other input and output from a calculation.

A RestraintTable contains Restraint Objects of a specific type (distance, dihedral, etc.). RestraintContribution objects hold the detailed information; they are needed for complex restraints, like coupled phi and psi dihedral restraints.

The CalculationStep object is used to track the calculation history of StructureData, storing input and output StructureData IDs, and the names of the programs used.

Data object storing links to the data structures (PeakLists, Spectra, StructureEnsembles etc.) connected to a given StructureData, and their associated calculation parameters.

A StructureEnsemble object is a container for ensembles of coordinate structures, with each coordinate structure defined by a Model object.

Note objects contain free-text information to be stored in a project.

A Collection is a container, a list of core objects. It can also contain nested collections.

A DataTable is a container for a pandas dataFrame object.

Common Class elements

All classes in this module are subclasses of the core._implementation.AbstractWrapperObject, and inherit the following elements:

project - ccpn.core.Project

The Project (root) containing the object.

pid - ccpn.util.Pid.Pid

Identifier for the object, unique within the project. Set automatically from the short class name and object.id E.g. ‘NA:A.102.ALA.CA’

longPid - ccpn.util.Pid.Pid

Identifier for the object, unique within the project. Set automatically from the full class name and object.id E.g. ‘NmrAtom:A.102.ALA.CA’

id - str

Identifier for the object, used to generate the pid and longPid. Generated by combining the id of the containing object, with the value of one or more key attributes that uniquely identify the object in context. E.g. the id for an Atom, ‘A.55.VAL.HA’ is generated from:

  • ‘A’ Chain.shortName

  • ‘55’ Residue.sequenceCode

  • ‘VAL’ Residue.residueType

  • ‘HA’ Atom.name

delete()

Delete object, with all contained objects and underlying data.

getByPid(pidString)

Get an arbitrary data object from either its pid (e.g. ‘SP:HSQC2’) or its longPid (e.g. ‘Spectrum:HSQC2’

Returns None for invalid or unrecognised input strings.

rename(newName)

Change the object name or other key attribute(s), changing the object id, pid, and all internal references to maintain consistency. A number of Objects (Chain, Residue, Atom, Peak, cannot be renamed

Data access

The data of objects are accessed with the normal Python syntax (x = object.value; object.value = x. There are no public getter and setter functions. For collections you will get an unmodifiable copy of the internal collection, to prevent accidental modification of the data (e.g. myPeakList.peaks will return a tuple, not a list)

Each object has a link to the containing (parent) object (e.g. myPeakList.spectrum)

Each class has a link to contained objects, and a function to get a contained object by relative id. E.g. myProject.peaks, mySpectrum.peaks, and myPeakList.peaks will each get all peaks contained within the relevant object. The lists will be in creation order (where applicable) otherwise sorted by name or underlying key. Similarly, a given peak can be found by either myProject.getPeak(‘HSQC2.1.593’), mySpectrum.getPeak(‘1.593’), or myPeakList.getPeak(‘593’)

Most objects can be created using a newXyzObject method on the parent. E.g. you can create a new Restraint object with the myRestraintTable.newRestraint(…) function. ‘new’ functions create a single objects, using the passed-in parameters. There is no ‘newSpectrum’ function; spectra are created with ‘loadSpectrum’ as a complete spectrum object requires an external file with the data.

More complex object creation is done with ‘create…()’ functions, that may create multiple objects, and use heuristics to fill in missing parameters. E.g. the myRestraintTable.createRestraint(….) function creates a Restraint with the contained RestraintContributions and restraintItems.

Functions whose names start with ‘get’ (e.g. getNmrAtom(…)) mostly take some kind of identifier as an argument and returns the identified object if it exists, None otherwise.

Functions whose names start with ‘fetch’ (e.g. fetchNmrAtom(…)) also take some kind of identifier as an argument. These will return the identified object if it exists, but will create a new object otherwise.

Other common prefixes for function names include ‘add’ and ‘remove’ (which add and remove pre-existing objects to collections), ‘copy’, ‘clear’, ‘load’, ‘process’ and ‘toggle’, all of which should be self-explanatory.

Objects sort by type (in import order) then by parent, then by local key. Sorting the objects will give a sensible and reproducible ordering for all classes. A number of classes are returned sorted by creation order (e.g. NmrAtoms), but are sorted by a more significant key (for NmrAtoms alphabetically by name). ChemicalShift objects sort as the NmrAtom they belong to. NmrResidue objects behave in there different ways:

  • If they are assigned to a Residue they sort like the Residue, in sequential order

  • If they belong to a connected NmrChain, they sort by the order they appear in the NmrChain.

  • In other 4cases they sort by creation order.

  • Offset NmrResidues in all cases sort alongside their main NmrResidue, by offset.

Subpackages

Submodules

ccpn.core.Atom module

Module documentation here

class ccpn.core.Atom.Atom(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

A molecular Atom, contained in a Residue.

addInterAtomBond(atom: ccpn.core.Atom.Atom)[source]

ADVANCED Add generic bond between atoms - for creating disulfides or other crosslinks The bound-to atom will appear in self.boundAtoms.

NB This function does not remove superfluous atoms (like CYS HG), or check for chemical plausibility. Programmer beware!

property boundAtoms: Tuple[ccpn.core.Atom.Atom]

- Tuple[ForwardRef(‘Atom’)], immutable - Atoms that are covalently bound to this Atom

className = 'Atom'
property componentAtoms: Tuple[ccpn.core.Atom.Atom]

- Tuple[ForwardRef(‘Atom’)], immutable - Atoms that are combined to make up this atom - reverse of ‘compoundAtoms’

For simple atoms this is empty. For wildcard atoms (e.g. HB%, QB) this gives the individual atoms that combine into atom. For non-stereo atoms (e.g. HBx, HBy, HGx%) it gives the two alternative stereospecific atoms

Compound atoms may be nested - e.g. Valine HG1% has the components HG11, HG12, HG13 and is itself a component of HGx%, HGy%, HG%, and QG

property compoundAtoms: Tuple[ccpn.core.Atom.Atom]

- Tuple[ForwardRef(‘Atom’)], immutable - wildcard-, pseudo-, and nonstereo- atoms that incorporate this atom. - reverse of ‘componentAtoms’

Compound atoms may be nested - e.g. Valine HG1% has the components HG11, HG12, HG13 and is itself a component of HGx%, HGy%, HG%, and QG

property elementSymbol

- None, immutable -

property exchangesWithWater: bool

- bool, immutable - True if atom exchanges with water on a msx time scale, and so is mostly unobservable.

Holds for e.g. OH atoms, NH£ groups and His side chain NH protons, but NOT for amide protons

property isAssigned: bool

- bool, immutable - :return: True if Atom has as NmrAtom with an associated ChemicalShift object

property isEquivalentAtomGroup: Optional[bool]

- bool=None, immutable - Is this atom a group of equivalent atoms? Values are:

  • True (group of equivalent atoms, e.g. H%, ALA HB%, LYS HZ%, VAL HG1% or any M pseudoatom)

  • False (all single atoms, all xy nonstereo atoms, LEU HB%, ILE HG1%, VAL HG%, or any Q non-aromatic pseudoatom)

  • None = sometimes equivalent (TYR and PHE HD%, HE%, CD%, CE%, QD, QE)

property name: str

- str, immutable - Atom name string (e.g. ‘HA’)

property nmrAtom: Optional[NmrAtom]

- ForwardRef(‘NmrAtom’)=None, immutable - NmrAtom to which Atom is assigned

NB Atom<->NmrAtom link depends solely on the NmrAtom name.

So no notifiers on the link - notify on the NmrAtom rename instead.

property residue: ccpn.core.Residue.Residue

- ccpn.core.Residue.Residue, immutable - Residue containing Atom.

shortClassName = 'MA'

Class name and Short class name, for PID.

ccpn.core.CalculationStep module

Module documentation here

class ccpn.core.CalculationStep.CalculationStep(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

CalculationStep information, for tracking successive calculations. Ordered from oldest to newest

className = 'CalculationStep'
property dataSet: ccpn.core.StructureData.StructureData

- ccpn.core.StructureData.StructureData, immutable - StructureData containing RestraintTable.

property inputDataUuid: Optional[str]

- str=None, mutable - Universal identifier (uuid) for calculation input data set.

property inputStructureData: Optional[ccpn.core.StructureData.StructureData]

- ccpn.core.StructureData.StructureData=None, mutable - Calculation input data set.

property outputDataUuid: Optional[str]

- str=None, mutable - Universal identifier (uuid) for calculation output data set

property outputStructureData: Optional[ccpn.core.StructureData.StructureData]

- ccpn.core.StructureData.StructureData=None, mutable - Calculation output data set.

property programName: str

- str, mutable - Name of program doing calculation

property programVersion: Optional[str]

- str=None, mutable - Version of program doing calculation

property script: Optional[str]

- str=None, mutable - Text of script used for calculation

property scriptName: Optional[str]

- str=None, mutable - Name of script used for calculation

property serial: int

- int, immutable - serial number of CalculationStep, used in Pid and to identify the CalculationStep.

shortClassName = 'DC'

Short class name, for PID.

ccpn.core.Chain module

class ccpn.core.Chain.Chain(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

A molecular Chain, containing one or more Residues.

property atoms

- (‘ccpn.core.Atom.Atom,) - contained Atom objects in name order This is identical to the standard sorting order.

property chainType

- None, immutable -

className = 'Chain'
clone(shortName: str = None) ccpn.core.Chain.Chain[source]

Make copy of chain.

property complexes: Tuple[ccpn.core.Complex.Complex, ...]

- Tuple[ccpn.core.Complex.Complex, …], mutable - Complexes that contain Chain

property compoundName: str

- str, immutable - Short name of chemical compound (e.g. ‘Lysozyme’) making up Chain

getAtom(relativeId: str) ccpn.core.Atom.Atom

Get contained ‘ccpn.core.Atom.Atom object by relative ID

getResidue(relativeId: str) ccpn.core.Residue.Residue

Get contained ‘ccpn.core.Residue.Residue object by relative ID

property hasAssignedAtoms: bool

- bool, immutable - :return: True if any of its atoms have an assignment

property isCyclic: bool

- bool, immutable - True if this is a cyclic polymer.

property name: str

- str, mutable - short form of name

property nmrChain: Optional[NmrChain]

- ForwardRef(‘NmrChain’)=None, immutable - NmrChain to which Chain is assigned

rename(value: str)[source]

Rename Chain, changing its shortName and Pid.

renumberResidues(offset: int, start: int = None, stop: int = None)[source]

Renumber residues in range start-stop (inclusive) by adding offset

The residue number is the integer starting part of the sequenceCode, e.g. residue ‘12B’ is renumbered to ‘13B’ (offset=1)

if start (stop) is None, there is no lower (upper) limit

NB Will rename residues one by one, and stop on error.

property residues

- (‘ccpn.core.Residue.Residue,) - contained Residue objects in sequential order This is identical to the standard sorting order

property role: str

- str, mutable - The role of the chain in a molecular complex or sample - free text. Could be ‘free’, ‘’bound’, ‘open’, ‘closed’, ‘minor form B’, …

property sampleComponents: Tuple[ccpn.core.SampleComponent.SampleComponent, ...]

- Tuple[ccpn.core.SampleComponent.SampleComponent, …], immutable - SampleComponents matching to Chain (based on chain.compoundName)

property sequence

- None, immutable - :return: the full sequence as a single string of one letter codes

shortClassName = 'MC'

Short class name, for PID.

property shortName: str

- str, mutable - short form of name

property substances: Tuple[ccpn.core.Substance.Substance, ...]

- Tuple[ccpn.core.Substance.Substance, …], immutable - Substances matching to Chain (based on chain.compoundName)

ccpn.core.ChemicalShift module

Module Documentation here

class ccpn.core.ChemicalShift.ChemicalShift(project, chemicalShiftList, _uniqueId)[source]

Bases: ccpn.core._implementation.V3CoreObjectABC.V3CoreObjectABC

Chemical Shift, containing a ChemicalShift value for the NmrAtom they belong to.

Chemical shift values are continuously averaged over peaks assigned to the NmrAtom, (unless this behaviour is turned off)

ChemicalShift objects are sorted by uniqueId.

property allAssignedPeaks: tuple

- tuple, immutable - All assigned peaks for attached nmrAtom.

property assignedPeaks: tuple

- tuple, immutable - Assigned peaks for attached nmrAtom belonging to this chemicalShiftList.

property atomName: Optional[str]

- str=None, mutable - atomName for attached nmrAtom Optional user value if nmrAtom is None

property chainCode: Optional[str]

- str=None, mutable - chainCode for attached nmrAtom. Optional user value if nmrAtom is None

property chemicalShiftList

- None, immutable - ChemicalShiftList containing ChemicalShift.

className = 'ChemicalShift'
delete()[source]

Delete the shift

property dynamic: bool

- bool, immutable - Dynamic state of ChemicalShift. :return: not chemicalShift.static

property figureOfMerit: Optional[float]

- float=None, mutable - Figure of Merit for ChemicalShift, between 0.0 and 1.0 inclusive.

getStatic() bool[source]

Return the local static state of the chemicalShift

property id: str

- str, immutable - Identifier for the object, used to generate the pid and longPid. Generated by combining the id of the containing object, i.e. the checmialShift instance, with the value of one or more key attributes that uniquely identify the object in context E.g. ‘default.1’

property name: str

- str, mutable - Not allowed for ChemicalShift

property nmrAtom: Optional[ccpn.core.NmrAtom.NmrAtom]

- ccpn.core.NmrAtom.NmrAtom=None, mutable - Attached NmrAtom.

property orphan

- None, immutable - Orphan state of the chemicalShift :return: True if not static (i.e. dynamic), and has no associated peaks

property peakPpmPositions: tuple

- tuple, immutable - Return a tuple of the assigned peak positions (in ppm)

rename(value: str)[source]

Not allowed for ChemicalShift

property residueType: Optional[str]

- str=None, mutable - residueType for attached nmrAtom. Optional user value if nmrAtom is None

property sequenceCode: Optional[str]

- str=None, mutable - sequenceCode for attached nmrAtom. Optional user value if nmrAtom is None

shortClassName = 'CS'

Short class name, for PID.

property state

- None, immutable - State of chemicalShift

property static: bool

- bool, immutable - Static state of ChemicalShift. :return: True if chemicalShift or parent chemicalShiftTable is static

property value: Optional[float]

- float=None, mutable - shift value of ChemicalShift, in unit as defined in the ChemicalShiftList.

property valueError: Optional[float]

- float=None, mutable - shift valueError of ChemicalShift, in unit as defined in the ChemicalShiftList.

class ccpn.core.ChemicalShift.ShiftParameters(uniqueId, isDeleted, static, value, valueError, figureOfMerit, nmrAtom, chainCode, sequenceCode, residueType, atomName, comment)

Bases: tuple

atomName

Alias for field number 10

chainCode

Alias for field number 7

comment

Alias for field number 11

figureOfMerit

Alias for field number 5

isDeleted

Alias for field number 1

nmrAtom

Alias for field number 6

residueType

Alias for field number 9

sequenceCode

Alias for field number 8

static

Alias for field number 2

uniqueId

Alias for field number 0

value

Alias for field number 3

valueError

Alias for field number 4

ccpn.core.ChemicalShiftList module

class ccpn.core.ChemicalShiftList.ChemicalShiftList(project: ccpn.core.Project.Project, wrappedData: ccpnmodel.ccpncore.api.ccp.nmr.Nmr.ShiftList)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

An object containing Chemical Shifts. Note: the object is not a (subtype of a) Python list. To access all ChemicalShift objects, use chemicalShiftList.chemicalShifts.

A chemical shift list named ‘default’ is used by default for new experiments, and is created if necessary.

property autoChangeStatic: bool

- bool, mutable - Prevent further queries

property autoUpdate: bool

- bool, mutable - Automatically update Chemical Shifts from assigned peaks - True/False

property chemicalShifts

- None, immutable - Return the shifts belonging to ChemicalShiftList

className = 'ChemicalShiftList'
delete()[source]

Delete the chemicalShiftList and associated chemicalShifts

deleteChemicalShift(nmrAtom: None | ccpn.core.NmrAtom.NmrAtom, str=None, uniqueId: int = None)[source]

Delete a chemicalShift by nmrAtom or uniqueId

duplicate(includeSpectra=False, autoUpdate=False)[source]
Parameters
  • includeSpectra – move the spectra to the newly created ChemicalShiftList

  • autoUpdate – automatically update according to the project changes.

Returns

a duplicated copy of itself containing all chemicalShifts.

getChemicalShift(nmrAtom: Optional[ccpn.core.NmrAtom.NmrAtom | str] = None, uniqueId: Optional[int] = None, _includeDeleted: bool = False)[source]

Return a chemicalShift by nmrAtom or uniqueId Shift is returned as a namedTuple

get_OldChemicalShift(relativeId: str) ccpn.core._OldChemicalShift._OldChemicalShift

Get contained ‘ccpn.core._OldChemicalShift._OldChemicalShift object by relative ID

property isSimulated: bool

- bool, mutable - True if the ChemicalShiftList is simulated.

property name: str

- str, mutable - name of ChemicalShiftList.

newChemicalShift(value: float = None, valueError: float = None, figureOfMerit: float = 1.0, static: bool = False, nmrAtom: Optional[ccpn.core.NmrAtom.NmrAtom | str, ccpn.core.lib.Pid.Pid] = None, chainCode: str = None, sequenceCode: str = None, residueType: str = None, atomName: str = None, comment: str = None)[source]

Create new ChemicalShift within ChemicalShiftList.

An nmrAtom can be attached to the shift as required. nmrAtom can be core object, Pid or pid string If attached (chainCode, sequenceCode, residueType, atomName) will be derived from the nmrAtom.pid If nmrAtom is not specified, (chainCode, sequenceCode, residueType, atomName) can be set as string values. A chemicalShift is not static by default (dynamic), i.e., its value will update when there are changes to the assigned peaks.

See the ChemicalShift class for details.

Parameters
  • value – float shift value

  • valueError – float

  • figureOfMerit – float, default = 1.0

  • static – bool, default = False

  • nmrAtom – nmrAtom as object or pid, or None if not required

  • chainCode

  • sequenceCode

  • residueType

  • atomName

  • comment – optional comment string

Returns

a new ChemicalShift tuple.

rename(value: str)[source]

Rename ChemicalShiftList, changing its name and Pid.

property serial: int

- int, immutable - Shift list serial number

shortClassName = 'CL'

Short class name, for PID.

property spectra: Tuple[ccpn.core.Spectrum.Spectrum, ...]

- Tuple[ccpn.core.Spectrum.Spectrum, …], mutable - ccpn.Spectra that use ChemicalShiftList to store chemical shifts

property static: bool

- bool, mutable - True if the ChemicalShiftList is static. Overrides chemicalShift.static

property unit: str

- str, mutable - Measurement unit of ChemicalShiftList. Should always be ‘ppm’

class ccpn.core.ChemicalShiftList.ChemicalShiftState(value)[source]

Bases: ccpn.util.LabelledEnum.LabelledEnum

An enumeration.

DYNAMIC = 1
ORPHAN = 2
STATIC = 0

ccpn.core.Collection module

Module Documentation here

class ccpn.core.Collection.Collection(project, collectionList, _uniqueId)[source]

Bases: ccpn.core._implementation.V3CoreObjectABC.V3CoreObjectABC

Collection object, holding a list of core objects.

addItems(items: Sequence[Any])[source]

Add an object or list of core objects to the collection. Action is ignored if the list is empty.

Raise an error if there are any non-core objects

Parameters

items – single object or list of core objects, as objects or pid strings.

className = 'Collection'
delete()[source]

Delete the collection

getByObjectType(objectTypes=None, search=None, useLongPid=None, caseSensitive=None, disableLeadingTrailingSearch=None, recursive=None, depth=None)[source]

Return a list of items of types specified in objectTypes list.

ObjectTypes is a list of core objects expressed as object classes or short/long classnames. If objectTypes is not specified then all objects will be returned.

For example, class Note can be specified as Note, ‘Note’, ‘NO’, ‘note’ or ‘no’. caseSensitive is False by default, if caseSensitive is True, objectTypes as class names must be specified exactly.

ObjectTypes can be a single item or tuple/list, or None to return all items. Any Nones in lists will be ignored.

search is a regex search string applied to the pids of objects in the collection. useLongPid can be specified with the search option to use the londPid descriptor of core objects as the search item. if caseSensitive is True, the exact pid or longPid is used for simple searches, although more detailed regex searches can be used to override this.

Simple searches can use * as wildcard to represent 1 or more characters. Use ? to specify a single charaacter. Leading and trailing *’s are added by default. This can be disabled with disableLeadingTrailingSearch=True

Set depth=0 or recursive=True to search through all nested collections, recursion=False or depth=1 will only search through the top collection, ignoring nested collections. Full recursion is the default setting.

Please specify either recursive OR depth.

Examples:

collection.getByObjectTypes()
collection.getByObjectTypes(objectTypes=Note)
collection.getByObjectTypes(objectTypes='NO', recursive=False)
collection.getByObjectTypes(objectTypes='Note', depth=2)
collection.getByObjectTypes(objectTypes=['Note', Spectrum])
collection.getByObjectTypes(search='someNotes', useLongPid=True, caseSensiive=True)
Parameters
  • objectTypes – optional single item, or list of core objects as object class or classnames

  • search – optional regex search string

  • useLongPid – optional True/False, only use with search

  • caseSensitive – optional True/False

  • disableLeadingTrailingSearch – optional True/False

  • recursive – optional True/False, only use with search

  • depth – optional int >= 0

Returns

tuple of core items.

property items: Tuple[Any, ...]

- Tuple[Any, …], mutable - List of items attached to the collection

removeItems(items: Sequence[Any])[source]

Remove an object or list of core objects from the collection. The items must belong to the collection. Action is ignored if the list is empty.

Raise an error if there are any non-core objects.

Parameters

items – single object or list of core objects, as objects or pid strings.

searchCycles(depth=0)[source]

Check whether there are any cycles in the collections

shortClassName = 'CO'

Short class name, for PID.

class ccpn.core.Collection.CollectionParameters(uniqueId, isDeleted, name, items, comment)

Bases: tuple

comment

Alias for field number 4

isDeleted

Alias for field number 1

items

Alias for field number 3

name

Alias for field number 2

uniqueId

Alias for field number 0

ccpn.core.Complex module

class ccpn.core.Complex.Complex(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

A group of Chains, which can be used as a single object to describe a molecular complex.

property chains: Tuple[ccpn.core.Chain.Chain, ...]

- Tuple[ccpn.core.Chain.Chain, …], mutable - Chains that make up Complex.

className = 'Complex'
property comment: str

- str, mutable - Free-form text comment

property name: str

- str, mutable - Name of Complex, part of identifier

rename(value: str)[source]

Rename Complex, changing its name and Pid.

property serial: str

- str, immutable - Serial number of Complex, used for sorting

shortClassName = 'MX'

Class name and Short class name, for PID.

ccpn.core.Data module

class ccpn.core.Data.Data(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Object storing links to the data structures (PeakLists, Spectra, StructureEnsembles etc.) connected to a given StructureData, and their associated calculation parameters.

property attachedObject: Optional[ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject]

- ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject=None, mutable - attached object - derived from self.attachedObjectPid.

If no attached object matching attachedObjectPid can be found (object has been renamed, deleted, or the attachedObjectPid is incorrect) this attribute has the value None.

property attachedObjectPid: Optional[str]

- str=None, mutable - Pid for attached object - used to calculate the attachedObject

Remains unchanged also if the object pointed to is renamed or deleted, to preserve, as far as possible, the original data.

property calculationStep: ccpn.core.StructureData.StructureData

- ccpn.core.StructureData.StructureData, immutable - StructureData containing Data.

className = 'Data'
clearDataParameters()[source]

Delete all parameters

property dataParameters: dict

- dict, immutable - Keyword-value dictionary of parameters. NB the value is a copy - modifying it will not modify the actual data. Use the setDataParameter, deleteDataParameter, clearDataParameters, and updateDataParameters methods to modify the parameters.

Dictionary values can be anything that can be exported to JSON, including OrderedDict, numpy.ndarray, ccpn.util.Tensor, or pandas DataFrame, Series, or Panel

deleteDataParameter(name: str)[source]

Delete parameter named ‘name’

property name: str

- str, mutable - name of Data object, used in Pid and to identify the Data object.

print()[source]
rename(value: str)[source]

Rename Data, changing its name and Pid.

setDataParameter(name: str, value)[source]

Add name:value to parameters, overwriting existing entries

shortClassName = 'DA'

Short class name, for PID.

updateDataParameters(value: dict)[source]

Convenience routine, similar to dict.update(). Calls self.setDataParameter(key, value) for each key,value pair in the input.

ccpn.core.DataTable module

Module Documentation here

class ccpn.core.DataTable.DataTable(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Container for pandas dataFrame.

className = 'DataTable'
clearMetadata()[source]

Delete all metadata.

property columns: list

- list, immutable - Return the columns in the dataFrame

property data: ccpn.core.DataTable.TableFrame

- ccpn.core.DataTable.TableFrame, mutable - Return the pandas dataFrame.

deleteMetadata(name: str)[source]

Delete metadata named ‘name’.

getMetadata(name: str)[source]

Return value from metadata.

property metadata: dict

- dict, immutable - Keyword-value dictionary of metadata. NB the value is a copy - modifying it will not modify the actual data. Use the setMetadata, deleteMetadata, clearMetadata, and updateMetadata methods to modify the metadata.

Dictionary values can be anything that can be exported to JSON, including OrderedDict, numpy.ndarray, ccpn.util.Tensor, or pandas DataFrame, Series, or Panel.

property name: str

- str, mutable - Name of DataTable, part of identifier.

property nefCompatibleColumns

- None, immutable - Return the columns in the dataFrame

rename(value: str)[source]

Rename DataTable, changing its name and Pid.

property serial: int

- int, immutable - ID number of DataTable, used in Pid and to identify the DataTable.

setMetadata(name: str, value)[source]

Add name:value to metadata, overwriting existing entry.

shortClassName = 'DT'

Short class name, for PID.

updateMetadata(value: dict)[source]

Convenience routine, similar to dict.update(). Calls self.setMetadata(key, value) for each key,value pair in the input.

class ccpn.core.DataTable.TableFrame(*args, **kwargs)[source]

Bases: ccpn.core._implementation.DataFrameABC.DataFrameABC

Generic data - as a Pandas DataFrame.

ccpn.core.Integral module

Module documentation here

class ccpn.core.Integral.Integral(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

n-dimensional Integral, with integration region and value.

Includes fields for per-dimension values.

property annotation: Optional[str]

- str=None, mutable - Integral text annotation

property axisCodes: Tuple[str, ...]

- Tuple[str, …], immutable - Spectrum axis codes in dimension order matching position.

property baseline: float

- float, mutable - baseline of Integral

property bias: float

- float, mutable - Baseplane offset used in calculating integral value

className = 'Integral'
property constraintWeight: Optional[float]

- float=None, mutable - constraintWeight of Integral

property figureOfMerit: Optional[float]

- float=None, mutable - figureOfMerit of Integral, between 0.0 and 1.0 inclusive.

property integralList: ccpn.core.IntegralList.IntegralList

- ccpn.core.IntegralList.IntegralList, immutable - IntegralList containing Integral.

property limits: List[Tuple[float, float]]

- List[Tuple[float, float]], mutable - Integration limits in axis value (ppm), per dimension, with lowest ppm value first :return list of (low_ppm, high_ppm) tuples

property offset: float

- float, mutable - offset of Integral

property peak

- None, mutable - The peak attached to the integral.

property pointLimits: List[Tuple[float, float]]

- List[Tuple[float, float]], mutable -

property serial: int

- int, immutable - serial number of Integral, used in Pid and to identify the Integral.

shortClassName = 'IT'

Short class name, for PID.

property slopes: Optional[List[float]]

- List[float]=None, mutable - slope (in dimension order) used in calculating integral value

The slope is defined as the intensity in point i+1 minus the intensity in point i

property value: Optional[float]

- float=None, mutable - value of Integral

property valueError: Optional[float]

- float=None, mutable - value error of Integral

ccpn.core.IntegralList module

class ccpn.core.IntegralList.IntegralList(*args, **kwds)[source]

Bases: ccpn.core._implementation.PMIListABC.PMIListABC

An object containing Integrals. Note: the object is not a (subtype of a) Python list. To access all Integral objects, use integralList.integrals.

automaticIntegral1D(minimalLineWidth=0.01, deltaFactor=1.5, findPeak=False, noiseThreshold=None) List[Integral][source]

minimalLineWidth: an attempt to exclude noise. Below this threshold the area is discarded. noiseThreshold: value used to calculate the intersectingLine to get the peak limits

className = 'IntegralList'
findLimits(f=20, stdFactor=0.001)[source]
getIntegral(relativeId: str) ccpn.core.Integral.Integral

Get contained ‘ccpn.core.Integral.Integral object by relative ID

property integralListViews: Tuple[ccpn.ui._implementation.IntegralListView.IntegralListView, ...]

- Tuple[ccpn.ui._implementation.IntegralListView.IntegralListView, …], immutable - IntegralListViews showing Spectrum

property integrals

- (‘ccpn.core.Integral.Integral,) - contained Integral objects in creation order. This may differ from the standard sorting order

newIntegral(value: List[float] = None, comment: str = None, **kwds)[source]

Create a new integral within an IntegralList.

See the Integral class for details.

Optional keyword arguments can be passed in; see Integral._newIntegral for details.

Parameters
  • value – (min, max) values in ppm for the integral

  • comment – optional comment string

Returns

a new Integral instance

shortClassName = 'IL'

Short class name, for PID.

ccpn.core.Model module

class ccpn.core.Model.ChainedAssignmentWarningSuppressor(f: Any)[source]

Bases: object

Suppress Pandas’ warnings about chained assignment when using an assignment strategy known to not suffer from chained assignment.

class ccpn.core.Model.Model(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

ccpn.Model - Structural Model, or one member of the structure ensemble.

className = 'Model'
clearData()[source]

Remove all data for model by successively calling the deleteRow method

property data: ccpn.core.Model.ModelData

- ccpn.core.Model.ModelData, immutable - Model data pandas object - a view on the data in the StructureEnsemble.

delete()[source]

Delete should notify structureEnsemble of a delete.

property label: str

- str, mutable - title of Model - a line of free-form text.

property serial: int

- int, immutable - ID number of Model, used in Pid and to identify the Model.

shortClassName = 'MD'

Short class name, for PID.

property structureEnsemble: ccpn.core.StructureEnsemble.StructureEnsemble

- ccpn.core.StructureEnsemble.StructureEnsemble, immutable - StructureEnsemble containing Model.

class ccpn.core.Model.ModelData(model: Optional[ccpn.core.Model.Model] = None)[source]

Bases: object

A view of a single model within an ensemble.

Once created, a ModelData object should behave exactly like an Ensemble. If it doesn’t, please report it as a bug.

Note that ModelData objects are only valid when linked to an existing StructureEnsemble and that self._modelNumber must match.

ccpn.core.Multiplet module

class ccpn.core.Multiplet.Multiplet(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Multiplet object, holding position, intensity, and assignment information

Measurements that require more than one NmrAtom for an individual assignment (such as splittings, J-couplings, MQ dimensions, reduced-dimensionality experiments etc.) are not supported (yet). Assignments can be viewed and set either as a list of assignments for each dimension (dimensionNmrAtoms) or as a list of all possible assignment combinations (assignedNmrAtoms)

addPeaks(peaks: Sequence[ccpn.core.Peak.Peak | str])[source]

Add a peak or list of peaks to the Multiplet. The peaks must belong to the spectrum containing the multipletList.

Parameters

peaks – single peak or list of peaks as objects or pids.

property aliasing: Tuple[Optional[float], ...]

- Tuple[float=None, …], immutable - Aliasing.

property annotation: Optional[str]

- str=None, mutable - Multiplet text annotation.

property axisCodes: Tuple[str, ...]

- Tuple[str, …], immutable - Spectrum axis codes in dimension order matching position.

property boxWidths: Tuple[Optional[float], ...]

- Tuple[float=None, …], immutable - The full width of the peak footprint in points for each dimension, i.e. the width of the area that should be considered for integration, fitting, etc. .

className = 'Multiplet'
property constraintWeight: Optional[float]

- float=None, mutable - constraintWeight of Multiplet.

property figureOfMerit: Optional[float]

- float=None, mutable - figureOfMerit of Multiplet, between 0.0 and 1.0 inclusive.

property height: Optional[float]

- float=None, immutable - height of Multiplet.

property heightError: Optional[float]

- float=None, immutable - height error of Multiplet.

property limits: List[Tuple[float, float]]

- List[Tuple[float, float]], mutable - limits (in dimension order) of the multiplet.

property lineWidths: Tuple[Optional[float], ...]

- Tuple[float=None, …], mutable - Full-width-half-height of peak/multiplet for each dimension.

property multipletList: Optional[ccpn.core.MultipletList.MultipletList]

- ccpn.core.MultipletList.MultipletList=None, immutable - parent containing multiplet.

property numPeaks: int

- int, immutable - return number of peaks in the multiplet.

property offset: Optional[float]

- float=None, mutable - offset of Multiplet.

property peaks: Optional[Tuple[Any, ...]]

- Tuple[Any, …]=None, mutable - List of peaks attached to the multiplet.

property pointLimits: List[Tuple[float, float]]

- List[Tuple[float, float]], mutable - pointLimits (in dimension order) of the multiplet.

property pointLineWidths: Tuple[Optional[float], ...]

- Tuple[float=None, …], immutable - Full-width-half-height of peak for each dimension, in points.

property pointPositions: Optional[Tuple[float, ...]]

- Tuple[float, …]=None, immutable - Multiplet position in points (or other relevant unit) in dimension order calculated as Center Of Mass.

property position: Optional[Tuple[float, ...]]

- Tuple[float, …]=None, immutable - Multiplet position in ppm (or other relevant unit) in dimension order calculated as Center Of Mass.

property positionError: Tuple[Optional[float], ...]

- Tuple[float=None, …], immutable - Peak position error in ppm (or other relevant unit).

property ppmLineWidths: Tuple[Optional[float], ...]

- Tuple[float=None, …], mutable - Full-width-half-height of peak/multiplet for each dimension.

property ppmPositions: Optional[Tuple[float, ...]]

- Tuple[float, …]=None, immutable - Multiplet position in ppm (or other relevant unit) in dimension order calculated as Center Of Mass.

removePeaks(peaks: Sequence[ccpn.core.Peak.Peak | str])[source]

Remove a peak or list of peaks from the Multiplet. The peaks must belong to the multiplet.

Parameters

peaks – single peak or list of peaks as objects or pids

property serial: int

- int, immutable - serial number of Multiplet, used in Pid and to identify the Multiplet.

shortClassName = 'MT'

Short class name, for PID.

property slopes: List[float]

- List[float], mutable - slope (in dimension order) used in calculating multiplet value.

property volume: Optional[float]

- float=None, mutable - volume of Multiplet.

property volumeError: Optional[float]

- float=None, mutable - volume error of Multiplet.

ccpn.core.MultipletList module

class ccpn.core.MultipletList.MultipletList(*args, **kwds)[source]

Bases: ccpn.core._implementation.PMIListABC.PMIListABC

MultipletList object, holding position, intensity, and assignment information

Measurements that require more than one NmrAtom for an individual assignment (such as splittings, J-couplings, MQ dimensions, reduced-dimensionality experiments etc.) are not supported (yet). Assignments can be viewed and set either as a list of assignments for each dimension (dimensionNmrAtoms) or as a list of all possible assignment combinations (assignedNmrAtoms)

className = 'MultipletList'
getMultiplet(relativeId: str) ccpn.core.Multiplet.Multiplet

Get contained ‘ccpn.core.Multiplet.Multiplet object by relative ID

property multipletAveraging: str

- str, mutable - Multiplet averaging method

property multipletListViews: Tuple[ccpn.ui._implementation.MultipletListView.MultipletListView, ...]

- Tuple[ccpn.ui._implementation.MultipletListView.MultipletListView, …], immutable - MultipletListViews showing Spectrum

property multiplets

- (‘ccpn.core.Multiplet.Multiplet,) - contained Multiplet objects in creation order. This may differ from the standard sorting order

newMultiplet()[source]

Create a new Multiplet within a multipletList.

See the Multiplet class for details.

Optional keyword arguments can be passed in; see Multiplet._newMultiplet for details.

Parameters
  • peaks – list of peaks as objects, or pids

  • comment – optional comment string

Returns

a new Multiplet instance.

shortClassName = 'ML'

Short class name, for PID.

ccpn.core.NmrAtom module

class ccpn.core.NmrAtom.NmrAtom(project: ccpn.core.Project.Project, wrappedData)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

NmrAtom objects are used for assignment. An NmrAtom within an assigned NmrResidue is by definition assigned to the Atom with the same name (if any).

NmrAtoms serve as a way of connecting a named nucleus to an observed chemical shift, and peaks are assigned to NmrAtoms. Renaming an NmrAtom (or its containing NmrResidue or NmrChain) automatically updates peak assignments and ChemicalShifts that use the NmrAtom, preserving the link.

assignTo(chainCode: str = None, sequenceCode: int | str = None, residueType: str = None, name: str = None, mergeToExisting=False) ccpn.core.NmrAtom.NmrAtom[source]

Assign NmrAtom to naming parameters) and return the reassigned result

If the assignedTo NmrAtom already exists the function raises ValueError. If mergeToExisting is True it instead merges the current NmrAtom into the target and returns the merged target. NB Merging is NOT undoable

WARNING: is mergeToExisting is True, always use in the form “x = x.assignTo(…)”, as the call ‘x.assignTo(…) may cause the source x object to be deleted.

Passing in empty parameters (e.g. chainCode=None) leaves the current value unchanged. E.g.: for NmrAtom NR:A.121.ALA.HA calling with sequenceCode=124 will assign to (chainCode=’A’, sequenceCode=124, residueType=’ALA’, atomName=’HA’)

The function works as:

nmrChain = project.fetchNmrChain(shortName=chainCode)

nmrResidue = nmrChain.fetchNmrResidue(sequenceCode=sequenceCode, residueType=residueType)

(or nmrChain.fetchNmrResidue(sequenceCode=sequenceCode) if residueType is None)

property assignedPeaks: Tuple[Peak]

- Tuple[ForwardRef(‘Peak’)], immutable - All Peaks assigned to the NmrAtom

property atom: Atom

- ‘Atom’, immutable - Atom to which NmrAtom is assigned. NB resetting the atom will rename the NmrAtom

property boundNmrAtoms: ccpn.core.NmrAtom.NmrAtom

- ‘NmrAtom’, immutable - NmrAtoms directly bound to this one, as calculated from assignment and NmrAtom name matches (NOT from peak assignment)

property chemicalShifts: tuple

- tuple, immutable - Return the chemicalShifts containing the nmrAtom

className = 'NmrAtom'
deassign()[source]

Reset NmrAtom back to its originalName, cutting all assignment links

delete()[source]

Delete self and update the chemicalShift values

property isotopeCode: str

- str, immutable - isotopeCode of NmrAtom. Used to facilitate the nmrAtom assignment.

mergeNmrAtoms(nmrAtoms: ccpn.core.NmrAtom.NmrAtom | Sequence[ccpn.core.NmrAtom.NmrAtom])[source]
property name: str

- str, mutable - Atom name string (e.g. ‘HA’)

property nmrResidue: ccpn.core.NmrResidue.NmrResidue

- ccpn.core.NmrResidue.NmrResidue, immutable - Parent (containing) object.

rename(value: str = None)[source]

Rename the NmrAtom, changing its name, Pid, and internal representation.

property serial: int

- int, immutable - NmrAtom serial number - set at creation and unchangeable

shortClassName = 'NA'

Short class name, for PID.

ccpn.core.NmrChain module

class ccpn.core.NmrChain.NmrChain(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

NmrChains are used for NMR assignment. An NmrChain is by definition assigned to the Chain with the same shortName (if any).

An NmrChain created without a name will be given the name @ij’, where ij is the serial number of the NmrChain. Names of this form are reserved. Setting the NmrChain shortName to None will revert to this default name.

The order of NmrResidues within an NmrChain is not significant (they are given in sorted order). NmrChains with isConnected==True are used to describe connected but as yet unassigned stretches of NmrResidues, and here the NmrResidues are given in sequential order (N-terminal to C-terminal for proteins). Connected NmrChains have names of the form ‘#ij’ where ij is the serial number of the NmrChain, and cannot be renamed. Names of this form are reserved.

assignConnectedResidues(firstResidue: ccpn.core.Residue.Residue | str)[source]

Assign all NmrResidues in connected NmrChain sequentially, with the first NmrResidue assigned to firstResidue.

Returns ValueError if NmrChain is not connected, or if any of the Residues are missing or already assigned

assignSingleResidue(thisNmrResidue: NmrResidue, firstResidue: Residue | str)[source]

Assign a single unconnected residue from the default ‘@-’ chain

property chain: ccpn.core.Chain.Chain

- ccpn.core.Chain.Chain, immutable - Chain to which NmrChain is assigned

className = 'NmrChain'
deassign()[source]

Reset NmrChain back to its originalName, cutting all assignment links

fetchNmrResidue(sequenceCode: int | str = None, residueType: str = None)[source]

Fetch NmrResidue with sequenceCode=sequenceCode and residueType=residueType, creating it if necessary.

if sequenceCode is None will create a new NmrResidue.

if bool(residueType) is False will return any existing NmrResidue that matches the sequenceCode.

Parameters
  • sequenceCode

  • residueType

Returns

an NmrResidue instance.

getNmrAtom(relativeId: str) ccpn.core.NmrAtom.NmrAtom

Get contained ‘ccpn.core.NmrAtom.NmrAtom object by relative ID

getNmrResidue(relativeId: str) ccpn.core.NmrResidue.NmrResidue

Get contained ‘ccpn.core.NmrResidue.NmrResidue object by relative ID

property isConnected: bool

- bool, immutable - True if this this NmrChain is a connected stretch (in which case the mainNmrResidues are sequentially connected).

property label: str

- str, mutable - Identifying label of NmrChain. Defaults to ‘?’

property mainNmrResidues: Tuple[NmrResidue]

- Tuple[ForwardRef(‘NmrResidue’)], mutable - NmrResidues belonging to NmrChain that are NOT defined relative to another NmrResidue (sequenceCode ending in ‘-1’, ‘+1’, etc.) For connected NmrChains in sequential order, otherwise sorted by assignment

property name: str

- str, mutable - short form of name, used in Pid and to identify the NmrChain Names of the form ‘@ijk’ and ‘#ijk’ (where ijk is an integers) are reserved and cannot be set. They can be obtained by the deassign command. Connected NmrChains (isConnected == True) always have canonical names of the form ‘#ijk’

newNmrResidue(sequenceCode: int | str = None, residueType: str = None, comment: str = None)[source]

Create new NmrResidue within NmrChain.

If NmrChain is connected, append the new NmrResidue to the end of the stretch.

Parameters
  • sequenceCode

  • residueType

  • comment

Returns

a new NmrResidue instance.

property nmrAtoms

- (‘ccpn.core.NmrAtom.NmrAtom,) - contained NmrAtom objects in creation order. This may differ from the standard sorting order

property nmrResidues

- (‘ccpn.core.NmrResidue.NmrResidue,) - contained NmrResidue objects in sequential order (for assigned or connected NmrChains), otherwise in creation order. This is identical to the standard sorting order.

rename(value: str)[source]

Rename NmrChain, changing its shortName and Pid. Use the ‘deassign’ function if you want to revert to the canonical name

renumberNmrResidues(offset: int, start: int = None, stop: int = None)[source]

Renumber nmrResidues in range start-stop (inclusive) by adding offset

The nmrResidue number is the integer starting part of the sequenceCode, e.g. nmrResidue ‘12B’ is renumbered to ‘13B’ (offset=1) and e.g. nmrResidue @119’ is ignored

if start (stop) is None, there is no lower (upper) limit

NB Will rename nmrResidues one by one, and stop on error.

reverse(_force=False)[source]

Reverse order of NmrResidues within NmrChain

Illegal for assigned NmrChains, and only relevant for connected NmrChains. Serves mainly as building block to make disconnections easier to undo

property serial: int

- int, immutable - NmrChain serial number - set at creation and unchangeable

shortClassName = 'NC'

Short class name, for PID.

property shortName: str

- str, immutable - short form of name, used in Pid and to identify the NmrChain Names of the form ‘@ijk’ and ‘#ijk’ (where ijk is an integers) are reserved and cannot be set. They can be obtained by the deassign command. Connected NmrChains (isConnected == True) always have canonical names of the form ‘#ijk’

ccpn.core.NmrResidue module

Module documentation here

class ccpn.core.NmrResidue.NmrResidue(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Nmr Residues are used for assignment. An NmrResidue within an assigned NmrChain is by definition assigned to the Residue with the same sequenceCode (if any). An NmrResidue is defined by its containing chain and sequenceCode, so you cannot have two NmrResidues with the same NmrChain and sequenceCode but different residueType.

An NmrResidue created without a name will be given the name @ij’, where ij is the serial number of the NmrResidue. Names of this form are reserved. Setting the NmrResidue sequenceCode to None will revert to this default name.

An NmrResidue can be defined by a sequential offset relative to another NmrResidue. E.g. the NmrResidue i-1 relative to NmrResidue @5.@185.ALA would be named @5.@185-1.VAL. Reassigning NR:@5.@185.ALA to NR:B.do1.ALA or NR:B.125.THR, would cause the offset NmrResidue to be reassigned to NR:B.do1-1.VAL or NR:B.125-1.VAL, respectively. Offsets can be any integer (including ‘+0’).

NmrResidues that are not offset can be linked into consecutive stretches by putting them into connected NmrChains (see NmrChain).

NmrResidue objects behave in there different ways when sorted:

  • If they are assigned to a Residue they sort like the Residue, in sequential order

  • If they belong to a connected NmrChain, they sort by the order they appear in the NmrChain.

  • In other 4cases they sort by creation order.

  • Offset NmrResidues in all cases sort alongside their main NmrResidue, by offset.

assignTo(chainCode: str = None, sequenceCode: int | str = None, residueType: str = None, mergeToExisting: bool = False) ccpn.core.NmrResidue.NmrResidue[source]

Assign NmrResidue to new assignment, as defined by the naming parameters and return the result.

Empty parameters (e.g. chainCode=None) retain the previous value. E.g.: for NmrResidue NR:A.121.ALA calling with sequenceCode=123 will reassign to ‘A.123.ALA’.

If no assignment with the same chainCode and sequenceCode exists, the current NmrResidue will be reassigned. If an NmrResidue with the same chainCode and sequenceCode already exists, the function will either raise ValueError. If mergeToExisting is set to False, it will instead merge the two NmrResidues, delete the current one, and return the new one . NB Merging is NOT undoable. WARNING: When calling with mergeToExisting=True, always use in the form “x = x.assignTo(…)”, as the call ‘x.assignTo(…) may cause the source x object to become deleted.

NB resetting the NmrChain for an NmrResidue in the middle of a connected NmrChain will cause an error. Use moveToNmrChain(newNmrChainOrPid) instead

className = 'NmrResidue'
connectNext(nmrResidue: ccpn.core.NmrResidue.NmrResidue | str) ccpn.core.NmrChain.NmrChain[source]

Connect free end of self to free end of next residue in sequence, and return resulting connected NmrChain

Raises error if self is assigned, or if either self or value is offset.

NB Undoing a connection between two connected stretches will get back a ‘value’ stretch with a new shortName

connectPrevious(nmrResidue=None) ccpn.core.NmrChain.NmrChain[source]

Connect free end of self to free end of previous residue in sequence, and return resulting connected NmrChain

Raises error if self is assigned, or if either self or value is offset.

NB Undoing a connection between two connected stretches will get back a ‘value’ stretch with a new shortName

deassign()[source]

Reset sequenceCode and residueType assignment to default values

deassignNmrChain()[source]
delete()[source]

Delete routine to check whether the item can be deleted otherwise raise api error.

disconnect()[source]
disconnectAll()[source]
disconnectNext() Optional[ccpn.core.NmrChain.NmrChain][source]
disconnectPrevious()[source]
fetchNmrAtom(name: str, isotopeCode: Optional[str] = None)[source]

Fetch NmrAtom with name=name, creating it if necessary

Parameters
  • name – string name for new nmrAtom if created

  • isotopeCode – optional isotope code only used for a new nmrAtom.

Returns

new or existing nmrAtom

getNmrAtom(relativeId: str) ccpn.core.NmrAtom.NmrAtom

Get contained ‘ccpn.core.NmrAtom.NmrAtom object by relative ID

getOffsetNmrResidue(offset: int) Optional[ccpn.core.NmrResidue.NmrResidue][source]

Get offset NmrResidue with indicated offset (or None, if no such offset NmrResidue exists

property mainNmrResidue: Optional[ccpn.core.NmrResidue.NmrResidue]

- ForwardRef(‘NmrResidue’)=None, immutable - Main NmrResidue (self, or the residue that self is offset relative to

mergeNmrResidues(nmrResidues: Sequence[ccpn.core.NmrResidue.NmrResidue])[source]
moveToNmrChain(newNmrChain: ccpn.core.NmrChain.NmrChain | str = 'NC:@-', sequenceCode: str = None, residueType: str = None)[source]

Move residue to newNmrChain, breaking connected NmrChain if necessary. Optionally rename residue using sequenceCode and residueType

newNmrChain default resets to NmrChain ‘@-’ Routine is illegal for offset NmrResidues, use the main nmrResidue instead

Routine will fail if current sequenceCode,residueType already exists in newNmrChain, as the nmrResidue is first moved then renamed; consider moving to temporary chain first.

newNmrAtom(name: str = None, isotopeCode: str = None, comment: str = None, **kwds)[source]
Create new NmrAtom within NmrResidue. If name is None, use default name

(of form e.g. @_123, @H_211’, @N_45’, …)

See the NmrAtom class for details

Parameters
  • name – string name of the new nmrAtom

  • isotopeCode – isotope code

  • comment – optional string comment

Returns

a new NmrAtom instance.

property nextNmrResidue: Optional[ccpn.core.NmrResidue.NmrResidue]

- ForwardRef(‘NmrResidue’)=None, immutable - Next sequentially connected NmrResidue (or None, as appropriate). Either from a connected NmrChain, or the NmrResidue assigned to the next Residue in the same Chain

property nmrAtoms

- (‘ccpn.core.NmrAtom.NmrAtom,) - contained NmrAtom objects in creation order. This may differ from the standard sorting order

property nmrChain: ccpn.core.NmrChain.NmrChain

- ccpn.core.NmrChain.NmrChain, immutable - NmrChain containing NmrResidue. Use self.assignTo to reset the NmrChain

property offsetNmrResidues: Tuple[ccpn.core.NmrResidue.NmrResidue, ...]

- Tuple[ForwardRef(‘NmrResidue’), …], immutable - “All other NmrResidues with the same sequenceCode sorted by offSet suffix ‘-1’, ‘+1’, etc.

property previousNmrResidue: Optional[ccpn.core.NmrResidue.NmrResidue]

- ForwardRef(‘NmrResidue’)=None, immutable - Previous sequentially connected NmrResidue (or None, as appropriate). Either from a connected NmrChain, or the NmrResidue assigned to the previous Residue in the same Chain

property probableResidueTypes: Tuple[Tuple[str, float]]

- Tuple[Tuple[str, float]], mutable - tuple of (residueType, probability) tuples for probable residue types sorted by decreasing probability

property probableResidues: Tuple[Tuple[ccpn.core.Residue.Residue, float], ...]

- Tuple[Tuple[ccpn.core.Residue.Residue, float], …], mutable - tuple of (residue, probability) tuples for probable residue assignments sorted by decreasing probability. Probabilities are normalised to 1

property relativeOffset: Optional[int]

- int=None, immutable - Sequential offset of NmrResidue relative to mainNmrResidue May be 0. Is None for residues that are not offset.

rename(sequenceCode: str = None, residueType: str = None)[source]

Rename NmrResidue. changing its sequenceCode and residueType.

Specifying None for the sequenceCode will reset the nmrResidue to its canonical form, ‘@<serial>.

property residue: ccpn.core.Residue.Residue

- ccpn.core.Residue.Residue, immutable - Residue to which NmrResidue is assigned

property residueType: str

- str, mutable - Residue type string (e.g. ‘ALA’). Part of id. Use self.assignTo or self.rename to reset the residueType

property sequenceCode: str

- str, immutable - Residue sequence code and id (e.g. ‘1’, ‘127B’, ‘@157+1) Names of the form ‘@ijk’, ‘@ijk+n’, and ‘@ijk-n’ (where ijk and n are integers) are reserved and cannot be set. They are obtained by the deassign command.

property serial: int

- int, immutable - NmrResidue serial number - set at creation and unchangeable

shortClassName = 'NR'

Short class name, for PID.

unlinkNextNmrResidue()[source]
unlinkPreviousNmrResidue()[source]

ccpn.core.Note module

class ccpn.core.Note.Note(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Project note.

className = 'Note'
property created: Optional[str]

- str=None, mutable - Note creation time

property header: Optional[str]

- str=None, immutable - Note header == first line of note

property lastModified: str

- str, mutable - Note last modification time

property name: str

- str, mutable - Name of note, part of identifier

rename(value: str)[source]

Rename Note, changing its name and Pid.

property serial: int

- int, immutable - serial number of note - immutable, part of identifier

shortClassName = 'NO'

Short class name, for PID.

property text: str

- str, mutable - Free-form text comment

ccpn.core.Peak module

class ccpn.core.Peak.Peak(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Peak object, holding position, intensity, and assignment information

Measurements that require more than one NmrAtom for an individual assignment (such as splittings, J-couplings, MQ dimensions, reduced-dimensionality experiments etc.) are not supported (yet). Assignments can be viewed and set either as a list of assignments for each dimension (dimensionNmrAtoms) or as a list of all possible assignment combinations (assignedNmrAtoms)

addAssignment(value: Sequence[str | ccpn.core.NmrAtom.NmrAtom])[source]

Add a peak assignment - a list of one NmrAtom or Pid for each dimension

property aliasing: Tuple[Optional[float], ...]

- Tuple[float=None, …], mutable - Aliasing for the peak in each dimension. Defined as integer number of spectralWidths added or subtracted along each dimension

property annotation: Optional[str]

- str=None, mutable - Peak text annotation.

assignDimension(axisCode: str, value: str | ccpn.core.NmrAtom.NmrAtom, Sequence[Union[str, ccpn.core.NmrAtom.NmrAtom]] = None)[source]

Assign dimension with axisCode to value (NmrAtom, or Pid or sequence of either, or None).

property assignedNmrAtoms: Tuple[Tuple[Optional[ccpn.core.NmrAtom.NmrAtom], ...], ...]

- Tuple[Tuple[ForwardRef(‘NmrAtom’)=None, …], …], mutable - Peak assignment - a tuple of tuples of NmrAtom combinations. (e.g. a tuple of triplets for a 3D spectrum). One of two alternative views on the Peak assignment. Missing assignments are entered as None.

Example, for 13H HSQC::

((<NA:A.127.LEU.HA>, <NA:A.127.LEU.CA>),

(<NA:A.127.LEU.HBX>, <NA:A.127.LEU.CB>),

(<NA:A.127.LEU.HBY>, <NA:A.127.LEU.CB>),

(<NA:A.127.LEU.HG>, None),)

To add a single assignment tuple, use the Peak.addAssignment method

See also dimensionNmrAtoms, which gives assignments per dimension.

property assignments: Tuple[Tuple[Optional[ccpn.core.NmrAtom.NmrAtom], ...], ...]

- Tuple[Tuple[ForwardRef(‘NmrAtom’)=None, …], …], mutable - Peak assignment - a tuple of tuples of NmrAtom combinations. (e.g. a tuple of triplets for a 3D spectrum). One of two alternative views on the Peak assignment. Missing assignments are entered as None.

Example, for 13H HSQC::

((<NA:A.127.LEU.HA>, <NA:A.127.LEU.CA>),

(<NA:A.127.LEU.HBX>, <NA:A.127.LEU.CB>),

(<NA:A.127.LEU.HBY>, <NA:A.127.LEU.CB>),

(<NA:A.127.LEU.HG>, None),)

To add a single assignment tuple, use the Peak.addAssignment method

See also dimensionNmrAtoms, which gives assignments per dimension.

property assignmentsByDimensions: Tuple[Tuple[ccpn.core.NmrAtom.NmrAtom, ...], ...]

- Tuple[Tuple[ForwardRef(‘NmrAtom’), …], …], mutable - Peak dimension assignment - a tuple of tuples with the assigned NmrAtoms for each dimension. One of two alternative views on the Peak assignment.

Example, for a 13C HSQC:

((<NA:A.127.LEU.HA>, <NA:A.127.LEU.HBX>, <NA:A.127.LEU.HBY>, <NA:A.127.LEU.HG>,

(<NA:A.127.LEU.CA>, <NA:A.127.LEU.CB>) )

Assignments as a list of individual combinations is given in ‘assignedNmrAtoms’. Note that by setting dimensionAssignments you tel the program that all combinations are possible - in the example that all four protons could be bound to either of the carbons

To (re)set the assignment for a single dimension, use the Peak.assignDimension method.

property axisCodes: Tuple[str, ...]

- Tuple[str, …], immutable - Spectrum axis codes in dimension order matching position.

property boxWidths: Tuple[Optional[float], ...]

- Tuple[float=None, …], mutable - The full width of the peak footprint in points for each dimension, i.e. the width of the area that should be considered for integration, fitting, etc.

property chemicalShiftList

- None, immutable - Convenience property to get the spectrum, equivalent to peak.peakList.chemicalShiftList

className = 'Peak'
property clusterId

- None, mutable - Get the clusterId for the peak

copyTo(targetPeakList: ccpn.core.PeakList.PeakList, includeAllProperties: bool = True) ccpn.core.Peak.Peak[source]

Make (and return) a copy of the Peak in targetPeakList. IncludeAll, True to copy all properties from origin to target Peak. False will copy only position and assignments (if available)

delete()[source]

Delete a peak.

property dimensionNmrAtoms: Tuple[Tuple[ccpn.core.NmrAtom.NmrAtom, ...], ...]

- Tuple[Tuple[ForwardRef(‘NmrAtom’), …], …], mutable - Peak dimension assignment - a tuple of tuples with the assigned NmrAtoms for each dimension. One of two alternative views on the Peak assignment.

Example, for a 13C HSQC:

((<NA:A.127.LEU.HA>, <NA:A.127.LEU.HBX>, <NA:A.127.LEU.HBY>, <NA:A.127.LEU.HG>,

(<NA:A.127.LEU.CA>, <NA:A.127.LEU.CB>) )

Assignments as a list of individual combinations is given in ‘assignedNmrAtoms’. Note that by setting dimensionAssignments you tel the program that all combinations are possible - in the example that all four protons could be bound to either of the carbons

To (re)set the assignment for a single dimension, use the Peak.assignDimension method.

estimateVolume(volumeIntegralLimit=2.0)[source]

Estimate the volume of the peak from a gaussian distribution. The width of the volume integral in each dimension is the lineWidth (FWHM) * volumeIntegralLimit, the default is 2.0 * FWHM of the peak. :param volumeIntegralLimit: integral width as a multiple of lineWidth (FWHM)

property figureOfMerit: Optional[float]

- float=None, mutable - figureOfMerit of Peak, between 0.0 and 1.0 inclusive.

fit(fitMethod=None, halfBoxSearchWidth=2, keepPosition=False, iterations=10)[source]

Fit the peak to recalculate position and lineWidths. Use peak.estimateVolume to recalculate the volume.

Parameters
  • fitMethod – str, one of [‘gaussian’, ‘lorentzian’, ‘parabolic’] Default: the fitting method defined in the general preferences. If not given or not included in the available options, it uses the default.

  • halfBoxSearchWidth – int. Default: 2. Used to increase the searching area limits from the initial position.

  • keepPosition – bool. Default: False. if True, reset to the original position after applying the fitting method. Height is calculated using spectrum.getHeight()

  • iterations – int. Default: 3. How many times the fitting method will run before it converges.

Returns

None.

getByAxisCodes(parameterName: str, axisCodes: Optional[Sequence[str]] = None, exactMatch: bool = False) list[source]

Return a list of values defined by parameterName in order defined by axisCodes (default order if None). Perform a mapping if exactMatch=False (eg. ‘H’ to ‘Hn’)

Parameters
  • parameterName – a str denoting a Spectrum dimensional attribute

  • axisCodes – a tuple or list of axisCodes

  • exactMatch – a boolean optional testing for an exact match with the instance axisCodes

Returns

the values defined by parameterName in axisCode order

Related: Use getByDimensions() for dimensions (1..dimensionCount) based access of dimensional parameters of the

Peak class.

getByDimensions(parameterName: str, dimensions: Optional[Sequence[int]] = None) list[source]

Return a list of values of Peak dimensional attribute parameterName in order defined by dimensions (default order if None).

Parameters
  • parameterName – a str denoting a Spectrum dimensional attribute

  • dimensions – a tuple or list of dimensions (1..dimensionCount)

Returns

the values defined by parameterName in dimensions order

Related: Use getByAxisCodes() for axisCode based access of dimensional parameters of the Spectrum class.

getInAxisOrder(attributeName: str, axisCodes: Optional[Sequence[str]] = None)[source]

Get attributeName in order defined by axisCodes : (default order if None)

property height: Optional[float]

- float=None, mutable - height of Peak.

property heightError: Optional[float]

- float=None, mutable - height error of Peak.

property integral

- None, mutable - Return the integral attached to the peak.

isFullyAssigned()[source]

Whether peak is fully assigned.

isPartlyAssigned()[source]

Whether peak is partly assigned.

property lineWidths: Tuple[Optional[float], ...]

- Tuple[float=None, …], mutable - Full-width-half-height of peak for each dimension, in Hz/ppm.

property multiplets: Optional[Tuple[Any]]

- Tuple[Any]=None, immutable - List of multiplets containing the Peak.

property peakList: Optional[ccpn.core.PeakList.PeakList]

- ccpn.core.PeakList.PeakList=None, immutable - PeakList containing Peak.

property pointLineWidths: Tuple[Optional[float], ...]

- Tuple[float=None, …], mutable - Full-width-half-height of peak for each dimension, in points.

property pointPositions: Tuple[float, ...]

- Tuple[float, …], mutable - Peak position in points.

property position: Tuple[float, ...]

- Tuple[float, …], mutable - Peak position in ppm (or other relevant unit) in dimension order.

property positionError: Tuple[Optional[float], ...]

- Tuple[float=None, …], mutable - Peak position error in ppm (or other relevant unit).

property ppmLineWidths: Tuple[Optional[float], ...]

- Tuple[float=None, …], mutable - Full-width-half-height of peak for each dimension, in Hz/ppm.

property ppmPositions: Tuple[float, ...]

- Tuple[float, …], mutable - Peak position in ppm (or other relevant unit) in dimension order.

reorderValues(values, newAxisCodeOrder)[source]

Reorder values in spectrum dimension order to newAxisCodeOrder by matching newAxisCodeOrder to spectrum axis code order.

property restraints: Tuple[ccpn.core.Restraint.Restraint, ...]

- Tuple[ccpn.core.Restraint.Restraint, …], mutable - Restraints corresponding to Peak

property serial: int

- int, immutable - serial number of Peak, used in Pid and to identify the Peak.

setByAxisCodes(parameterName: str, values: Sequence, axisCodes: Optional[Sequence[str]] = None, exactMatch: bool = False) list[source]

Set attributeName to values in order defined by axisCodes (default order if None) Perform a mapping if exactMatch=False (eg. ‘H’ to ‘Hn’)

Parameters
  • parameterName – a str denoting a Spectrum dimensional attribute

  • values – an iterable with values

  • axisCodes – a tuple or list of axisCodes

  • exactMatch – a boolean optional testing for an exact match with the instance axisCodes

Returns

a list of newly set values of parameterName (in default order)

Related: Use setByDimensions() for dimensions (1..dimensionCount) based setting of dimensional parameters of the

Peak class.

setByDimensions(parameterName: str, values: Sequence, dimensions: Optional[Sequence[int]] = None) list[source]

Set Spectrum dimensional attribute parameterName to values in the order as defined by dimensions (1..dimensionCount)(default order if None)

Parameters
  • parameterName – a str denoting a Spectrum dimensional attribute

  • dimensions – a tuple or list of dimensions (1..dimensionCount)

Returns

a list of newly set values of parameterName (in default order)

Related: Use setByAxisCodes() for axisCode based setting of dimensional parameters of the Spectrum class.

setInAxisOrder(attributeName: str, values: Sequence[Any], axisCodes: Optional[Sequence[str]] = None)[source]

Set attributeName from values in order defined by axisCodes (default order if None)

shortClassName = 'PK'

Short class name, for PID.

property signalToNoiseRatio

- None, immutable - :return: float. Estimated Signal to Noise ratio based on the spectrum noiseLevel values. SNratio = |factor*(height/DeltaNoise)|

height: peak height DeltaNoise: spectrum noise levels factor: multiplication factor. Default: 2.5

snapToExtremum(halfBoxSearchWidth: int = 4, halfBoxFitWidth: int = 4, minDropFactor: float = 0.1, fitMethod: str = 'parabolic', searchBoxMode=False, searchBoxDoFit=False)[source]

Snap the Peak to the closest local extrema, if within range.

property spectrum

- None, immutable - Convenience property to get the spectrum, equivalent to peak.peakList.spectrum

property volume: Optional[float]

- float=None, mutable - volume of Peak.

property volumeError: Optional[float]

- float=None, mutable - volume error of Peak.

ccpn.core.PeakCluster module

class ccpn.core.PeakCluster.PeakCluster(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

PeakCluster object, holding position, intensity, and assignment information.

Measurements that require more than one NmrAtom for an individual assignment (such as splittings, J-couplings, MQ dimensions, reduced-dimensionality experiments etc.) are not supported (yet). Assignments can be viewed and set either as a list of assignments for each dimension (dimensionNmrAtoms) or as a list of all possible assignment combinations (assignedNmrAtoms).

addPeaks(peaks: Sequence[ccpn.core.Peak.Peak | str])[source]

Add a peak or list of peaks to the peakCluster. The peaks must belong to the spectrum containing the multipletList.

Parameters

peaks – single peak or list of peaks, as objects or pid strings.

property annotation: Optional[str]

- str=None, mutable - Peak text annotation

className = 'PeakCluster'
property numPeaks: int

- int, immutable - return number of peaks in the peakCluster

property peakClusterParent: Optional[ccpn.core.Project.Project]

- ForwardRef(‘Project’)=None, immutable - parent containing peakCluster.

property peaks: Optional[Tuple[Any]]

- Tuple[Any]=None, immutable - List of peaks attached to the peakCluster

removePeaks(peaks: Sequence[ccpn.core.Peak.Peak | str])[source]

Remove a peak or list of peaks from the peakCluster. The peaks must belong to the peakCluster.

Parameters

peaks – single peak or list of peaks, as objects or pid strings.

property serial: int

- int, immutable - serial number of PeakCluster, used in Pid and to identify the PeakCluster.

shortClassName = 'PC'

Short class name, for PID.

ccpn.core.PeakList module

class ccpn.core.PeakList.PeakList(*args, **kwds)[source]

Bases: ccpn.core._implementation.PMIListABC.PMIListABC

An object containing Peaks. Note: the object is not a (subtype of a) Python list. To access all Peak objects, use PeakList.peaks.

calculateClusterIds(tolerances=None, clustererName=None)[source]

Calculate clusterIDs for peaks using the in Depth-First-Search (DFS) algorithm.

property chemicalShiftList: ccpn.core.ChemicalShiftList.ChemicalShiftList

- ccpn.core.ChemicalShiftList.ChemicalShiftList, mutable - ChemicalShiftList associated with PeakList.

className = 'PeakList'
copyTo(targetSpectrum: ccpn.core.Spectrum.Spectrum, targetPeakList=None, includeAllPeakProperties=True, **kwargs) ccpn.core.PeakList.PeakList[source]

Copy the origin PeakList peaks to a targetSpectrum. If targetPeakList is given, peaks will be added to it, otherwise a new PeakList is created (default behaviour). return the target PeakList with the newly copied peaks.

Parameters
  • targetSpectrum – object: Core.Spectrum or Str: Pid

  • targetPeakList – object: Core.PeakList or Str: Pid

  • kwargs – any extra PeakList attributes for newly created peakLists. Not used if it is given a targetPeakList

delete()[source]

Delete peakList

estimateVolumes(volumeIntegralLimit=2.0)[source]

Estimate the volumes for the peaks in this peakList The width of the volume integral in each dimension is the lineWidth * volumeIntegralLimit, the default is 2.0 * FWHM of the peak. :param volumeIntegralLimit: integral width as a multiple of lineWidth (FWHM)

fitExistingPeaks(peaks: Sequence[Peak], fitMethod: str = 'gaussian', singularMode: bool = True, halfBoxSearchWidth: int = 2, halfBoxFitWidth: int = 2)[source]

Refit the current selected peaks. Must be called with peaks that belong to this peakList

getPeak(relativeId: str) ccpn.core.Peak.Peak

Get contained ‘ccpn.core.Peak.Peak object by relative ID

getPeakAliasingRanges()[source]

Return the min/max aliasing values for the peaks in the list, if there are no peaks, return None

newPeak(ppmPositions: Sequence[float] = (), height: float = None, comment: str = None, **kwds)[source]

Create a new Peak within a peakList.

See the Peak class for details.

Optional keyword arguments can be passed in; see Peak._newPeak for details.

NB you must create the peak before you can assign it. The assignment attributes are: - assignments (assignedNmrAtoms) - A tuple of all (e.g.) assignment triplets for a 3D spectrum - assignmentsByDimensions (dimensionNmrAtoms) - A tuple of tuples of assignments, one for each dimension

Parameters
  • ppmPositions – peak position in ppm for each dimension (related attributes: positionError, pointPositions)

  • height – height of the peak (related attributes: volume, volumeError, lineWidths)

  • comment – optional comment string

Returns

a new Peak instance.

newPickedPeak(pointPositions: Sequence[float] = None, height: float = None, lineWidths: Sequence[float] = (), fitMethod: str = 'parabolic', **kwds)[source]

Create a new Peak within a peakList from a picked peak

See the Peak class for details.

Optional keyword arguments can be passed in; see Peak._newPickedPeak for details.

Parameters
  • height – height of the peak (related attributes: volume, volumeError, lineWidths)

  • pointPositions – peak position in points for each dimension (related attributes: positionError, pointPositions)

  • fitMethod – type of curve fitting

  • lineWidths

  • serial – optional serial number.

Returns

a new Peak instance.

property peakListViews: Tuple[ccpn.ui._implementation.PeakListView.PeakListView, ...]

- Tuple[ccpn.ui._implementation.PeakListView.PeakListView, …], immutable - PeakListViews showing Spectrum

property peaks

- (‘ccpn.core.Peak.Peak,) - contained Peak objects in creation order. This may differ from the standard sorting order

pickPeaksNd(regionToPick: Optional[Sequence[float]] = None, doPos: bool = True, doNeg: bool = True, fitMethod: str = 'gaussian', excludedRegions=None, excludedDiagonalDims=None, excludedDiagonalTransform=None, minDropFactor: float = 0.1)[source]
pickPeaksRegion(regionToPick: dict = {}, doPos: bool = True, doNeg: bool = True, minLinewidth=None, exclusionBuffer=None, minDropFactor: float = 0.1, checkAllAdjacent: bool = True, fitMethod: str = 'parabolic', excludedRegions=None, excludedDiagonalDims=None, excludedDiagonalTransform=None, estimateLineWidths=True)[source]
reorderPeakListAxes(newAxisOrder)[source]

Reorder the peak position according to the newAxisOrder

reorderValues(values, newAxisCodeOrder)[source]

Reorder values in spectrum dimension order to newAxisCodeOrder by matching newAxisCodeOrder to spectrum axis code order

resetClusterIds()[source]

Reset clusterIDs to a default enumeration.

restrictedPick(positionCodeDict, doPos, doNeg)[source]
shortClassName = 'PL'

Short class name, for PID.

subtractPeakLists(peakList: ccpn.core.PeakList.PeakList) ccpn.core.PeakList.PeakList[source]

Subtracts peaks in peakList2 from peaks in peakList1, based on position, and puts those in a new peakList3. Assumes a common spectrum for now.

ccpn.core.Project module

class ccpn.core.Project.Project(wrappedData: ccpnmodel.ccpncore.api.ccp.nmr.Nmr.NmrProject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

The Project is the object that contains all data objects and serves as the hub for navigating between them.

There are 15 top-level data objects directly within a project, of which 8 have child objects of their own, e.g. Spectrum, Sample, Chain, NmrChain, ChemicalShiftList, DataSet and StructureEnsemble. The child data objects are organised in a logical hierarchy; for example, a Spectrum has PeakLists, which in turn, are made up of Peaks, whereas a Chain is made up of Residues, which are made up of Atoms.

property application

- None, immutable -

property archivesPath: ccpn.util.Path.Path

- ccpn.util.Path.Path, immutable - :return: the absolute path to the archives sub-directory of the current project

as a Path instance

property atoms

- (‘ccpn.core.Atom.Atom,) - contained Atom objects in name order This is identical to the standard sorting order.

property axes

- (‘ccpn.ui._implementation.Axis.Axis,) - contained Axis objects in order of underlying key. This may differ from the standard sorting order

property backupPath

- None, immutable - path to directory containing backup Project

blankNotification()[source]

Disable notifiers temporarily e.g. to disable ‘object modified’ notifiers during object creation

Caller is responsible to make sure necessary notifiers are called, and to unblank after use

blockWaypoints()[source]

Block the setting of undo waypoints, so that command echoing (_startCommandBLock) does not set waypoints

NB The programmer must GUARANTEE (try: … finally) that waypoints are unblocked again

property calculationSteps

- (‘ccpn.core.CalculationStep.CalculationStep,) - contained CalculationStep objects in creation order. This may differ from the standard sorting order

property chains

- (‘ccpn.core.Chain.Chain,) - contained Chain objects in name order This is identical to the standard sorting order.

property chemicalShiftLists

- (‘ccpn.core.ChemicalShiftList.ChemicalShiftList,) - contained ChemicalShiftList objects in creation order. This may differ from the standard sorting order

property chemicalShifts

- None, immutable - Return the list of chemicalShifts in the project

className = 'Project'
close()[source]

Clean up the wrapper project previous to deleting or replacing Cleanup includes wrapped data graphics objects (e.g. Window, Strip, …)

property collections

- None, immutable - Return the list of collections in the project

property complexes

- (‘ccpn.core.Complex.Complex,) - contained Complex objects in creation order. This may differ from the standard sorting order

createChain(sequence: str | Sequence[str], compoundName: str = None, startNumber: int = 1, molType: str = None, isCyclic: bool = False, shortName: str = None, role: str = None, comment: str = None, expandFromAtomSets: bool = True, addPseudoAtoms: bool = True, addNonstereoAtoms: bool = True, **kwds)[source]

Create new chain from sequence of residue codes, using default variants.

Automatically creates the corresponding polymer Substance if the compoundName is not already taken

See the Chain class for details.

Optional keyword arguments can be passed in; see Chain._createChain for details.

Parameters
  • sequence (Sequence) – string of one-letter codes or sequence of residue types

  • compoundName (str) – name of new Substance (e.g. ‘Lysozyme’) Defaults to ‘Molecule_n

  • molType (str) – molType (‘protein’,’DNA’, ‘RNA’). Needed only if sequence is a string.

  • startNumber (int) – number of first residue in sequence

  • shortName (str) – shortName for new chain (optional)

  • role (str) – role for new chain (optional)

  • comment (str) – comment for new chain (optional)

  • expandFromAtomSets (bool) – Create new Atoms corresponding to the ChemComp AtomSets definitions. Eg. H1, H2, H3 equivalent atoms will add a new H% atom. This will facilitate assignments workflows. See ccpn.core.lib.MoleculeLib.expandChainAtoms for details.

Returns

a new Chain instance.

createPolymerSubstance(sequence: Sequence[str], name: str, labelling: str = None, userCode: str = None, smiles: str = None, synonyms: Sequence[str] = (), comment: str = None, startNumber: int = 1, molType: str = None, isCyclic: bool = False, **kwds)[source]

Make new Substance from sequence of residue codes, using default linking and variants

NB: For more complex substances, you must use advanced, API-level commands.

See the Substance class for details.

Optional keyword arguments can be passed in; see Substance._fetchNefSubstance for details.

Parameters
  • sequence (Sequence) – string of one-letter codes or sequence of residueNames

  • name (str) – name of new substance

  • labelling (str) – labelling for new substance. Optional - None means ‘natural abundance’

  • userCode (str) – user code for new substance (optional)

  • smiles (str) – smiles string for new substance (optional)

  • synonyms (Sequence[str]) – synonyms for Substance name

  • comment (str) – comment for new substance (optional)

  • startNumber (int) – number of first residue in sequence

  • molType (str) – molType (‘protein’,’DNA’, ‘RNA’). Required only if sequence is a string.

  • isCyclic (bool) – Should substance created be cyclic?

Returns

a new Substance instance.

property data

- (‘ccpn.core.Data.Data,) - contained Data objects in name order This is identical to the standard sorting order.

property dataPath: ccpn.util.Path.Path

- ccpn.util.Path.Path, immutable - :return: the absolute path to the data sub-directory of the current project

as a Path instance

property dataTables

- (‘ccpn.core.DataTable.DataTable,) - contained DataTable objects in creation order. This may differ from the standard sorting order

deleteObjects(*objs: Sequence[str | ccpn.core.lib.Pid.Pid, ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject])[source]

Delete one or more objects, given as either objects or Pids

exportNef(path: str = None, overwriteExisting: bool = False, skipPrefixes: Sequence[str] = (), expandSelection: bool = True, includeOrphans: bool = False, pidList: Sequence[str] = None)[source]

Export selected contents of the project to a Nef file.

skipPrefixes: ( ‘ccpn’, …, <str> ) expandSelection: <bool> includeOrphans: <bool>

Include ‘ccpn’ in the skipPrefixes list will exclude ccpn specific items from the file expandSelection = True will include all data from the project, this may not be data that

is not defined in the Nef standard.

includeOrphans = True will include chemicalShifts that have no peak assignments (orphans)

PidList is a list of <str>, e.g. ‘NC:@-’, obtained from the objects to be included. The Nef file may also contain further dependent items associated with the pidList.

Parameters
  • path – output path and filename

  • skipPrefixes – items to skip

  • expandSelection – expand the selection

  • includeOrphans – include chemicalShift orphans

  • pidList – a list of pids

fetchCollection(name: str = None) Collection[source]

Get or create Collection. See the Collection class for details.

Parameters

name

Returns

a new Collection instance.

fetchDataTable(name: str)[source]

Get or create new DataTable. :param name: name for the DataTable.

fetchNefSubstance(sequence: Sequence[dict], name: str = None, **kwds)[source]

Fetch Substance that matches sequence of NEF rows and/or name

See the Substance class for details.

Optional keyword arguments can be passed in; see Substance._fetchNefSubstance for details.

Parameters
  • self

  • sequence

  • name

Returns

a new Nef Substance instance.

fetchNmrChain(shortName: str = None)[source]

Fetch chain with given shortName; If none exists call newNmrChain to make one first

If shortName is None returns a new NmrChain with name starting with ‘@’

Parameters

shortName – string name of required nmrAtom

Returns

an NmrChain instance.

fetchSample(name: str)[source]

Get or create Sample with given name. See the Sample class for details. :param self: project :param name: sample name :return: new or existing Sample instance.

fetchSubstance(name: str, labelling: str = None)[source]

Get or create Substance with given name and labelling. See the Substance class for details.

Parameters
  • self

  • name

  • labelling

Returns

new or existing Substance instance.

getAtom(relativeId: str) ccpn.core.Atom.Atom

Get contained ‘ccpn.core.Atom.Atom object by relative ID

getAxis(relativeId: str) ccpn.ui._implementation.Axis.Axis

Get contained ‘ccpn.ui._implementation.Axis.Axis object by relative ID

getByPids(pids: list)[source]

Optimise method to get all found objects from a list of pids. Remove any None.

getCalculationStep(relativeId: str) ccpn.core.CalculationStep.CalculationStep

Get contained ‘ccpn.core.CalculationStep.CalculationStep object by relative ID

getCcpCodeData(ccpCode, molType=None, atomType=None)[source]

Get the CcpCode for molType/AtomType

getChain(relativeId: str) ccpn.core.Chain.Chain

Get contained ‘ccpn.core.Chain.Chain object by relative ID

getChemicalShiftList(relativeId: str) ccpn.core.ChemicalShiftList.ChemicalShiftList

Get contained ‘ccpn.core.ChemicalShiftList.ChemicalShiftList object by relative ID

getCollection(name: str) Optional[Collection][source]

Return the collection from the supplied name

getComplex(relativeId: str) ccpn.core.Complex.Complex

Get contained ‘ccpn.core.Complex.Complex object by relative ID

getData(relativeId: str) ccpn.core.Data.Data

Get contained ‘ccpn.core.Data.Data object by relative ID

getDataTable(relativeId: str) ccpn.core.DataTable.DataTable

Get contained ‘ccpn.core.DataTable.DataTable object by relative ID

getExperimentClassifications() dict[source]

Get a dictionary of dictionaries of dimensionCount:sortedNuclei:ExperimentClassification named tuples.

getIntegral(relativeId: str) ccpn.core.Integral.Integral

Get contained ‘ccpn.core.Integral.Integral object by relative ID

getIntegralList(relativeId: str) ccpn.core.IntegralList.IntegralList

Get contained ‘ccpn.core.IntegralList.IntegralList object by relative ID

getIntegralListView(relativeId: str) ccpn.ui._implementation.IntegralListView.IntegralListView

Get contained ‘ccpn.ui._implementation.IntegralListView.IntegralListView object by relative ID

getMark(relativeId: str) ccpn.ui._implementation.Mark.Mark

Get contained ‘ccpn.ui._implementation.Mark.Mark object by relative ID

getModel(relativeId: str) ccpn.core.Model.Model

Get contained ‘ccpn.core.Model.Model object by relative ID

getMultiplet(relativeId: str) ccpn.core.Multiplet.Multiplet

Get contained ‘ccpn.core.Multiplet.Multiplet object by relative ID

getMultipletList(relativeId: str) ccpn.core.MultipletList.MultipletList

Get contained ‘ccpn.core.MultipletList.MultipletList object by relative ID

getMultipletListView(relativeId: str) ccpn.ui._implementation.MultipletListView.MultipletListView

Get contained ‘ccpn.ui._implementation.MultipletListView.MultipletListView object by relative ID

getNefSubstance(sequence: Sequence[dict], name: str = None, **kwds)[source]

Get existing Substance that matches sequence of NEF rows and/or name

See the Substance class for details.

Optional keyword arguments can be passed in; see Substance._fetchNefSubstance for details.

Parameters
  • self

  • sequence

  • name

Returns

a new Nef Substance instance.

getNmrAtom(relativeId: str) ccpn.core.NmrAtom.NmrAtom

Get contained ‘ccpn.core.NmrAtom.NmrAtom object by relative ID

getNmrChain(relativeId: str) ccpn.core.NmrChain.NmrChain

Get contained ‘ccpn.core.NmrChain.NmrChain object by relative ID

getNmrResidue(relativeId: str) ccpn.core.NmrResidue.NmrResidue

Get contained ‘ccpn.core.NmrResidue.NmrResidue object by relative ID

getNote(relativeId: str) ccpn.core.Note.Note

Get contained ‘ccpn.core.Note.Note object by relative ID

getObjectsById(className: str, id: str) List[ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject][source]

get objects from class name / shortName and the start of the ID.

The function does NOT interrogate the API level, which makes it faster in a number fo cases, e.g. for NmrResidues

getObjectsByPartialId(className: str, idStartsWith: str) List[ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject][source]

get objects from class name / shortName and the start of the ID.

The function does NOT interrogate the API level, which makes it faster in a number fo cases, e.g. for NmrResidues

getObjectsByPids(pids: list)[source]

Optimise method to get all found objects from a list of pids. Remove any None. Warning: do not use with zip

getPeak(relativeId: str) ccpn.core.Peak.Peak

Get contained ‘ccpn.core.Peak.Peak object by relative ID

getPeakCluster(relativeId: str) ccpn.core.PeakCluster.PeakCluster

Get contained ‘ccpn.core.PeakCluster.PeakCluster object by relative ID

getPeakList(relativeId: str) ccpn.core.PeakList.PeakList

Get contained ‘ccpn.core.PeakList.PeakList object by relative ID

getPeakListView(relativeId: str) ccpn.ui._implementation.PeakListView.PeakListView

Get contained ‘ccpn.ui._implementation.PeakListView.PeakListView object by relative ID

getPidsByObjects(objs: list)[source]

Optimise method to get all found pids from a list of objects. Remove any None. Warning: do not use with zip

getPseudoDimension(relativeId: str) ccpn.core.PseudoDimension.PseudoDimension

Get contained ‘ccpn.core.PseudoDimension.PseudoDimension object by relative ID

getResidue(relativeId: str) ccpn.core.Residue.Residue

Get contained ‘ccpn.core.Residue.Residue object by relative ID

getRestraint(relativeId: str) ccpn.core.Restraint.Restraint

Get contained ‘ccpn.core.Restraint.Restraint object by relative ID

getRestraintContribution(relativeId: str) ccpn.core.RestraintContribution.RestraintContribution

Get contained ‘ccpn.core.RestraintContribution.RestraintContribution object by relative ID

getRestraintTable(relativeId: str) ccpn.core.RestraintTable.RestraintTable

Get contained ‘ccpn.core.RestraintTable.RestraintTable object by relative ID

getSample(relativeId: str) ccpn.core.Sample.Sample

Get contained ‘ccpn.core.Sample.Sample object by relative ID

getSampleComponent(relativeId: str) ccpn.core.SampleComponent.SampleComponent

Get contained ‘ccpn.core.SampleComponent.SampleComponent object by relative ID

getSpectrum(relativeId: str) ccpn.core.Spectrum.Spectrum

Get contained ‘ccpn.core.Spectrum.Spectrum object by relative ID

getSpectrumDisplay(relativeId: str) ccpn.ui._implementation.SpectrumDisplay.SpectrumDisplay

Get contained ‘ccpn.ui._implementation.SpectrumDisplay.SpectrumDisplay object by relative ID

getSpectrumGroup(relativeId: str) ccpn.core.SpectrumGroup.SpectrumGroup

Get contained ‘ccpn.core.SpectrumGroup.SpectrumGroup object by relative ID

getSpectrumHit(relativeId: str) ccpn.core.SpectrumHit.SpectrumHit

Get contained ‘ccpn.core.SpectrumHit.SpectrumHit object by relative ID

getSpectrumReference(relativeId: str) ccpn.core.SpectrumReference.SpectrumReference

Get contained ‘ccpn.core.SpectrumReference.SpectrumReference object by relative ID

getSpectrumView(relativeId: str) ccpn.ui._implementation.SpectrumView.SpectrumView

Get contained ‘ccpn.ui._implementation.SpectrumView.SpectrumView object by relative ID

getStrip(relativeId: str) ccpn.ui._implementation.Strip.Strip

Get contained ‘ccpn.ui._implementation.Strip.Strip object by relative ID

getStructureData(relativeId: str) ccpn.core.StructureData.StructureData

Get contained ‘ccpn.core.StructureData.StructureData object by relative ID

getStructureEnsemble(relativeId: str) ccpn.core.StructureEnsemble.StructureEnsemble

Get contained ‘ccpn.core.StructureEnsemble.StructureEnsemble object by relative ID

getSubstance(relativeId: str) ccpn.core.Substance.Substance

Get contained ‘ccpn.core.Substance.Substance object by relative ID

getViolationTable(relativeId: str) ccpn.core.ViolationTable.ViolationTable

Get contained ‘ccpn.core.ViolationTable.ViolationTable object by relative ID

getWindow(relativeId: str) ccpn.ui._implementation.Window.Window

Get contained ‘ccpn.ui._implementation.Window.Window object by relative ID

get_OldChemicalShift(relativeId: str) ccpn.core._OldChemicalShift._OldChemicalShift

Get contained ‘ccpn.core._OldChemicalShift._OldChemicalShift object by relative ID

property integralListViews

- (‘ccpn.ui._implementation.IntegralListView.IntegralListView,) - contained IntegralListView objects in order of underlying key. This may differ from the standard sorting order

property integralLists

- (‘ccpn.core.IntegralList.IntegralList,) - contained IntegralList objects in creation order. This may differ from the standard sorting order

property integrals

- (‘ccpn.core.Integral.Integral,) - contained Integral objects in creation order. This may differ from the standard sorting order

static isCoreClass(klass) bool[source]

Return True if type(klass) is a core ccpn object type

static isCoreObject(obj) bool[source]

Return True if obj is a core ccpn object

property isModified

- None, immutable - Return true if any part of the project has been modified

property isNew

- None, immutable - Return true if the project is new

property isTemporary

- None, immutable - Return true if the project is temporary, i.e., not saved or updated.

loadData(path: str, ccpn.util.Path.Path) list[source]

Just a stub for backward compatibility

property marks

- (‘ccpn.ui._implementation.Mark.Mark,) - contained Mark objects in creation order. This may differ from the standard sorting order

property models

- (‘ccpn.core.Model.Model,) - contained Model objects in creation order. This may differ from the standard sorting order

property multipletListViews

- (‘ccpn.ui._implementation.MultipletListView.MultipletListView,) - contained MultipletListView objects in order of underlying key. This may differ from the standard sorting order

property multipletLists

- (‘ccpn.core.MultipletList.MultipletList,) - contained MultipletList objects in creation order. This may differ from the standard sorting order

property multiplets

- (‘ccpn.core.Multiplet.Multiplet,) - contained Multiplet objects in creation order. This may differ from the standard sorting order

property name: str

- str, immutable - name of Project

newChemicalShiftList(name: str = None, spectra=(), **kwds)[source]

Create new ChemicalShiftList. See the ChemicalShiftList class for details.

Parameters
  • name

  • spectra

Returns

a new ChemicalShiftList instance.

newCollection(items: Sequence[Any] = None, **kwds) Optional[Collection][source]

Create new Collection.

See the Collection class for details.

Optional keyword arguments can be passed in; see Collection._newCollection for details.

Parameters

items – optional list of core objects as objects or pids.

Returns

a new Collection instance.

newComplex(name: str, chains=(), **kwds)[source]

Create new Complex. See the Complex class for details. Optional keyword arguments can be passed in; see Complex._newComplex for details.

Parameters
  • name

  • chains

Returns

a new Complex instance.

newDataTable(name: str = None, data=None, comment: str = None, **kwds)[source]

Create new DataTable.

See the DataTable class for details.

Optional keyword arguments can be passed in; see DataTable._newDataTable for details.

Parameters
  • name – new name for the DataTable.

  • data – Pandas dataframe.

  • comment – optional comment string

Returns

a new DataTable instance.

newEmptySpectrum(isotopeCodes: Sequence[str], dimensionCount=None, name='emptySpectrum', path=None, **parameters)[source]

Make new Empty spectrum from isotopeCodes list - without data and with default parameters. default parameters are defined in: SpectrumDataSourceABC.isotopeDefaultDataDict

Parameters
  • isotopeCodes – a tuple/list of isotope codes that define the dimensions; e.g. (‘1H’, ‘13C’)

  • name – the name of the resulting spectrum

  • path – an optional path to be stored with the Spectrum instance

  • **parameters

    optional spectrum (parameter, value) pairs

DimensionCount

an optional dimensionCount parameter; default derived from len(isotopeCodes)

Returns

a new Spectrum instance.

newHdf5Spectrum(isotopeCodes: Sequence[str], name='hdf5Spectrum', path=None, **parameters)[source]

Make new hdf5 spectrum from isotopeCodes list - without data and with default parameters.

Parameters
  • isotopeCodes

  • name – name of the spectrum

  • path – optional path (autogenerated from name when None; resulting file will be in data/spectra folder of the project)

  • **parameters

    optional spectrum (parameter, value) pairs

Returns

a new Spectrum instance.

newMark(colour: str, positions: Sequence[float], axisCodes: Sequence[str], style: str = 'simple', units: Sequence[str] = (), labels: Sequence[str] = ())[source]

To be depreciated in next version; use mainWindow.newMark() instead

newNmrChain(shortName: str = None, isConnected: bool = False, label: str = '?', comment: str = None)[source]

Create new NmrChain. Setting isConnected=True produces a connected NmrChain.

Parameters
  • shortName (str) – shortName for new nmrChain (optional, defaults to @ijk’ or ‘#ijk’, ijk positive integer

  • isConnected (bool) – (default to False) If true the NmrChain is a connected stretch. This can NOT be changed later

  • label (str) – Modifiable NmrChain identifier that does not change with reassignment. Defaults to @ijk’/’#ijk

  • comment (str) – comment for new nmrChain (optional)

Returns

a new NmrChain instance.

newNote(name: str = None, text: str = None, comment: str = None, **kwds)[source]

Create new Note.

See the Note class for details.

Optional keyword arguments can be passed in; see Note._newNote for details.

Parameters
  • name – name for the note.

  • text – contents of the note.

Returns

a new Note instance.

newPeakCluster(peaks: Sequence[Peak | str] = None, **kwds) Optional[PeakCluster][source]

Create new PeakCluster.

See the PeakCluster class for details.

Optional keyword arguments can be passed in; see PeakCluster._newPeakCluster for details.

Parameters

peaks – optional list of peaks as objects or pids.

Returns

a new PeakCluster instance.

newSample(name: str = None, pH: float = None, ionicStrength: float = None, amount: float = None, amountUnit: str = None, isVirtual: bool = False, isHazardous: bool = None, creationDate: datetime.datetime = None, batchIdentifier: str = None, plateIdentifier: str = None, rowNumber: int = None, columnNumber: int = None, comment: str = None, **kwds)[source]

Create new Sample.

See the Sample class for details.

Optional keyword arguments can be passed in; see Sample._newSample for details.

Parameters
  • name

  • pH

  • ionicStrength

  • amount

  • amountUnit

  • isVirtual

  • isHazardous

  • creationDate

  • batchIdentifier

  • plateIdentifier

  • rowNumber

  • columnNumber

  • comment

  • serial – optional serial number.

Returns

a new Sample instance.

newSpectrum(path: str, name: str = None)[source]

Creation of new Spectrum defined by path; optionally set name.

newSpectrumGroup(name: str, spectra=(), **kwds)[source]

Create new SpectrumGroup

See the SpectrumGroup class for details.

Optional keyword arguments can be passed in; see SpectrumGroup._newSpectrumGroup for details.

Parameters
  • name – name for the new SpectrumGroup

  • spectra – optional list of spectra as objects or pids

Returns

a new SpectrumGroup instance.

newStructureData(name: str = None, title: str = None, programName: str = None, programVersion: str = None, dataPath: str = None, creationDate: datetime.datetime = None, uuid: str = None, comment: str = None, moleculeFilePath: str = None, **kwds)[source]

Create new StructureData

See the StructureData class for details.

Optional keyword arguments can be passed in; see StructureData._newStructureData for details.

Parameters
  • title – deprecated - original name for StructureData, please use .name

  • name

  • programName

  • programVersion

  • dataPath

  • creationDate

  • uuid

  • comment

Returns

a new StructureData instance.

newStructureEnsemble(name: str = None, data=None, comment: str = None, **kwds)[source]

Create new StructureEnsemble.

See the StructureEnsemble class for details.

Optional keyword arguments can be passed in; see StructureEnsemble._newStructureEnsemble for details.

Parameters
  • name – new name for the StructureEnsemble.

  • data – Pandas dataframe.

  • comment – optional comment string

Returns

a new StructureEnsemble instance.

newSubstance(name: str = None, labelling: str = None, substanceType: str = 'Molecule', userCode: str = None, smiles: str = None, inChi: str = None, casNumber: str = None, empiricalFormula: str = None, molecularMass: float = None, comment: str = None, synonyms: Sequence[str] = (), atomCount: int = 0, bondCount: int = 0, ringCount: int = 0, hBondDonorCount: int = 0, hBondAcceptorCount: int = 0, polarSurfaceArea: float = None, logPartitionCoefficient: float = None, **kwds)[source]

Create new substance WITHOUT storing the sequence internally (and hence not suitable for making chains). SubstanceType defaults to ‘Molecule’.

ADVANCED alternatives are ‘Cell’ and ‘Material’

See the Substance class for details.

Optional keyword arguments can be passed in; see Substance._newSubstance for details.

Parameters
  • name

  • labelling

  • substanceType

  • userCode

  • smiles

  • inChi

  • casNumber

  • empiricalFormula

  • molecularMass

  • comment

  • synonyms

  • atomCount

  • bondCount

  • ringCount

  • hBondDonorCount

  • hBondAcceptorCount

  • polarSurfaceArea

  • logPartitionCoefficient

Returns

a new Substance instance.

newUndoPoint()[source]

Set a point in the undo stack, you can undo/redo to

newWindow(title: str = None, position: tuple = (), size: tuple = (), **kwds)[source]

Create new child Window.

See the Window class for details.

Optional keyword arguments can be passed in; see Window._newWindow for details.

Parameters
  • title (str) – window title (optional, defaults to ‘W1’, ‘W2’, ‘W3’, …

  • position (tuple) – x,y position for new window in integer pixels.

  • size (tuple) – x,y size for new window in integer pixels.

Returns

a new Window instance.

property nmrAtoms

- (‘ccpn.core.NmrAtom.NmrAtom,) - contained NmrAtom objects in creation order. This may differ from the standard sorting order

property nmrChains

- (‘ccpn.core.NmrChain.NmrChain,) - contained NmrChain objects in creation order. This may differ from the standard sorting order

property nmrResidues

- (‘ccpn.core.NmrResidue.NmrResidue,) - contained NmrResidue objects in sequential order (for assigned or connected NmrChains), otherwise in creation order. This is identical to the standard sorting order.

property notes

- (‘ccpn.core.Note.Note,) - contained Note objects in creation order. This may differ from the standard sorting order

property path: str

- str, immutable - return absolute path to directory containing Project

property peakClusters

- (‘ccpn.core.PeakCluster.PeakCluster,) - contained PeakCluster objects in creation order. This may differ from the standard sorting order

property peakListViews

- (‘ccpn.ui._implementation.PeakListView.PeakListView,) - contained PeakListView objects in order of underlying key. This may differ from the standard sorting order

property peakLists

- (‘ccpn.core.PeakList.PeakList,) - contained PeakList objects in creation order. This may differ from the standard sorting order

property peaks

- (‘ccpn.core.Peak.Peak,) - contained Peak objects in creation order. This may differ from the standard sorting order

property pipelinePath: ccpn.util.Path.Path

- ccpn.util.Path.Path, immutable - :return: the absolute path to the state/pipeline sub-directory of

the current project as a Path instance

property pluginDataPath: ccpn.util.Path.Path

- ccpn.util.Path.Path, immutable - :return: the absolute path to the data/plugins sub-directory of the

current project as a Path instance

produceNmrAtom(atomId: str = None, chainCode: str = None, sequenceCode: int | str = None, residueType: str = None, name: str = None)[source]
Get chainCode, sequenceCode, residueType and atomName from dot-separated atomId or Pid

or explicit parameters, and find or create an NmrAtom that matches Empty chainCode gets NmrChain:@- ; empty sequenceCode get a new NmrResidue

Parameters
  • atomId

  • chainCode

  • sequenceCode

  • residueType

  • name – new or existing nmrAtom, matching parameters

Returns

property projectPath: ccpn.util.Path.Path

- ccpn.util.Path.Path, immutable - Convenience, as project.path (currently) does not yield a Path instance :return: the absolute path to the project as a Path instance

property pseudoDimensions

- (‘ccpn.core.PseudoDimension.PseudoDimension,) - contained PseudoDimension objects in order of underlying key. This may differ from the standard sorting order

registerNotifier(className: str, target: str, func: Callable[[...], None], parameterDict: dict = {}, onceOnly: bool = False) Callable[[...], None][source]

Register notifiers to be triggered when data change

Parameters
  • className (str) – className of wrapper class to monitor (AbstractWrapperObject for ‘all’)

  • target (str) –

    can have the following values

    ’create’ is called after the creation (or undeletion) of the object and its wrapper. Notifier functions are called with the created V3 core object as the only parameter.

    ’delete’ is called before the object is deleted Notifier functions are called with the deleted to be deleted V3 core object as the only parameter.

    ’rename’ is called after the id and pid of an object has changed Notifier functions are called with the renamed V3 core object and the old pid as parameters.

    ’change’ when any object attribute changes value. Notifier functions are called with the changed V3 core object as the only parameter. rename and crosslink notifiers (see below) may also trigger change notifiers.

    Any other value is interpreted as the name of a V3 core class, and the notifier is triggered when a cross link (NOT a parent-child link) between the className and the target class is modified

  • func (Callable) –

    The function to call when the notifier is triggered.

    for actions ‘create’, ‘delete’ and ‘change’ the function is called with the object created (deleted, undeleted, changed) as the only parameter

    For action ‘rename’ the function is called with an additional parameter: oldPid, the value of the pid before renaming.

    If target is a second className, the function is called with the project as the only parameter.

  • parameterDict (dict) –

    Parameters passed to the notifier function before execution.

    This allows you to use the same function with different parameters in different contexts

  • onceOnly (bool) –

    If True, only one of multiple copies is executed

    when notifiers are resumed after a suspension.

:return The registered notifier (which can be passed to removeNotifier or duplicateNotifier)

removeNotifier(notifier: Callable[[...], None])[source]

Unregister the the notifier from all places where it appears.

property residues

- (‘ccpn.core.Residue.Residue,) - contained Residue objects in sequential order This is identical to the standard sorting order

property restraintContributions

- (‘ccpn.core.RestraintContribution.RestraintContribution,) - contained RestraintContribution objects in creation order. This may differ from the standard sorting order

property restraintTables

- (‘ccpn.core.RestraintTable.RestraintTable,) - contained RestraintTable objects in creation order. This may differ from the standard sorting order

property restraints

- (‘ccpn.core.Restraint.Restraint,) - contained Restraint objects in creation order. This may differ from the standard sorting order

resumeNotification()[source]

Execute accumulated notifiers and resume immediate notifier execution

property sampleComponents

- (‘ccpn.core.SampleComponent.SampleComponent,) - contained SampleComponent objects in name order This is identical to the standard sorting order.

property samples

- (‘ccpn.core.Sample.Sample,) - contained Sample objects in creation order. This may differ from the standard sorting order

save(newPath: Optional[str] = None, changeBackup: bool = True, createFallback: bool = False, overwriteExisting: bool = False, checkValid: bool = False, changeDataLocations: bool = False) bool[source]

Save project with all data, optionally to new location or with new name. Unlike lower-level functions, this function ensures that data in high level caches are saved. Return True if save succeeded otherwise return False (or throw error)

saveToArchive() ccpn.util.Path.Path[source]

Make new time-stamped archive of project :return path to .tgz archive file as a Path object

property scriptsPath: ccpn.util.Path.Path

- ccpn.util.Path.Path, immutable - :return: the absolute path to the script sub-directory of the current project

as a Path instance

property shiftAveraging

- None, mutable - Return shiftAveraging

shortClassName = 'PR'

Short class name, for PID.

property spectra

- (‘ccpn.core.Spectrum.Spectrum,) - contained Spectrum objects in approximate creation order This is different from the standard sorting order

property spectraPath

- None, immutable - :return: the absolute path to the data sub-directory of the current project

as a Path instance

property spectrumDisplays

- (‘ccpn.ui._implementation.SpectrumDisplay.SpectrumDisplay,) - contained SpectrumDisplay objects in order of underlying key. This may differ from the standard sorting order

property spectrumGroups

- (‘ccpn.core.SpectrumGroup.SpectrumGroup,) - contained SpectrumGroup objects in creation order. This may differ from the standard sorting order

property spectrumHits

- (‘ccpn.core.SpectrumHit.SpectrumHit,) - contained SpectrumHit objects in order of underlying key. This may differ from the standard sorting order

property spectrumReferences

- (‘ccpn.core.SpectrumReference.SpectrumReference,) - contained SpectrumReference objects in order of underlying key. This may differ from the standard sorting order

property spectrumViews

- (‘ccpn.ui._implementation.SpectrumView.SpectrumView,) - contained SpectrumView objects in order of underlying key. This may differ from the standard sorting order

property statePath: ccpn.util.Path.Path

- ccpn.util.Path.Path, immutable - :return: the absolute path to the state sub-directory of the current project

as a Path instance

property strips

- (‘ccpn.ui._implementation.Strip.Strip,) - contained Strip objects in creation order. This may differ from the standard sorting order

property structureData

- (‘ccpn.core.StructureData.StructureData,) - contained StructureData objects in creation order. This may differ from the standard sorting order

property structureEnsembles

- (‘ccpn.core.StructureEnsemble.StructureEnsemble,) - contained StructureEnsemble objects in creation order. This may differ from the standard sorting order

property substances

- (‘ccpn.core.Substance.Substance,) - contained Substance objects in name order This is identical to the standard sorting order.

suspendNotification()[source]

Suspend notifier execution and accumulate notifiers for later execution

unRegisterNotifier(className: str, target: str, notifier: Callable[[...], None])[source]

Unregister the notifier from this className, and target

unblankNotification()[source]

Resume notifier execution after blanking

unblockWaypoints()[source]

Block the setting of undo waypoints, so that command echoing (_startCommandBLock) does not set waypoints

NB The programmer must GUARANTEE (try: … finally) that waypoints are unblocked again

property violationTables

- (‘ccpn.core.ViolationTable.ViolationTable,) - contained ViolationTable objects in creation order. This may differ from the standard sorting order

property windows

- (‘ccpn.ui._implementation.Window.Window,) - contained Window objects in order of underlying key. This may differ from the standard sorting order

ccpn.core.PseudoDimension module

class ccpn.core.PseudoDimension.PseudoDimension(project, wrappedData)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject, ccpn.core._implementation.SpectrumDimensionAttributes.SpectrumDimensionAttributes

A sampled Spectrum axis with non-gridded values. Can be used (V2 legacy) to describe sampled-value axes in pseudo-2D and nD experiments, such as the time delay axis for T1 experiments.

property assignmentTolerance: float

- float, mutable - Assignment Tolerance; Always 0.0

property axisParameter: str

- str, mutable - Name of the condition or parameter that is varied along the axis. Use ‘sample’ if samples are different for each point on the dimension

className = 'PseudoDimension'
property defaultAssignmentTolerance: float

- float, immutable - Default assignment tolerance (in ppm);

dimensionType = 'Sampled'
property foldingLimits: Tuple[float, float]

- Tuple[float, float], immutable - Return the foldingLimits of this dimension as a tuple of floats.

property isAcquisition: bool

- bool, mutable - Always False

property isReversed: bool

- bool, mutable - Always False

property maxAliasedFrequency: float

- float, mutable - maximum possible peak frequency; emulated to be always ppmValue of pointCounts +0.5

property minAliasedFrequency: float

- float, mutable - minimum possible frequency; emulated to be always ppmValue of point 0.5

property orderedSamples: Tuple[ccpn.core.Sample.Sample, ...]

- Tuple[ccpn.core.Sample.Sample, …], mutable - Samples used to acquire the individual points in this sampled dimension

property phase0: Optional[float]

- float=None, mutable - Zero-order phase; always None

property phase1: Optional[float]

- float=None, mutable - First-order phase; always None

property pointErrors: Tuple[float, ...]

- Tuple[float, …], mutable - point errors for PseudoDimension).

pointToPpm(point: float) float

:return ppm-value corresponding to point (float)

pointToValue(point: float) float[source]

:return ppm-value corresponding to point (float)

property pointValues: Tuple[float, ...]

- Tuple[float, …], mutable - point values for PseudoDimension.

ppmToPoint(value: float) float

:return point (float) corresponding to ppm-value

property referencePoint: float

- float, mutable - point used for axis (chemical shift) referencing. emulated to always be 1.0

property referenceValue: float

- float, mutable - ppm-value used for axis (chemical shift) referencing. emulated to always be 1.0 (as axis is not reversed)

shortClassName = 'PD'

Short class name, for PID.

property spectralWidth: float

- float, mutable - spectral width in ppm emulated to always be self.pointCount

property spectralWidthHz: float

- float, mutable - spectral width in Hz emulated to always be 1.0 * spectrometerFrequency

property spectrometerFrequency: float

- float, mutable - Absolute frequency at carrier (or at splitting 0.0). In MHz or dimensionless. Emulated to always be 1.0

property spectrum: ccpn.core.Spectrum.Spectrum

- ccpn.core.Spectrum.Spectrum, immutable - Spectrum containing PseudoDimension.

property spectrumHits: List[ccpn.core.SpectrumHit.SpectrumHit]

- List[ccpn.core.SpectrumHit.SpectrumHit], immutable - SpectrumHits (for screening/metabolomics) that refer to individual points in the PseudoDimension

property spectrumLimits: Tuple[float, float]

- Tuple[float, float], immutable - Return the limits of this spectrum dimension as a tuple of floats

valueToPoint(value: float) float[source]

:return point (float) corresponding to ppm-value

ccpn.core.Residue module

class ccpn.core.Residue.Residue(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

A molecular Residue, contained in a Chain, and containing Atoms. Crucial attributes: residueType (e.g. ‘ALA’), residueVariant (NEF-based), sequenceCode (e.g. ‘123’)

property allNmrResidues: Tuple[NmrResidue]

- Tuple[ForwardRef(‘NmrResidue’)], immutable - AllNmrResidues corresponding to Residue - E.g. (for MR:A.87) NmrResidues NR:A.87, NR:A.87+0, NR:A.88-1, NR:A.82+5, etc.

property atoms

- (‘ccpn.core.Atom.Atom,) - contained Atom objects in name order This is identical to the standard sorting order.

property chain: ccpn.core.Chain.Chain

- ccpn.core.Chain.Chain, immutable - Chain containing residue.

className = 'Residue'
property configuration: Optional[str]

- str=None, mutable - Residue conformation or other non-covalent distinction.

Example: cis/trans/None for the peptide bonds N-terminal to a residue

delete()[source]

delete residue. Causes an error when just calling residue._wrappedData.delete() new method to delete from the chainFragment

property descriptor: str

- str, mutable - variant descriptor (protonation state etc.) for residue, as defined in the CCPN V2 ChemComp description.

getAtom(relativeId: str) ccpn.core.Atom.Atom

Get contained ‘ccpn.core.Atom.Atom object by relative ID

property hasAssignedAtoms: bool

- bool, immutable - :return: True if any of its atoms have an assignment

property linking: str

- str, mutable - linking (substitution pattern) code for residue

Allowed values are:

For linear polymers: ‘start’, ‘end’, ‘middle’, ‘single’, ‘break’, ‘cyclic’ For other molecules: ‘nonlinear’

‘cyclic’ and ‘break’ are used at the end of linear polymer stretches to signify, respectively, that the polymer is cyclic, or that the residue is bound to an unknown residue or to a cap, so that the linear polymer chain does not continue.

newAtom(name: str, elementSymbol: str = None, **kwds) Atom[source]

Create new Atom within Residue. If elementSymbol is None, it is derived from the name

See the Atom class for details.

Optional keyword arguments can be passed in; see Atom._newAtom for details.

Parameters
  • name

  • elementSymbol

Returns

a new Atom instance.

property nextResidue: Optional[ccpn.core.Residue.Residue]

- ForwardRef(‘Residue’)=None, immutable - Next residue in sequence, if any, otherwise None

property nmrResidue: Optional[NmrResidue]

- ForwardRef(‘NmrResidue’)=None, immutable - NmrResidue to which Residue is assigned

NB Residue<->NmrResidue link depends solely on the NmrResidue name. So no notifiers on the link - notify on the NmrResidue rename instead.

property previousResidue: Optional[ccpn.core.Residue.Residue]

- ForwardRef(‘Residue’)=None, immutable - Previous residue in sequence, if any,otherwise None

rename(sequenceCode: str = None)[source]

Reset Residue.sequenceCode (residueType is immutable). Renaming to None sets the sequence code to the seqId (serial number equivalent)

resetVariantToDefault()[source]

Reset Residue.residueVariant to the default variant

property residueType: str

- str, immutable - Residue type name string (e.g. ‘ALA’)

property residueVariant: Optional[str]

- str=None, immutable - NEF convention Residue variant descriptor (protonation state etc.) for residue

property sequenceCode: str

- str, immutable - Residue sequence code and id (e.g. ‘1’, ‘127B’)

shortClassName = 'MR'

Short class name, for PID.

property shortName: str

- str, immutable -

ccpn.core.Restraint module

class ccpn.core.Restraint.Restraint(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Restraint. The type is defined in the containing RestraintTable.

Most of the values are the consensus of the values in the contained RestraintContributions. In the normal case, where you have only one RestraintContribution per Restraint, you can get and set the values directly from the Restraint without reference to the RestraintContributions.

property additionalLowerLimit: float

- float, mutable - additionalLowerLimit of restraint - consensus of all contributions or None Used for potential functions that require more than one parameter, typically for parabolic-linear potentials where the additionalLowerLimit marks the transition from parabolic to linear potential

property additionalUpperLimit: float

- float, mutable - additionalUpperLimit of restraint - consensus of all contributions or None. Used for potential functions that require more than one parameter, typically for parabolic-linear potentials where the additionalUpperLimit marks the transition from parabolic to linear potential

className = 'Restraint'
property error: float

- float, mutable - standard error of restraint - consensus of all contributions or None

property figureOfMerit: str

- str, mutable - Restraint figure of merit, between 0.0 and 1.0 inclusive.

getRestraintContribution(relativeId: str) ccpn.core.RestraintContribution.RestraintContribution

Get contained ‘ccpn.core.RestraintContribution.RestraintContribution object by relative ID

property lowerLimit: float

- float, mutable - lowerLimit of restraint - consensus of all contributions or None

newRestraintContribution(targetValue: float = None, error: float = None, weight: float = 1.0, upperLimit: float = None, lowerLimit: float = None, additionalUpperLimit: float = None, additionalLowerLimit: float = None, scale: float = 1.0, isDistanceDependent: bool = False, combinationId: int = None, restraintItems: Sequence = (), **kwds)[source]

Create new RestraintContribution within Restraint.

See the RestraintContribution class for details.

Optional keyword arguments can be passed in; see RestraintContribution._newRestraintContribution for details.

Parameters
  • targetValue

  • error

  • weight

  • upperLimit

  • lowerLimit

  • additionalUpperLimit

  • additionalLowerLimit

  • scale

  • isDistanceDependent

  • combinationId

  • restraintItems

  • serial – optional serial number.

Returns

a new RestraintContribution instance.

property peaks: Tuple[ccpn.core.Peak.Peak, ...]

- Tuple[ccpn.core.Peak.Peak, …], mutable - peaks used to derive restraint

property restraintContributions

- (‘ccpn.core.RestraintContribution.RestraintContribution,) - contained RestraintContribution objects in creation order. This may differ from the standard sorting order

property restraintTable: ccpn.core.RestraintTable.RestraintTable

- ccpn.core.RestraintTable.RestraintTable, immutable - RestraintTable object containing restraint.

property serial: int

- int, immutable - serial number of Restraint, used in Pid and to identify the Restraint.

shortClassName = 'RE'

Short class name, for PID.

property targetValue: float

- float, mutable - target value of constraint - consensus of all contributions or None

property upperLimit: float

- float, mutable - upperLimit of restraint - consensus of all contributions or None

property vectorLength: str

- str, mutable - Reference vector length, where applicable. (Mainly?) for Rdc

property weight: float

- float, mutable - weight of restraint - consensus of all contributions or None

ccpn.core.RestraintContribution module

class ccpn.core.RestraintContribution.RestraintContribution(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Restraint contribution, corresponding to a set of alternative Atom tuples with associated limits, target value, weight, and other parameters. Simple restraints will have only contribution, whereas more complex restraints can have multiple contributions with different parameters and possibly logical relationships

addRestraintItem(restraintItem: Sequence[str], _string2Item: Optional[Dict] = None)[source]

Add a restraint item, given as aa tuple of atomId (NOT Pid). Example value: (‘A.127.ALA.HA’,’A.130.SER.H’)

The optional _string2Item dictionary speeds up the generation of many restraintItems in a single operation. It must be initialised with StructureData._getTempItemMap(), and serves only for a single StructureData. On principle it must be used for a closed set of operations and then discarded, since it is a cache of underlying FixedResonance objects which are in theory mutable (don’t ask)

property additionalLowerLimit: float

- float, mutable - additionalLowerLimit of contribution Used for potential functions that require more than one parameter, typically for parabolic-linear potentials where the additionalLowerLimit marks the transition from parabolic to linear potential

property additionalUpperLimit: float

- float, mutable - additionalUpperLimit of contribution. Used for potential functions that require more than one parameter, typically for parabolic-linear potentials where the additionalUpperLimit marks the transition from parabolic to linear potential

className = 'RestraintContribution'
property combinationId: int

- int, mutable - combinationId of contribution. Contributions with the same combinationId are AND’ed together, where contributions with different combinationId (or combinationId None) are OR’ed

property error: float

- float, mutable - error of contribution

property isDistanceDependent: bool

- bool, mutable - Does targetValue depend on a variable distance (where this is relevant, e.g. for Rdc)

property lowerLimit: float

- float, mutable - lowerLimit of contribution

property restraint: ccpn.core.Restraint.Restraint

- ccpn.core.Restraint.Restraint, immutable - Restraint object containing restraintContribution.

property restraintItems: Tuple[Tuple[str, ...]]

- Tuple[Tuple[str, …]], mutable - restraint items of contribution - given as a tuple of tuples of AtomId (not Pid).

Example value: ((‘A.127.ALA.HA’,’A.130.SER.H’), (‘A.93.VAL.HA’,’A.93.TYR.H’))

property scale: float

- float, mutable - scaling factor (relevant mainly for RDC) to be multiplied with targetValue to get scaled value

property serial: int

- int, immutable - serial number of RestraintContribution, used in Pid and to identify the RestraintContribution.

shortClassName = 'RC'

Short class name, for PID.

property targetValue: float

- float, mutable - targetValue of contribution

property upperLimit: float

- float, mutable - upperLimit of contribution

property weight: float

- float, mutable - weight of contribution

ccpn.core.RestraintTable module

class ccpn.core.RestraintTable.RestraintTable(project, wrappedData)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

An object containing Restraints. Note: the object is not a (subtype of a) Python list. To access all Restraint objects, use RestraintTable.restraints.

The type of restraint is determined by the restraintType attribute. Typical examples are Distance, Dihedral and Rdc restraints, but can also be used to store measurements or derived values (Rdc, J coupling, T1, T2, Chemical Shift, …)

className = 'RestraintTable'
createSimpleRestraint(comment: str = None, figureOfMerit: float = None, peaks: Sequence = (), targetValue: float = None, error: float = None, weight: float = 1.0, upperLimit: float = None, lowerLimit: float = None, additionalUpperLimit: float = None, additionalLowerLimit: float = None, scale=1.0, vectorLength=None, restraintItems: Sequence = (), **kwds)[source]

Create a Restraint with a single RestraintContribution within the RestraintTable. The function takes all the information needed and creates the RestraintContribution as well as the Restraint proper.

This function should be used routinely, unless there is a need to create more complex Restraints.

See the Restraint class for details.

Optional keyword arguments can be passed in; see Restraint._createSimpleRestraint for details.

Parameters
  • comment

  • figureOfMerit

  • peaks

  • targetValue

  • error

  • weight

  • upperLimit

  • lowerLimit

  • additionalUpperLimit

  • additionalLowerLimit

  • scale

  • vectorLength

  • restraintItems

Returns

a new simple Restraint instance.

getRestraint(relativeId: str) ccpn.core.Restraint.Restraint

Get contained ‘ccpn.core.Restraint.Restraint object by relative ID

getRestraintContribution(relativeId: str) ccpn.core.RestraintContribution.RestraintContribution

Get contained ‘ccpn.core.RestraintContribution.RestraintContribution object by relative ID

property measurementType: str

- str, mutable - Type of measurements giving rise to Restraints. Used for restraintTypes like T1 (types z, zz), T2 (types SQ, DQ), … Freely settable for now - precise enumerations will eventually be introduced.

property moleculeFilePath

- None, mutable - :return: a filePath for corresponding molecule. Saved in the parent Class StructureData E.g., PDB file path for displaying molecules in a molecular viewer

property name: str

- str, mutable - name of Restraint List

newRestraint(figureOfMerit: float = None, comment: str = None, peaks: Sequence[Peak | str] = (), vectorLength: float = None, **kwds)[source]

Create new Restraint within RestraintTable.

ADVANCED: Note that you just create at least one RestraintContribution afterwards in order to have valid data. Use the simpler createSimpleRestraint instead, unless you have specific reasons for needing newRestraint.

See the Restraint class for details.

Optional keyword arguments can be passed in; see Restraint._newRestraint for details.

Parameters
  • figureOfMerit

  • comment – optional comment string

  • peaks – optional list of peaks as objects or pids

  • vectorLength

Returns

a new Restraint instance.

property origin: str

- str, mutable - Data origin for restraints. Free text. Examples would be ‘noe’, ‘hbond’, ‘mutation’, or ‘shift-perturbation’ (for a distance restraint list), ‘jcoupling’ or ‘talos’ (for a dihedral restraint list), ‘measured’ (for any observed value)

property potentialType: str

- str, mutable - Potential type for restraints

rename(value: str)[source]

Rename RestraintTable, changing its name and Pid.

property restraintContributions

- (‘ccpn.core.RestraintContribution.RestraintContribution,) - contained RestraintContribution objects in creation order. This may differ from the standard sorting order

property restraintItemLength: int

- int, immutable - Length of restraintItem - number of atom ID identifying a restraint

property restraintType: str

- str, immutable - Restraint type.

Recommended types are Distance, Rdc, JCoupling, ChemicalShift, Csa, Dihedral, T1, T2, … Freely settable for now - further enumerations will eventually be introduced.

restraintTypes = ('Distance', 'Dihedral', 'Rdc', 'JCoupling', 'ChemicalShift', 'Csa', 'T1', 'T2', 'T1rho', 'pKa')
property restraints

- (‘ccpn.core.Restraint.Restraint,) - contained Restraint objects in creation order. This may differ from the standard sorting order

property serial: int

- int, immutable - serial number of RestraintTable, used in Pid and to identify the RestraintTable.

shortClassName = 'RT'

Short class name, for PID.

property structureData: ccpn.core.StructureData.StructureData

- ccpn.core.StructureData.StructureData, immutable - StructureData containing RestraintTable.

property tensor: ccpn.util.Tensor.Tensor

- ccpn.util.Tensor.Tensor, mutable - orientation tensor for restraints.

property tensorChainCode: float

- float, mutable - tensorChainCode of orientation tensor. Used to identify tensor in coordinate files

property tensorIsotropicValue: float

- float, immutable - tensor IsotropicValue of orientation tensor.

property tensorMagnitude: float

- float, immutable - tensor Magnitude of orientation tensor.

property tensorResidueType: float

- float, mutable - tensorResidueType of orientation tensor. Used to identify tensor in coordinate files

property tensorRhombicity: float

- float, immutable - tensor Rhombicity of orientation tensor. U

property tensorSequenceCode: float

- float, mutable - tensorSequenceCode of orientation tensor. Used to identify tensor in coordinate files

property unit: str

- str, mutable - Unit for restraints

ccpn.core.Sample module

class ccpn.core.Sample.Sample(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Corresponds to an NMR (or other) sample, with properties such as amount, pH, and sample identifiers. The composition is given through the contained SampleComponent objects.

property amount: float

- float, mutable - amount of sample, in unit of amountUnit. In most cases this is the volume, but there are other possibilities, e.g. for solid state NMR.

property amountUnit: str

- str, mutable - amountUnit for sample, one of : ‘L’, ‘g’, ‘mole’

property amountUnits: str

- str, mutable - amountUnits for sample, one of list AMOUNT_UNITS

property batchIdentifier: str

- str, mutable - batch identifier for sample

className = 'Sample'
property columnNumber: int

- int, mutable - Column number on plate

property creationDate: datetime.datetime

- datetime.datetime, mutable - Creation timestamp for sample (not for the description record)

getSampleComponent(relativeId: str) ccpn.core.SampleComponent.SampleComponent

Get contained ‘ccpn.core.SampleComponent.SampleComponent object by relative ID

getSampleComponentsSpectra()[source]

Gets spectra linked to sampleComponents through substances. These spectra are normally the reference spectra used in screening/metabolomics, and used to match signal to the sample.spectra when a sample it’s a mixtures.

property ionicStrength: float

- float, mutable - ionicStrength of sample

property ionicStrengthUnits: str

- str, mutable - ionicStrengthUnits for sample, one of list IONICSTRENGTH_UNITS

property isHazardous: bool

- bool, mutable - True if this Sample is a hazard?

property isVirtual: bool

- bool, mutable - True if this sample is virtual and does not describe an actual Sample.. Virtual samples serve as templates and may not be linked to Spectra

property name: str

- str, mutable - actual sample name

newSampleComponent(name: str = None, labelling: str = None, comment: str = None, **kwds)[source]

Create new SampleComponent within Sample.

Automatically creates the corresponding Substance if the name is not already taken.

See the SampleComponent class for details.

Optional keyword arguments can be passed in; see SampleComponent._newSampleComponent for details.

Parameters
  • name

  • labelling

  • comment – optional comment string

Returns

a new SampleComponent instance.

property pH: float

- float, mutable - pH of sample

property plateIdentifier: str

- str, mutable - plate identifier for sample

property pseudoDimensions: ccpn.core.PseudoDimension.PseudoDimension

- ccpn.core.PseudoDimension.PseudoDimension, immutable - Pseudodimensions where sample is used for only one point along the sampled dimension

rename(value: str)[source]

Rename Sample, changing its name and Pid.

property rowNumber: int

- int, mutable - Row number on plate

property sampleComponents

- (‘ccpn.core.SampleComponent.SampleComponent,) - contained SampleComponent objects in name order This is identical to the standard sorting order.

property serial: int

- int, immutable - Sample serial number, used for sorting

shortClassName = 'SA'

Short class name, for PID.

property spectra: Tuple[ccpn.core.Spectrum.Spectrum, ...]

- Tuple[ccpn.core.Spectrum.Spectrum, …], mutable - ccpn.Spectra acquired using ccpn.Sample (excluding multiSample spectra)

property spectrumHits: Tuple[ccpn.core.SpectrumHit.SpectrumHit, ...]

- Tuple[ccpn.core.SpectrumHit.SpectrumHit, …], immutable - SpectrumHits that were found using Sample

ccpn.core.SampleComponent module

class ccpn.core.SampleComponent.SampleComponent(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

A Samplecomponent indicates a Substance contained in a specific Sample, (e.g. protein, buffer, salt), and its concentrations.

The Substance referred to is defined by the ‘name’ and ‘labelling’ attributes. For this reason the SampleComponent cannot be renamed. See Substance.

property chains: Tuple[ccpn.core.Chain.Chain, ...]

- Tuple[ccpn.core.Chain.Chain, …], immutable - ccpn.Chains that correspond to ccpn.SampleComponent (if defined)

className = 'SampleComponent'
property concentration: float

- float, mutable -

property concentrationError: float

- float, mutable - Estimated Standard error of SampleComponent.concentration

property concentrationUnit: str

- str, mutable - Unit of SampleComponent.concentration, one of: ‘Molar’, ‘g/L’, ‘L/L’, ‘mol/mol’, ‘g/g’ , ‘eq’

copyTo(targetSample: ccpn.core.Sample.Sample)[source]
property isotopeCode2Fraction: Dict[str, float]

- Dict[str, float], mutable - {isotopeCode:fraction} dictionary giving uniform isotope percentages

isotopeCodes are of the form ‘12C’, ‘13C’, and all relevant isotopes for a given nucleus must be entered. Fractions must add up to 1.0 for each element.

Example value: {‘12C’:0.289, ‘13C’:0.711, ‘1H’:0.99985, ‘2H’:0.00015}

NBNB the internal dictionary is returned directly without checks or encapsulation

property labelling: str

- str, immutable - labelling descriptor of SampleComponent and corresponding substance

property name: str

- str, immutable - name of SampleComponent and corresponding substance

property purity: float

- float, mutable - SampleComponent.purity on a scale between 0 and 1

property role: str

- str, mutable - Role of SampleComponent in solvent, e.g. ‘solvent’, ‘buffer’, ‘target’, …

property sample: ccpn.core.Sample.Sample

- ccpn.core.Sample.Sample, immutable - Sample containing SampleComponent.

shortClassName = 'SC'

Short class name, for PID.

property spectrumHits: Tuple[ccpn.core.SpectrumHit.SpectrumHit, ...]

- Tuple[ccpn.core.SpectrumHit.SpectrumHit, …], immutable - ccpn.SpectrumHits found for SampleComponent

property substance: Optional[ccpn.core.Substance.Substance]

- ccpn.core.Substance.Substance=None, immutable - Substance corresponding to SampleComponent

ccpn.core.Spectrum module

Spectrum class. Maintains the parameters of a spectrum, including per-dimension/axis values. Values that are not defined for a given dimension (e.g. sampled dimensions) are given as None.

Dimension identifiers run from 1 to the number of dimensions, i.e. dimensionCount, (e.g. 1,2,3 for a 3D). CCPN data the preferred convention is to have the acquisition dimension as dimension 1.

Axes identifiers run from 0 to the dimensionCount-1 (e.g. 0,1,2 for a 3D) Per-axis values are given in the order data are stored in the spectrum file

The axisCodes are used as an alternative axis identifier. These are unique strings that typically reflect the isotope on the relevant axis. By default upon loading a new spectrum, the axisCodes are derived from the isotopeCodes that define the experimental data for each dimension. They can match the dimension identifiers in the reference experiment templates, linking a dimension to the correct reference experiment dimension. They are also used to automatically map spectrum display-axes between different spectra on a first character basis. Axes that are linked by a one-bond magnetisation transfer could be given a lower-case suffix to show the nucleus bound to. Duplicate axis names should be distinguished by a numerical suffix. The rules are best illustrated by example:

Experiment axisCodes

15N-NOESY-HSQC OR 15N-HSQC-NOESY: Hn, Nh, H 4D HCCH-TOCSY Hc, Ch, Hc1, Ch1 HNCA/CB H, N, C HNCO H, N, CO HCACO H, CA, CO 3D proton NOESY-TOCSY H, H1, H2

1D Bromine NMR Br 19F-13C-HSQC Fc, Cf

Useful reordering methods exist to get dimensional/axis parameters in a particular order, i.e.: getByDimension(), setByDimension(), getByAxisCode(), setByAxisCode() See doc strings of these methods for detailed documentation

class ccpn.core.Spectrum.Spectrum(project: ccpn.core.Project.Project, wrappedData: ccpnmodel.ccpncore.api.ccp.nmr.Nmr.DataSource)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

A Spectrum object contains all the stored properties of an NMR spectrum, as well as the path to the NMR (binary) data file. The Spectrum object has methods to get the binary data as SpectrumData (i.e. numpy.ndarray) objects.

MAXDIM = 8
property acquisitionAxisCode: Optional[str]

- str=None, immutable - Axis code of acquisition axis - None if not known

property aliasingIndexes: Tuple[Tuple[int, int], ...]

- Tuple[Tuple[int, int], …], mutable - Return a tuple of the number of times the spectralWidth are folded in each dimension. This is a derived property from the aliasingLimits; setting aliasingIndexes value will alter the aliasingLimits parameter accordingly.

property aliasingIndices: Tuple[Tuple[int, int], ...]

- Tuple[Tuple[int, int], …], mutable - Return a tuple of the number of times the spectralWidth are folded in each dimension. This is a derived property from the aliasingLimits; setting aliasingIndexes value will alter the aliasingLimits parameter accordingly.

property aliasingLimits: List[Tuple[float, float]]

- List[Tuple[float, float]], mutable - List of tuples of sorted(minAliasingLimit, maxAliasingLimit) per dimension. Setting these values will round them to the nearest multiple of the spectralWidth.

property aliasingPointLimits: Tuple[Tuple[int, int], ...]

- Tuple[Tuple[int, int], …], immutable - Return a tuple of sorted(minAliasingPointLimit, maxAliasingPointLimit) per dimension. i.e. The actual point limits of the full (including the aliased regions) limits.

allPlanes(axisCodes: tuple, exactMatch: bool = True)[source]

An iterator over all planes defined by axisCodes, yielding (positions, data-array) tuples.

Parameters
  • axisCodes – a tuple/list of two axisCodes defining the plane

  • exactMatch – match the axisCodes if True

Returns

iterator (position, data-array); position is a (1-based) tuple of length dimensionCount

allPoints()[source]

An iterator over all points yielding (positions, pointValue) tuples.

Returns

iterator (position, data-array); position is a (1-based) tuple of length dimensionCount

allSlices(axisCode: str, exactMatch: bool = True)[source]

An iterator over all slices defined by axisCode, yielding (positions, data-array) tuples.

Parameters
  • axisCode – an axisCodes defining the slice

  • exactMatch – match the axisCodes if True

Returns

iterator (position, data-array); position is a (1-based) tuple of length dimensionCount

property assignmentTolerances: List[float]

- List[float], mutable - Assignment tolerance in axis unit (ppm); per dimension; set to default value on basis of isotopeCode

property axesReversed: Tuple[Optional[bool], ...]

- Tuple[bool=None, …], mutable - Return True if the axis is reversed per dimension

property axisCodes: List[Optional[str]]

- List[str=None], mutable - List of an unique axisCode per dimension

property axisIndices: tuple

- tuple, immutable - Convenience: tuple (len dimensionCount) with the dimension indices (0-based); e.g. (0,1,2,3). Useful for mapping in axisCodes order: eg: self.getByAxisCodes(‘dimensionIndices’, [‘N’,’C’,’H’])

property axisUnits: List[Optional[str]]

- List[str=None], mutable - List of axis units (most commonly ‘ppm’) or None; per dimension

property chemicalShiftList: ccpn.core.ChemicalShiftList.ChemicalShiftList

- ccpn.core.ChemicalShiftList.ChemicalShiftList, mutable - ccpn.ChemicalShiftList used for ccpn.Spectrum

className = 'Spectrum'
cloneAsHdf5(path=None, suffix='_cloned')[source]

Clone self and all peakLists as an Hdf5 type file :return: a Spectrum instance of the cloned spectrum

copyParameters(axisCodes, target)[source]

Copy non-dimensional and dimensional parameters for axisCodes from self to target

createPeak(peakList=None, height=None, **ppmPositions) Optional[Peak][source]

Create and return peak at position specified by the ppmPositions dict.

Ppm positions are passed in as a dict of (axisCode, ppmValue) key, value pairs with the ppmValue supplied mapping to the closest matching axis. Illegal or non-matching axisCodes will return None.

Example ppmPosition dict:

{‘Hn’: 7.0, ‘Nh’: 110}

Example calling function: >>> peak = spectrum.createPeak(**ppmPositions) >>> peak = spectrum.createPeak(peakList, **ppmPositions) >>> peak = spectrum.createPeak(peakList=peakList, Hn=7.0, Nh=110)

Parameters
  • peakList – peakList to create new peak in, or None for the last peakList belonging to spectrum

  • ppmPositions – dict of (axisCode, ppmValue) key,value pairs

Returns

new peak or None

property dataFormat: str

- str, mutable - The spectrum data-format identifier (e.g. Hdf5, NMRPipe); Automatically determined upon creating newSpectrum from a path containing spectral data. (change at your own peril!)

property dataSource

- None, immutable - A SpectrumDataSource instance for reading (writing) of the (binary) spectrum data. None indicates no valid spectrum data file has been defined

delete()[source]

Delete Spectrum

property dimensionCount: int

- int, immutable - Number of dimensions in spectrum

property dimensionIndices: tuple

- tuple, immutable - Convenience: tuple (len dimensionCount) with the dimension indices (0-based); e.g. (0,1,2,3). Useful for mapping in axisCodes order: eg: self.getByAxisCodes(‘dimensionIndices’, [‘N’,’C’,’H’])

property dimensionTriples: tuple

- tuple, immutable - Convenience: return a tuple of triples (dimensionIndex, axisCode, dimension) for each dimension

Useful for iterating over axis codes; eg in an H-N-CO ordered spectrum

for dimIndex, axisCode, dimension in self.getByAxisCodes(‘dimensionTriples’, (‘N’,’C’,’H’), exactMatch=False)

would yield:

(1, ‘N’, 2) (2, ‘CO’, 3) (0, ‘H’, 1)

property dimensionTypes: List[Optional[str]]

- List[str=None], mutable - Dimension types (‘Time’ / ‘Frequency’ / ‘Sampled’) per dimension

property dimensions: tuple

- tuple, immutable - Convenience: tuple (len dimensionCount) with the dimension integers (1-based); e.g. (1,2,3,..). Useful for mapping in axisCodes order: eg: self.getByAxisCodes(‘dimensions’, [‘N’,’C’,’H’])

property displayFoldedContours

- None, mutable - Return whether the folded spectrum contours are to be displayed

estimateNoise()[source]

Estimate and return the noise level, or None if it cannot be

property experiment

- None, immutable - Return the experiment assigned to the spectrum

property experimentName: str

- str, mutable - Common experiment type descriptor (May not be unique).

property experimentType: Optional[str]

- str=None, mutable - Systematic experiment type descriptor (CCPN system).

extractPlaneToFile(axisCodes: tuple, list, position=None, path=None, dataFormat='Hdf5')[source]

Save a plane, defined by axisCodes and position, to path using dataFormat Dimensionality must be >= 2

Parameters
  • axisCodes – tuple/list of two axisCodes

  • position – a list/tuple of point-positions (1-based)

  • path – path of the resulting file; auto-generated if None

  • dataFormat – a data format valid for writing (default=’Hdf5’)

:returns plane as Spectrum instance

extractProjectionToFile(axisCodes: tuple, list, method: str = 'max', threshold=None, path=None, dataFormat='Hdf5')[source]

Save a projected plane, defined by axisCodes and position, using method and an optional threshold, to path using dataFormat Dimensionality must be >= 2

Parameters
  • axisCodes – tuple/list of two axisCodes

  • method – ‘max’, ‘max above threshold’, ‘min’, ‘min below threshold’, ‘sum’, ‘sum above threshold’, ‘sum below threshold’

  • threshold – threshold value for relevant method

  • path – path of the resulting file; auto-generated if None

  • dataFormat – a data format valid for writing

:returns projected plane as Spectrum instance

extractSliceToFile(axisCode, position, path=None, dataFormat='Hdf5')[source]

Extract 1D slice from self as new Spectrum instance; saved to path (autogenerated if None) if 1D it effectively yields a copy of self

Parameters
  • axisCode – axiscode of slice to extract

  • position – position vector (1-based)

  • path – optional path; if None, constructed from current filePath

  • dataFormat – string identifier for dataFormat of resulting file; dataFormat need to have writing abilty (currently only for Hdf5)

Returns

Spectrum instance

property filePath: Optional[str]

- str=None, mutable - Definition of the NMR (binary) dataSource file; can contain redirections (e.g. $DATA) Use Spectrum.path attribute for an absolute, decoded path

property foldingLimits: List[Tuple[float, float]]

- List[Tuple[float, float]], immutable - list of tuples of (ppmPoint(0.5), ppmPoint(n+0.5)) for each dimension

property foldingModes: List[Optional[str]]

- List[str=None], mutable - List of folding modes (values: ‘circular’, ‘mirror’, None); per dimension

property gaussianBroadenings: List[Optional[float]]

- List[float=None], mutable - Gaussian broadening or None; per dimension

get1Dlimits()[source]

Get the 1D spectrum ppm-limits and the intensity limits :return ((ppm1, ppm2), (minValue, maxValue)

getAvailableReferenceExperimentDimensions(_experimentType=None) tuple[source]

Return list of available reference experiment dimensions based on spectrum isotopeCodes

getByAxisCodes(parameterName: str, axisCodes: Optional[Sequence[str]] = None, exactMatch: bool = False) list[source]

Return a list of values defined by parameterName in order defined by axisCodes (default order if None). Perform a mapping if exactMatch=False (eg. ‘H’ to ‘Hn’)

Parameters
  • parameterName – a str denoting a Spectrum dimensional attribute

  • axisCodes – a tuple or list of axisCodes

  • exactMatch – a boolean optional testing for an exact match with the instance axisCodes

Returns

the values defined by parameterName in axisCode order

Related: Use getByDimensions() for dimensions (1..dimensionCount) based access of dimensional parameters of the

Spectrum class.

getByDimensions(parameterName: str, dimensions: Optional[Sequence[int]] = None) list[source]

Return a list of values of Spectrum dimensional attribute parameterName in order defined by dimensions (default order if None).

Parameters
  • parameterName – a str denoting a Spectrum dimensional attribute

  • dimensions – a tuple or list of dimensions (1..dimensionCount)

Returns

a list of values defined by parameterName in dimensions order

Related: Use getByAxisCodes() for axisCode based access of dimensional parameters of the Spectrum class.

getHeight(ppmPositions) float[source]

Returns the interpolated height at the ppm position

getIntegral(relativeId: str) ccpn.core.Integral.Integral

Get contained ‘ccpn.core.Integral.Integral object by relative ID

getIntegralList(relativeId: str) ccpn.core.IntegralList.IntegralList

Get contained ‘ccpn.core.IntegralList.IntegralList object by relative ID

getIntensity(ppmPositions) float[source]

Returns the interpolated height at the ppm position

getMultiplet(relativeId: str) ccpn.core.Multiplet.Multiplet

Get contained ‘ccpn.core.Multiplet.Multiplet object by relative ID

getMultipletList(relativeId: str) ccpn.core.MultipletList.MultipletList

Get contained ‘ccpn.core.MultipletList.MultipletList object by relative ID

getPeak(relativeId: str) ccpn.core.Peak.Peak

Get contained ‘ccpn.core.Peak.Peak object by relative ID

getPeakAliasingRanges()[source]

Return the min/max aliasing Values for the peakLists in the spectrum, if there are no peakLists with peaks, return None

getPeakList(relativeId: str) ccpn.core.PeakList.PeakList

Get contained ‘ccpn.core.PeakList.PeakList object by relative ID

getPlane(axisCodes, position=None) ccpn.core._implementation.SpectrumData.PlaneData[source]

Get a plane defined by axisCodes and position as a a PlaneData object (i.e. a 2D numpy.ndarray in order (yDim, xDim)). Dimensionality must be >= 2

Parameters
  • axisCodes – tuple/list of two axisCodes; expand if exactMatch=False

  • position – A list/tuple of point-positions (1-based)

  • axisCodes – A list/tuple of axisCodes that define the plane dimensions

Returns

a PlaneData object (i.e. a 2D numpy.ndarray in order (yDim, xDim))

NB: use getPlaneData method for dimension based access

getPlaneData(position=None, xDim: int = 1, yDim: int = 2) ccpn.core._implementation.SpectrumData.PlaneData[source]

Get a plane defined by by xDim and yDim (‘1’-based), and a position vector (‘1’-based) as a PlaneData object (i.e. a 2D numpy.ndarray). Dimensionality must be >= 2

Parameters
  • position – A list/tuple of point-positions (1-based)

  • xDim – Dimension of the first axis (1-based)

  • yDim – Dimension of the second axis (1-based)

Returns

a PlaneData object (i.e. a 2D numpy.ndarray in order (yDim, xDim))

NB: use getPlane() method for axisCode based access

getPointValue(pointPositions) float[source]

Return the value interpolated at the position given in points (1-based, float values).

getPpmArray(axisCode=None, dimension=None) numpy.array[source]

Return a numpy array with ppm values of the grid points along axisCode or dimension

getProjection(axisCodes: tuple, list, method: str = 'max', threshold=None) ccpn.core._implementation.SpectrumData.PlaneData[source]

Get projected plane defined by two axisCodes, using method and an optional threshold

Parameters
  • axisCodes – tuple/list of two axisCodes; expand if exactMatch=False

  • method – ‘max’, ‘max above threshold’, ‘min’, ‘min below threshold’, ‘sum’, ‘sum above threshold’, ‘sum below threshold’

  • threshold – threshold value for relevant method

Returns

projected spectrum data as a PlaneData object (i.e. a 2D numpy.ndarray in order (yDim, xDim))

getPseudoDimension(relativeId: str) ccpn.core.PseudoDimension.PseudoDimension

Get contained ‘ccpn.core.PseudoDimension.PseudoDimension object by relative ID

getRegion(**axisDict) ccpn.core._implementation.SpectrumData.RegionData[source]

Return the region of the spectrum data defined by the axis limits in ppm as a RegionData object, i.e. a numpy.ndarray of the same dimensionality as defined by the Spectrum instance.

Axis limits are passed in as a dict of (axisCode, tupleLimit) key, value pairs with the tupleLimit supplied as (startPpm,stopPpm) axis limits in ppm (lower ppm value first). For axisCodes that are not included in the axisDict, the limits will by taken from the spectrum limits along the relevant axis For axisCodes that are None, the limits will by taken from the spectrum limits along the relevant axis. Illegal axisCodes will raise an error.

Example axisDict:

{‘Hn’: (7.0, 9.0), ‘Nh’: (110, 130)}

Example calling function:

regionData = spectrum.getRegion(**limitsDict) regionData = spectrum.getRegion(Hn=(7.0, 9.0), Nh=(110, 130))

Parameters

axisDict – dict of (axisCode, (startPpm,stopPpm)) key,value pairs

Returns

RegionData object

getSlice(axisCode, position) ccpn.core._implementation.SpectrumData.SliceData[source]

Get a slice defined by axisCode and a position vector a SliceData object (i.e. a numpy array)

Parameters
  • axisCode – valid axisCode of the slice axis

  • position – An optional list/tuple of point positions (1-based); defaults to [1,1,1,1]

Returns

SliceData 1D data array

NB: use getSliceData() method for dimension based access

getSliceData(position=None, sliceDim: int = 1) ccpn.core._implementation.SpectrumData.SliceData[source]

Get a slice defined by sliceDim and a position vector as a SliceData object (i.e. a numpy array).

Parameters
  • position – An optional list/tuple of point positions (1-based); defaults to [1,1,1,1]

  • sliceDim – Dimension of the slice axis (1-based); defaults to 1

Returns

SliceData 1D data array

NB: use getSlice() method for axisCode based access

getSpectrumHit(relativeId: str) ccpn.core.SpectrumHit.SpectrumHit

Get contained ‘ccpn.core.SpectrumHit.SpectrumHit object by relative ID

getSpectrumReference(relativeId: str) ccpn.core.SpectrumReference.SpectrumReference

Get contained ‘ccpn.core.SpectrumReference.SpectrumReference object by relative ID

hasValidPath() bool[source]

Return true if the spectrum’s dataSource currently defines an valid dataSource object with a valid path defined

property includeNegativeContours

- None, mutable - Include flag for the negative contours

property includePositiveContours

- None, mutable - Include flag for the positive contours

property integralLists

- (‘ccpn.core.IntegralList.IntegralList,) - contained IntegralList objects in creation order. This may differ from the standard sorting order

property integrals

- (‘ccpn.core.Integral.Integral,) - contained Integral objects in creation order. This may differ from the standard sorting order

property intensities: ccpn.core._implementation.SpectrumData.SliceData

- ccpn.core._implementation.SpectrumData.SliceData, mutable - spectral intensities as a SliceData (i.e. NumPy array) for 1D spectra

property isAquisition: List[bool]

- List[bool], mutable - Boolean per dimension denoting if it is the aquisition dimension

isBuffered()[source]

Return True if dataSource of spectrum is buffered

property isComplex: List[bool]

- List[bool], mutable - Boolean denoting Complex data per dimension

isEmptySpectrum() bool[source]

Return True if instance refers to an empty spectrum; i.e. as in without actual spectral data”

property isSampledDomains: list

- list, immutable - Conveniance: A list of booleans per dimension indicating if dimension is sampled

property isTimeDomains: list

- list, immutable - Conveniance: A list of booleans per dimension indicating if dimension is time domain

property isotopeCodes: List[str]

- List[str], mutable - isotopeCode or None; per dimension

property lorentzianBroadenings: List[Optional[float]]

- List[float=None], mutable - Lorenzian broadening (in Hz) or None; per dimension

property magnetisationTransfers: Tuple[ccpn.core.lib.SpectrumLib.MagnetisationTransferTuple, ...]

- Tuple[ccpn.core.lib.SpectrumLib.MagnetisationTransferTuple, …], immutable - tuple of MagnetisationTransferTuple describing magnetisation transfer between the spectrum dimensions.

MagnetisationTransferTuple is a namedtuple with the fields [‘dimension1’, ‘dimension2’, ‘transferType’, ‘isIndirect’] of types [int, int, str, bool] The dimensions are dimension numbers (one-origin] transfertype is one of (in order of increasing priority): ‘onebond’, ‘Jcoupling’, ‘Jmultibond’, ‘relayed’, ‘relayed-alternate’, ‘through-space’ isIndirect is used where there is more than one successive transfer step; it is combined with the highest-priority transferType in the transfer path.

The magnetisationTransfers are deduced from the experimentType and axisCodes. Only when the experimentType is unset or does not match any known reference experiment magnetisationTransfers are kept separately in the API layer.

property measurementTypes: List[Optional[str]]

- List[str=None], mutable - Type of value being measured, per dimension. In normal cases the measurementType will be ‘Shift’, but other values might be ‘MQSHift’ (for multiple quantum axes), JCoupling (for J-resolved experiments), ‘T1’, ‘T2’, — defined SpectrumLib.MEASUREMENT_TYPES

property multipletLists

- (‘ccpn.core.MultipletList.MultipletList,) - contained MultipletList objects in creation order. This may differ from the standard sorting order

property multiplets

- (‘ccpn.core.Multiplet.Multiplet,) - contained Multiplet objects in creation order. This may differ from the standard sorting order

property name: str

- str, mutable - short form of name, used for id

property negativeContourBase: float

- float, mutable - base level of negative contours

property negativeContourColour: str

- str, mutable - colour of negative contours

property negativeContourCount: int

- int, mutable - number of negative contours to draw

property negativeContourFactor: float

- float, mutable - level multiplier for negative contours

property negativeNoiseLevel: float

- float, mutable - Negative noise level value. Stored in Internal

newIntegralList(title: str = None, symbolColour: str = None, textColour: str = None, comment: str = None, **kwds)[source]

Create new IntegralList within Spectrum.

See the IntegralList class for details.

Optional keyword arguments can be passed in; see IntegralList._newIntegralList for details.

Parameters
  • self

  • title

  • symbolColour

  • textColour

  • comment

Returns

a new IntegralList attached to the spectrum.

newMultipletList(title: str = None, symbolColour: str = None, textColour: str = None, lineColour: str = None, multipletAveraging=None, comment: str = None, multiplets: Sequence[Multiplet | str] = None, **kwds)[source]

Create new MultipletList within Spectrum.

See the MultipletList class for details.

Optional keyword arguments can be passed in; see MultipletList._newMultipletList for details.

Parameters
  • title – title string

  • symbolColour

  • textColour

  • lineColour

  • multipletAveraging

  • comment – optional comment string

  • multiplets – optional list of multiplets as objects or pids

Returns

a new MultipletList attached to the Spectrum.

newPeakList(title: str = None, comment: str = None, isSimulated: bool = False, symbolStyle: str = None, symbolColour: str = None, textColour: str = None, **kwds)[source]

Create new empty PeakList within Spectrum

See the PeakList class for details.

Optional keyword arguments can be passed in; see PeakList._newPeakList for details.

Parameters
  • title

  • comment

  • isSimulated

  • symbolStyle

  • symbolColour

  • textColour

Returns

a new PeakList attached to the spectrum.

newSpectrumHit(substanceName: str, pointNumber: int = 0, pseudoDimensionNumber: int = 0, pseudoDimension=None, figureOfMerit: float = None, meritCode: str = None, normalisedChange: float = None, isConfirmed: bool = None, concentration: float = None, concentrationError: float = None, concentrationUnit: str = None, comment: str = None, **kwds)[source]

Create new SpectrumHit within Spectrum.

See the SpectrumHit class for details.

Optional keyword arguments can be passed in; see SpectrumHit._newSpectrumHit for details.

Parameters
  • substanceName

  • pointNumber

  • pseudoDimensionNumber

  • pseudoDimension

  • figureOfMerit

  • meritCode

  • normalisedChange

  • isConfirmed

  • concentration

  • concentrationError

  • concentrationUnit

  • comment – optional comment string

Returns

a new SpectrumHit instance.

property noiseLevel: (<class 'float'>, None)

- (float, None), mutable - Noise level for the spectrum

orderByAxisCodes(iterable, axisCodes: Optional[Sequence[str]] = None, exactMatch: bool = False) list[source]

Return a list with values of an iterable in order defined by axisCodes (default order if None). Perform a mapping if exactMatch=False (eg. ‘H’ to ‘Hn’)

Parameters
  • iterable – an iterable (tuple, list)

  • axisCodes – a tuple or list of axisCodes

  • exactMatch – a boolean optional testing for an exact match with the instance axisCodes

Returns

the values defined by iterable in axisCode order

Related: Use getByDimensions() for dimensions (1..dimensionCount) based access of dimensional parameters of the

Spectrum class.

Use getByAxisCodes() for axisCode based access of dimensional parameters of the Spectrum class.

orderByDimensions(iterable, dimensions=None) list[source]

Return a list of values of iterable in order defined by dimensions (default order if None).

Parameters
  • iterable – an iterable (tuple, list)

  • dimensions – a tuple or list of dimensions (1..dimensionCount)

Returns

a list with values defined by iterable in dimensions order

property path: ccpn.util.Path.Path

- ccpn.util.Path.Path, immutable - return a Path instance defining the absolute, decoded path of filePath

property peakLists

- (‘ccpn.core.PeakList.PeakList,) - contained PeakList objects in creation order. This may differ from the standard sorting order

property peakPicker

- None, mutable - A PeakPicker instance for region picking in this spectrum. None indicates no valid PeakPicker has been defined

property peaks

- (‘ccpn.core.Peak.Peak,) - contained Peak objects in creation order. This may differ from the standard sorting order

property phases0: List[Optional[float]]

- List[float=None], mutable - Zero-order phase correction (or None), per dimension

property phases1: List[Optional[float]]

- List[float=None], mutable - First-order phase correction (or None) per dimension

pickPeaks(peakList=None, positiveThreshold=None, negativeThreshold=None, **ppmRegions) Tuple[Peak, ...][source]

Pick peaks in the region defined by the ppmRegions dict.

Ppm regions are passed in as a dict containing the axis codes and the required limits. Each limit is defined as a key, value pair: (str, tuple), with the tuple supplied as (min, max) axis limits in ppm. Axis codes supplied are mapped to the closest matching axis. Illegal or non-matching axisCodes will return None.

Example ppmRegions dict:

{‘Hn’: (7.0, 9.0), ‘Nh’: (110, 130)}

Example calling function: >>> peaks = spectrum.pickPeaks(**ppmRegions) >>> peaks = spectrum.pickPeaks(peakList, **ppmRegions) >>> peaks = spectrum.pickPeaks(peakList=peakList, Hn=(7.0, 9.0), Nh=(110, 130))

Parameters
  • peakList – peakList to create new peak in, or None for the last peakList belonging to spectrum

  • positiveThreshold – float or None specifying the positive threshold above which to find peaks. if None, positive peak picking is disabled.

  • negativeThreshold – float or None specifying the negative threshold below which to find peaks. if None, negative peak picking is disabled.

  • ppmRegions – dict of (axisCode, tupleValue) key, value pairs

Returns

tuple of new Peak instances

point2ppm(value, axisCode=None, dimension=None)[source]

Convert point value to ppm for axis corresponding to to either axisCode or dimension (1-based)

property pointCounts: List[int]

- List[int], mutable - Number of points per dimension

property positions: numpy.array

- <built-in function array>, mutable - spectral region in ppm as NumPy array for 1D spectra

property positiveContourBase: float

- float, mutable - base level of positive contours

property positiveContourColour: str

- str, mutable - colour of positive contours

property positiveContourCount: int

- int, mutable - number of positive contours to draw

property positiveContourFactor: float

- float, mutable - level multiplier for positive contours

ppm2point(value, axisCode=None, dimension=None)[source]

Convert ppm value to point value for axis corresponding to either axisCode or dimension (1-based)

property ppmPerPoints: List[float]

- List[float], immutable - Convenience; ppm-per-point for each dimension

printParameters(includeDimensions=True)[source]

Print the info string

property pseudoDimensions

- (‘ccpn.core.PseudoDimension.PseudoDimension,) - contained PseudoDimension objects in order of underlying key. This may differ from the standard sorting order

property referenceExperimentDimensions: Tuple[Optional[str], ...]

- Tuple[str=None, …], mutable - dimensions of reference experiment - None if no code

property referencePoints: List[Optional[float]]

- List[float=None], mutable - List of points used for axis (chemical shift) referencing; per dimension.

property referenceSubstance

- None, mutable - Deprecated. See referenceSubstances

property referenceSubstances

- None, mutable - :return: a list of substances

property referenceValues: List[Optional[float]]

- List[float=None], mutable - List of ppm-values used for axis (chemical shift) referencing; per dimension.

reload(path: str = None)[source]

Reload the spectrum as defined by path; DataFormat and dimensionality need to match with the current Spectrum instance. All other parameters will be pulled from the (binary) spectrum data.

Parameters

path – a path to the spectrum; may contain redirections (e.g. $DATA) defaults to self.filePath.

rename(value: str)[source]

Rename Spectrum, changing its name and Pid.

property sample: Optional[ccpn.core.Sample.Sample]

- ccpn.core.Sample.Sample=None, mutable - ccpn.Sample used to acquire ccpn.Spectrum

property scale: float

- float, mutable - Scaling factor for data in the spectrum.

setBuffering(isBuffered: bool, path: Optional[str] = None)[source]

Set Hdf5-buffering. Buffering status is retained (upon exit/save) if path is None; i.e. autobuffering, until buffering is disabled by isBuffered=False

Parameters
  • isBuffered – set the buffering status

  • path – store hdf5buffer file at path; implies non-temporary buffer

setByAxisCodes(parameterName: str, values: Sequence, axisCodes: Optional[Sequence[str]] = None, exactMatch: bool = False) list[source]

Set attributeName to values in order defined by axisCodes (default order if None) Perform a mapping if exactMatch=False (eg. ‘H’ to ‘Hn’)

Parameters
  • parameterName – a str denoting a Spectrum dimensional attribute

  • values – an iterable with values

  • axisCodes – a tuple or list of axisCodes

  • exactMatch – a boolean optional testing for an exact match with the instance axisCodes

Returns

a list of newly set values of parameterName (in default order)

Related: Use setByDimensions() for dimensions (1..dimensionCount) based setting of dimensional parameters of the

Spectrum class.

setByDimensions(parameterName: str, values: Sequence, dimensions: Optional[Sequence[int]] = None) list[source]

Set Spectrum dimensional attribute parameterName to values in the order as defined by dimensions (1..dimensionCount)(default order if None)

Parameters
  • parameterName – a str denoting a Spectrum dimensional attribute

  • values – a list of values to set for each dimension

  • dimensions – a tuple or list of dimensions (1..dimensionCount)

Returns

a list of newly set values of parameterName (in default order)

Related: Use setByAxisCodes() for axisCode based setting of dimensional parameters of the Spectrum class.

setPeakAliasing(peaks, aliasingIndexes, updateSpectrumAliasingIndexes=False)[source]

Set the peak aliasing for a set of peaks in the spectrum

Peaks is an iterable of type str of Peak - bad strings are ignored Core objects that are not of type Peak will raise error

Parameters
  • peaks

  • aliasingIndexes – tuple(int, int)

  • updateSpectrumAliasingIndexes – True/False

Returns

setPlaneData(data, position: Optional[Sequence] = None, xDim: int = 1, yDim: int = 2)[source]

Set the plane data as defined by xDim, yDim and position (all 1-based).

Parameters
  • data – A 2-dimensional float32 numpy array in order (yDim, xDim)

  • position – position: A list/tuple of point-positions (1-based)

  • xDim – Dimension of the first axis (1-based)

  • yDim – Dimension of the second axis (1-based)

setPreferredDimensionOrdering(dimensionOrder)[source]

Set the preferred dimension ordering ;param dimensionOrder: tuple,list of dimensions (1-based; len dimensionCount)

setSliceData(data, position: Optional[Sequence] = None, sliceDim: int = 1)[source]

Set data as slice defined by sliceDim and position (all 1-based)

shortClassName = 'SP'

Short class name, for PID.

property sineWindowShifts: List[Optional[float]]

- List[float=None], mutable - Shift of sine/sine-square window function (in degrees) or None; per dimension

property sliceColour: str

- str, mutable - colour of 1D slices

property spectralWidths: List[float]

- List[float], mutable - spectral width (in ppm) per dimension

property spectralWidthsHz: List[float]

- List[float], mutable - spectral width (in Hz) per dimension

property spectrometerFrequencies: List[float]

- List[float], mutable - Spectrometer frequency; per dimension

property spectrumDimensions: tuple

- tuple, immutable - :return A tuple with the spectrum dimensions (== SpectrumReference or PseudoDimension) instances

property spectrumGroups: Tuple[ccpn.core.SpectrumGroup.SpectrumGroup, ...]

- Tuple[ccpn.core.SpectrumGroup.SpectrumGroup, …], mutable - SpectrumGroups that contain Spectrum

property spectrumHits

- (‘ccpn.core.SpectrumHit.SpectrumHit,) - contained SpectrumHit objects in order of underlying key. This may differ from the standard sorting order

property spectrumLimits: List[Tuple[float, float]]

- List[Tuple[float, float]], immutable - list of tuples of (ppmPoint(1), ppmPoint(n)) for each dimension

property spectrumReferences

- (‘ccpn.core.SpectrumReference.SpectrumReference,) - contained SpectrumReference objects in order of underlying key. This may differ from the standard sorting order

property spectrumViews: tuple

- tuple, immutable - Return a tuple of SpectrumView instances associated with this spectrum

property spinningRate: float

- float, mutable - NMR tube spinning rate (in Hz)

property synonym: Optional[str]

- str=None, immutable - Systematic experiment type descriptor (CCPN system).

property temperature

- None, mutable - The temperature of the spectrometer when the spectrum was recorded

property windowFunctions: List[Optional[str]]

- List[str=None], mutable - Window function name (or None); per dimension e.g. ‘EM’, ‘GM’, ‘SINE’, ‘QSINE’, …. (defined in SpectrumLib.WINDOW_FUNCTIONS)

ccpn.core.SpectrumGroup module

class ccpn.core.SpectrumGroup.SeriesTypes(value)[source]

Bases: ccpn.util.LabelledEnum.LabelledEnum

Class to handle series types in spectrumGroups

FLOAT = 0
INTEGER = 1
PYTHONLITERAL = 3
STRING = 2
class ccpn.core.SpectrumGroup.SpectrumGroup(project, wrappedData)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Combines multiple Spectrum objects into a group, so they can be treated as a single object.

SPECTRUM_ORDER = 'spectrum_order'
addSpectrum(spectrum, seriesValue=None)[source]

Add a spectrum Instance to the spectrum group

Parameters
  • spectrum – a Spectrum instance to be added to the group

  • seriesValue – a value associated with this series

className = 'SpectrumGroup'
clone()[source]
property comment: str

- str, mutable - Free-form text comment

property name: str

- str, mutable - Name of SpectrumGroup, part of identifier

property negativeContourColour: str

- str, mutable - nD negative contour colour for group

property positiveContourColour: str

- str, mutable - nD positive contour colour for group

rename(value: str)[source]

Rename SpectrumGroup, changing its name and Pid.

property serial: str

- str, immutable - Serial number of SpectrumGroup, used for sorting

property series: Tuple[Any, ...]

- Tuple[Any, …], mutable - Returns a tuple of series items for the attached spectra

series = (val1, val2, …, valN)

where val1-valN correspond to the series items in the attached spectra associated with this group For a spectrum with no values, returns None in place of Item

property seriesPeakHeightForNmrResidue

- None, immutable - return: Pandas DataFrame with the following structure:

Index: ID for the nmrResidue(s) assigned to the peak ; Columns => Spectrum series values sorted by ascending values, if series values are not set, then the

spectrum name is used instead.

SP1 | SP2 | SP3

NR_ID | | | |

————+———–+———–+———–+———

A.1.ARG | 10 | 100 | 1000

property seriesPeakHeightForPosition

- None, immutable - return: Pandas DataFrame with the following structure:

Index: multiIndex => axisCodes as levels; Columns => NR_ID: ID for the nmrResidue(s) assigned to the peak if available

Spectrum series values sorted by ascending values, if series values are not set, then the spectrum name is used instead.

NR_ID | SP1 | SP2 | SP3

H N | | | |

————-+——– +———–+———–+———

7.5 104.3 | A.1.ARG | 10 | 100 | 1000

property seriesType

- None, mutable - Return the seriesType for the spectrumGroup

property seriesUnits

- None, mutable - Return the seriesUnits for the spectrumGroup

shortClassName = 'SG'

Short class name, for PID.

property sliceColour: str

- str, mutable - 1D slice colour for group

sortSpectraByName(reverse=True)[source]
sortSpectraBySeries(reverse=True)[source]
property spectra: Tuple[ccpn.core.Spectrum.Spectrum, ...]

- Tuple[ccpn.core.Spectrum.Spectrum, …], mutable - Spectra that make up SpectrumGroup.

ccpn.core.SpectrumHit module

class ccpn.core.SpectrumHit.SpectrumHit(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Used in screening and metabolomics implementations to describe a ‘hit’, i.e. that a Substance has been found to be present (metabolomics) or active (screening) in a given spectrum.

The Substance referred to is defined by the SubsanceName attribute, which is part of the ID. For this reason SpectrumHits cannot be renamed.

className = 'SpectrumHit'
property concentration: float

- float, mutable - Concentration determined for the spectrumHit - used for e.g. Metabolomics where concentrations are not known a priori.

property concentrationError: float

- float, mutable - Estimated Standard error of SpectrumHit.concentration

property concentrationUnit: str

- str, mutable - Unit of SpectrumHit.concentration, one of: %s% Constants.concentrationUnits

property figureOfMerit: float

- float, mutable - Figure of merit describing quality of hit, between 0.0 and 1.0 inclusive.

property isConfirmed: Optional[bool]

- bool=None, mutable - True if this Hit is confirmed? True: yes; False; no; None: not determined

property meritCode: str

- str, mutable - User-defined merit code string describing quality of hit.

property normalisedChange: float

- float, mutable - Normalized size of effect (normally intensity change). in range -1 <= x <= 1. Positive values denote expected changes, while negative values denote changes in the ‘wrong’ direction, e.g. intensity increase where a decrease was expected.

property pointNumber: int

- int, immutable - Point number for pseudoDimension (0 if none), if the Hit only refers to one point in a pseudoDimension

property pseudoDimension: ccpn.core.PseudoDimension.PseudoDimension

- ccpn.core.PseudoDimension.PseudoDimension, immutable - PseudoDimension, if the Hit only refers to one point in a pseudoDimension

property pseudoDimensionNumber: int

- int, immutable - Dimension number for pseudoDimension (0 if none), if the Hit only refers to one point in a pseudoDimension

property sample: ccpn.core.Sample.Sample

- ccpn.core.Sample.Sample, immutable - ccpn.Sample in which ccpn.SpectrumHit (for screening/metabolomics) is found

property sampleComponent: ccpn.core.SampleComponent.SampleComponent

- ccpn.core.SampleComponent.SampleComponent, immutable - ccpn.SampleComponent in which ccpn.SpectrumHit is found

shortClassName = 'SH'

Short class name, for PID.

property spectrum: ccpn.core.Spectrum.Spectrum

- ccpn.core.Spectrum.Spectrum, immutable - Spectrum containing spectrumHit.

property substanceName: str

- str, immutable - Name of hit substance

ccpn.core.SpectrumReference module

class ccpn.core.SpectrumReference.SpectrumReference(project, wrappedData)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject, ccpn.core._implementation.SpectrumDimensionAttributes.SpectrumDimensionAttributes

A SpectrumReference holds detailed information about axes and referencing needed for e.g. multple-quantum, projection, and reduced-dimensionality experiments.

SpectrumReferences can only exist for frequency dimensions. Required for describing experiments with assignable splittings (e.g. J-coupling, RDC), reduced dimensionality, more than one nucleus per axis, or multi-atom parameters (J-dimensions, MQ dimensions).

className = 'SpectrumReference'
pointToPpm(point: float) float

:return ppm-value corresponding to point (float)

pointToValue(point: float) float[source]

:return ppm-value corresponding to point (float)

ppmToPoint(value: float) float

:return point (float) corresponding to ppm-value

shortClassName = 'SR'

Short class name, for PID.

property spectrum: ccpn.core.Spectrum.Spectrum

- ccpn.core.Spectrum.Spectrum, immutable - Spectrum containing spectrumReference.

valueToPoint(value: float) float[source]

:return point (float) corresponding to ppm-value

ccpn.core.StructureData module

class ccpn.core.StructureData.StructureData(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Data set. Used to store the input to (or output from) a calculation, including data selection and parameters, to group Restraints that are used together, to track data history and file loads.

property calculationSteps

- (‘ccpn.core.CalculationStep.CalculationStep,) - contained CalculationStep objects in creation order. This may differ from the standard sorting order

className = 'StructureData'
property creationDate: Optional[datetime.datetime]

- datetime.datetime=None, mutable - Creation timestamp for StructureData

property data

- (‘ccpn.core.Data.Data,) - contained Data objects in name order This is identical to the standard sorting order.

property dataPath: Optional[str]

- str=None, mutable - File path where structureData is stored

getCalculationStep(relativeId: str) ccpn.core.CalculationStep.CalculationStep

Get contained ‘ccpn.core.CalculationStep.CalculationStep object by relative ID

getData(relativeId: str) ccpn.core.Data.Data

Get contained ‘ccpn.core.Data.Data object by relative ID

getRestraint(relativeId: str) ccpn.core.Restraint.Restraint

Get contained ‘ccpn.core.Restraint.Restraint object by relative ID

getRestraintContribution(relativeId: str) ccpn.core.RestraintContribution.RestraintContribution

Get contained ‘ccpn.core.RestraintContribution.RestraintContribution object by relative ID

getRestraintTable(relativeId: str) ccpn.core.RestraintTable.RestraintTable

Get contained ‘ccpn.core.RestraintTable.RestraintTable object by relative ID

getViolationTable(relativeId: str) ccpn.core.ViolationTable.ViolationTable

Get contained ‘ccpn.core.ViolationTable.ViolationTable object by relative ID

property inputCalculationSteps: List[ccpn.core.CalculationStep.CalculationStep]

- List[ccpn.core.CalculationStep.CalculationStep], immutable - ccpn.CalculationSteps (from this StructureData) that yielded StructureData as output NB there can be more than one, because the StructureData may result from multiple calculations that do not have intermediate StructureDatas stored

property moleculeFilePath

- None, mutable - :return: a filePath for corresponding molecule. E.g., PDB file path for displaying molecules in a molecular viewer

property name: str

- str, mutable - Name of StructureData.

newCalculationStep(programName: str = None, programVersion: str = None, scriptName: str = None, script: str = None, inputDataUuid: str = None, outputDataUuid: str = None, inputStructureData=None, outputStructureData=None, **kwds)[source]

Create new CalculationStep within StructureData.

See the CalculationStep class for details.

Optional keyword arguments can be passed in; see CalculationStep._newCalculationStep for details.

Parameters
  • programName

  • programVersion

  • scriptName

  • script

  • inputDataUuid

  • outputDataUuid

  • inputStructureData

  • outputStructureData

Returns

a new CalculationStep instance.

newData(name: str, attachedObjectPid: str = None, attachedObject: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject = None, **kwds)[source]

Create new Data within StructureData.

See the Data class for details.

Optional keyword arguments can be passed in; see Data._newData for details.

Parameters
  • name

  • attachedObjectPid

  • attachedObject

Returns

a new Data instance.

newRestraintTable(restraintType, name: str = None, origin: str = None, comment: str = None, unit: str = None, potentialType: str = 'unknown', tensorMagnitude: float = 0.0, tensorRhombicity: float = 0.0, tensorIsotropicValue: float = 0.0, tensorChainCode: str = None, tensorSequenceCode: str = None, tensorResidueType: str = None, restraintItemLength=None, **kwds)[source]

Create new RestraintTable of type restraintType within StructureData.

See the RestraintTable class for details.

Optional keyword arguments can be passed in; see RestraintTable._newRestraintTable for details.

Parameters
  • restraintType

  • name

  • origin

  • comment

  • unit

  • potentialType

  • tensorMagnitude

  • tensorRhombicity

  • tensorIsotropicValue

  • tensorChainCode

  • tensorSequenceCode

  • tensorResidueType

  • restraintItemLength

Returns

a new RestraintTable instance.

newViolationTable(name: str = None, data=None, comment: str = None, **kwds)[source]

Create new ViolationTable.

See the ViolationTable class for details.

Optional keyword arguments can be passed in; see ViolationTable._newViolationTable for details.

Parameters
  • name – new name for the ViolationTable.

  • data – Pandas dataframe.

  • comment – optional comment string

Returns

a new ViolationTable instance.

property outputCalculationSteps: List[ccpn.core.CalculationStep.CalculationStep]

- List[ccpn.core.CalculationStep.CalculationStep], immutable - ccpn.CalculationSteps (from other StructureData) that used StructureData as input

property programName: str

- str, mutable - Name of program performing the calculation

property programVersion: Optional[str]

- str=None, mutable - Version of program performing the calculation

rename(value: str)[source]

Rename StructureData, changing its name and Pid. NB, the serial remains immutable.

property restraintContributions

- (‘ccpn.core.RestraintContribution.RestraintContribution,) - contained RestraintContribution objects in creation order. This may differ from the standard sorting order

property restraintTables

- (‘ccpn.core.RestraintTable.RestraintTable,) - contained RestraintTable objects in creation order. This may differ from the standard sorting order

property restraints

- (‘ccpn.core.Restraint.Restraint,) - contained Restraint objects in creation order. This may differ from the standard sorting order

property serial: int

- int, immutable - serial number of StructureData, used in Pid and to identify the StructureData.

shortClassName = 'SD'

Short class name, for PID.

property title: str

- str, mutable - Title of StructureData.

property uuid: Optional[str]

- str=None, mutable - Universal identifier for structureData

property violationTables

- (‘ccpn.core.ViolationTable.ViolationTable,) - contained ViolationTable objects in creation order. This may differ from the standard sorting order

ccpn.core.StructureEnsemble module

class ccpn.core.StructureEnsemble.StructureEnsemble(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Ensemble of coordinate structures.

className = 'StructureEnsemble'
property data: ccpn.util.StructureData.EnsembleData

- ccpn.util.StructureData.EnsembleData, mutable - EnsembleData (Pandas DataFrame) with structure data.

Note that modifying the data via setValues, ‘data[column] = ‘ or ‘data.column = ‘ will be echoed and put on the undo stack. Changing the data by direct pandas access will not.

getModel(relativeId: str) ccpn.core.Model.Model

Get contained ‘ccpn.core.Model.Model object by relative ID

property models

- (‘ccpn.core.Model.Model,) - contained Model objects in creation order. This may differ from the standard sorting order

property name: str

- str, mutable - Name of StructureEnsemble, part of identifier

newModel(label: str = None, comment: str = None, **kwds)[source]

Create new Model.

See the Model class for details.

Optional keyword arguments can be passed in; see Model._newModel for details.

Parameters
  • label – new name for the model.

  • comment – optional comment string.

Returns

a new Model instance.

rename(value: str)[source]

Rename StructureEnsemble, changing its name and Pid. NB, the serial remains immutable.

resetModels()[source]

Remove models without data, add models to reflect modelNumbers present

property serial: int

- int, immutable - ID number of StructureEnsemble, used in Pid and to identify the StructureEnsemble.

shortClassName = 'SE'

Short class name, for PID.

ccpn.core.Substance module

class ccpn.core.Substance.Substance(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

A Substance is a chemical entity or material that can be added to a Sample. Substances are defined by their name and labelling attributes (labelling defaults to None). Renaming a Substance will also rename all SampleComponents and SpectrumHits associated with it, so as to preserve the link between the objects.

The most common case (by far) is substanceType ‘Molecule’, which corresponds to a chemical entity, such as Calmodulin, ATP, or NaCl. This type of Substance will have Smiles strings, sequence, and other molecular attributes as appropriate. Such a Substance may be associated with one or more Chains, and can be used as a starting point to generate new Chains, using the Project.createPolymerSubstance() function.

ADVANCED: It is also possible to create Substances with substanceType ‘Material’ or ‘Cell’. Materials are used to describe chemical mixtures, such as fetal calf serum, algal lysate, or ‘standard experiment buffer number 3’.

property atomCount: int

- int, mutable - Number of atoms in the molecule - for Molecular substances

property bondCount: int

- int, mutable - Number of bonds in the molecule - for Molecular substances

property casNumber: Optional[str]

- str=None, mutable - CAS number string - for substances that have one

property chains: Tuple[ccpn.core.Chain.Chain, ...]

- Tuple[ccpn.core.Chain.Chain, …], immutable - ccpn.Chains that correspond to ccpn.Substance (if defined)

className = 'Substance'
clearSpecificAtomLabelling()[source]

Clear specificAtomLabelling

createChain(shortName: str = None, role: str = None, comment: str = None, expandFromAtomSets: bool = True, addPseudoAtoms: bool = True, addNonstereoAtoms: bool = True, **kwds)[source]

Create new Chain that matches Substance

See the Chain class for details.

Optional keyword arguments can be passed in; see Chain._createChainFromSubstance for details.

Parameters
  • shortName

  • role

  • comment – optional comment string

Returns

a new Chain instance.

property empiricalFormula: Optional[str]

- str=None, mutable - Empirical molecular formula string - for substances that have one

getChain(shortName: str = None, role: str = None, comment: str = None, **kwds)[source]

Get existing Chain that matches Substance

See the Chain class for details.

Optional keyword arguments can be passed in; see Chain._createChainFromSubstance for details.

Parameters
  • shortName

  • role

  • comment – optional comment string

Returns

a new Chain instance.

getSpecificAtomLabelling(atom: str | Atom) Dict[str, float][source]

Get specificAtomLabelling dictionary for atom. atom may be an Atom object, an atomId or an atom Pid

returns dictionary of the form e.g. {‘12C’:0.32, ‘13C’:0.68}

property hBondAcceptorCount: int

- int, mutable - Number of hydrogen bond acceptors in the molecule - for Molecular substances

property hBondDonorCount: int

- int, mutable - Number of hydrogen bond donors in the molecule - for Molecular substances

property inChi: Optional[str]

- str=None, mutable - inChi string - for substances that have one

property labelling: str

- str, immutable - labelling descriptor of Substance (default is ‘std’)

property logPartitionCoefficient: Optional[float]

- float=None, mutable - Logarithm of the octanol-water partition coefficient (logP) - for Molecular substances

property molecularMass: Optional[float]

- float=None, mutable - Molecular mass - for substances that have one

property name: str

- str, immutable - name of Substance

property polarSurfaceArea: Optional[float]

- float=None, mutable - Polar surface area (in square Angstrom) of the molecule - for Molecular substances

property referenceSpectra: Tuple[ccpn.core.Spectrum.Spectrum, ...]

- Tuple[ccpn.core.Spectrum.Spectrum, …], mutable - Reference Spectra acquired for Substance

removeSpecificAtomLabelling(atom: str | Atom)[source]

Remove specificAtomLabelling for atom designated by atomId

NBNB labelling is removed for the matching atom in all chains that match the Substance also if the other chains have a different numbering.

rename(name: str = None, labelling: str = None)[source]

Rename Substance, changing its name and/or labelling and Pid, and rename SampleComponents and SpectrumHits with matching names. If name is None, the existing value will be used. Labelling ‘None’ means ‘Natural abundance’

property ringCount: int

- int, mutable - Number of rings in the molecule - for Molecular substances

property sampleComponents: Tuple[ccpn.core.SampleComponent.SampleComponent, ...]

- Tuple[ccpn.core.SampleComponent.SampleComponent, …], immutable - SampleComponents that correspond to Substance

property sequenceString: Optional[str]

- str=None, mutable - Molecular sequence string - set by the createPolymerSubstance function. Substances created by this function can be used to generate matching chains with the substance.createChain function

For standard polymers defaults to a string of one-letter codes; for other molecules to a comma-separated tuple of three-letter codes

setSpecificAtomLabelling(atom: str | Atom, isotopeLabels: dict)[source]

Set isotopeLabels dict as labelling for atom designated by atomId.

NBNB labelling is set for the matching atom in all chains that match the Substance also if the other chains have a different numbering.

isotopeLabels must be a dictionary of the form (e.g.) {‘12C’:0.32, ‘13C’:0.68} where the atom fractions add up to 1.0 and the isotope Codes cover the possibilities for the atom.

shortClassName = 'SU'

Short class name, for PID.

property smiles: Optional[str]

- str=None, mutable - Smiles string - for substances that have one

property specificAtomLabelling: Dict[str, Dict[str, float]]

- Dict[str, Dict[str, float]], immutable - Site-specific labelling for all chains matching Substance in the form of (atomId:{isotopeCode:fraction}} dictionary. Note that changing the labelling for a site in one chain simultaneously affects the matching site in other matching chains. To modify this attribute use the functions setSpecificAtomLabelling, removeSpecificAtomLabelling, clearSpecificAtomLabelling, updateSpecificAtomLabelling

Example value (for two chains where the numbering of B is offset 200 from chain A):

{‘A.11.ALA.CB’:{‘12C’:0.32, ‘13C’:0.68},
‘B.211.ALA.CB’:{‘12C’:0.32, ‘13C’:0.68},}
property substanceType: str

- str, immutable - Category of substance: Molecule, Cell, Material, or Composite

  • Molecule is a single molecule, including plasmids

  • Cell is a cell,

  • Material is a mixture, like fetal calf serum, growth medium, or standard buffer,

  • Composite is multiple components in fixed ratio, like a protein-ligand or multiprotein complex, or (technically) a Cell containing a particular plasmid.

property synonyms: Tuple[str, ...]

- Tuple[str, …], mutable - Synonyms for Substance name

updateSpecificAtomLabelling(dictionary: Dict[str, Dict[str, float]])[source]

Update Site-specific labelling for all chains matching Substance. The input must be an (atomId:{isotopeCode:fraction}} dictionary. Note that changing the labelling for a site in one chain simultaneously affects the matching site in other matching chains, So you should only update teh labeling for one chain.

Example value (for two chains where the numbering of B is offset 200 from chain A):

{‘A.11.ALA.CB’:{‘12C’:0.32, ‘13C’:0.68},}

which will also affect ‘B.211.ALA.CB’ (if it exists)

property userCode: Optional[str]

- str=None, mutable - User-defined compound code

ccpn.core.Substance.getter(self: ccpn.core.SampleComponent.SampleComponent) Optional[ccpn.core.Substance.Substance][source]

ccpn.core.ViolationTable module

Module Documentation here

class ccpn.core.ViolationTable.ViolationFrame(*args, **kwargs)[source]

Bases: ccpn.core._implementation.DataFrameABC.DataFrameABC

Generic data - as a Pandas DataFrame.

class ccpn.core.ViolationTable.ViolationTable(project: Project, wrappedData: ccpnmodel.ccpncore.api.memops.Implementation.DataObject)[source]

Bases: ccpn.core._implementation.AbstractWrapperObject.AbstractWrapperObject

Container for pandas dataFrame.

className = 'ViolationTable'
clearMetadata()[source]

Delete all metadata.

property columns: list

- list, immutable - Return the columns in the dataFrame

property data: ccpn.core.ViolationTable.ViolationFrame

- ccpn.core.ViolationTable.ViolationFrame, mutable - Return the pandas dataFrame.

deleteMetadata(name: str)[source]

Delete metadata named ‘name’.

getMetadata(name: str)[source]

Return value from metadata.

property metadata: dict

- dict, immutable - Keyword-value dictionary of metadata. NB the value is a copy - modifying it will not modify the actual data. Use the setMetadata, deleteMetadata, clearMetadata, and updateMetadata methods to modify the metadata.

Dictionary values can be anything that can be exported to JSON, including OrderedDict, numpy.ndarray, ccpn.util.Tensor, or pandas DataFrame, Series, or Panel.

property name: str

- str, mutable - Name of ViolationTable, part of identifier.

property nefCompatibleColumns

- None, immutable - Return the columns in the dataFrame

rename(value: str)[source]

Rename ViolationTable, changing its name and Pid.

property serial: int

- int, immutable - ID number of ViolationTable, used in Pid and to identify the ViolationTable.

setMetadata(name: str, value)[source]

Add name:value to metadata, overwriting existing entry.

shortClassName = 'VT'

Short class name, for PID.

property structureData: ccpn.core.StructureData.StructureData

- ccpn.core.StructureData.StructureData, immutable - StructureData containing ViolationTable.

updateMetadata(value: dict)[source]

Convenience routine, similar to dict.update(). Calls self.setMetadata(key, value) for each key,value pair in the input.