Compound
Overview
- class modifinder.classes.Compound(spectrum: List[Tuple[float, float]], precursor_mz: float, precursor_charge: int, adduct: str, smiles: str | None = None, **kwargs)[source]
A class to represent a compound
The compound always has spectrum data. If the compound structure is known, it also has a structure property.
- id(str)
- Type:
The id of the compound
- spectrum(Spectrum)
- Type:
Spectrum Tuple representing mz, intensity, Precursor mass and Charge for mass spectrumetry data
- structure(Chem.Mol)
- Type:
The structure of the compound
- is_known(bool)
- Type:
A boolean indicating whether the compound is known, derived from the structure
- name(str)
- Type:
The name of the compound
- accession(str)
- Type:
The accession of the compound
- library_membership(str)
- Type:
The GNPS library membership of the compound
Examples
Create a compound by providing the necessary information:
>>> compound = Compound(id="CCMSLIB00005435812", peaks=[[110.066925,38499.089844],[138.060638,412152.093750],[195.079575,6894530.000000],[195.200180,480874.812500],[196.082092,43027.628906]], precursor_mz=195.087, precursor_charge=1, adduct="[M+H]+", smiles="CN1C=NC2=C1C(=O)N(C(=O)N2C)C")
Alternatively, you can create a compound by providing a dictionary of data:
>>> data = { ... "id": "CCMSLIB00005435812", ... "peaks": [[110.066925,38499.089844],[138.060638,412152.093750],[195.079575,6894530.000000],[195.200180,480874.812500],[196.082092,43027.628906]], ... "precursor_mz": 195.087, ... "charge": 1, ... "adduct": "[M+H]+", ... "smiles": "CN1C=NC2=C1C(=O)N(C(=O)N2C)C" ... } >>> compound = Compound(data)
- __init__(spectrum: List[Tuple[float, float]], precursor_mz: float, precursor_charge: int, adduct: str, smiles: str | None = None, **kwargs)[source]
Initialize the Compound class
The compound class can be initialized in three different ways: 1. By providing a dictionary of data to the data parameter that contains all the necessary information 2. By providing the necessary information as parameter
If both the data and the parameters are provided, the parameters will override the data.
If of the incoming data and kwargs are provided, an empty instance of the class will be created.
- Parameters:
incoming_data (input data (optional, default: None)) – The data to initialize the class with, can be a dictionary of data or a compound object. If not provided, the class will be initialized with the provided keyword arguments. If provided, the keyword arguments will still override the data.
kwargs (keyword arguments (optional, default: No attributes)) – Attributes to initialize the class with, if provided, they will override the attributes from the data
See also
Methods
clear()Clear the compound data and reset all the attributes to None
copy()Return a copy of the compound
Get the meta data of the compound