Skip to content

Adapters to ms data

Spectral library adapters

ms2ml.data.adapters.bibliospec.BiblioSpecAdapter(file: str, config: Config, in_hook: Callable | None = None, out_hook: Callable | None = None, collate_fn: Callable = list)

Bases: BaseAdapter

Implements an adapter that reads bibliospec files

PARAMETER DESCRIPTION
file

Path to the bibliospec file

TYPE: str

config

The config object

TYPE: Config

in_hook

A function to apply to each element before processing. Defaults to None.

TYPE: Callable DEFAULT: None

out_hook

A function to apply to each element after processing. Defaults to None.

TYPE: Callable DEFAULT: None

collate_fn

A function to collate the elements. Defaults to list.

TYPE: Callable DEFAULT: list

Attributes

ms2ml.data.adapters.bibliospec.BiblioSpecAdapter.parser = BiblioSpecParser(file) instance-attribute

Functions

ms2ml.data.adapters.bibliospec.BiblioSpecAdapter.parse() -> Iterator[AnnotatedPeptideSpectrum]
ms2ml.data.adapters.bibliospec.BiblioSpecAdapter.parse_file(file) -> Iterator[AnnotatedPeptideSpectrum]

ms2ml.data.adapters.encyclopedia.EncyclopeDIAAdapter(file: str, config: Config, in_hook: Callable | None = None, out_hook: Callable | None = None, collate_fn: Callable = list)

Bases: BaseAdapter

Implements an adapter that reads bibliospec files

PARAMETER DESCRIPTION
file

Path to the .elib or .dlib file

TYPE: str

config

The config object

TYPE: Config

in_hook

A function to apply to each element before processing. Defaults to None.

TYPE: Callable DEFAULT: None

out_hook

A function to apply to each element after processing. Defaults to None.

TYPE: Callable DEFAULT: None

collate_fn

A function to collate the elements. Defaults to list.

TYPE: Callable DEFAULT: list

Attributes

ms2ml.data.adapters.encyclopedia.EncyclopeDIAAdapter.parser = EncyclopeDIAParser(file) instance-attribute

Functions

ms2ml.data.adapters.encyclopedia.EncyclopeDIAAdapter.parse() -> Iterator[AnnotatedPeptideSpectrum]
ms2ml.data.adapters.encyclopedia.EncyclopeDIAAdapter.parse_file(file) -> Iterator[AnnotatedPeptideSpectrum]

ms2ml.data.adapters.msp.MSPAdapter(config: Config, file: Optional[str] = None, in_hook: Optional[Callable] = None, out_hook: Optional[Callable] = None, collate_fn: Callable = pad_collate)

Bases: BaseAdapter

Attributes

ms2ml.data.adapters.msp.MSPAdapter.parser = MSPParser(file) instance-attribute

Functions

ms2ml.data.adapters.msp.MSPAdapter.parse_text(text) -> Iterator[AnnotatedPeptideSpectrum]
ms2ml.data.adapters.msp.MSPAdapter.parse() -> Iterator[AnnotatedPeptideSpectrum]
ms2ml.data.adapters.msp.MSPAdapter.parse_file(file) -> Iterator[AnnotatedPeptideSpectrum]
ms2ml.data.adapters.msp.MSPAdapter.batch(batch_size: int) -> Iterator[AnnotatedPeptideSpectrum]

ms2ml.data.adapters.pin.PinAdapter(file: PathLike[Any], config: Config, in_hook: Callable | None = None, out_hook: Callable | None = None, collate_fn: Callable[..., Any] | None = None, raw_file_locations: list[PathLike] | None = None)

Bases: PinParser, BaseAdapter

Provides an adapter for pin files.

PARAMETER DESCRIPTION
file

Path to the file to be parsed.

TYPE: PathLike[Any]

config

The config object to use.

TYPE: Config

in_hook

A function to apply to the input of the adapter. Defaults to None.

TYPE: Callable DEFAULT: None

out_hook

A function to apply to the output of the adapter. Defaults to None.

TYPE: Callable DEFAULT: None

collate_fn

A function to use to collate the output of the adapter. Defaults to pad_collate.

TYPE: Callable[..., Any] DEFAULT: None

raw_file_locations

A list of locations to search for raw files, if none is provided, attempts to find the files recursively in the current working directory. Defaults to None.

TYPE: list[PathLike] DEFAULT: None

Attributes

ms2ml.data.adapters.pin.PinAdapter.mzml_adapters = {} instance-attribute
ms2ml.data.adapters.pin.PinAdapter.raw_file_locations = ['.'] instance-attribute

Functions

ms2ml.data.adapters.pin.PinAdapter.parse_file(file: PathLike[Any]) -> Iterator[AnnotatedPeptideSpectrum]

Parses a pin file and yields one spectrum at a time.

The spectra are yielded as AnnotatedPeptideSpectrum

ms2ml.data.adapters.mokapot.MokapotPSMAdapter(file: PathLike, config: Config, in_hook: Callable | None = None, out_hook: Callable | None = None, collate_fn: Callable[..., Any] | None = None, raw_file_locations: list[PathLike] | PathLike = '.')

Bases: BaseAdapter, MokapotPSMParser

Attributes

ms2ml.data.adapters.mokapot.MokapotPSMAdapter.mzml_adapters = {} instance-attribute
ms2ml.data.adapters.mokapot.MokapotPSMAdapter.raw_file_locations = ['.'] instance-attribute

Functions

ms2ml.data.adapters.mokapot.MokapotPSMAdapter.parse_file(file: PathLike) -> Iterator[AnnotatedPeptideSpectrum]

Parses a pin file and yields one spectrum at a time.

The spectra are yielded as AnnotatedPeptideSpectrum

ms2ml.data.adapters.spectronaut.SpectronautAdapter(config: Config, in_hook: Callable = None, out_hook: Callable = None, collate_fn: Callable[..., Any] = None)

Bases: SpectronautLibraryParser, BaseAdapter

Functions

ms2ml.data.adapters.spectronaut.SpectronautAdapter.parse_file(file) -> Iterator[AnnotatedPeptideSpectrum]

Peptide Adapters

ms2ml.data.adapters.fasta.FastaAdapter(file: PathLike, config: Config, only_unique: bool = True, enzyme: str = 'trypsin', missed_cleavages: int = 2, allow_modifications: bool = False, in_hook: Callable | None = None, out_hook: Callable | None = None, collate_fn: Callable = list)

Bases: BaseAdapter, FastaDataset

Implements an adapter that reads fasta files

PARAMETER DESCRIPTION
file

Path to the fasta file

TYPE: str

config

The config object

TYPE: Config

only_unique

Whether to only keep unique peptides. Defaults to True.

TYPE: bool DEFAULT: True

enzyme

The enzyme to use. Defaults to "trypsin".

TYPE: str DEFAULT: 'trypsin'

missed_cleavages

The number of missed cleavages. Defaults to 2.

TYPE: int DEFAULT: 2

in_hook

A function to apply to each element before processing. Defaults to None.

TYPE: Callable DEFAULT: None

out_hook

A function to apply to each element after processing. Defaults to None.

TYPE: Callable DEFAULT: None

collate_fn

A function to collate the elements. Defaults to list.

TYPE: Callable DEFAULT: list

Attributes

ms2ml.data.adapters.fasta.FastaAdapter.allow_modifications = allow_modifications instance-attribute

Functions

ms2ml.data.adapters.fasta.FastaAdapter.parse() -> Iterator[Peptide]

MS data adapters

ms2ml.data.adapters.mzml.MZMLAdapter(file, config: Config, out_hook: Optional[Callable] = None, in_hook: Optional[Callable] = None, collate_fn: Callable = pad_collate)

Bases: BaseAdapter

Provides an adapter for mzML files.

PARAMETER DESCRIPTION
file

Path to the file to be parsed.

TYPE: str

config

The config object to use.

TYPE: Config

out_hook

A function to apply to the output of the adapter. Defaults to None.

TYPE: Optional[Callable] DEFAULT: None

in_hook

A function to apply to the input of the adapter. Defaults to None.

TYPE: Optional[Callable] DEFAULT: None

collate_fn

A function to use to collate the output of the adapter. Defaults to pad_collate.

TYPE: Callable DEFAULT: pad_collate

Attributes

ms2ml.data.adapters.mzml.MZMLAdapter.file = str(file) instance-attribute
ms2ml.data.adapters.mzml.MZMLAdapter.config = config instance-attribute
ms2ml.data.adapters.mzml.MZMLAdapter.out_hook = out_hook instance-attribute
ms2ml.data.adapters.mzml.MZMLAdapter.reader = read_mzml(self.file, use_index=True, huge_tree=True) instance-attribute
ms2ml.data.adapters.mzml.MZMLAdapter.instrument = list(instrument_data.values())[0] instance-attribute

Functions

ms2ml.data.adapters.mzml.MZMLAdapter.parse() -> Generator[Spectrum, None, None]

Parse the file and yield the spectra.

RAISES DESCRIPTION
NotImplementedError

If the file contains a spectrum that is not centroided.

Examples:

adapter = MZMLAdapter("tests/data/BSA1.mzML") for spec in adapter.parse(): print(spec)

ms2ml.data.adapters.mzml.MZMLAdapter.parse_ms1() -> Generator[Spectrum, None, None]

Parse the file and yield the MS1 spectra.

Examples:

adapter = MZMLAdapter("tests/data/BSA1.mzML") for spec in adapter.parse_ms1(): print(spec)

ms2ml.data.adapters.mzml.MZMLAdapter.get_scan_info() -> pd.DataFrame
ms2ml.data.adapters.mzml.MZMLAdapter.__repr__()
ms2ml.data.adapters.mzml.MZMLAdapter.__getitem__(idx) cached