ProForma#

class pyopenms.ProForma#

Bases: object

ProForma v2 peptidoform notation parser and data structures.

This class provides parsing, serialization, and conversion functionality for the ProForma v2 peptidoform notation standard. It contains nested types that form the Abstract Syntax Tree (AST) representation of parsed ProForma strings.

All methods are static. Use ProForma.parse() to parse a ProForma string.

Usage example:

pf = ProForma.parse("EM[UNIMOD:35]K")
# pf now contains the parsed Peptidoform AST
s = ProForma.toString(pf, ProForma.WriteMode.LOSSLESS)
# s is "EM[UNIMOD:35]K"
__init__(*args, **kwargs)#

Methods

__init__(*args, **kwargs)

canCalculateMass(pf)

Check if mass can be calculated for a Peptidoform

canCalculateMassIon(pfi)

Check if mass can be calculated for a PeptidoformIon

canGenerateSpectrum(pf)

Check if a theoretical spectrum can be generated for a Peptidoform

canGenerateSpectrumIon(pfi)

Check if a theoretical spectrum can be generated for a PeptidoformIon

fromAASequence(seq)

Create a Peptidoform from an OpenMS AASequence

generateSpectrum(pf, min_charge, max_charge, ...)

Generate theoretical MS/MS spectrum for a Peptidoform.

generateSpectrumIon(pfi, min_charge, ...)

Generate theoretical MS/MS spectrum for a PeptidoformIon (supports cross-linked peptides).

getAASequenceConversionIssues(pf)

Get a list of all issues that would arise during AASequence conversion

getMZ(pfi)

Calculate m/z for a PeptidoformIon using its charge state

getMZCharge(pf, charge)

Calculate m/z for a Peptidoform at a given charge state

getMassCalculationIssues(pf)

Get issues preventing mass calculation for a Peptidoform

getMassCalculationIssuesIon(pfi)

Get issues preventing mass calculation for a PeptidoformIon

getMonoWeight(pf)

Calculate monoisotopic mass of a Peptidoform in Daltons

getMonoWeightIon(pfi)

Calculate monoisotopic mass of a PeptidoformIon in Daltons

getSpectrumGenerationIssues(pf)

Get issues preventing spectrum generation for a Peptidoform

getSpectrumGenerationIssuesIon(pfi)

Get issues preventing spectrum generation for a PeptidoformIon

isRepresentableAsAASequence(pf)

Check if a Peptidoform can be fully represented as an AASequence

parse(input)

Parse a ProForma string into a Peptidoform AST

parseIon(input)

Parse a ProForma string into a PeptidoformIon AST (with charge state)

peptidoformFromJSON(json_str)

Construct Peptidoform from JSON string

peptidoformIonFromJSON(json_str)

Construct PeptidoformIon from JSON string

peptidoformIonToJSON(pfi)

Convert PeptidoformIon to JSON string representation

peptidoformToJSON(pf)

Convert Peptidoform to JSON string representation

resolveModifications(pf)

Resolve all modifications in a Peptidoform using ModificationsDB

toAASequence(pf, policy)

Convert a Peptidoform to an OpenMS AASequence

toJSON(pf)

Convert Peptidoform to JSON string

toJSONIon(pfi)

Convert PeptidoformIon to JSON string

toString(pf, mode)

Convert a Peptidoform AST back to ProForma string notation with specified mode

toStringIon(pfi, mode)

Convert a PeptidoformIon AST back to ProForma string notation with specified mode

class ConversionIssueType(*values)#

Bases: IntEnum

ALTERNATIVE_MODS = 9#
AMBIGUOUS_MOD = 4#
AMBIGUOUS_REGION = 5#
GLOBAL_MOD = 3#
LABILE_MOD = 2#
MODIFIED_RANGE = 6#
MULTIPLE_CHAINS = 8#
UNLOCALISED_MOD = 1#
UNRESOLVED_MOD = 0#
UNSUPPORTED_FEATURE = 10#
as_integer_ratio()#

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()#

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()#

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()#

Returns self, the complex conjugate of any int.

denominator#

the denominator of a rational number in lowest terms

classmethod from_bytes(bytes, byteorder='big', *, signed=False)#

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

getMapping()#

Returns a dict mapping int values to enum member name strings.

imag#

the imaginary part of a complex number

is_integer()#

Returns True. Exists for duck type compatibility with float.is_integer.

numerator#

the numerator of a rational number in lowest terms

real#

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)#

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class ConversionPolicy(*values)#

Bases: IntEnum

BEST_EFFORT = 2#
DROP_UNLOCALISED = 1#
FAIL_ON_LOSS = 0#
as_integer_ratio()#

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()#

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()#

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()#

Returns self, the complex conjugate of any int.

denominator#

the denominator of a rational number in lowest terms

classmethod from_bytes(bytes, byteorder='big', *, signed=False)#

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

getMapping()#

Returns a dict mapping int values to enum member name strings.

imag#

the imaginary part of a complex number

is_integer()#

Returns True. Exists for duck type compatibility with float.is_integer.

numerator#

the numerator of a rational number in lowest terms

real#

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)#

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class CvDatabase(*values)#

Bases: IntEnum

GNO = 4#
MOD = 1#
RESID = 2#
UNIMOD = 0#
XLMOD = 3#
as_integer_ratio()#

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()#

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()#

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()#

Returns self, the complex conjugate of any int.

denominator#

the denominator of a rational number in lowest terms

classmethod from_bytes(bytes, byteorder='big', *, signed=False)#

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

getMapping()#

Returns a dict mapping int values to enum member name strings.

imag#

the imaginary part of a complex number

is_integer()#

Returns True. Exists for duck type compatibility with float.is_integer.

numerator#

the numerator of a rational number in lowest terms

real#

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)#

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

class WriteMode(*values)#

Bases: IntEnum

CANONICAL = 1#
LOSSLESS = 0#
as_integer_ratio()#

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()#

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()#

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()#

Returns self, the complex conjugate of any int.

denominator#

the denominator of a rational number in lowest terms

classmethod from_bytes(bytes, byteorder='big', *, signed=False)#

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

getMapping()#

Returns a dict mapping int values to enum member name strings.

imag#

the imaginary part of a complex number

is_integer()#

Returns True. Exists for duck type compatibility with float.is_integer.

numerator#

the numerator of a rational number in lowest terms

real#

the real part of a complex number

to_bytes(length=1, byteorder='big', *, signed=False)#

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

static canCalculateMass(pf: pyopenms.Peptidoform) → bool#
static canCalculateMass(pfi: pyopenms.PeptidoformIon) → bool

Check if mass can be calculated for a Peptidoform

static canCalculateMassIon(pfi: pyopenms.PeptidoformIon) → bool#

Check if mass can be calculated for a PeptidoformIon

static canGenerateSpectrum(pf: pyopenms.Peptidoform) → bool#
static canGenerateSpectrum(pfi: pyopenms.PeptidoformIon) → bool

Check if a theoretical spectrum can be generated for a Peptidoform

static canGenerateSpectrumIon(pfi: pyopenms.PeptidoformIon) → bool#

Check if a theoretical spectrum can be generated for a PeptidoformIon

static fromAASequence(seq: pyopenms.AASequence) → pyopenms.Peptidoform#

Create a Peptidoform from an OpenMS AASequence

static generateSpectrum(pf: pyopenms.Peptidoform, min_charge: int, max_charge: int, ion_types: str, add_losses: bool, add_metainfo: bool) → pyopenms.MSSpectrum#
static generateSpectrum(pfi: pyopenms.PeptidoformIon, min_charge: int, max_charge: int, ion_types: str, add_losses: bool, add_metainfo: bool) → pyopenms.MSSpectrum

Generate theoretical MS/MS spectrum for a Peptidoform. ion_types uses chars a,b,c,x,y,z for ion series, M for precursor, I for immonium (e.g. “by” or “abyM”)

static generateSpectrumIon(pfi: pyopenms.PeptidoformIon, min_charge: int, max_charge: int, ion_types: str, add_losses: bool, add_metainfo: bool) → pyopenms.MSSpectrum#

Generate theoretical MS/MS spectrum for a PeptidoformIon (supports cross-linked peptides). ion_types uses chars a,b,c,x,y,z for ion series, M for precursor, I for immonium

static getAASequenceConversionIssues(pf: pyopenms.Peptidoform) → list[pyopenms.ConversionIssue]#

Get a list of all issues that would arise during AASequence conversion

static getMZ(pfi: pyopenms.PeptidoformIon) → float#
static getMZ(pf: pyopenms.Peptidoform, charge: int) → float

Calculate m/z for a PeptidoformIon using its charge state

static getMZCharge(pf: pyopenms.Peptidoform, charge: int) → float#

Calculate m/z for a Peptidoform at a given charge state

static getMassCalculationIssues(pf: pyopenms.Peptidoform) → list[pyopenms.ConversionIssue]#
static getMassCalculationIssues(pfi: pyopenms.PeptidoformIon) → list[pyopenms.ConversionIssue]

Get issues preventing mass calculation for a Peptidoform

static getMassCalculationIssuesIon(pfi: pyopenms.PeptidoformIon) → list[pyopenms.ConversionIssue]#

Get issues preventing mass calculation for a PeptidoformIon

static getMonoWeight(pf: pyopenms.Peptidoform) → float#
static getMonoWeight(pfi: pyopenms.PeptidoformIon) → float

Calculate monoisotopic mass of a Peptidoform in Daltons

static getMonoWeightIon(pfi: pyopenms.PeptidoformIon) → float#

Calculate monoisotopic mass of a PeptidoformIon in Daltons

static getSpectrumGenerationIssues(pf: pyopenms.Peptidoform) → list[pyopenms.ConversionIssue]#
static getSpectrumGenerationIssues(pfi: pyopenms.PeptidoformIon) → list[pyopenms.ConversionIssue]

Get issues preventing spectrum generation for a Peptidoform

static getSpectrumGenerationIssuesIon(pfi: pyopenms.PeptidoformIon) → list[pyopenms.ConversionIssue]#

Get issues preventing spectrum generation for a PeptidoformIon

static isRepresentableAsAASequence(pf: pyopenms.Peptidoform) → bool#

Check if a Peptidoform can be fully represented as an AASequence

static parse(input: str) → pyopenms.Peptidoform#

Parse a ProForma string into a Peptidoform AST

static parseIon(input: str) → pyopenms.PeptidoformIon#

Parse a ProForma string into a PeptidoformIon AST (with charge state)

static peptidoformFromJSON(json_str: str) → pyopenms.Peptidoform#

Construct Peptidoform from JSON string

static peptidoformIonFromJSON(json_str: str) → pyopenms.PeptidoformIon#

Construct PeptidoformIon from JSON string

static peptidoformIonToJSON(pfi: pyopenms.PeptidoformIon) → str#

Convert PeptidoformIon to JSON string representation

static peptidoformToJSON(pf: pyopenms.Peptidoform) → str#

Convert Peptidoform to JSON string representation

static resolveModifications(pf: pyopenms.Peptidoform) → None#

Resolve all modifications in a Peptidoform using ModificationsDB

static toAASequence(pf: pyopenms.Peptidoform, policy: pyopenms.ProForma.ConversionPolicy) → pyopenms.AASequence#

Convert a Peptidoform to an OpenMS AASequence

static toJSON(pf: pyopenms.Peptidoform) → str#

Convert Peptidoform to JSON string

static toJSONIon(pfi: pyopenms.PeptidoformIon) → str#

Convert PeptidoformIon to JSON string

static toString(pf: pyopenms.Peptidoform, mode: pyopenms.ProForma.WriteMode) → str#
static toString(pfi: pyopenms.PeptidoformIon, mode: pyopenms.ProForma.WriteMode) → str

Convert a Peptidoform AST back to ProForma string notation with specified mode

static toStringIon(pfi: pyopenms.PeptidoformIon, mode: pyopenms.ProForma.WriteMode) → str#

Convert a PeptidoformIon AST back to ProForma string notation with specified mode