SKILL.md
Version Compatibility
Reference examples tested with: pyOpenMS 3.1+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures - R:
packageVersion("<pkg>")then?function_nameto verify parameters
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Protein Inference
"Resolve protein groups from my peptide identifications" → Group peptide-spectrum matches into protein groups, resolving shared-peptide ambiguity using parsimony or probabilistic methods, then apply protein-level FDR.
- Python:
pyopenms.ProteinInference()for parsimony-based grouping - R: Bioconductor protein inference workflows
The Protein Inference Problem
Peptides can map to multiple proteins (shared peptides), making protein identification ambiguous.
# Example: Peptide mapping
peptide_to_proteins = {
'PEPTIDEK': ['P12345', 'P67890'], # Shared between paralogs
'UNIQUER': ['P12345'], # Unique to P12345
'ANOTHERONE': ['P12345'], # Unique to P12345
'SHAREDK': ['P67890', 'P11111'], # Shared
}
# P12345 has 2 unique peptides -> confident identification
# P67890 has 0 unique peptides -> subset, may be grouped with P12345
Parsimony Principle
Goal: Resolve protein identification ambiguity from shared peptides by finding the minimal protein set explaining all observed peptides.
Approach: Build a peptide-to-protein mapping, then greedily select proteins that cover the most unassigned peptides until all peptides are accounted for, producing a minimal explanatory protein list.
def apply_parsimony(peptide_protein_map):
'''Find minimal set of proteins explaining all peptides'''
proteins = set()
for prots in peptide_protein_map.values():
proteins.update(prots)
protein_peptides = {p: set() for p in proteins}
for pep, prots in peptide_protein_map.items():
for p in prots:
protein_peptides[p].add(pep)
covered_peptides = set()
selected_proteins = []
# Greedy: select protein covering most uncovered peptides
while covered_peptides != set(peptide_protein_map.keys()):
best_protein = max(protein_peptides.keys(),
key=lambda p: len(protein_peptides[p] - covered_peptides))
new_coverage = protein_peptides[best_protein] - covered_peptides
if not new_coverage:
break
selected_proteins.append(best_protein)
covered_peptides.update(new_coverage)
return selected_proteins
