Skip to content

Add alignment candidate options and enhance OSWReader for selection#210

Merged
singjc merged 3 commits intoPyProphet:masterfrom
singjc:master
May 8, 2026
Merged

Add alignment candidate options and enhance OSWReader for selection#210
singjc merged 3 commits intoPyProphet:masterfrom
singjc:master

Conversation

@singjc
Copy link
Copy Markdown
Contributor

@singjc singjc commented May 8, 2026

This pull request adds support for using candidate alignments from the FEATURE_MS2_ALIGNMENT_CANDIDATE table for across-run alignment in IPF propagation, with configurable options for minimum mapping confidence and fallback behavior. It introduces new CLI options, updates configuration handling, and implements the logic for both DuckDB and SQLite backends.

New alignment candidate support:

  • Added two new configuration options to IPFIOConfig and the CLI: use_alignment_candidates (to enable using FEATURE_MS2_ALIGNMENT_CANDIDATE table) and min_alignment_mapping_confidence (to set the minimum MAPPING_CONFIDENCE required for candidate alignments). [1] [2] [3]
  • Updated CLI and configuration parsing to accept and propagate the new options throughout the codebase. [1] [2] [3] [4]

Backend implementation:

  • Implemented logic in DuckDB and SQLite readers to use FEATURE_MS2_ALIGNMENT_CANDIDATE when enabled, filtering by MAPPING_CONFIDENCE, and falling back to FEATURE_MS2_ALIGNMENT if the candidate table is not available. [1] [2]

Copilot AI review requested due to automatic review settings May 8, 2026 23:04
@singjc singjc enabled auto-merge May 8, 2026 23:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds optional use of FEATURE_MS2_ALIGNMENT_CANDIDATE for across-run alignment group mapping in the IPF workflow, exposing configuration/CLI knobs to control candidate usage and minimum mapping confidence.

Changes:

  • Added use_alignment_candidates and min_alignment_mapping_confidence to IPFIOConfig and wired them through the pyprophet ipf CLI.
  • Updated OSW (DuckDB + SQLite) alignment mapping readers to optionally read from FEATURE_MS2_ALIGNMENT_CANDIDATE, filter by MAPPING_CONFIDENCE, and fall back when the table is absent.
  • Updated related config documentation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pyprophet/io/ipf/osw.py Adds candidate-table-based alignment mapping queries for DuckDB and SQLite, with fallback behavior.
pyprophet/cli/ipf.py Introduces CLI flags/options to enable candidate mapping and set the minimum mapping confidence.
pyprophet/_config.py Extends IPFIOConfig with the new alignment candidate options and wires them through from_cli_args.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyprophet/io/ipf/osw.py
Comment on lines +307 to +357
logger.info(
"Using FEATURE_MS2_ALIGNMENT_CANDIDATE for across-run alignment groups "
f"with MAPPING_CONFIDENCE >= {min_confidence}."
)
query = f"""
SELECT
DENSE_RANK() OVER (ORDER BY merged.PRECURSOR_ID, merged.ALIGNMENT_ID) AS ALIGNMENT_GROUP_ID,
merged.ALIGNMENT_ID,
merged.FEATURE_ID,
merged.PRECURSOR_ID,
merged.FEATURE_TYPE
FROM (
SELECT DISTINCT
fmac.ALIGNMENT_ID,
fmac.REFERENCE_FEATURE_ID AS FEATURE_ID,
fmac.PRECURSOR_ID,
'REFERENCE' AS FEATURE_TYPE
FROM osw.FEATURE_MS2_ALIGNMENT_CANDIDATE AS fmac
WHERE fmac.SELECTED = 1
AND fmac.MAPPING_CONFIDENCE >= {min_confidence}
AND fmac.REFERENCE_FEATURE_ID != fmac.ALIGNED_FEATURE_ID
AND fmac.ALIGNED_FEATURE_ID != -1

UNION

SELECT DISTINCT
fmac.ALIGNMENT_ID,
fmac.ALIGNED_FEATURE_ID AS FEATURE_ID,
fmac.PRECURSOR_ID,
'QUERY' AS FEATURE_TYPE
FROM osw.FEATURE_MS2_ALIGNMENT_CANDIDATE AS fmac
WHERE fmac.SELECTED = 1
AND fmac.MAPPING_CONFIDENCE >= {min_confidence}
AND fmac.REFERENCE_FEATURE_ID != fmac.ALIGNED_FEATURE_ID
AND fmac.ALIGNED_FEATURE_ID != -1
) AS merged
ORDER BY
ALIGNMENT_GROUP_ID,
CASE merged.FEATURE_TYPE
WHEN 'REFERENCE' THEN 0
WHEN 'QUERY' THEN 1
END;
"""

df = con.execute(query).fetchdf()
return df.rename(columns=str.lower)

logger.warning(
"Requested FEATURE_MS2_ALIGNMENT_CANDIDATE for IPF propagation, "
"but the table was not found. Falling back to FEATURE_MS2_ALIGNMENT."
)
Comment thread pyprophet/io/ipf/osw.py
Comment on lines +596 to +620
if use_alignment_candidates:
if check_sqlite_table(con, "FEATURE_MS2_ALIGNMENT_CANDIDATE"):
logger.info(
"Using FEATURE_MS2_ALIGNMENT_CANDIDATE for across-run alignment groups "
f"with MAPPING_CONFIDENCE >= {min_confidence}."
)
query = """
SELECT
DENSE_RANK() OVER (ORDER BY PRECURSOR_ID, ALIGNMENT_ID) AS ALIGNMENT_GROUP_ID,
ALIGNMENT_ID,
FEATURE_ID,
PRECURSOR_ID,
FEATURE_TYPE
FROM (
SELECT DISTINCT
ALIGNMENT_ID,
PRECURSOR_ID,
REFERENCE_FEATURE_ID AS FEATURE_ID,
'REFERENCE' AS FEATURE_TYPE
FROM FEATURE_MS2_ALIGNMENT_CANDIDATE
WHERE SELECTED = 1
AND MAPPING_CONFIDENCE >= ?
AND REFERENCE_FEATURE_ID != ALIGNED_FEATURE_ID
AND ALIGNED_FEATURE_ID != -1

Comment thread pyprophet/io/ipf/osw.py
Comment on lines +305 to +307
if use_alignment_candidates:
if check_duckdb_table(con, "main", "FEATURE_MS2_ALIGNMENT_CANDIDATE"):
logger.info(
@singjc singjc merged commit 23c8093 into PyProphet:master May 8, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants