OSWReader

class pyprophet.io.export.osw.OSWReader(config: ExportIOConfig)[source]

Bases: BaseOSWReader

Class for reading and processing data from an OpenSWATH workflow OSW-sqlite based file. Extended to support exporting functionality.

__init__(config: ExportIOConfig)[source]

Initialize the reader with a given configuration.

Parameters:

config (BaseIOConfig) – Configuration object containing input details, and module specific config for params for reading.

_add_peptide_data(data, con, cfg)[source]

Add peptide-level error rate data.

_add_protein_data(data, con)[source]

Add protein identifier data.

_add_protein_error_data(data, con, cfg)[source]

Add protein-level error rate data.

_add_transition_data(data, con, cfg)[source]

Add transition-level quantification data.

_augment_data(data, con, cfg)[source]

Apply common data augmentations to the base dataset.

_build_score_sql(con)[source]

Build SQL fragment for score columns in unscored files.

_check_alignment_presence(con)[source]

Check if alignment data is present.

_check_ipf_presence(con, cfg)[source]

Check if IPF data is present and should be used.

_create_indexes()[source]

Create necessary indexes for export queries.

_fetch_alignment_features(con, cfg)[source]

Fetch aligned features with good alignment scores.

This method retrieves features that have been aligned across runs and pass the alignment quality threshold. Only features whose reference feature passes the MS2 QVALUE threshold are included, ensuring that recovered peaks are aligned to high-quality reference features.

Parameters:
  • con – Database connection

  • cfg – Configuration object with max_alignment_pep threshold

Returns:

DataFrame with aligned feature IDs that pass quality threshold

_get_base_openswath_data(con, cfg)[source]

Get base OpenSWATH data without augmentations.

_get_ipf_augmentation_data(con, cfg)[source]

Get IPF data for augmentation.

_get_ms1_score_info(con)[source]

Get MS1 score information if available.

_get_peptide_protein_score_table_sqlite(con, level: str) str[source]

SQLite-compatible view builder for peptide/protein score tables. Always exposes the same columns: - *_EXPERIMENT_WIDE_(SCORE|PVALUE|QVALUE|PEP) (per RUN_ID) - *_RUN_SPECIFIC_(SCORE|PVALUE|QVALUE|PEP) (per RUN_ID) - *_GLOBAL_(SCORE|PVALUE|QVALUE|PEP) (no RUN_ID)

_has_im(con) bool[source]

Return True if the FEATURE table contains the EXP_IM column.

Older OSW files may not have this column; centralise the PRAGMA check so callers don’t duplicate the logic.

_has_im_boundaries(con) bool[source]

Return True if the FEATURE table contains IM boundary columns.

Older OSW files may not have these columns; this helper centralises the PRAGMA check so callers don’t duplicate the logic.

_is_unscored_file(con)[source]

Check if the file is unscored (no score tables present).

_read_augmented_data(con, cfg)[source]

Read standard data augmented with IPF information.

_read_for_export_scored_report(con) DataFrame[source]

Lightweight reader that returns the minimal scored-report columns from an OSW SQLite. It tolerates missing tables by emitting NULL columns for absent sources.

_read_peptidoform_data(con, cfg)[source]

Read data with peptidoform IPF information.

_read_sqlite(con)[source]

Main entry point for reading SQLite data, delegates to specific methods.

_read_standard_data(con, cfg)[source]

Read standard OpenSWATH data without IPF, optionally including aligned features.

_read_unscored_data(con)[source]

Read data from unscored files.

export_feature_scores(outfile: str, plot_callback)[source]

Export feature scores from OSW file for plotting.

Detects if SCORE tables exist and adjusts behavior: - If SCORE tables exist: applies RANK==1 filtering and plots SCORE + VAR_ columns - If SCORE tables don’t exist: plots only VAR_ columns

Parameters:
  • outfile (str) – Path to the output PDF file.

  • plot_callback (callable) – Function to call for plotting each level’s data. Signature: plot_callback(df, outfile, level, append)

read() DataFrame[source]

Read data from the OpenSWATH workflow OSW-sqlite based file.