Export Files for GNPS ===================== With pyOpenMS you can automatically generate all files needed for GNPS Feature-Based Molecular Networking (FBMN) and Ion Identity Molecular Networking (IIMN). Pre-requisites are your input :term:`mzML` files and a :py:class:`~.ConsensusMap`, generated by an `untargeted metabolomics pre-processing workflow `_. Ensure that :term:`MS2` data has been mapped to the :py:class:`~.FeatureMap` objects with :py:class:`~.IDMapper`. For IIMN adduct detection must have been performed on the :py:class:`~.FeatureMap` objects during pre-processing with :py:class:`~.MetaboliteFeatureDeconvolution`. First, download two example :term:`mzML` files that have been map aligned based on a :term:`feature map` alignment. .. code-block:: python from urllib.request import urlretrieve gh = "https://raw.githubusercontent.com/OpenMS/pyopenms-docs/master" urlretrieve( gh + "/src/data/Metabolomics_1_aligned.mzML", "Metabolomics_1_aligned.mzML" ) urlretrieve( gh + "/src/data/Metabolomics_2_aligned.mzML", "Metabolomics_2_aligned.mzML" ) urlretrieve( gh + "/src/data/UntargetedMetabolomics.consensusXML", "UntargetedMetabolomics.consensusXML", ) .. code-block:: python import pyopenms as oms mzML_files = ["Metabolomics_1_aligned.mzML", "Metabolomics_2_aligned.mzML"] consensusXML_file = "UntargetedMetabolomics.consensusXML" Since GNPS only works with features that contain :term:`MS2` fragmentation spectra, the first step is to filter out features from your :py:class:`~.ConsensusMap` that have no :term:`MS2` spectra annotated. .. code-block:: python consensus_map = oms.ConsensusMap() oms.ConsensusXMLFile().load(consensusXML_file, consensus_map) filtered_map = oms.ConsensusMap(consensus_map) filtered_map.clear(False) for feature in consensus_map: if feature.getPeptideIdentifications(): filtered_map.push_back(feature) consensusXML_file = "filtered.consensusXML" oms.ConsensusXMLFile().store(consensusXML_file, filtered_map) Now you can export your all files for FBMN and IIMN. .. code-block:: python # for FFBM oms.GNPSMGFFile().store( oms.String(consensusXML_file), [file.encode() for file in mzML_files], oms.String("MS2data.mgf"), ) oms.GNPSQuantificationFile().store(consensus_map, "FeatureQuantificationTable.txt") oms.GNPSMetaValueFile().store(consensus_map, "MetaValueTable.tsv") # for IIMN oms.IonIdentityMolecularNetworking().annotateConsensusMap(consensus_map) oms.IonIdentityMolecularNetworking().writeSupplementaryPairTable( consensus_map, "SupplementaryPairTable.csv" )