Contents Menu Expand Light mode Dark mode Auto light/dark mode
pyOpenMS 2.8.0 documentation
pyOpenMS 2.8.0 documentation

Introduction

  • Introduction
  • Background

Getting started

  • Installation
  • Import pyopenms
  • Getting help
  • First look at data

Mass Spectrometry Concepts

  • MS Data
  • Chemistry
  • Peptides and Proteins
  • Oligonucleotides: RNA
  • Fragment spectrum generation
  • Spectrum alignment
  • Digestion
  • Identification Data
  • Quantitative Data

OpenMS Algorithms

  • Parameter Handling
  • Algorithms
  • Smoothing
  • Centroiding
  • Spectrum normalization
  • Charge and Isotope Deconvolution
  • Feature Detection
  • Map Alignment
  • Feature Linking
  • Peptide Search
  • Chromagraphic Analysis
  • Quality Control
  • Mass Decomposition

Example Workflows

  • Identification by Accurate Mass

How to contribute

  • Contribute

Advanced Topics

  • Reading Raw MS data
  • Other MS data formats
  • mzML files
  • Export to pandas DataFrame
  • Query MSExperiment with MassQL
  • Memory management
  • pyOpenMS in R
  • Build from source
  • Wrapping Workflow and wrapping new Classes
  • Interactive plots
  • Interfacing with ML libraries

Full API documentation

  • Full API documentation
    • pyopenms
      • pyopenms.free_mem
      • pyopenms.peptide_identifications_to_df
      • AAIndex
      • AASeqWithMass
      • AASequence
      • AMSE_AdductInfo
      • AQS_featureConcentration
      • AQS_runConcentration
      • AScore
      • AbsoluteQuantitation
      • AbsoluteQuantitationMethod
      • AbsoluteQuantitationMethodFile
      • AbsoluteQuantitationStandards
      • AbsoluteQuantitationStandardsFile
      • AccurateMassSearchEngine
      • AccurateMassSearchResult
      • Acquisition
      • AcquisitionInfo
      • ActivationMethod
      • Adduct
      • AggregationMethod
      • AnalysisSummary
      • AnnotationState
      • AnnotationStatistics
      • ArrayWrapperFloat
      • Assay
      • Attachment
      • AverageLinkage
      • BSpline2d
      • Base64
      • BaseFeature
      • BasicProteinInferenceAlgorithm
      • BayesianProteinInferenceAlgorithm
      • BernNorm
      • BiGaussFitter1D
      • BiGaussModel
      • BilinearInterpolation
      • BinnedSpectrum
      • BoundaryCondition
      • BoxElement
      • CV
      • CVMappingFile
      • CVMappingRule
      • CVMappingTerm
      • CVMappings
      • CVReference
      • CVTerm
      • CVTermList
      • CVTermListInterface
      • CVTerm_ControlledVocabulary
      • CachedMzMLHandler
      • CachedSwathFileConsumer
      • CachedmzML
      • CalibrationData
      • ChannelInfo
      • ChargePair
      • ChargedIndexSet
      • ChecksumType
      • ChromatogramExtractor
      • ChromatogramExtractorAlgorithm
      • ChromatogramPeak
      • ChromatogramSettings
      • ChromatogramTools
      • ChromeleonFile
      • ClusterProxyKD
      • ClusteringGrid
      • CoarseIsotopePatternGenerator
      • ColumnHeader
      • CompNovoIdentification
      • CompNovoIdentificationCID
      • CompNovoIonScoring
      • CompNovoIonScoringCID
      • ComplementFilter
      • ComplementMarker
      • Compomer
      • Compound
      • ConfidenceScoring
      • Configuration
      • ConsensusFeature
      • ConsensusIDAlgorithm
      • ConsensusIDAlgorithmAverage
      • ConsensusIDAlgorithmBest
      • ConsensusIDAlgorithmIdentity
      • ConsensusIDAlgorithmPEPIons
      • ConsensusIDAlgorithmPEPMatrix
      • ConsensusIDAlgorithmRanks
      • ConsensusIDAlgorithmSimilarity
      • ConsensusIDAlgorithmWorst
      • ConsensusMap
      • ConsensusMapNormalizerAlgorithmMedian
      • ConsensusMapNormalizerAlgorithmQuantile
      • ConsensusMapNormalizerAlgorithmThreshold
      • ConsensusXMLFile
      • Contact
      • ContactPerson
      • ContinuousWaveletTransform
      • ContinuousWaveletTransformNumIntegration
      • ControlledVocabulary
      • ConvexHull2D
      • CrossLinkSpectrumMatch
      • CrossLinksDB
      • CsiAdapterHit
      • CsiAdapterIdentification
      • CsiAdapterRun
      • CsiFingerIdMzTabWriter
      • CsvFile
      • CubicSpline2d
      • DBoundingBox2
      • DIAScoring
      • DPosition1
      • DPosition2
      • DRange1
      • DRange2
      • DRangeIntersection
      • DTA2DFile
      • DTAFile
      • DataFilter
      • DataFilters
      • DataProcessing
      • DataType
      • DataValue
      • Date
      • DateTime
      • DeNovoIonScore
      • DecoyGenerator
      • DecoyTransitionType
      • Deisotoper
      • DigestSimulation
      • Digestion
      • DigestionEnzyme
      • DigestionEnzymeProtein
      • DigestionEnzymeRNA
      • DimensionDescription
      • DistanceMatrix
      • DocumentIdentifier
      • DriftTimeUnit
      • EDTAFile
      • Element
      • ElementDB
      • ElutionModelFitter
      • ElutionPeakDetection
      • EmgFitter1D
      • EmgGradientDescent
      • EmgModel
      • EmgScoring
      • EmpiricalFormula
      • EnzymaticDigestion
      • EnzymaticDigestionLogModel
      • ExperimentalDesign
      • ExperimentalDesignFile
      • ExperimentalDesign_MSFileSectionEntry
      • ExperimentalDesign_SampleSection
      • ExperimentalSettings
      • ExtractionCoordinates
      • FASTAEntry
      • FASTAFile
      • FIAMSDataProcessor
      • FIAMSScheduler
      • FalseDiscoveryRate
      • Feature
      • FeatureDeconvolution
      • FeatureDistance
      • FeatureFileOptions
      • FeatureFinder
      • FeatureFinderAlgorithmIsotopeWavelet
      • FeatureFinderAlgorithmMetaboIdent
      • FeatureFinderAlgorithmPicked
      • FeatureFinderIdentificationAlgorithm
      • FeatureFinderMetaboIdentCompound
      • FeatureFinderMultiplexAlgorithm
      • FeatureFindingMetabo
      • FeatureGroupingAlgorithm
      • FeatureGroupingAlgorithmKD
      • FeatureGroupingAlgorithmLabeled
      • FeatureGroupingAlgorithmQT
      • FeatureGroupingAlgorithmUnlabeled
      • FeatureHandle
      • FeatureMap
      • FeatureMapping
      • FeatureMapping_FeatureMappingInfo
      • FeatureMapping_FeatureToMs2Indices
      • FeatureXMLFile
      • File
      • FileHandler
      • FileType
      • FileTypes
      • FilterFunctor
      • FineIsotopePatternGenerator
      • Fitter1D
      • FloatDataArray
      • GNPSMGFFile
      • GNPSMetaValueFile
      • GNPSQuantificationFile
      • GaussFilter
      • GaussFitResult
      • GaussFitter
      • GaussTraceFitter
      • GoodDiffFilter
      • Gradient
      • GridBasedCluster
      • HMMState
      • HPLC
      • HiddenMarkovModel
      • HyperScore
      • IBSpectraFile
      • IDConflictResolverAlgorithm
      • IDDecoyProbability
      • IDFilter
      • IDMapper
      • IDMapper_SpectraIdentificationState
      • IDRipper
      • ILPDCWrapper
      • IMFormat
      • IMSAlphabet
      • IMSElement
      • IMSIsotopeDistribution
      • IMSIsotopeDistribution_Peak
      • IMSWeights
      • IMTypes
      • ISDGroup
      • ITRAQ_TYPES
      • IdXMLFile
      • Identification
      • IdentificationData
      • IdentificationDataConverter
      • IdentificationHit
      • IdentificationRuns
      • IncludeExcludeTarget
      • InclusionExclusionList
      • IndexTriple
      • IndexedMzMLDecoder
      • IndexedMzMLFileLoader
      • IndexedMzMLHandler
      • InspectInfile
      • InspectOutfile
      • Instrument
      • InstrumentSettings
      • IntegerDataArray
      • IntensityBalanceFilter
      • Interfaces
      • InternalCalibration
      • InternalCalibration_LockMass
      • Internal_MzMLValidator
      • InterpolationModel
      • IonDetector
      • IonIdentityMolecularNetworking
      • IonOpticsType
      • IonSource
      • IonType
      • IsobaricChannelExtractor
      • IsobaricChannelInformation
      • IsobaricIsotopeCorrector
      • IsobaricNormalizer
      • IsobaricQuantifier
      • IsobaricQuantifierStatistics
      • IsotopeCluster
      • IsotopeDiffFilter
      • IsotopeDistribution
      • IsotopeDistributionCache
      • IsotopeFitter1D
      • IsotopeLabelingMDVs
      • IsotopeMarker
      • IsotopeModel
      • IsotopePattern
      • IsotopeVariant
      • IsotopeWavelet
      • IsotopeWaveletTransform
      • ItraqConstants
      • ItraqEightPlexQuantitationMethod
      • ItraqFourPlexQuantitationMethod
      • JavaInfo
      • KDTreeFeatureMaps
      • KDTreeFeatureNode
      • Kernel_MassTrace
      • KroenikFile
      • LLMParam
      • LPWrapper
      • LabeledPairFinder
      • LibSVMEncoder
      • LightCompound
      • LightMRMTransitionGroupCP
      • LightModification
      • LightProtein
      • LightTargetedExperiment
      • LightTransition
      • LinearInterpolation
      • LinearResampler
      • LinearResamplerAlign
      • LocalLinearMap
      • LogType
      • LowessSmoothing
      • MRMAssay
      • MRMDecoy
      • MRMFP_ComponentGroupParams
      • MRMFP_ComponentParams
      • MRMFQC_ComponentGroupPairQCs
      • MRMFQC_ComponentGroupQCs
      • MRMFQC_ComponentQCs
      • MRMFeature
      • MRMFeatureFilter
      • MRMFeatureFinderScoring
      • MRMFeaturePicker
      • MRMFeaturePickerFile
      • MRMFeatureQC
      • MRMFeatureQCFile
      • MRMFragmentSelection
      • MRMIonSeries
      • MRMMapping
      • MRMRTNormalizer
      • MRMScoring
      • MRMTransitionGroupCP
      • MRMTransitionGroupPicker
      • MS2File
      • MSChromatogram
      • MSDGroup
      • MSDataAggregatingConsumer
      • MSDataCachedConsumer
      • MSDataSqlConsumer
      • MSDataStoringConsumer
      • MSExperiment
      • MSNumpressCoder
      • MSPFile
      • MSPGenericFile
      • MSQuantifications
      • MSSim
      • MSSpectrum
      • MSstatsFile
      • MT_QUANTMETHOD
      • MZTrafoModel
      • MZTrafoModel_MODELTYPE
      • MapAlignmentAlgorithmIdentification
      • MapAlignmentAlgorithmKD
      • MapAlignmentAlgorithmPoseClustering
      • MapAlignmentAlgorithmSpectrumAlignment
      • MapAlignmentEvaluationAlgorithmPrecision
      • MapAlignmentEvaluationAlgorithmRecall
      • MapAlignmentTransformer
      • MapConversion
      • MarkerMower
      • MascotGenericFile
      • MascotInfile
      • MascotXMLFile
      • MassAnalyzer
      • MassDecomposition
      • MassDecompositionAlgorithm
      • MassExplainer
      • MassTrace
      • MassTraceDetection
      • MassTraces
      • MasstraceCorrelator
      • MatrixDouble
      • Measure
      • MetaInfo
      • MetaInfoDescription
      • MetaInfoInterface
      • MetaInfoRegistry
      • MetaboTargetedAssay
      • MetaboTargetedAssay_CompoundTargetDecoyPair
      • MetaboTargetedTargetDecoy
      • MetaboTargetedTargetDecoy_MetaboTargetDecoyMassMapping
      • MetaboliteFeatureDeconvolution
      • MetaboliteSpectralMatching
      • Modification
      • ModificationDefinition
      • ModificationDefinitionsSet
      • ModificationsDB
      • ModifiedPeptideGenerator
      • ModifiedPeptideGenerator_MapToResidueType
      • MorpheusScore
      • MorpheusScore_Result
      • MorphologicalFilter
      • MsInspectFile
      • MultiplexDeltaMasses
      • MultiplexDeltaMassesGenerator
      • MultiplexDeltaMassesGenerator_Label
      • MultiplexDeltaMasses_DeltaMass
      • MultiplexIsotopicPeakPattern
      • MzDataFile
      • MzIdentMLFile
      • MzMLFile
      • MzMLSpectrumDecoder
      • MzMLSqliteHandler
      • MzMLSwathFileConsumer
      • MzQCFile
      • MzQuantMLFile
      • MzTab
      • MzTabFile
      • MzTabM
      • MzTabMFile
      • MzXMLFile
      • NASequence
      • NLargest
      • NeutralLossDiffFilter
      • NeutralLossMarker
      • NoiseEstimator
      • NonNegativeLeastSquaresSolver
      • NoopMSDataWritingConsumer
      • NormalizationMethod
      • Normalizer
      • NumpressConfig
      • OMSSACSVFile
      • OMSSAXMLFile
      • OPXLDataStructs
      • OPXLHelper
      • OPXLSpectrumProcessingAlgorithms
      • OPXL_PreprocessedPairSpectra
      • OSBinaryDataArray
      • OSChromatogram
      • OSChromatogramMeta
      • OSSpectrum
      • OSSpectrumMeta
      • OSWFile
      • OSW_ChromExtractParams
      • OfflinePrecursorIonSelection
      • OnDiscMSExperiment
      • OpenMSBuildInfo
      • OpenMSOSInfo
      • OpenPepXLAlgorithm
      • OpenPepXLLFAlgorithm
      • OpenSwathDataAccessHelper
      • OpenSwathHelper
      • OpenSwathOSWWriter
      • OpenSwathScoring
      • OpenSwath_Scores
      • OpenSwath_Scores_Usage
      • OptimizationFunctions_PenaltyFactors
      • OptimizePeakDeconvolution
      • OptimizePeakDeconvolution_Data
      • OptimizePick
      • OptimizePick_Data
      • OriginAnnotationFormat
      • PI_PeakArea
      • PI_PeakBackground
      • PI_PeakShapeMetrics
      • PSLPFormulation
      • PSProteinInference
      • PScore
      • Param
      • ParamCTDFile
      • ParamEntry
      • ParamNode
      • ParamValue
      • ParamXMLFile
      • ParentPeakMower
      • Peak1D
      • Peak2D
      • PeakBoundary
      • PeakCandidate
      • PeakFileOptions
      • PeakIndex
      • PeakIntegrator
      • PeakIntensityPredictor
      • PeakMap
      • PeakMarker
      • PeakPickerCWT
      • PeakPickerHiRes
      • PeakPickerIterative
      • PeakPickerMRM
      • PeakPickerMaxima
      • PeakPickerSH
      • PeakShape
      • PeakSpectrum
      • PeakTypeEstimator
      • PeakWidthEstimator
      • PenaltyFactorsIntensity
      • PepXMLFile
      • PepXMLFileMascot
      • Peptide
      • PeptideAndProteinQuant
      • PeptideAndProteinQuant_PeptideData
      • PeptideAndProteinQuant_ProteinData
      • PeptideAndProteinQuant_Statistics
      • PeptideEntry
      • PeptideEvidence
      • PeptideHit
      • PeptideHit_AnalysisResult
      • PeptideHit_PeakAnnotation
      • PeptideIdentification
      • PeptideIndexing
      • PeptideProteinResolution
      • PeptideProteinResolution_ConnectedComponent
      • PercolatorFeatureSetHelper
      • PercolatorInfile
      • PercolatorOutfile
      • PlainMSDataWritingConsumer
      • PosteriorErrorProbabilityModel
      • Precursor
      • PrecursorCorrection
      • PrecursorIonSelection
      • PrecursorIonSelectionPreprocessing
      • PrecursorPurity
      • Prediction
      • ProbablePhosphoSites
      • Product
      • ProgressLogger
      • ProtXMLFile
      • ProteaseDB
      • ProteaseDigestion
      • Protein
      • ProteinEntry
      • ProteinGroup
      • ProteinHit
      • ProteinIdentification
      • ProteinInference
      • ProteinProteinCrossLink
      • ProteinResolver
      • ProteinResolverResult_Type
      • ProtonDistributionModel
      • Publication
      • PurityScores
      • QTCluster
      • QTClusterFinder
      • QcMLFile
      • QualityParameter
      • QuantitativeExperimentalDesign
      • QuotingMethod
      • RANSAC
      • RANSACParam
      • RANSACQuadratic
      • RNPxlMarkerIonExtractor
      • RNPxlModificationMassesResult
      • RNPxlModificationsGenerator
      • RNPxlReport
      • RNPxlReportRow
      • RNPxlReportRowHeader
      • RNaseDB
      • RNaseDigestion
      • RansacModelLinear
      • RansacModelQuadratic
      • Ratio
      • ReactionMonitoringTransition
      • RealMassDecomposer
      • RegularSwathFileConsumer
      • Residue
      • ResidueDB
      • ResidueModification
      • ResolverResult
      • RetentionTime
      • Ribonucleotide
      • RibonucleotideDB
      • RichPeak2D
      • RipFileContent
      • RipFileIdentifier
      • SIDE
      • SILACLabeler
      • SVMData
      • SVMPrediction
      • SVMWrapper
      • Sample
      • SavitzkyGolayFilter
      • Scaler
      • ScanMode
      • ScanWindow
      • SearchParameters
      • Seed
      • SeedListGenerator
      • SemanticValidator
      • SemanticValidator_CVTerm
      • SequestInfile
      • SequestOutfile
      • SignalToNoiseEstimatorMeanIterative
      • SignalToNoiseEstimatorMedian
      • SignalToNoiseEstimatorMedianChrom
      • SignalToNoiseEstimatorMedianRapid
      • SimProtein
      • SimRandomNumberGenerator
      • SimpleOpenMSSpectraFactory
      • SimplePairFinder
      • SimplePeak
      • SimpleSVM
      • SimpleSearchEngineAlgorithm
      • SimpleTSGXLMS
      • SiriusAdapterAlgorithm
      • SiriusAdapterHit
      • SiriusAdapterIdentification
      • SiriusAdapterRun
      • SiriusFragmentAnnotation
      • SiriusFragmentAnnotation_SiriusTargetDecoySpectra
      • SiriusMSFile
      • SiriusMSFile_AccessionInfo
      • SiriusMSFile_CompoundInfo
      • SiriusMzTabWriter
      • SiriusMzTabWriter_SiriusSpectrumMSInfo
      • SiriusTemporaryFileSystemObjects
      • Software
      • SolverParam
      • SourceFile
      • SpectraMerger
      • SpectraSTSimilarityScore
      • SpectralMatch
      • SpectrumAccessOpenMS
      • SpectrumAccessOpenMSCached
      • SpectrumAccessOpenMSInMemory
      • SpectrumAccessQuadMZTransforming
      • SpectrumAccessSqMass
      • SpectrumAccessTransforming
      • SpectrumAlignment
      • SpectrumAlignmentScore
      • SpectrumAnnotator
      • SpectrumHelper
      • SpectrumIdentification
      • SpectrumLookup
      • SpectrumMetaData
      • SpectrumMetaDataLookup
      • SpectrumSettings
      • SplineInterpolatedPeaks
      • SplinePackage
      • SplineSpectrum_Navigator
      • SqMassConfig
      • SqMassFile
      • SqrtMower
      • StablePairFinder
      • String
      • StringDataArray
      • StringView
      • SvmModelParameterSet
      • SvmTheoreticalSpectrumGenerator
      • SvmTheoreticalSpectrumGeneratorSet
      • SvmTheoreticalSpectrumGeneratorTrainer
      • SwathFile
      • SwathMap
      • SwathMapMassCorrection
      • SwathWindowLoader
      • SysInfo
      • TICFilter
      • TMTElevenPlexQuantitationMethod
      • TMTSixPlexQuantitationMethod
      • TMTSixteenPlexQuantitationMethod
      • TMTTenPlexQuantitationMethod
      • TM_DataPoint
      • TOFCalibration
      • TSE_Match
      • Tagger
      • Tagging
      • TargetedExperiment
      • TargetedExperiment_Instrument
      • TargetedExperiment_Interpretation
      • TargetedExperiment_Modification
      • TargetedSpectraExtractor
      • TermSpecificityNuc
      • TextFile
      • TheoreticalIsotopePattern
      • TheoreticalSpectrumGenerator
      • TheoreticalSpectrumGeneratorXLMS
      • ThresholdMower
      • ToolInfo
      • TraMLFile
      • TraMLProduct
      • TraceInfo
      • TransformationDescription
      • TransformationModelBSpline
      • TransformationModelInterpolated
      • TransformationModelLinear
      • TransformationModelLowess
      • TransformationStatistics
      • TransformationXMLFile
      • TransitionPQPFile
      • TransitionTSVFile
      • TwoDOptimization
      • UnimodXMLFile
      • UniqueIdGenerator
      • Unit
      • UnitType
      • ValueType
      • VersionDetails
      • VersionInfo
      • WindowMower
      • XFDRAlgorithm
      • XLPrecursor
      • XMLFile
      • XMLHandler
      • XQuestResultXMLFile
      • XQuestScores
      • XRefType_CVTerm_ControlledVocabulary
      • XTandemInfile
      • XTandemXMLFile
      • streampos
    • pyopenms.Constants
    • pyopenms.Plotting
      • pyopenms.Plotting.mirror_plot_spectrum
      • pyopenms.Plotting.plot_chromatogram
      • pyopenms.Plotting.plot_spectrum
      • MSChromatogram
      • MSSpectrum
    • pyopenms.dataframes
      • pyopenms.dataframes.peptide_identifications_to_df
      • ConsensusFeature
      • ConsensusMap
      • ConsensusMapDF
      • ControlledVocabulary
      • Feature
      • FeatureMap
      • FeatureMapDF
      • File
      • IonSource
      • MSExperiment
      • MSExperimentDF
      • PeakMap
      • PeptideIdentification
      • defaultdict
    • pyopenms.python_extras
      • pyopenms.python_extras.peptide_identifications_to_df
      • ConsensusMap
      • FeatureMap
      • MSExperiment
      • PeakMap
      • SimpleOpenMSSpectraFactory

Support

  • Support
  • Frequently Asked Questions
Back to top
Edit this page

Peptide Search#

In MS-based proteomics, fragment ion spectra (MS2 spectra) are often interpreted by comparing them against a theoretical set of spectra generated from a FASTA database. OpenMS contains a (simple) implementation of such a “search engine” that compares experimental spectra against theoretical spectra generated from an enzymatic or chemical digest of a proteome (e.g. tryptic digest).

_images/database_search_illustration.png

SimpleSearch#

In most proteomics applications, a dedicated search engine (such as Comet, Crux, Mascot, MSGFPlus, MSFragger, Myrimatch, OMSSA, SpectraST or XTandem; all of which are supported by pyOpenMS) will be used to search data. Here, we will use the internal SimpleSearchEngineAlgorithm from OpenMS used for teaching purposes. This makes it very easy to search an (experimental) mzML file against a fasta database of protein sequences:

from urllib.request import urlretrieve
from pyopenms import *
gh = "https://raw.githubusercontent.com/OpenMS/pyopenms-docs/master"
urlretrieve (gh +"/src/data/SimpleSearchEngine_1.mzML", "searchfile.mzML")
urlretrieve (gh +"/src/data/SimpleSearchEngine_1.fasta", "search.fasta")
protein_ids = []
peptide_ids = []
SimpleSearchEngineAlgorithm().search("searchfile.mzML", "search.fasta", protein_ids, peptide_ids)

This will print search engine output including the number of peptides and proteins in the database and how many spectra were matched to peptides and proteins:

Peptide statistics

  unmatched                : 0 (0 %)
  target/decoy:
    match to target DB only: 3 (100 %)
    match to decoy DB only : 0 (0 %)
    match to both          : 0 (0 %)

PSM inspection#

We can now investigate the individual hits as we have done before in the Identification tutorial.

for peptide_id in peptide_ids:
  # Peptide identification values
  print (35*"=")
  print ("Peptide ID m/z:", peptide_id.getMZ())
  print ("Peptide ID rt:", peptide_id.getRT())
  print ("Peptide scan index:", peptide_id.getMetaValue("scan_index"))
  print ("Peptide scan name:", peptide_id.getMetaValue("scan_index"))
  print ("Peptide ID score type:", peptide_id.getScoreType())
  # PeptideHits
  for hit in peptide_id.getHits():
    print(" - Peptide hit rank:", hit.getRank())
    print(" - Peptide hit charge:", hit.getCharge())
    print(" - Peptide hit sequence:", hit.getSequence())
    mz = hit.getSequence().getMonoWeight(Residue.ResidueType.Full, hit.getCharge()) / hit.getCharge()
    print(" - Peptide hit monoisotopic m/z:", mz)
    print(" - Peptide ppm error:", abs(mz - peptide_id.getMZ())/mz *10**6 )
    print(" - Peptide hit score:", hit.getScore())

We notice that the second peptide spectrum match (PSM) was found for the third spectrum in the file for a precursor at 775.38 m/z for the sequence RPGADSDIGGFGGLFDLAQAGFR.

tsg = TheoreticalSpectrumGenerator()
thspec = MSSpectrum()
p = Param()
p.setValue("add_metainfo", "true")
tsg.setParameters(p)
peptide = AASequence.fromString("RPGADSDIGGFGGLFDLAQAGFR")
tsg.getSpectrum(thspec, peptide, 1, 1)
# Iterate over annotated ions and their masses
for ion, peak in zip(thspec.getStringDataArrays()[0], thspec):
    print(ion, peak.getMZ())

e = MSExperiment()
MzMLFile().load("searchfile.mzML", e)
print ("Spectrum native id", e[2].getNativeID() )
mz,i = e[2].get_peaks()
peaks = [(mz,i) for mz,i in zip(mz,i) if i > 1500 and mz > 300]
for peak in peaks:
  print (peak[0], "mz", peak[1], "int")

Comparing the theoretical spectrum and the experimental spectrum for RPGADSDIGGFGGLFDLAQAGFR we can easily see that the most abundant ions in the spectrum are y8 (877.452 m/z), b10 (926.432), y9 (1024.522 m/z) and b13 (1187.544 m/z).

Visualization#

When loading the searchfile.mzML into the OpenMS visualization software TOPPView, we can convince ourselves that the observed spectrum indeed was generated by the peptide RPGADSDIGGFGGLFDLAQAGFR by loading the corresponding theoretical spectrum into the viewer using “Tools”->”Generate theoretical spectrum”:

_images/psm.png

From our output above, we notice that the second peptide spectrum match (PSM) at 775.38 m/z for sequence RPGADSDIGGFGGLFDLAQAGFR was found with an error tolerance of 2.25 ppm, therefore if we set the precursor mass tolerance to 4 ppm (+/- 2ppm), we expect that we will not find the hit at 775.38 m/z any more:

salgo = SimpleSearchEngineAlgorithm()
p = salgo.getDefaults()
print ( p.items() )
p[b'precursor:mass_tolerance'] = 4.0
salgo.setParameters(p)

protein_ids = []
peptide_ids = []
salgo.search("searchfile.mzML", "search.fasta", protein_ids, peptide_ids)
print("Found", len(peptide_ids), "peptides")

As we can see, using a smaller precursor mass tolerance leads the algorithm to find only one hit instead of two. Similarly, if we use the wrong enzyme for the digestion (e.g. p[b'enzyme'] = "Formic_acid"), we find no results.

More detailed example#

Now include some additional decoy database generation step as well as subsequent FDR filtering.

from urllib.request import urlretrieve
searchfile = "../../src/data/BSA1.mzML"
searchdb = "../../src/data/18Protein_SoCe_Tr_detergents_trace.fasta"

# generate a protein database with additional decoy sequenes
targets = list()
decoys = list()
FASTAFile().load(searchdb, targets) # read FASTA file into a list of FASTAEntrys
decoy_generator = DecoyGenerator()
for entry in targets:
    rev_entry = FASTAEntry(entry) # copy entry
    rev_entry.identifier = "DECOY_" + rev_entry.identifier # mark as decoy
    aas = AASequence().fromString(rev_entry.sequence) # convert string into amino acid sequence
    rev_entry.sequence = decoy_generator.reverseProtein(aas).toString() # reverse
    decoys.append(rev_entry)

target_decoy_database = "search_td.fasta"
FASTAFile().store(target_decoy_database, targets + decoys) # store the database with appended decoy sequences

# Run SimpleSearchAlgorithm, store protein and peptide ids
protein_ids = []
peptide_ids = []

# set some custom search parameters
simplesearch = SimpleSearchEngineAlgorithm()
params = simplesearch.getDefaults()
score_annot = [b'fragment_mz_error_median_ppm', b'precursor_mz_error_ppm']
params.setValue(b'annotate:PSM', score_annot)
params.setValue(b'peptide:max_size', 30)
simplesearch.setParameters(params)

simplesearch.search(searchfile, target_decoy_database, protein_ids, peptide_ids)

# Annotate q-value
FalseDiscoveryRate().apply(peptide_ids)

# Filter by 1% PSM FDR (q-value < 0.01)
idfilter = IDFilter()
idfilter.filterHitsByScore(peptide_ids, 0.01)
idfilter.removeDecoyHits(peptide_ids)

# store PSM-FDR filtered
IdXMLFile().store("searchfile_results_1perc_FDR.idXML", protein_ids, peptide_ids)

However, usually researchers are interested in the most confidently identified proteins. This so called protein inference problem is a difficult problem because of often occurring shared/ambiguous peptides. To be able to calculate a target/decoy-based FDR on the protein level, we need to assign scores to proteins first (e.g. based on their observed peptides). This is done by applying one of the available protein inference algorithms on the peptide and protein IDs.

protein_ids = []
peptide_ids = []

# Re-run search since we need to keep decoy hits for inference
simplesearch.search(searchfile, target_decoy_database, protein_ids, peptide_ids)

# Run inference
BasicProteinInferenceAlgorithm().run(peptide_ids, protein_ids)

# Annotate q-value on protein level
FalseDiscoveryRate().apply(protein_ids)

# Filter by 1% protein FDR (q-value < 0.01)
idfilter = IDFilter()
idfilter.filterHitsByScore(protein_ids, 0.01)
idfilter.removeDecoyHits(protein_ids)
# Restore valid references into the proteins
remove_peptides_without_reference = True
idfilter.updateProteinReferences(peptide_ids, protein_ids, remove_peptides_without_reference)

# store protein-FDR filtered
IdXMLFile().store("searchfile_results_1perc_protFDR.idXML", protein_ids, peptide_ids)
Next
Chromagraphic Analysis
Previous
Feature Linking
Copyright © 2022, OpenMS Team
Made with Sphinx and @pradyunsg's Furo
Contents
  • Peptide Search
    • SimpleSearch
    • PSM inspection
    • Visualization
    • More detailed example