ccpn.core.lib package

Submodules

ccpn.core.lib.AssignmentLib module

Library functions for (semi)automatic assignment routines

ccpn.core.lib.AssignmentLib.assignAlphas(nmrResidue: ccpn.core.NmrResidue.NmrResidue, peaks: List[ccpn.core.Peak.Peak])[source]

Assigns CA and CA-1 NmrAtoms to dimensions of specified peaks.

ccpn.core.lib.AssignmentLib.assignBetas(nmrResidue: ccpn.core.NmrResidue.NmrResidue, peaks: List[ccpn.core.Peak.Peak])[source]

Assigns CB and CB-1 NmrAtoms to dimensions of specified peaks.

ccpn.core.lib.AssignmentLib.copyPeakAssignments(refPeak, peaks)[source]
ccpn.core.lib.AssignmentLib.copyPeakListAssignments(referencePeakList: ccpn.core.PeakList.PeakList, matchPeakList: ccpn.core.PeakList.PeakList)[source]

Takes a reference peakList and assigns NmrAtoms to dimensions of a match peakList based on matching axis codes.

ccpn.core.lib.AssignmentLib.findClosePeaks(peak, matchPeakList)[source]
ccpn.core.lib.AssignmentLib.getBoundNmrAtomPairs(nmrAtoms, nucleus)[source]
ccpn.core.lib.AssignmentLib.getNmrAtomPrediction(ccpCode: str, value: float, isotopeCode: str, strict: bool = False)[source]

Takes a ccpCode, a chemical shift value and an isotope code and returns a dictionary of atom type predictions to confidence values..

ccpn.core.lib.AssignmentLib.getNmrResiduePrediction(nmrResidue: ccpn.core.NmrResidue.NmrResidue, chemicalShiftList: ccpn.core.ChemicalShiftList.ChemicalShiftList, prior: float = 0.05)[source]

Takes an NmrResidue and a ChemicalShiftList and returns a dictionary of the residue type to confidence levels for that NmrResidue.

ccpn.core.lib.AssignmentLib.getSpinSystemsLocation(project: ccpn.core.Project.Project, nmrResidues: List[ccpn.core.NmrResidue.NmrResidue], chain: ccpn.core.Chain.Chain, chemicalShiftList: ccpn.core.ChemicalShiftList.ChemicalShiftList)[source]

Determines location of a set of NmrResidues in the specified chain using residue type predictions.

ccpn.core.lib.AssignmentLib.isInterOnlyExpt(experimentType: str) → bool[source]

Determines if the specified experiment is an inter-residual only experiment

ccpn.core.lib.AssignmentLib.nmrAtomPairsByDimensionTransfer(peakLists: Sequence[ccpn.core.PeakList.PeakList]) → dict[source]

From one or more peakLists belonging to the same spectrum, get a dictionary of magnetisationTransferTuple (See Spectrum.magnetisationTransfers for documentation) to a set of NmrAtom pairs tha are coupled by the magnetisation transfer. If the two dimensions have the same nucleus, the NmrAtom pairs are sorted, otherwise they are in the dimension order.

Peak.assignedNmrAtoms are used to determine which NmrAtoms are connected

ccpn.core.lib.AssignmentLib.propagateAssignments(peaks: List[ccpn.core.Peak.Peak] = None, referencePeak: ccpn.core.Peak.Peak = None, current: object = None, tolerances: List[float] = None)[source]

Propagates dimensionNmrAtoms for each dimension of the specified peaks to dimensions of other peaks.

ccpn.core.lib.CcpnNefIo module

Code for CCPN-specific NEF I/O

class ccpn.core.lib.CcpnNefIo.CcpnNefReader(application, specificationFile=None, mode='standard', testing=False)[source]

Bases: object

fetchDataSet(serial=None)[source]

Fetch DataSet with given serial. If input is None, use self.defaultDataSetSerial If that too is None, create a new DataSet and use its serial as the default

NB when reading, all DataSets with known serials should be instantiated BEFORE calling with input None

getNefData(path)[source]

Get NEF data structure from file

importNewProject(project: ccpn.core.Project.Project, dataBlock: ccpn.util.nef.StarIo.NmrDataBlock, projectIsEmpty=True)[source]

Import entire project from dataBlock into empty Project

importers = {'ccpn_substance': <function CcpnNefReader.load_ccpn_substance at 0x7fe603e3f598>, 'nef_peak': <function CcpnNefReader.load_nef_peak at 0x7fe603e3f2f0>, 'nef_distance_restraint_list': <function CcpnNefReader.load_nef_restraint_list at 0x7fe603e3be18>, 'ccpn_sample': <function CcpnNefReader.load_ccpn_sample at 0x7fe603e3f510>, 'nef_chemical_shift': <function CcpnNefReader.load_nef_chemical_shift at 0x7fe603e3bd90>, 'ccpn_spectrum_dimension': <function CcpnNefReader.load_ccpn_spectrum_dimension at 0x7fe603e3f1e0>, 'nef_dihedral_restraint': <function CcpnNefReader.load_nef_restraint at 0x7fe603e3bea0>, 'nef_covalent_links': <function CcpnNefReader.load_nef_covalent_links at 0x7fe603e3bbf8>, 'nef_rdc_restraint': <function CcpnNefReader.load_nef_restraint at 0x7fe603e3bea0>, 'nef_nmr_meta_data': <function CcpnNefReader.load_nef_nmr_meta_data at 0x7fe603e3ba60>, 'ccpn_dataset': <function CcpnNefReader.load_ccpn_dataset at 0x7fe603e3f7b8>, 'nef_nmr_spectrum': <function CcpnNefReader.load_nef_nmr_spectrum at 0x7fe603e3bf28>, 'nef_peak_restraint_link': <function CcpnNefReader.load_nef_peak_restraint_link at 0x7fe603e3f400>, 'nef_chemical_shift_list': <function CcpnNefReader.load_nef_chemical_shift_list at 0x7fe603e3bd08>, 'ccpn_restraint_list': <function CcpnNefReader.load_nef_restraint_list at 0x7fe603e3be18>, 'nef_peak_restraint_links': <function CcpnNefReader.load_nef_peak_restraint_links at 0x7fe603e3f378>, 'nef_sequence': <function CcpnNefReader.load_nef_sequence at 0x7fe603e3bb70>, 'ccpn_notes': <function CcpnNefReader.load_ccpn_notes at 0x7fe603e3f6a8>, 'nef_distance_restraint': <function CcpnNefReader.load_nef_restraint at 0x7fe603e3bea0>, 'nef_rdc_restraint_list': <function CcpnNefReader.load_nef_restraint_list at 0x7fe603e3be18>, 'nef_dihedral_restraint_list': <function CcpnNefReader.load_nef_restraint_list at 0x7fe603e3be18>, 'ccpn_assignments': <function CcpnNefReader.load_ccpn_assignments at 0x7fe603e3f620>, 'nef_molecular_system': <function CcpnNefReader.load_nef_molecular_system at 0x7fe603e3bae8>, 'ccpn_restraint': <function CcpnNefReader.load_nef_restraint at 0x7fe603e3bea0>, 'ccpn_integral_list': <function CcpnNefReader.load_ccpn_integral_list at 0x7fe603e3f730>, 'ccpn_spectrum_group': <function CcpnNefReader.load_ccpn_spectrum_group at 0x7fe603e3f488>}
load_ccpn_assignments(project, saveFrame)[source]
load_ccpn_dataset(project, saveFrame)[source]
load_ccpn_integral_list(project, saveFrame)[source]
load_ccpn_notes(project, saveFrame)[source]
load_ccpn_sample(project, saveFrame)[source]
load_ccpn_spectrum_dimension(spectrum, loop) → dict[source]

Read ccpn_spectrum_dimension loop, set the relevant values, and return the spectrum and other parameters for further processing

load_ccpn_spectrum_group(project, saveFrame)[source]
load_ccpn_substance(project, saveFrame)[source]
load_nef_chemical_shift(parent, loop)[source]

load nef_chemical_shift loop

load_nef_chemical_shift_list(project, saveFrame)[source]

load nef_chemical_shift_list saveFrame

Load nef_sequence loop

load_nef_molecular_system(project, saveFrame)[source]

load nef_molecular_system saveFrame

load_nef_nmr_meta_data(project, saveFrame)[source]

load nef_nmr_meta_data saveFrame

load_nef_nmr_spectrum(project, saveFrame)[source]
load_nef_peak(peakList, loop)[source]

Serves to load nef_peak loop

Load nef_peak_restraint_link loop

load nef_peak_restraint_links saveFrame

load_nef_restraint(restraintList, loop, itemLength=None)[source]

Serves to load nef_distance_restraint, nef_dihedral_restraint, nef_rdc_restraint and ccpn_restraint loops

load_nef_restraint_list(project, saveFrame)[source]

Serves to load nef_distance_restraint_list, nef_dihedral_restraint_list, nef_rdc_restraint_list and ccpn_restraint_list

load_nef_sequence(project, loop)[source]

Load nef_sequence loop

load_nef_spectrum_dimension_transfer(spectrum, loop)[source]
preloadAssignmentData(dataBlock)[source]

Set up NmrChains and NmrResidues with reserved names to ensure the serials are OK

NB later we can store serials in CCPN projects, but something is needed that works anyway

process_nef_spectrum_dimension_transfer(spectrum, dataLists)[source]
produceNmrAtom(nmrResidue, name)[source]

Get NmrAtom from NmrResidue and name, correcting for possible errors

produceNmrChain(chainCode: str = None)[source]

Get NmrChain, correcting for possible errors

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

Get NmrResidue, correcting for possible errors

read_nef_spectrum_dimension(project, loop)[source]

Read nef_spectrum_dimension loop and convert data to a dictionary of ccpnTag:[per-dimension-value]

read_nef_spectrum_dimension_transfer(loop)[source]
updateMetaData(metaDataFrame)[source]

Add meta information to main data set. Must be done at end of read

warning(message)[source]
class ccpn.core.lib.CcpnNefIo.CcpnNefWriter[source]

Bases: object

CCPN NEF reader/writer

chains2Nef(chains: List[ccpn.Chain]) → ccpn.util.nef.StarIo.NmrSaveFrame[source]

Convert selected Chains to CCPN NEF saveframe

chemicalShiftList2Nef(chemicalShiftList) → ccpn.util.nef.StarIo.NmrSaveFrame[source]

Convert ChemicalShiftList to CCPN NEF saveframe

exportDataSet()[source]

Get dataSet and all objects linked to therein as NEF object tree for export

exportProject() → ccpn.util.nef.StarIo.NmrDataBlock[source]

Get project and all contents as NEF object tree for export

makeNefMetaData()[source]

make NEF metadata saveframe from Project

notes2Nef(notes: List[ccpn.Note]) → ccpn.util.nef.StarIo.NmrSaveFrame[source]

Convert Notes to CCPN NEF saveframe

peakList2Nef()[source]

Convert PeakList to CCPN NEF saveframe

peakRestraintLinks2Nef(restraintLists: Sequence[ccpn.RestraintList], peakLists: Sequence[ccpn.PeakList]) → ccpn.util.nef.StarIo.NmrSaveFrame[source]
restraintList2Nef(restraintList, singleDataSet=False) → ccpn.util.nef.StarIo.NmrSaveFrame[source]

Convert RestraintList to CCPN NEF saveframe

sample2Nef()[source]

Convert Sample to CCPN NEF saveframe

spectrum2Nef()[source]

Convert spectrum to NEF saveframes - one per peaklist

Will crate a peakList if none are present

substance2Nef()[source]

Convert Substance to CCPN NEF saveframe

ccpn.core.lib.CcpnNefIo.convert2NefString(project, skipPrefixes=())[source]

Convert project to NEF string

ccpn.core.lib.CcpnNefIo.createSpectrum(project: ccpn.core.Project.Project, spectrumName: str, spectrumParameters: dict, dimensionData: dict, transferData)[source]

Get or create spectrum using dictionaries of attributes, such as read in from NEF.

:param spectrumParameters keyword-value dictionary of attribute to set on resulting spectrum

:params Dictionary of keyword:list parameters, with per-dimension parameters. Either ‘axisCodes’ or ‘isotopeCodes’ must be present and fully populated. A number of other dimensionData are treated specially (see below)

ccpn.core.lib.CcpnNefIo.makeNefAxisCodes(isotopeCodes, dimensionIds, acquisitionAxisIndex, transferData)[source]
ccpn.core.lib.CcpnNefIo.saveNefProject(project: ccpn.core.Project.Project, path: str, overwriteExisting: bool = False, skipPrefixes=())[source]

Save project NEF file to path

ccpn.core.lib.CcpnSorting module

Ccpn-specific variant of functions for sorting and comparison.

ccpn.core.lib.CcpnSorting.stringSortKey(key: str) → tuple[source]

Sort key for strings.

Usage: sorted(aList, key=stringSortKey) or aList.sort(key=stringSortKey)

Custom CCPN version of stringSortKey that sorts Pids on their individual components.

Advanced:

Splits on embedded dots before further processing, and Returns an alternating tuple of (possibly empty) strings interspersed with (float,string) tuples, where the float is the converted value of the substring. First and last element are always strings.

If the entire string evaluates to a float, the result is (‘’, ‘(floatVal, stringVal), ‘’)

Otherwise the numeric tuples are (intVal, subStringVal). Substrings recognised as integers are an optional series of ‘ ‘, an optional sign, and a series of digits - or REGEX ‘[ ]*[+-]?d+’ For this type the key tuple is extended by (0,’‘), # so that end-of-key sorts as 0 rather thn coming first.

Example of sorting order [‘’, ‘NaN’, ‘-1’, ‘-1A’, ‘0.0’, ‘1’, ‘2’, ‘15’, ‘3.2e12’, ‘Inf’, ‘Ahh’, ‘b’, ‘b2’, ‘b12’, ‘bb’, ‘ciao’]

ccpn.core.lib.CcpnSorting.universalSortKey(key)[source]

Custom universalSortKey, used to sort a list of mixed-type Python objects.

Usage: sorted(aList, key=universalSortKey) or aList.sort(key=universalSortKey)

Uses the local stringSortKey variant for strings and CCPN WrapperObjects sorted together

ccpn.core.lib.DataIo module

Module Documentation here

ccpn.core.lib.DataIo.alignNmrChain(nmrChain)[source]

Correct sequenceCodes in an assigned nmrChain to compensate for a sequence offset relative to the molecular system.

Will only modify data if all residues match in the result, but not in the starting situation, and will choose the smallest (most negative) value of offset that achieves this.

ccpn.core.lib.DataIo.cleanUpDocrProject(project)[source]

Clean up DOCR project - converting restraints to ambiguous atoms (e.g. HBa/HBb) to restraints to % atoms (e.g. HB%). This is SPECIFIC for DOCR projects, since it appears that only HB% type restraints appear as HBa/HBb

ccpn.core.lib.DataIo.collapseXH3Groups()[source]

Convert triplets of NmrAtoms to single CH3/NH3 NmrAtoms and change ‘*’ to ‘%’.

Triplets Habc1,Habc2,Habc3 will be converted to Habc% provided they are not of the form ‘Hijk’ or 'H@ijk‘ where ‘ijk’ is an integer.

NB This will miss N-terminal NH3 groups, but the alternative might catch non-XH3 groups.

ccpn.core.lib.DataIo.convertBmrbAmbiguousAtoms(nmrChain)[source]

Convert NmrAtoms with na.ccpnInternalData[‘ambiguityCode’] 2 or 3 to the ‘XY’ convention. Names are of form ‘Nabi’ or ‘Nabi%’ or ‘NAbi*’ where ‘N’ is a one-letter nucleus code. ‘ab’ is any string that is not an integer or ‘@’ followed by an integer and ‘i’ is 1, 2 or 3. The new names will be of the form ‘NabX’ or ‘NabY’ or ‘NabX%’, ‘NabY%’

If ‘abi’ for one nucleus name matches ‘abi’ for another nucleus name, (e.g. HG1 and CG1), both will match after name substitution (to e.g. HGX and CGX) In these cases, if ANY nucleus is ambiguous, all will be treated as ambiguous.

If matching names are found for i==1, i==2, and i==3, (should not happen), no changes are made

NBNB inconsistent ambiguity codes are NOT guaranteed to give sensible results

ccpn.core.lib.DataIo.extractCyanaRestraints(restraintList, text)[source]

Extract CYANA restraints from tect. NBNB HACK!

This is an ad-hoc function to read information from PDB=-deposited restraint blocks, customised for (a) particular case(s)

residueTypes are not read, to avoid complications with non-standard DNA/RNA names. User beware

ccpn.core.lib.DataIo.getProject(projectPath)[source]
ccpn.core.lib.DataIo.importCyanaRestraints(project, dataPath, restraintType='Distance')[source]
ccpn.core.lib.DataIo.loadCasdData(project, casdDirectory)[source]

“AD-HOC function: Load Montelione CASD data - with file names hardwired

ccpn.core.lib.DataIo.loadCasdPeakList(project, nmrPipeScriptFile, peakFile, spectrumName=None)[source]

NB this assumes unassigned, cyana format peak lists, and uses the nmrpipe script file to extract spectrum parameters

ccpn.core.lib.DataIo.loadCasdRdcList(project, path)[source]

Load RDC constraint lists from CASD rdc file

ccpn.core.lib.DataIo.loadCyanaPeakList(spectrum, peakFile, axisCodes=None)[source]

Load unassigned Cyana peak file into spectrum. axisCodes (or spectrum.axisCodes) must be the axisCodes of the sepctrum in the order dimensions appear in the cyana peak file

ccpn.core.lib.DataIo.loadDocrProject()[source]

Load DOCR project, reading chemical shifts from bmrbEntryPath, with allowance for ambiguity codes 2 and 3, mapping restraints to match NmrAtom names

If casdDirectory is given, read peak lists from std Montelions CASD-2013 file structure

ccpn.core.lib.DataIo.loadNmrStarChemicalShifts()[source]

Extract NmrStar ChemicalShifts to new ChemicalShiftList. Chains will be named A, B, ... taking the next free letter

NB This is a quick hack. E.g.No use is made of author naming info.

ccpn.core.lib.DataIo.parseCyanaPeakList(path)[source]

Parse cyana peakList, returning labels (in order) and a list of lines, one per peak

ccpn.core.lib.DataIo.parseNmrPipeScript(path)[source]

Extract data of form -xABC valuex -yABC valuey -zABC valuez as a dictionary of {‘ABC:(valuex, valuey, valuez)} from nmrpipr input script

ccpn.core.lib.DataIo.readNmrStarChemicalShifts(project, path)[source]

Read chemical shifts from star file at path into project

ccpn.core.lib.DataIo.remapRestraintItems(project)[source]

Remap restraintItems from original names to massaged names

  • relies on NmrAtom.ccpnInternalData[‘originalName’] being set

ccpn.core.lib.Documentation module

Generation of Sphinx automatic documentation

ccpn.core.lib.Documentation.getNamedSubdirectories(path, prefixes=()) → List[str][source]

Get a list of all subdirectories of path whose basename starts with one of the prefixes

Does not look inside the selected subdirectories

ccpn.core.lib.Documentation.refreshSphinxDocumentation()[source]

(Re)create sphinx documentation. Locations are hardwired

ccpn.core.lib.LabelingLib module

Labeling scheme handling.

WARNING not tested since V3 upgrade

ccpn.core.lib.LabelingLib.atomLabelingFractions()[source]

get {isotopeCode:labelingFraction} in given sample for atom/nmrAtom or ID string

ccpn.core.lib.LabelingLib.atomPairLabelingFractions(project: ccpn.core.Project.Project, atomPair: Sequence[T_co], labeling: str) → dict[source]

get {(isotopeCode1,isotopeCode2):labelingFraction with given labeling for atom pair each atom in atomPair may be an Atom, an NmrAtom, or an atom ID string

ccpn.core.lib.LabelingLib.sampleLabelingFractions()[source]

get {isotopeCode:labelingFraction} with given labeling for atom/nmrAtom or ID string

ccpn.core.lib.LabelingLib.samplePairLabelingFractions(sample: ccpn.core.Sample.Sample, atomPair: Sequence[T_co]) → dict[source]

get {(isotopeCode1,isotopeCode2):labelingFraction in given sample for atom pair each atom in atomPair may be an Atom, an NmrAtom, or an atom ID string

ccpn.core.lib.MoleculeLib module

Library functions for Molecule-related data

ccpn.core.lib.MoleculeLib.duplicateAtomBonds(chainMap: Dict[ccpn.core.Chain.Chain, ccpn.core.Chain.Chain])[source]

Duplicate atom-atom bonds within source chains to target chains, skipping those that already exist.

Input is a map from source chains to corresponding trget chains.

Atoms are mapped on matching Pids (with different chain codes

ccpn.core.lib.MoleculeLib.extraBoundAtomPairs(project: ccpn.core.Project.Project, selectSequential: bool = None) → List[Tuple[ccpn.core.Atom.Atom, ccpn.core.Atom.Atom]][source]

Get pairs of bound Atoms whose bonds are NOT defined through the residue topology. The result and each individualnatom pair are both sorted

Returns sequential bond pairs if selectSequential is True, non-sequential bond pairs if selectSequential is False, and both if selectSequential is None

ccpn.core.lib.MoleculeLib.sequenceMatchOffset(reference: collections.OrderedDict, sequence: collections.OrderedDict) → int=None[source]

Check if residues in sequence match those in reference, directly or with an offset. Reference and sequence are OrderedDict(sequenceCode:residueType) Both integer and string sequenceCodes (or a mixture) will give correct results - other types of key will not.

Returns 0 if all(reference.get(key) == val for key, val in sequence.items())

Otherwise tries to convert keys in sequence and reference to integers and checks if all (reference.get(key+offset) == val for key, val in sequence.items()) for some offset.

Returns the offset is a match is found,, None if no match is found

ccpn.core.lib.Pid module

Pid (Project ID) class for within-project unique ID strings.

class ccpn.core.lib.Pid.Pid(string: str, **kw)[source]

Bases: str

Pid routines, adapted from path idea in: Python Cookbook, A. Martelli and D. Ascher (eds), O’Reilly 2002, pgs 140-142

A Pid is a string with extra functionality. It consists of a non-empty type substring separated by a mandatory ‘:’ character from an optional id substring, consisting of field substrings separated by dots. The isValid function checks for validity

The type, id, and list of fields are available as properties.

New Pids can be created by pid.clone, by pid.extend (which creates a new Pid with additional fields) and by Pid.new, which combines a type and a list of fields into a new Pid, converting the values to string as necessary.

Pids can also be created by modifying individual fields relative to a source pid. pid.modify(index, value) will set the value of the field at index, whereas pid.increment(index, value) (resp. decrement) will convert the field at index to an integer (where possible) and increment (decrement) it by ‘value’.

Examples:

pid = Pid.new(‘Residue’,’mol1’,’A’, 502) # elements need not be strings; but will be converted -> Residue:mol1.A.502 (Pid instance)

which is equivalent to:

pid = Pid(‘Residue:mol1.A.502’) -> Residue:mol1.A.502 (Pid instance)

Behaves as a string: pid == ‘Residue:mol1.A.502’ -> True

pid.str -> ‘Residue:mol1.A.502’ (str instance)

pid.type -> ‘Residue’ (str instance)

pid.id -> ‘mol1.A.502’ (str instance)

pid2 = pid.modify(1, ‘B’, type=’Atom’) -> Atom:mol1.B.502 (Pid instance)

but also: pid3 = Pid(‘Residue’).extend(‘mol2’) -> Residue:mol2 (Pid instance)

pid4 = pid.decrement(2,1) -> Residue:mol1.A.501 (Pid instance) or pid4 = pid.increment(2,-1) NB fails on elements that cannot be converted to int’s

pid5 = pid.clone() # equivalent to pid5 = Pid(pid) -> Residue:mol1.A.502 (Pid instance)

pid==pid5 -> True

‘502’ in pid.fields -> True

502 in pid.fields -> False # all pid elements are strings

clone() → ccpn.core.lib.Pid.Pid[source]

Return copy of pid

decrement(index: int, value: int) → ccpn.core.lib.Pid.Pid[source]

Return new pid with position index decremented by value Assumes integer valued id at position index

extend(*args: object)[source]

Make copy with additional fields

fields

- Tuple[str, ...], immutable - id part of pid as a tuple of fields

id

- str, immutable - return id part of pid

increment()[source]

Return new pid with position index incremented by value Assumes integer valued id at position index

static isValid(text: str) → bool[source]
modify()[source]

Return new pid with position index modified by newId

nameMap = {'MO': 'Molecule'}
static new(*args: object) → ccpn.core.lib.Pid.Pid[source]

Return Pid object from arguments Apply str() on all arguments Have to use this as intermediate as str baseclass of Pid only accepts one argument

str

- None, immutable - Convenience: return as string rather than object; allows to do things as obj.asPid.str rather then str(obj.asPid)

type

- str, immutable - return type part of pid

ccpn.core.lib.Pid.createId(*args) → str[source]

make id from list of successive keys. Keys are converted to string, and illegal characters are converted to altCharacter

ccpn.core.lib.Pid.createPid(head: str, *args: str) → ccpn.core.lib.Pid.Pid[source]

make pid from head and list of successive keys. Head may be an existing pid, or a naked string Keys are converted to string, and illegal characters are converted to altCharacter The head is not checked - it should be either a valid pid or a class code

ccpn.core.lib.Pid.decodePid(sourceObject, thePid: ccpn.core.lib.Pid.Pid) → ccpn.core.lib.Pid.Pid=None[source]

try to decode thePid relative to sourceObject return decoded pid object or None on not found or Error

ccpn.core.lib.Pid.splitId(idString) → List[str=None][source]

Split idString into tuple of component elements, mapping altCharacter back to separator and replacing empty strings with None

ccpn.core.lib.RestraintLib module

General utilities for Restraints

ccpn.core.lib.RestraintLib.dihedralName(project, restraintItem: tuple) → str[source]

Get dihedral angle name from four-element atomId tuple

ccpn.core.lib.SpectrumLib module

SPectrum-related functions and utiliities

class ccpn.core.lib.SpectrumLib.MagnetisationTransferTuple(dimension1, dimension2, transferType, isIndirect)

Bases: tuple

dimension1

Alias for field number 0

dimension2

Alias for field number 1

isIndirect

Alias for field number 3

transferType

Alias for field number 2

ccpn.core.lib.Util module

CCPN-level utility code independent of model content

class ccpn.core.lib.Util.AtomIdTuple(chainCode, sequenceCode, residueType, atomName)

Bases: tuple

atomName

Alias for field number 3

chainCode

Alias for field number 0

residueType

Alias for field number 2

sequenceCode

Alias for field number 1

ccpn.core.lib.Util.commandParameterString(*params, *, values: dict = None, defaults: dict = None)[source]

Make parameter string to insert into function call string.

params are positional parameters in order, values are keyword prameters. If the defaults dictionary is passed in, only parameters in defaults are added to the string, and only if the value differs from the default. This allows you to pass in values=locals(). The order of keyword parameters follows defaults if given, else values, so you can get ordered parametrs by passing in ordered dictionaries.

Wrapper object values are replaced with their Pids

values is a dict of values to use, mandatories are mandatory positional parameters (in order), defaults are a (parameter:default} ordered dictionary for keyword arguments. Only values given in mandatories or defaults are added, and values equal to their default are not added to the string. Wrapper object values are replaced with their Pids

Example:

commandParameterString(11, values={a:1, b:<Note NO:notename>, c:2, d:3, e:4},
defaults=OrderedDict(d=8, b=None, c=2))

will return

“11, d=8, b=’NO:notename’”

ccpn.core.lib.Util.expandDollarFilePath()[source]

Expand paths that start with $REPOSITORY to full path

NBNB Should be moved to ccpnmodel.ccpncore.lib.ccp.general.DataLocation.DataLocationstore

ccpn.core.lib.Util.pid2PluralName(pid: str) → str[source]

Get plural class name, (e.g. ‘peaks’, ‘spectra’ from short-form or long-form, Pid string Unrecognised strings are returned unchanged