annotation-coverage-statistics-computation
Summary
Compute per-attribute fill-rate statistics and annotation coverage metrics from MSMetaEnhancer's Logger component output, quantifying the enrichment of metadata fields (SMILES, InChI, CAS number) in .msp mass spectrometry files before and after multi-service annotation.
When to use
You have run MSMetaEnhancer's annotate_spectra() method on a .msp file using multiple converters (CIR, CTS, PubChem, IDSM, BridgeDb, RDKit) and need to measure the effectiveness of the annotation pipeline by tracking which metadata attributes were successfully enriched, how many records gained new values, and what proportion of the dataset now has complete metadata coverage.
When NOT to use
- The .msp file has not yet been processed by annotate_spectra(); you need to run the annotation pipeline first before computing coverage statistics.
- You are interested only in the enriched .msp output file itself, not in quantitative evaluation of annotation effectiveness or metadata completeness.
- The Logger component was not enabled or Logger records were not captured during the annotation run, making fill-rate computation impossible.
Inputs
- .msp file loaded into Application class
- Logger records from annotate_spectra() execution with all converter services active
- Metadata attribute names (SMILES, InChI, CAS number, formula, InChI key, IUPAC name, canonical_smiles)
- Conversion job specifications (source_field, target_field, service_name tuples)
Outputs
- Summary table with per-attribute fill-rate statistics (rows=metadata fields, columns=initial fill rate, final fill rate, absolute gain)
- Per-attribute conversion success/failure event counts
- Structured annotation coverage metrics (count of enriched records per metadata field)
- Data frame or CSV with field-wise coverage analysis
How to apply
After executing the asynchronous annotate_spectra() method with all supported conversion jobs, capture the structured output and failure events from the Logger component for each metadata attribute (SMILES, InChI, CAS number, formula, InChI key, IUPAC name, etc.). Parse Logger records to identify conversion successes and failures, then compute fill-rate statistics: count non-null values per attribute in the original dataset, count non-null values after annotation, and calculate absolute gain (records converted from null to non-null). Generate a summary table with rows for each metadata field and columns for initial fill rate, final fill rate, and absolute gain. This tabular output quantifies the benefit of each converter service and reveals which metadata fields remain sparse despite annotation attempts.
Related tools
- MSMetaEnhancer (Primary tool that executes asynchronous annotation and logs per-attribute conversion events; Logger component produces the structured records parsed to compute coverage statistics) — https://github.com/RECETOX/MSMetaEnhancer
- CIR (Chemical converter service that fetches metadata and contributes to per-service fill-rate statistics)
- CTS (Chemical converter service that fetches metadata and contributes to per-service fill-rate statistics)
- PubChem (Chemical converter service that fetches metadata and contributes to per-service fill-rate statistics)
- IDSM (Chemical converter service that fetches metadata and contributes to per-service fill-rate statistics)
- BridgeDb (Chemical converter service that fetches metadata and contributes to per-service fill-rate statistics)
- RDKit (Local computational converter that derives chemical properties (e.g., SMILES from InChI) and contributes to per-service fill-rate statistics)
- Python (Language in which MSMetaEnhancer is implemented and in which Logger record parsing and fill-rate calculations are performed)
Examples
import asyncio
from MSMetaEnhancer import Application
from MSMetaEnhancer.libs.converters.web import CTS, CIR, IDSM, PubChem, BridgeDb
from MSMetaEnhancer.libs.converters.compute import RDKit
from MSMetaEnhancer.libs.utils.ConverterBuilder import ConverterBuilder
ConverterBuilder.register([CTS, CIR, IDSM, PubChem, BridgeDb, RDKit])
app = Application()
app.load_data('sample.msp', file_format='msp')
services = ['CTS', 'CIR', 'IDSM', 'PubChem', 'BridgeDb', 'RDKit']
jobs = [('name', 'inchi', 'IDSM'), ('inchi', 'formula', 'IDSM')]
asyncio.run(app.annotate_spectra(services, jobs))
# Parse Logger records to compute fill-rate statistics for each metadata attribute
Evaluation signals
- Initial fill rates for each metadata attribute sum to ≤100% (no record can have >1 value per attribute before annotation)
- Final fill rates for each metadata attribute are ≥ initial fill rates (annotation only adds values, never removes them)
- Absolute gain (final count − initial count) is non-negative for all attributes
- Sum of absolute gains across all attributes equals total number of conversion successes logged by the Logger component
- At least one metadata attribute shows final fill rate >initial fill rate, demonstrating that annotation had a measurable effect
Limitations
- Fill-rate statistics depend on Logger component being enabled and fully capturing conversion events; if logging is incomplete or disabled, coverage statistics will be underestimated.
- Some converter services (CIR, CTS, PubChem, IDSM, BridgeDb) are web services subject to network failures, rate limiting, or service unavailability, which may cause conversion attempts to fail silently or partially; coverage metrics reflect actual execution, not theoretical optimal coverage.
- Metadata attributes with null or missing input values (e.g., compounds without InChI keys in the original .msp) cannot be converted by downstream services; initial sparsity limits the theoretical maximum achievable fill rate for dependent fields.
- The skill measures only quantitative coverage (fill rates), not quality or correctness of enriched metadata; high fill rates do not guarantee that the fetched SMILES, InChI, or CAS numbers are accurate or match the parent compound.
Evidence
- [other] MSMetaEnhancer adds metadata including SMILES, InChI, and CAS number to .msp files through asynchronous annotation processing.: "MSMetaEnhancer adds metadata including SMILES, InChI, and CAS number to .msp files through asynchronous annotation processing."
- [other] Capture the structured output from the Logger component during annotation, recording per-attribute conversion success/failure events.: "Capture the structured output from the Logger component during annotation, recording per-attribute conversion success/failure events."
- [other] Parse Logger records to compute fill-rate statistics (count of non-null values per metadata attribute before and after annotation).: "Parse Logger records to compute fill-rate statistics (count of non-null values per metadata attribute before and after annotation)."
- [other] Generate a summary table with rows for each metadata field and columns for initial fill rate, final fill rate, and absolute gain in enriched records.: "Generate a summary table with rows for each metadata field and columns for initial fill rate, final fill rate, and absolute gain in enriched records."
- [readme] It adds metadata like SMILES, InChI, and CAS number fetched from the following services: CIR, CTS, PubChem, IDSM, and BridgeDb: "It adds metadata like SMILES, InChI, and CAS number fetched from the following services: CIR, CTS, PubChem, IDSM, and BridgeDb"
- [readme] The app uses asynchronous implementation of annotation process allowing for optimal fetching speed.: "The app uses asynchronous implementation of annotation process allowing for optimal fetching speed."
1---2name: annotation-coverage-statistics-computation3description: Use when you have run MSMetaEnhancer's annotate_spectra() method on a .4license: CC-BY-4.05---67# annotation-coverage-statistics-computation89## Summary1011Compute per-attribute fill-rate statistics and annotation coverage metrics from MSMetaEnhancer's Logger component output, quantifying the enrichment of metadata fields (SMILES, InChI, CAS number) in .msp mass spectrometry files before and after multi-service annotation.1213## When to use1415You have run MSMetaEnhancer's annotate_spectra() method on a .msp file using multiple converters (CIR, CTS, PubChem, IDSM, BridgeDb, RDKit) and need to measure the effectiveness of the annotation pipeline by tracking which metadata attributes were successfully enriched, how many records gained new values, and what proportion of the dataset now has complete metadata coverage.1617## When NOT to use1819- The .msp file has not yet been processed by annotate_spectra(); you need to run the annotation pipeline first before computing coverage statistics.20- You are interested only in the enriched .msp output file itself, not in quantitative evaluation of annotation effectiveness or metadata completeness.21- The Logger component was not enabled or Logger records were not captured during the annotation run, making fill-rate computation impossible.2223## Inputs2425- .msp file loaded into Application class26- Logger records from annotate_spectra() execution with all converter services active27- Metadata attribute names (SMILES, InChI, CAS number, formula, InChI key, IUPAC name, canonical_smiles)28- Conversion job specifications (source_field, target_field, service_name tuples)2930## Outputs3132- Summary table with per-attribute fill-rate statistics (rows=metadata fields, columns=initial fill rate, final fill rate, absolute gain)33- Per-attribute conversion success/failure event counts34- Structured annotation coverage metrics (count of enriched records per metadata field)35- Data frame or CSV with field-wise coverage analysis3637## How to apply3839After executing the asynchronous annotate_spectra() method with all supported conversion jobs, capture the structured output and failure events from the Logger component for each metadata attribute (SMILES, InChI, CAS number, formula, InChI key, IUPAC name, etc.). Parse Logger records to identify conversion successes and failures, then compute fill-rate statistics: count non-null values per attribute in the original dataset, count non-null values after annotation, and calculate absolute gain (records converted from null to non-null). Generate a summary table with rows for each metadata field and columns for initial fill rate, final fill rate, and absolute gain. This tabular output quantifies the benefit of each converter service and reveals which metadata fields remain sparse despite annotation attempts.4041## Related tools4243- **MSMetaEnhancer** (Primary tool that executes asynchronous annotation and logs per-attribute conversion events; Logger component produces the structured records parsed to compute coverage statistics) — https://github.com/RECETOX/MSMetaEnhancer44- **CIR** (Chemical converter service that fetches metadata and contributes to per-service fill-rate statistics)45- **CTS** (Chemical converter service that fetches metadata and contributes to per-service fill-rate statistics)46- **PubChem** (Chemical converter service that fetches metadata and contributes to per-service fill-rate statistics)47- **IDSM** (Chemical converter service that fetches metadata and contributes to per-service fill-rate statistics)48- **BridgeDb** (Chemical converter service that fetches metadata and contributes to per-service fill-rate statistics)49- **RDKit** (Local computational converter that derives chemical properties (e.g., SMILES from InChI) and contributes to per-service fill-rate statistics)50- **Python** (Language in which MSMetaEnhancer is implemented and in which Logger record parsing and fill-rate calculations are performed)5152## Examples5354```55import asyncio56from MSMetaEnhancer import Application57from MSMetaEnhancer.libs.converters.web import CTS, CIR, IDSM, PubChem, BridgeDb58from MSMetaEnhancer.libs.converters.compute import RDKit59from MSMetaEnhancer.libs.utils.ConverterBuilder import ConverterBuilder6061ConverterBuilder.register([CTS, CIR, IDSM, PubChem, BridgeDb, RDKit])62app = Application()63app.load_data('sample.msp', file_format='msp')64services = ['CTS', 'CIR', 'IDSM', 'PubChem', 'BridgeDb', 'RDKit']65jobs = [('name', 'inchi', 'IDSM'), ('inchi', 'formula', 'IDSM')]66asyncio.run(app.annotate_spectra(services, jobs))67# Parse Logger records to compute fill-rate statistics for each metadata attribute68```6970## Evaluation signals7172- Initial fill rates for each metadata attribute sum to ≤100% (no record can have >1 value per attribute before annotation)73- Final fill rates for each metadata attribute are ≥ initial fill rates (annotation only adds values, never removes them)74- Absolute gain (final count − initial count) is non-negative for all attributes75- Sum of absolute gains across all attributes equals total number of conversion successes logged by the Logger component76- At least one metadata attribute shows final fill rate >initial fill rate, demonstrating that annotation had a measurable effect7778## Limitations7980- Fill-rate statistics depend on Logger component being enabled and fully capturing conversion events; if logging is incomplete or disabled, coverage statistics will be underestimated.81- Some converter services (CIR, CTS, PubChem, IDSM, BridgeDb) are web services subject to network failures, rate limiting, or service unavailability, which may cause conversion attempts to fail silently or partially; coverage metrics reflect actual execution, not theoretical optimal coverage.82- Metadata attributes with null or missing input values (e.g., compounds without InChI keys in the original .msp) cannot be converted by downstream services; initial sparsity limits the theoretical maximum achievable fill rate for dependent fields.83- The skill measures only quantitative coverage (fill rates), not quality or correctness of enriched metadata; high fill rates do not guarantee that the fetched SMILES, InChI, or CAS numbers are accurate or match the parent compound.8485## Evidence8687- [other] MSMetaEnhancer adds metadata including SMILES, InChI, and CAS number to .msp files through asynchronous annotation processing.: "MSMetaEnhancer adds metadata including SMILES, InChI, and CAS number to .msp files through asynchronous annotation processing."88- [other] Capture the structured output from the Logger component during annotation, recording per-attribute conversion success/failure events.: "Capture the structured output from the Logger component during annotation, recording per-attribute conversion success/failure events."89- [other] Parse Logger records to compute fill-rate statistics (count of non-null values per metadata attribute before and after annotation).: "Parse Logger records to compute fill-rate statistics (count of non-null values per metadata attribute before and after annotation)."90- [other] Generate a summary table with rows for each metadata field and columns for initial fill rate, final fill rate, and absolute gain in enriched records.: "Generate a summary table with rows for each metadata field and columns for initial fill rate, final fill rate, and absolute gain in enriched records."91- [readme] It adds metadata like SMILES, InChI, and CAS number fetched from the following services: CIR, CTS, PubChem, IDSM, and BridgeDb: "It adds metadata like SMILES, InChI, and CAS number fetched from the following services: CIR, CTS, PubChem, IDSM, and BridgeDb"92- [readme] The app uses asynchronous implementation of annotation process allowing for optimal fetching speed.: "The app uses asynchronous implementation of annotation process allowing for optimal fetching speed."