Mercurial > repos > recetox > matchms_remove_spectra
diff matchms_remove_spectra.xml @ 1:c24ebd41dd53 draft
planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/matchms commit 2abca9206b76bf42e6322d751ed3a31a6cc003a4
author | recetox |
---|---|
date | Tue, 04 Jun 2024 07:10:48 +0000 |
parents | 80df426e7e47 |
children | fbe335d27d25 |
line wrap: on
line diff
--- a/matchms_remove_spectra.xml Thu May 30 18:07:29 2024 +0000 +++ b/matchms_remove_spectra.xml Tue Jun 04 07:10:48 2024 +0000 @@ -1,4 +1,4 @@ -<tool id="matchms_remove_spectra" name="matchms remove spectra" version="@TOOL_VERSION@+galaxy0" profile="21.09"> +<tool id="matchms_remove_spectra" name="matchms remove spectra" version="@TOOL_VERSION@+galaxy1" profile="21.09"> <description>Filters spectra based on metadata presence</description> <macros> @@ -28,9 +28,8 @@ require_retention_time, require_retention_index, require_valid_annotation from matchms.importing import load_from_mgf, load_from_msp -#set metadata_fields = str("', '").join([str($f) for $f in $metadata_fields]) -required_metadata = "$metadata_fields" - +#set metadata_fields = [str($f) for $f in $metadata_fields] +required_metadata = [x for x in $metadata_fields] if "$spectra.ext" == "msp": spectra = list(load_from_msp("${spectra}")) elif "$spectra.ext" == 'mgf': @@ -40,57 +39,44 @@ filtered_spectra = [] removed_spectra = [] -keep = False for spectrum in spectra: + keep = True + if 'smiles' in required_metadata: - keep = is_valid_smiles(spectrum.get('smiles')) + keep = keep and is_valid_smiles(spectrum.get('smiles', '').strip()) if 'inchi' in required_metadata: - keep = is_valid_inchi(spectrum.get('inchi')) + keep = keep and is_valid_inchi(spectrum.get('inchi', '').strip()) if 'inchikey' in required_metadata: - keep = is_valid_inchikey(spectrum.get('inchikey')) + inchikey = spectrum.get('inchikey', '') + keep = keep and is_valid_inchikey(inchikey.strip()) if 'precursor_mz' in required_metadata: result = require_precursor_mz(spectrum) - if result is not None: - keep = True - else: - keep = False + keep = keep and result is not None if 'valid_annotation' in required_metadata: result = require_valid_annotation(spectrum) - if result is not None: - keep = True - else: - keep = False - + keep = keep and result is not None + if 'formula' in required_metadata: result = require_formula(spectrum) - if result is not None: - keep = True - else: - keep = False + keep = keep and result is not None if 'compound_name' in required_metadata: result = require_compound_name(spectrum) - if result is not None: - keep = True - else: - keep = False - + keep = keep and result is not None + if 'retention_time' in required_metadata: result = require_retention_time(spectrum) - if result is not None: - keep = True - else: - keep = False + keep = keep and result is not None if 'retention_index' in required_metadata: result = require_retention_index(spectrum) if result is not None: - keep = True + keep = keep and float(result.get('retention_index', 0)) > 0 else: keep = False