Python API#

mzpaf.parse_annotation()#

Parse a string into one or more IonAnnotationBase instances.

Parameters#

annotation_stringstr

The string to be parsed

wrap_errorsbool, optional

Whether or not to capture parsing errors as InvalidAnnotation or not. Defaults to False.

Returns#

list[IonAnnotationBase] :

The annotations parsed

See Also#

mzpaf.AnnotationStringParser

class mzpaf.AnnotationStringParser(pattern)#

Bases: object

An annotation string parser using a specific parser pattern.

This class organizes the parsing of common and type-specific components of a string into one or more peak annotations.

Instances are Callable, with parse_annotation being the reference parser.

Parameters:

pattern (Pattern)

parse_annotation(annotation_string, **kwargs)#

Parse a string into one or more IonAnnotationBase instances.

Parameters:
  • annotation_string (str) – The string to be parsed

  • **kwargs – Passed to the _dispatch() which in turn creates IonAnnotationBase instances

Returns:

The annotations parsed

Return type:

list[IonAnnotationBase]

class mzpaf.IonAnnotationBase(series, neutral_losses=None, isotope=None, adducts=None, charge=None, analyte_reference=None, mass_error=None, confidence=None, rest=None, is_auxiliary=None)#

Bases: object

A base class for all mzPAF ion annotations.

Provides shared functionality and common attributes for the data model.

Parameters:
classmethod from_json(data)#

Convert parsed JSON data back into formal data structures.

Return type:

IonAnnotationBase

serialize()#

Serialize the data model back to an mzPAF formatted string.

Return type:

str

to_json(exclude_missing=False)#

Convert the data model into a JSON-serializable dict.

Return type:

dict

class mzpaf.ImmoniumIonAnnotation(series, amino_acid, modification=None, neutral_losses=None, isotope=None, adducts=None, charge=None, analyte_reference=None, mass_error=None, confidence=None, rest=None, is_auxiliary=None)#

Bases: IonAnnotationBase

Represent a single amino acid ionized with a neutral loss.

Parameters:
amino_acid#

The amino acid ionized

Type:

str

modification#

A modification still attached to the amino acid. Should be denoted using a controlled vocabulary term.

Type:

str or None

class mzpaf.PeptideFragmentIonAnnotation(series, position, sequence=None, neutral_losses=None, isotope=None, adducts=None, charge=None, analyte_reference=None, mass_error=None, confidence=None, rest=None, is_auxiliary=None)#

Bases: IonAnnotationBase, _HasSequenceMixin

Represent a canonical peptide backbone fragment, such as a b or y ion in the Roepstorff notation.

Parameters:
series#

The ion series

Type:

str

position#

The ordinal bond position relative to the series terminal for this fragment

Type:

int

sequence#

The sequence this fragment is derived from if it is not a specified analyte from the spectrum metadata. Should be written in ProForma 2.0 notation.

Type:

str or None

class mzpaf.InternalPeptideFragmentIonAnnotation(series, start_position, end_position, sequence=None, neutral_losses=None, isotope=None, adducts=None, charge=None, analyte_reference=None, mass_error=None, confidence=None, rest=None, is_auxiliary=None)#

Bases: IonAnnotationBase, _HasSequenceMixin

Represent an internal fragment of a peptide, containing neither of the original termini of the source peptide.

Parameters:
start_position#

The bond ordinal where the first break occurs relative to the N-terminal of the peptide.

Type:

int

end_position#

The bond ordinal where the second break occurs relative to the N-terminal of the peptide.

Type:

int

sequence#

The sequence this fragment is derived from if it is not a specified analyte from the spectrum metadata. Should be written in ProForma 2.0 notation.

Type:

str or None

class mzpaf.PrecursorIonAnnotation(series, neutral_losses=None, isotope=None, adducts=None, charge=None, analyte_reference=None, mass_error=None, confidence=None, rest=None, is_auxiliary=None)#

Bases: IonAnnotationBase

The intact, possibly charge-reduced, precursor ion.

Parameters:
class mzpaf.ReferenceIonAnnotation(series, reference, neutral_losses=None, isotope=None, adducts=None, charge=None, analyte_reference=None, mass_error=None, confidence=None, rest=None, is_auxiliary=None)#

Bases: IonAnnotationBase

An ion which matches a referencea entity like a TMT reporter ion or a signature ion.

Attribute#

referencestr

The reference identifier.

Parameters:
class mzpaf.NamedCompoundIonAnnotation(series, label, neutral_losses=None, isotope=None, adducts=None, charge=None, analyte_reference=None, mass_error=None, confidence=None, rest=None, is_auxiliary=None)#

Bases: IonAnnotationBase

Parameters:
class mzpaf.FormulaAnnotation(series, formula, neutral_losses=None, isotope=None, adducts=None, charge=None, analyte_reference=None, mass_error=None, confidence=None, rest=None, is_auxiliary=None)#

Bases: IonAnnotationBase

Parameters:
class mzpaf.SMILESAnnotation(series, smiles, neutral_losses=None, isotope=None, adducts=None, charge=None, analyte_reference=None, mass_error=None, confidence=None, rest=None, is_auxiliary=None)#

Bases: IonAnnotationBase

Parameters:
class mzpaf.Unannotated(series, unannotated_label, neutral_losses=None, isotope=None, adducts=None, charge=None, analyte_reference=None, mass_error=None, confidence=None, rest=None, is_auxiliary=None)#

Bases: IonAnnotationBase

Parameters:
serialize()#

Serialize the data model back to an mzPAF formatted string.

Return type:

str

class mzpaf.MassError(mass_error=0, unit=None)#

Bases: object

Represent the mass error of a peak annotation.

Parameters:
unit#

The unit of the mass error, may be Da (daltons) or ppm (parts-per-million)

Type:

str

mass_error#

The magnitude of the mass error

Type:

float

serialize()#

Serialize the mass error to the notation used in mzPAF.

Return type:

str

to_json()#

Serialize the mass error to a JSON-compatible dict

Return type:

dict

class mzpaf.InvalidAnnotation(content, error)#

Bases: IonAnnotationBase

Parameters:
serialize()#

Serialize the data model back to an mzPAF formatted string.

Return type:

str