pygecko.gc_tools.injection package
Submodules
pygecko.gc_tools.injection.fid_injection module
- class pygecko.gc_tools.injection.fid_injection.FID_Injection(metadata: dict, chromatogram: ndarray, solvent_delay: float | None = None, pos: bool = False)
Bases:
InjectionClass to represent FID injections.
- injector_pos
Position of the injector used for the injection.
- Type:
int
- sample_number
Number of the sample in the sequence.
- Type:
int
- acq_time
Acquisition time of the injection.
- Type:
str
- data_method
Data method used for the injection.
- Type:
- solvent_delay
Solvent delay applied to the injection.
- Type:
float
- chromatogram
Chromatogram of the injection.
- Type:
np.ndarray
- processed_chromatogram
Processed chromatogram of the injection.
- Type:
np.ndarray|None
- detector
Detector used for the injection.
- Type:
str
- acq_time: str
- analysis_settings: Analysis_Settings
- baseline_correction(**kwargs: dict) None
Applies a baseline correction to the injection’s chromatogram and sets the corrected chromatogram as the injection’s processed chromatogram.
- Parameters:
**kwargs – Keyword arguments for the baseline correction.
- chromatogram: ndarray
- detector: str
- injector_pos: int
- integrate() None
Integrates the area under the curve of the injection’s peaks and sets the area as the peak’s area attribute.
- pick_peaks(inplace: bool = True, **kwargs: dict) None | dict[float, FID_Peak]
Picks peaks from the injection’s chromatogram.
- Parameters:
inplace (bool) – If True, the peaks are assigned to the injection’s peaks attribute. Default is True.
**kwargs – Keyword arguments for the peak picking.
- Returns:
The peaks of the injection if the inplace argument is False, None otherwise.
- Return type:
None|dict[float, FID_Peak]
- processed_chromatogram: ndarray | None
- quantify(rt: float, method: str = 'polyarc', **kwargs) int
Returns the yield of the analyte with the given retention time calculated using the internal standard of the injection.
- Parameters:
rt (float) – Retention time of the analyte.
method (str) – Method to use for the quantification. Default is ‘polyarc’.
- Returns:
Yield of the analyte.
- Return type:
int
- report(path: str) None
Writes a csv report for the injection to the given path.
- Parameters:
path (str) – Path to write the report to.
- sample_number: int
- solvent_delay: float
pygecko.gc_tools.injection.injection module
- class pygecko.gc_tools.injection.injection.Injection(metadata: dict, peaks: dict[float, Peak] | None = None, pos: bool = False)
Bases:
objectBase class for all injections.
- acq_method
Name of the acquisition method.
- Type:
str
- instrument_name
Name of the instrument.
- Type:
str
- sample_description
Description of the sample.
- Type:
str
- sample_name
Name of the sample.
- Type:
str
- sample_type
Type of the sample.
- Type:
str
- vial_pos
Position of the sample’s vial in the autosampler.
- Type:
int
- acq_method: str
- analysis_settings: None
- chromatogram: None
- detector: None | str
- flag_peak(rt: float, flag: str | None = None, tolerance: float = 0.05, analyte: Analyte | None = None) None | Peak
Assigns a flag to the peak with the closest retention time to the given retention time within the tolerance.
- Parameters:
rt (float) – Retention time of the peak.
flag (str|None) – Flag to be assigned to the peak. Default is None.
tolerance (float) – Tolerance for the retention time matching. Default is 0.05.
analyte (Analyte|None) – Analyte object to be assigned to the peak. Default is None.
- Returns:
The peak with the closest retention time to the given retention time or None if no peak was found within the tolerance.
- Return type:
None|Peak
- get_plate_position()
Returns the plate position of the sample as string.
- instrument_name: str
- match_ri(ri: float, tolerance: int = 20, analyte: str | None = None, return_candidates: bool = False) Peak | None
Returns the peak with the closest retention index to the given retention index within the tolerance. Returns None if no peak was found within the tolerance.
- Parameters:
ri (float) – Retention index to match.
tolerance (int) – Tolerance for the retention index matching. Default is 20.
analyte (str|None) – Analyte object to be assigned to the peak. Default is None.
- Returns:
- The peak with the closest retention index to the given retention index or None if
no peak was found within the tolerance.
- Return type:
Peak|None
- plate_pos: str | None
- sample_description: str
- sample_name: str
- sample_type: str
- save(filename: str) None
Saves an Injection to a .pkl file.
- Parameters:
filename (str) – Name of the file to save the injection to.
- set_internal_standard(rt: float | int, tolerance: float = 0.05, name: str | None = None, smiles: str | None = None) None
Assigns the internal standard of the injection to the corresponding peak by creating an Analyte object for the internal standard and setting it as the peak’s analyte.
- Parameters:
rt (float|int) – Retention time of the internal standard.
tolerance (float) – Tolerance for the retention time matching. Default is 0.05.
name (str) – Name of the internal standard. Default is None.
smiles (str) – SMILES string of the internal standard. Default is None.
- set_plate_position(pos: str)
Takes in a plate position and sets it as the sample’s position.
- vial_pos: int
- view_chromatogram(path: str | None = None, **kwargs) None
Plots the chromatogram of the injection.
- Parameters:
**kwargs – Keyword arguments for the visualization.
pygecko.gc_tools.injection.ms_injection module
- class pygecko.gc_tools.injection.ms_injection.MS_Injection(metadata: dict | None, chromatogram: ndarray, peaks: dict | None, scans: DataFrame, pos: bool = False)
Bases:
InjectionClass to represent MS injections.
- chromatogram
Chromatogram of the injection.
- Type:
np.ndarray
- scans
Scans of the injection.
- Type:
pd.DataFrame
- detector
Detector used for the injection.
- Type:
str
- analysis_settings
Data method used for the injection.
- Type:
- solvent_delay
Solvent delay applied to the injection.
- Type:
float
- analysis_settings: Analysis_Settings
- chromatogram: ndarray
- detector: str
- match_mol(smiles: str, return_canidates=False, check_iso=True, **kwargs) MS_Peak'>, None)] | None
Returns the peak with the lowest isotope error for the m/z corresponding to the given molecule’s parent peak. Returns None if no peak was found matching the criteria.
- Parameters:
smiles (str) – SMILES string of the analyte.
- Returns:
The peak with the lowest isotope error for the given molecule or None if no peak was found matching the criteria.
- Return type:
MS_Peak|None
- match_mz(mz: float, **kwargs) MS_Peak | list[MS_Peak] | None
Returns the peak or a list of peaks whose mass spectra contain the given m/z. Returns None if no peak was found matching the criteria.
- pick_peaks(inplace: bool = True, **kwargs: dict) None | dict[float, MS_Peak]
Picks peaks from the injection’s chromatogram.
- Parameters:
inplace (bool) – If True, the peaks are assigned to the injection’s peaks attribute. Default is True.
**kwargs – Keyword arguments for the peak picking.
- Returns:
The peaks of the injection if the inplace argument is False, None otherwise.
- Return type:
None|dict[float, MS_Peak]
- save_peaks_mass_spectrum(rt: float, path: str) None
Saves the mass spectrum of all peaks in the injection to a CSV file. :param path: Path to the file where the mass spectra will be saved. :type path: str
- scans: DataFrame
- solvent_delay: float