CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-pyopenms

Python wrapper for C++ LC-MS library OpenMS for comprehensive mass spectrometry data analysis

Pending
Overview
Eval results
Files

peptide-protein.mddocs/

Peptide and Protein Analysis

Comprehensive support for peptide sequence analysis, database search results, and protein identification workflows. Includes modification handling, sequence properties, and identification result processing.

Capabilities

Peptide Sequences

AASequence

Amino acid sequence representation with comprehensive modification support.

class AASequence:
    def __init__(self) -> None: ...
    
    @staticmethod
    def fromString(sequence: str) -> AASequence:
        """
        Create sequence from string notation.
        
        Args:
            sequence (str): Peptide sequence with modifications (e.g., "PEPTIDE", "PEPTIDEM(Oxidation)")
            
        Returns:
            AASequence: Parsed amino acid sequence
        """
    
    def toString(self) -> str:
        """
        Convert sequence to string notation.
        
        Returns:
            str: String representation with modifications
        """
    
    def toUnmodifiedString(self) -> str:
        """
        Get unmodified sequence string.
        
        Returns:
            str: Plain amino acid sequence without modifications
        """
    
    def size(self) -> int:
        """
        Get sequence length.
        
        Returns:
            int: Number of amino acids
        """
    
    def empty(self) -> bool:
        """
        Check if sequence is empty.
        
        Returns:
            bool: True if empty sequence
        """
    
    def getMonoWeight(self) -> float:
        """
        Get monoisotopic molecular weight.
        
        Returns:
            float: Monoisotopic weight in Da
        """
    
    def getAverageWeight(self) -> float:
        """
        Get average molecular weight.
        
        Returns:
            float: Average weight in Da
        """
    
    def getFormula(self) -> EmpiricalFormula:
        """
        Get empirical formula.
        
        Returns:
            EmpiricalFormula: Molecular formula
        """
    
    def getResidue(self, index: int) -> Residue:
        """
        Get residue at position.
        
        Args:
            index (int): Position index (0-based)
            
        Returns:
            Residue: Amino acid residue
        """
    
    def setModification(self, index: int, modification: str) -> None:
        """
        Set modification at position.
        
        Args:
            index (int): Position index
            modification (str): Modification name
        """
    
    def getNTerminalModification(self) -> ResidueModification:
        """
        Get N-terminal modification.
        
        Returns:
            ResidueModification: N-terminal modification
        """
    
    def setNTerminalModification(self, mod: ResidueModification) -> None:
        """
        Set N-terminal modification.
        
        Args:
            mod (ResidueModification): N-terminal modification
        """
    
    def getCTerminalModification(self) -> ResidueModification:
        """
        Get C-terminal modification.
        
        Returns:
            ResidueModification: C-terminal modification
        """
    
    def setCTerminalModification(self, mod: ResidueModification) -> None:
        """
        Set C-terminal modification.
        
        Args:
            mod (ResidueModification): C-terminal modification
        """
    
    def setModificationByDiffMonoMass(self, index: int, diff_mono_mass: float) -> None:
        """
        Set modification by monoisotopic mass difference.
        
        Args:
            index (int): Position index
            diff_mono_mass (float): Mass difference in Da
        """
    
    def setNTerminalModificationByDiffMonoMass(self, diff_mono_mass: float, protein_term: bool = False) -> None:
        """
        Set N-terminal modification by mass difference.
        
        Args:
            diff_mono_mass (float): Mass difference in Da
            protein_term (bool): Whether this is a protein N-terminus
        """
    
    def setCTerminalModificationByDiffMonoMass(self, diff_mono_mass: float, protein_term: bool = False) -> None:
        """
        Set C-terminal modification by mass difference.
        
        Args:
            diff_mono_mass (float): Mass difference in Da
            protein_term (bool): Whether this is a protein C-terminus
        """
    
    def toUniModString(self) -> str:
        """
        Convert to UniMod-style string notation.
        
        Returns:
            str: UniMod-style string representation
        """
    
    def toBracketString(self, integer_mass: bool = True, mass_delta: bool = False) -> str:
        """
        Create TPP-compatible bracket notation string.
        
        Args:
            integer_mass (bool): Use integer masses
            mass_delta (bool): Show mass deltas instead of absolute masses
            
        Returns:
            str: Bracket notation string
        """
    
    def getPrefix(self, index: int) -> AASequence:
        """
        Get prefix sequence of specified length.
        
        Args:
            index (int): Length of prefix
            
        Returns:
            AASequence: Prefix sequence
        """
    
    def getSuffix(self, index: int) -> AASequence:
        """
        Get suffix sequence of specified length.
        
        Args:
            index (int): Length of suffix
            
        Returns:
            AASequence: Suffix sequence
        """
    
    def getSubsequence(self, index: int, length: int) -> AASequence:
        """
        Get subsequence starting at position.
        
        Args:
            index (int): Start position
            length (int): Length of subsequence
            
        Returns:
            AASequence: Subsequence
        """
    
    def getMZ(self, charge: int) -> float:
        """
        Get m/z value for given charge state.
        
        Args:
            charge (int): Charge state
            
        Returns:
            float: m/z value
        """
    
    def has(self, residue: Residue) -> bool:
        """
        Check if sequence contains residue.
        
        Args:
            residue (Residue): Residue to search for
            
        Returns:
            bool: True if residue found
        """
    
    def hasSubsequence(self, peptide: AASequence) -> bool:
        """
        Check if sequence contains subsequence.
        
        Args:
            peptide (AASequence): Subsequence to search for
            
        Returns:
            bool: True if subsequence found
        """
    
    def hasPrefix(self, peptide: AASequence) -> bool:
        """
        Check if sequence has given prefix.
        
        Args:
            peptide (AASequence): Prefix to check
            
        Returns:
            bool: True if sequence starts with prefix
        """
    
    def hasSuffix(self, peptide: AASequence) -> bool:
        """
        Check if sequence has given suffix.
        
        Args:
            peptide (AASequence): Suffix to check
            
        Returns:
            bool: True if sequence ends with suffix
        """
    
    def hasNTerminalModification(self) -> bool:
        """
        Check if N-terminal modification present.
        
        Returns:
            bool: True if N-terminal modification present
        """
    
    def hasCTerminalModification(self) -> bool:
        """
        Check if C-terminal modification present.
        
        Returns:
            bool: True if C-terminal modification present
        """
    
    def isModified(self) -> bool:
        """
        Check if sequence has modifications.
        
        Returns:
            bool: True if any modifications present
        """

Amino Acid Properties

Residue

Individual amino acid residue with chemical properties.

class Residue:
    def __init__(self) -> None: ...
    
    def getName(self) -> str:
        """
        Get residue name.
        
        Returns:
            str: Full residue name
        """
    
    def getOneLetterCode(self) -> str:
        """
        Get single letter code.
        
        Returns:
            str: One letter amino acid code
        """
    
    def getThreeLetterCode(self) -> str:
        """
        Get three letter code.
        
        Returns:
            str: Three letter amino acid code
        """
    
    def getMonoWeight(self) -> float:
        """
        Get monoisotopic weight.
        
        Returns:
            float: Monoisotopic weight in Da
        """
    
    def getAverageWeight(self) -> float:
        """
        Get average weight.
        
        Returns:
            float: Average weight in Da
        """
    
    def getFormula(self) -> EmpiricalFormula:
        """
        Get empirical formula.
        
        Returns:
            EmpiricalFormula: Chemical formula
        """
    
    def isModified(self) -> bool:
        """
        Check if residue is modified.
        
        Returns:
            bool: True if modified
        """
    
    def getModification(self) -> ResidueModification:
        """
        Get modification.
        
        Returns:
            ResidueModification: Residue modification
        """

class ResidueDB:
    @staticmethod
    def getInstance() -> ResidueDB:
        """
        Get singleton instance.
        
        Returns:
            ResidueDB: Residue database instance
        """
    
    def getResidue(self, name: str) -> Residue:
        """
        Get residue by name or code.
        
        Args:
            name (str): Residue name or code
            
        Returns:
            Residue: Amino acid residue
        """
    
    def getResidues(self) -> set[Residue]:
        """
        Get all residues.
        
        Returns:
            set[Residue]: All available residues
        """

Modifications

ResidueModification

Post-translational and chemical modifications.

class ResidueModification:
    def __init__(self) -> None: ...
    
    def getId(self) -> str:
        """
        Get modification ID.
        
        Returns:
            str: Unique modification identifier
        """
    
    def getFullId(self) -> str:
        """
        Get full modification ID.
        
        Returns:
            str: Complete modification identifier
        """
    
    def getFullName(self) -> str:
        """
        Get full modification name.
        
        Returns:
            str: Complete modification name
        """
    
    def getName(self) -> str:
        """
        Get short modification name.
        
        Returns:
            str: Short name
        """
    
    def getMonoMass(self) -> float:
        """
        Get monoisotopic mass delta.
        
        Returns:
            float: Mass change in Da
        """
    
    def getAverageMass(self) -> float:
        """
        Get average mass delta.
        
        Returns:
            float: Average mass change in Da
        """
    
    def getDiffFormula(self) -> EmpiricalFormula:
        """
        Get formula difference.
        
        Returns:
            EmpiricalFormula: Chemical formula change
        """
    
    def getOrigin(self) -> str:
        """
        Get amino acid origin.
        
        Returns:
            str: Target amino acid
        """
    
    def getClassification(self) -> TermSpecificity:
        """
        Get classification.
        
        Returns:
            TermSpecificity: Modification classification
        """

class ModificationsDB:
    @staticmethod
    def getInstance() -> ModificationsDB:
        """
        Get singleton instance.
        
        Returns:
            ModificationsDB: Modifications database instance
        """
    
    def getModification(self, name: str) -> ResidueModification:
        """
        Get modification by name.
        
        Args:
            name (str): Modification name
            
        Returns:
            ResidueModification: The modification
        """
    
    def getAllSearchModifications(self) -> list[ResidueModification]:
        """
        Get all search modifications.
        
        Returns:
            list[ResidueModification]: Available search modifications
        """
    
    def getModifications(self, residue: str, term_spec: TermSpecificity) -> list[ResidueModification]:
        """
        Get modifications for residue.
        
        Args:
            residue (str): Target amino acid
            term_spec (TermSpecificity): Terminal specificity
            
        Returns:
            list[ResidueModification]: Applicable modifications
        """

Database Search Results

PeptideIdentification

Peptide identification from database search.

class PeptideIdentification:
    def __init__(self) -> None: ...
    
    def getHits(self) -> list[PeptideHit]:
        """
        Get peptide hits.
        
        Returns:
            list[PeptideHit]: List of peptide hits
        """
    
    def setHits(self, hits: list[PeptideHit]) -> None:
        """
        Set peptide hits.
        
        Args:
            hits (list[PeptideHit]): Peptide hits to set
        """
    
    def insertHit(self, hit: PeptideHit) -> None:
        """
        Add peptide hit.
        
        Args:
            hit (PeptideHit): Peptide hit to add
        """
    
    def getRT(self) -> float:
        """
        Get retention time.
        
        Returns:
            float: Retention time in seconds
        """
    
    def setRT(self, rt: float) -> None:
        """
        Set retention time.
        
        Args:
            rt (float): Retention time in seconds
        """
    
    def getMZ(self) -> float:
        """
        Get precursor m/z.
        
        Returns:
            float: Precursor m/z
        """
    
    def setMZ(self, mz: float) -> None:
        """
        Set precursor m/z.
        
        Args:
            mz (float): Precursor m/z
        """
    
    def getScoreType(self) -> str:
        """
        Get score type name.
        
        Returns:
            str: Score type (e.g., "expect", "mascot_score")
        """
    
    def setScoreType(self, score_type: str) -> None:
        """
        Set score type.
        
        Args:
            score_type (str): Score type name
        """
    
    def getIdentifier(self) -> str:
        """
        Get identification run identifier.
        
        Returns:
            str: Run identifier
        """
    
    def setIdentifier(self, id: str) -> None:
        """
        Set identification run identifier.
        
        Args:
            id (str): Run identifier
        """
    
    def isHigherScoreBetter(self) -> bool:
        """
        Check if higher score is better.
        
        Returns:
            bool: True if higher score indicates better match
        """
    
    def setHigherScoreBetter(self, higher_better: bool) -> None:
        """
        Set score direction.
        
        Args:
            higher_better (bool): True if higher score is better
        """
    
    def getSignificanceThreshold(self) -> float:
        """
        Get significance threshold.
        
        Returns:
            float: Significance threshold
        """
    
    def setSignificanceThreshold(self, threshold: float) -> None:
        """
        Set significance threshold.
        
        Args:
            threshold (float): Significance threshold
        """

PeptideHit

Individual peptide hit with sequence and score.

class PeptideHit:
    def __init__(self) -> None: ...
    
    def getSequence(self) -> AASequence:
        """
        Get peptide sequence.
        
        Returns:
            AASequence: Peptide sequence with modifications
        """
    
    def setSequence(self, sequence: AASequence) -> None:
        """
        Set peptide sequence.
        
        Args:
            sequence (AASequence): Peptide sequence
        """
    
    def getScore(self) -> float:
        """
        Get peptide score.
        
        Returns:
            float: Search engine score
        """
    
    def setScore(self, score: float) -> None:
        """
        Set peptide score.
        
        Args:
            score (float): Search engine score
        """
    
    def getRank(self) -> int:
        """
        Get peptide rank.
        
        Returns:
            int: Rank among hits (1-based)
        """
    
    def setRank(self, rank: int) -> None:
        """
        Set peptide rank.
        
        Args:
            rank (int): Rank among hits
        """
    
    def getCharge(self) -> int:
        """
        Get peptide charge.
        
        Returns:
            int: Charge state
        """
    
    def setCharge(self, charge: int) -> None:
        """
        Set peptide charge.
        
        Args:
            charge (int): Charge state
        """
    
    def getPeptideEvidences(self) -> list[PeptideEvidence]:
        """
        Get peptide evidences.
        
        Returns:
            list[PeptideEvidence]: List of peptide evidences
        """
    
    def setPeptideEvidences(self, evidences: list[PeptideEvidence]) -> None:
        """
        Set peptide evidences.
        
        Args:
            evidences (list[PeptideEvidence]): Peptide evidences
        """
    
    def addPeptideEvidence(self, evidence: PeptideEvidence) -> None:
        """
        Add peptide evidence.
        
        Args:
            evidence (PeptideEvidence): Peptide evidence to add
        """

class PeptideEvidence:
    def __init__(self) -> None: ...
    
    def getProteinAccession(self) -> str:
        """
        Get protein accession.
        
        Returns:
            str: Protein accession number
        """
    
    def setProteinAccession(self, accession: str) -> None:
        """
        Set protein accession.
        
        Args:
            accession (str): Protein accession number
        """
    
    def getStart(self) -> int:
        """
        Get start position in protein.
        
        Returns:
            int: Start position (0-based)
        """
    
    def setStart(self, start: int) -> None:
        """
        Set start position.
        
        Args:
            start (int): Start position
        """
    
    def getEnd(self) -> int:
        """
        Get end position in protein.
        
        Returns:
            int: End position (0-based)
        """
    
    def setEnd(self, end: int) -> None:
        """
        Set end position.
        
        Args:
            end (int): End position
        """
    
    def getAABefore(self) -> str:
        """
        Get amino acid before peptide.
        
        Returns:
            str: Amino acid before cleavage site
        """
    
    def getAAAfter(self) -> str:
        """
        Get amino acid after peptide.
        
        Returns:
            str: Amino acid after cleavage site
        """

Protein Identification

ProteinIdentification

Protein identification run information and results.

class ProteinIdentification:
    def __init__(self) -> None: ...
    
    def getHits(self) -> list[ProteinHit]:
        """
        Get protein hits.
        
        Returns:
            list[ProteinHit]: List of protein hits
        """
    
    def setHits(self, hits: list[ProteinHit]) -> None:
        """
        Set protein hits.
        
        Args:
            hits (list[ProteinHit]): Protein hits to set
        """
    
    def insertHit(self, hit: ProteinHit) -> None:
        """
        Add protein hit.
        
        Args:
            hit (ProteinHit): Protein hit to add
        """
    
    def getIdentifier(self) -> str:
        """
        Get identification run identifier.
        
        Returns:
            str: Run identifier
        """
    
    def setIdentifier(self, id: str) -> None:
        """
        Set identification run identifier.
        
        Args:
            id (str): Run identifier
        """
    
    def getSearchEngine(self) -> str:
        """
        Get search engine name.
        
        Returns:
            str: Search engine name
        """
    
    def setSearchEngine(self, engine: str) -> None:
        """
        Set search engine name.
        
        Args:
            engine (str): Search engine name
        """
    
    def getSearchEngineVersion(self) -> str:
        """
        Get search engine version.
        
        Returns:
            str: Search engine version
        """
    
    def getSearchParameters(self) -> SearchParameters:
        """
        Get search parameters.
        
        Returns:
            SearchParameters: Search configuration
        """
    
    def setSearchParameters(self, params: SearchParameters) -> None:
        """
        Set search parameters.
        
        Args:
            params (SearchParameters): Search configuration
        """
    
    def getDateTime(self) -> DateTime:
        """
        Get identification date/time.
        
        Returns:
            DateTime: Identification timestamp
        """
    
    def getPrimaryMSRunPath(self, paths: list[str]) -> None:
        """
        Get primary MS run paths.
        
        Args:
            paths (list[str]): List to populate with paths
        """

class ProteinHit:
    def __init__(self) -> None: ...
    
    def getAccession(self) -> str:
        """
        Get protein accession.
        
        Returns:
            str: Protein accession number
        """
    
    def setAccession(self, accession: str) -> None:
        """
        Set protein accession.
        
        Args:
            accession (str): Protein accession number
        """
    
    def getScore(self) -> float:
        """
        Get protein score.
        
        Returns:
            float: Protein score
        """
    
    def setScore(self, score: float) -> None:
        """
        Set protein score.
        
        Args:
            score (float): Protein score
        """
    
    def getRank(self) -> int:
        """
        Get protein rank.
        
        Returns:
            int: Rank among hits (1-based)
        """
    
    def setRank(self, rank: int) -> None:
        """
        Set protein rank.
        
        Args:
            rank (int): Rank among hits
        """
    
    def getSequence(self) -> str:
        """
        Get protein sequence.
        
        Returns:
            str: Full protein sequence
        """
    
    def setSequence(self, sequence: str) -> None:
        """
        Set protein sequence.
        
        Args:
            sequence (str): Full protein sequence
        """
    
    def getDescription(self) -> str:
        """
        Get protein description.
        
        Returns:
            str: Protein description/name
        """
    
    def setDescription(self, description: str) -> None:
        """
        Set protein description.
        
        Args:
            description (str): Protein description
        """
    
    def getCoverage(self) -> float:
        """
        Get sequence coverage.
        
        Returns:
            float: Sequence coverage percentage
        """
    
    def setCoverage(self, coverage: float) -> None:
        """
        Set sequence coverage.
        
        Args:
            coverage (float): Coverage percentage
        """

Database Search Configuration

SearchParameters

Search engine configuration parameters.

class SearchParameters:
    def __init__(self) -> None: ...
    
    def getDatabase(self) -> str:
        """
        Get database filename.
        
        Returns:
            str: Database file path
        """
    
    def setDatabase(self, database: str) -> None:
        """
        Set database filename.
        
        Args:
            database (str): Database file path
        """
    
    def getEnzyme(self) -> str:
        """
        Get enzyme name.
        
        Returns:
            str: Enzyme name
        """
    
    def setEnzyme(self, enzyme: str) -> None:
        """
        Set enzyme name.
        
        Args:
            enzyme (str): Enzyme name
        """
    
    def getMissedCleavages(self) -> int:
        """
        Get allowed missed cleavages.
        
        Returns:
            int: Number of missed cleavages
        """
    
    def setMissedCleavages(self, missed: int) -> None:
        """
        Set allowed missed cleavages.
        
        Args:
            missed (int): Number of missed cleavages
        """
    
    def getPrecursorMassTolerance(self) -> float:
        """
        Get precursor mass tolerance.
        
        Returns:
            float: Mass tolerance value
        """
    
    def setPrecursorMassTolerance(self, tolerance: float) -> None:
        """
        Set precursor mass tolerance.
        
        Args:
            tolerance (float): Mass tolerance value
        """
    
    def getFragmentMassTolerance(self) -> float:
        """
        Get fragment mass tolerance.
        
        Returns:
            float: Mass tolerance value
        """
    
    def setFragmentMassTolerance(self, tolerance: float) -> None:
        """
        Set fragment mass tolerance.
        
        Args:
            tolerance (float): Mass tolerance value
        """
    
    def getVariableModifications(self) -> list[str]:
        """
        Get variable modifications.
        
        Returns:
            list[str]: Variable modification names
        """
    
    def setVariableModifications(self, mods: list[str]) -> None:
        """
        Set variable modifications.
        
        Args:
            mods (list[str]): Variable modification names
        """
    
    def getFixedModifications(self) -> list[str]:
        """
        Get fixed modifications.
        
        Returns:
            list[str]: Fixed modification names
        """
    
    def setFixedModifications(self, mods: list[str]) -> None:
        """
        Set fixed modifications.
        
        Args:
            mods (list[str]): Fixed modification names
        """

Usage Examples

Peptide Sequence Analysis

import pyopenms

# Create peptide sequences
peptide = pyopenms.AASequence.fromString("PEPTIDE")
modified_peptide = pyopenms.AASequence.fromString("PEPTIDEM(Oxidation)K")

# Get sequence properties
print(f"Sequence: {peptide.toString()}")
print(f"Length: {peptide.size()}")
print(f"Monoisotopic weight: {peptide.getMonoWeight():.4f} Da")
print(f"Average weight: {peptide.getAverageWeight():.4f} Da")
print(f"Formula: {peptide.getFormula().toString()}")

# Check modifications
print(f"Is modified: {modified_peptide.isModified()}")
print(f"Modified sequence: {modified_peptide.toString()}")
print(f"Unmodified sequence: {modified_peptide.toUnmodifiedString()}")

# Access individual residues
for i in range(peptide.size()):
    residue = peptide.getResidue(i)
    print(f"Position {i}: {residue.getOneLetterCode()} ({residue.getMonoWeight():.4f} Da)")

Working with Modifications

import pyopenms

# Access modifications database
mod_db = pyopenms.ModificationsDB.getInstance()

# Get specific modification
oxidation = mod_db.getModification("Oxidation")
print(f"Oxidation: {oxidation.getFullName()}")
print(f"Mass delta: {oxidation.getMonoMass():.6f} Da")
print(f"Target residue: {oxidation.getOrigin()}")

# Get all available modifications for methionine
mods = mod_db.getModifications("M", pyopenms.ResidueModification.ANYWHERE)
print(f"Available modifications for methionine: {len(mods)}")
for mod in mods:
    print(f"  {mod.getName()}: {mod.getMonoMass():+.6f} Da")

# Create modified sequence programmatically
seq = pyopenms.AASequence.fromString("METHIONINE")
seq.setModification(0, "Oxidation")  # Oxidize first methionine
print(f"Modified sequence: {seq.toString()}")

Processing Identification Results

import pyopenms

# Load identification results
protein_ids = []
peptide_ids = []
pyopenms.IdXMLFile().load("search_results.idXML", protein_ids, peptide_ids)

print(f"Loaded {len(protein_ids)} protein ID runs")
print(f"Loaded {len(peptide_ids)} peptide identifications")

# Process peptide identifications
high_confidence_hits = []
for pep_id in peptide_ids:
    hits = pep_id.getHits()
    if hits:
        best_hit = hits[0]  # Hits are sorted by score
        if best_hit.getScore() < 0.01:  # E-value < 0.01
            high_confidence_hits.append({
                'sequence': best_hit.getSequence().toString(),
                'score': best_hit.getScore(),
                'charge': best_hit.getCharge(),
                'rt': pep_id.getRT(),
                'mz': pep_id.getMZ()
            })

print(f"High confidence hits: {len(high_confidence_hits)}")

# Show top hits
for i, hit in enumerate(high_confidence_hits[:10]):
    print(f"{i+1}. {hit['sequence']} (score: {hit['score']:.2e}, charge: {hit['charge']})")

Protein Analysis

import pyopenms

# Process protein identifications
protein_ids = []
peptide_ids = []
pyopenms.IdXMLFile().load("search_results.idXML", protein_ids, peptide_ids)

if protein_ids:
    prot_id = protein_ids[0]  # First search run
    protein_hits = prot_id.getHits()
    
    print(f"Search engine: {prot_id.getSearchEngine()}")
    print(f"Database: {prot_id.getSearchParameters().getDatabase()}")
    print(f"Found {len(protein_hits)} protein hits")
    
    # Sort by score and display top proteins
    protein_hits.sort(key=lambda x: x.getScore(), reverse=True)
    
    for i, hit in enumerate(protein_hits[:10]):
        print(f"{i+1}. {hit.getAccession()}")
        print(f"   Score: {hit.getScore():.2f}")
        print(f"   Description: {hit.getDescription()}")
        print(f"   Coverage: {hit.getCoverage():.1f}%")
        print()

Export to Pandas DataFrame

import pyopenms

# Load identifications
protein_ids = []
peptide_ids = []
pyopenms.IdXMLFile().load("search_results.idXML", protein_ids, peptide_ids)

# Convert to DataFrame
df = pyopenms.peptide_identifications_to_df(peptide_ids)

print("Identification DataFrame:")
print(df.columns.tolist())
print(df.head())

# Basic statistics
print(f"\nTotal identifications: {len(df)}")
print(f"Unique sequences: {df['id'].nunique()}")
print(f"Score distribution:")
print(df['score'].describe())

# Filter high confidence identifications
high_conf = df[df['score'] < 0.01]
print(f"High confidence hits: {len(high_conf)}")

Install with Tessl CLI

npx tessl i tessl/pypi-pyopenms

docs

alignment.md

chemistry.md

feature-detection.md

file-io.md

index.md

ms-data.md

peptide-protein.md

targeted-analysis.md

tile.json