SMILES Identifier Assignment from Structure Files
Summary
Assigns SMILES (Simplified Molecular Input Line Entry System) identifiers to mass spectral library records by matching molecular structures extracted from SDF files to compound names or InChI keys. This enriches spectral records with canonicalized chemical structure notation required for MS-DIAL compatibility and downstream cheminformatics workflows.
When to use
When you have a mass spectral library (MSP format) that lacks SMILES annotations but is paired with a folder of MOL structure files (from Lib2NIST export or similar source). Apply this skill to populate the SMILES field before combining multi-source EI or MS/MS libraries or preparing libraries for MS-DIAL import.
When NOT to use
- Library records already contain valid SMILES in the SMILES field; skip directly to RI assignment.
- MOL or SDF structure files are missing or corrupt; SMILES extraction will fail or match zero records.
- Compound names in the library differ substantially from reference structure database names; name-based matching will have low recall.
Inputs
- MSP file (mass spectral library in mspcompiler format, read via read_lib())
- MOL folder (structure files exported from Lib2NIST or source database)
- SDF file (single combined structure file generated from MOL folder)
- Structure metadata table (TSV from extract_structure() with name, InChIKey, and SMILES)
Outputs
- Annotated library object with SMILES field populated for all records
- Library ready for RI assignment and MS-DIAL export
How to apply
First, combine all MOL files in the source folder into a single SDF file using combine_mol2sdf(), then extract molecular structures and metadata from that SDF using extract_structure(), producing a lookup table. Next, call assign_smiles() with the library object and the structure table, specifying the matching strategy: use match='name' for Linux/Mac systems or when InChIKey is unavailable (e.g., SWGDRUG), or use match='inchikey' for Windows systems with reliable InChIKey data. The function performs name-based string matching or InChIKey lookup to retrieve SMILES from the structure table and populate the SMILES field in each library record. Validate by checking that the SMILES field is no longer empty and contains valid SMILES strings (alphanumeric with allowed special characters like [, ], @, =, (, )).
Related tools
- mspcompiler (R package providing assign_smiles(), extract_structure(), and combine_mol2sdf() functions for SMILES assignment workflow) — https://github.com/QizhiSu/mspcompiler
- Lib2NIST (Utility to export NIST library as MSP + MOL folder pair; generates source files for SMILES assignment) — https://chemdata.nist.gov/dokuwiki/doku.php?id=chemdata:nist17
- ChemineR (R package for molecular structure I/O and SDF parsing; dependency for extract_structure() and combine_mol2sdf())
- ChemineOB (R wrapper for Open Babel; enables structure file format conversion and name-based compound lookup)
- MS-DIAL (Target software requiring SMILES-annotated MSP files; validates downstream usability of enriched library)
Examples
nist_ei <- assign_smiles(nist_ei, nist_ei_structure, match = "name")
Evaluation signals
- SMILES field is non-empty for ≥95% of library records (check record count before/after and inspect sample records with write_EI_msp() or read_lib() output).
- All assigned SMILES strings conform to standard SMILES grammar (contain only C, H, N, O, S, P, halogens, brackets, bonds, and stereochemistry markers).
- No duplicate SMILES are assigned to distinct compound names; one-to-many matches indicate name collision or structure database ambiguity.
- Downstream RI assignment (assign_ri) and MS-DIAL import complete without errors on the SMILES-enriched library.
- Manual spot-check: verify 5–10 SMILES strings against a canonical tool (e.g., PubChem, ChemSpider) for chemical correctness.
Limitations
- Name-based matching is unreliable when compound nomenclature differs between library and structure source (e.g., IUPAC vs. common name); InChIKey matching is more robust but requires high-quality InChIKey data in source.
- Processing time scales with MOL folder size (hundreds of thousands of files can require hours); parallel computing via future package is strongly recommended.
- MOL folder relocation after initial combine_mol2sdf() call will break the pipeline; users must finalize folder location before processing.
- SWGDRUG and other specialized libraries lack InChIKey annotations; must use match='name', reducing match specificity.
- Zero matches for a compound indicate that its name does not exist in the structure database or SDF was not generated from all MOL files; no SMILES will be assigned for that record.
Evidence
- [methods] Assign SMILES to the library: "Assign SMILES to the library."
- [methods] Extract and reorganize SMILES from structured files: "Extract structure based on the sdf file exported before."
- [readme] Name vs. InChIKey matching strategy for different platforms: "If you are working with Linux-based or Mac OS, please use "match = "inchikey". nist_ei <- assign_smiles(nist_ei, nist_ei_structure, match = "name")"
- [readme] SWGDRUG library constraint on matching method: "As the SWGDRUG file does not contain InChIKey information, even though you are working with Linux-based or Mac OS, you should not use "match = inchikey". "match = "name" is more than enough in this"
- [readme] MOL folder consolidation and structure extraction: "Combine all mol files into a single sdf file for subsequent structure retrieval. Extract structure based on the sdf file exported before."
- [readme] Time and resource requirements for parallel processing: "The whole process is time-consuming (several hours, depending on the capability of your PC), so we suggests to use parallel computing."
1---2name: smiles-identifier-assignment-from-structure-files3description: Use when when you have a mass spectral library (MSP format) that lacks SMILES annotations but is paired with a folder of MOL structure files (from Lib2NIST export or similar source).4license: CC-BY-4.05---67# SMILES Identifier Assignment from Structure Files89## Summary1011Assigns SMILES (Simplified Molecular Input Line Entry System) identifiers to mass spectral library records by matching molecular structures extracted from SDF files to compound names or InChI keys. This enriches spectral records with canonicalized chemical structure notation required for MS-DIAL compatibility and downstream cheminformatics workflows.1213## When to use1415When you have a mass spectral library (MSP format) that lacks SMILES annotations but is paired with a folder of MOL structure files (from Lib2NIST export or similar source). Apply this skill to populate the SMILES field before combining multi-source EI or MS/MS libraries or preparing libraries for MS-DIAL import.1617## When NOT to use1819- Library records already contain valid SMILES in the SMILES field; skip directly to RI assignment.20- MOL or SDF structure files are missing or corrupt; SMILES extraction will fail or match zero records.21- Compound names in the library differ substantially from reference structure database names; name-based matching will have low recall.2223## Inputs2425- MSP file (mass spectral library in mspcompiler format, read via read_lib())26- MOL folder (structure files exported from Lib2NIST or source database)27- SDF file (single combined structure file generated from MOL folder)28- Structure metadata table (TSV from extract_structure() with name, InChIKey, and SMILES)2930## Outputs3132- Annotated library object with SMILES field populated for all records33- Library ready for RI assignment and MS-DIAL export3435## How to apply3637First, combine all MOL files in the source folder into a single SDF file using combine_mol2sdf(), then extract molecular structures and metadata from that SDF using extract_structure(), producing a lookup table. Next, call assign_smiles() with the library object and the structure table, specifying the matching strategy: use match='name' for Linux/Mac systems or when InChIKey is unavailable (e.g., SWGDRUG), or use match='inchikey' for Windows systems with reliable InChIKey data. The function performs name-based string matching or InChIKey lookup to retrieve SMILES from the structure table and populate the SMILES field in each library record. Validate by checking that the SMILES field is no longer empty and contains valid SMILES strings (alphanumeric with allowed special characters like [, ], @, =, (, )).3839## Related tools4041- **mspcompiler** (R package providing assign_smiles(), extract_structure(), and combine_mol2sdf() functions for SMILES assignment workflow) — https://github.com/QizhiSu/mspcompiler42- **Lib2NIST** (Utility to export NIST library as MSP + MOL folder pair; generates source files for SMILES assignment) — https://chemdata.nist.gov/dokuwiki/doku.php?id=chemdata:nist1743- **ChemineR** (R package for molecular structure I/O and SDF parsing; dependency for extract_structure() and combine_mol2sdf())44- **ChemineOB** (R wrapper for Open Babel; enables structure file format conversion and name-based compound lookup)45- **MS-DIAL** (Target software requiring SMILES-annotated MSP files; validates downstream usability of enriched library)4647## Examples4849```50nist_ei <- assign_smiles(nist_ei, nist_ei_structure, match = "name")51```5253## Evaluation signals5455- SMILES field is non-empty for ≥95% of library records (check record count before/after and inspect sample records with write_EI_msp() or read_lib() output).56- All assigned SMILES strings conform to standard SMILES grammar (contain only C, H, N, O, S, P, halogens, brackets, bonds, and stereochemistry markers).57- No duplicate SMILES are assigned to distinct compound names; one-to-many matches indicate name collision or structure database ambiguity.58- Downstream RI assignment (assign_ri) and MS-DIAL import complete without errors on the SMILES-enriched library.59- Manual spot-check: verify 5–10 SMILES strings against a canonical tool (e.g., PubChem, ChemSpider) for chemical correctness.6061## Limitations6263- Name-based matching is unreliable when compound nomenclature differs between library and structure source (e.g., IUPAC vs. common name); InChIKey matching is more robust but requires high-quality InChIKey data in source.64- Processing time scales with MOL folder size (hundreds of thousands of files can require hours); parallel computing via future package is strongly recommended.65- MOL folder relocation after initial combine_mol2sdf() call will break the pipeline; users must finalize folder location before processing.66- SWGDRUG and other specialized libraries lack InChIKey annotations; must use match='name', reducing match specificity.67- Zero matches for a compound indicate that its name does not exist in the structure database or SDF was not generated from all MOL files; no SMILES will be assigned for that record.6869## Evidence7071- [methods] Assign SMILES to the library: "Assign SMILES to the library."72- [methods] Extract and reorganize SMILES from structured files: "Extract structure based on the sdf file exported before."73- [readme] Name vs. InChIKey matching strategy for different platforms: "If you are working with Linux-based or Mac OS, please use "match = "inchikey". nist_ei <- assign_smiles(nist_ei, nist_ei_structure, match = "name")"74- [readme] SWGDRUG library constraint on matching method: "As the SWGDRUG file does not contain InChIKey information, even though you are working with Linux-based or Mac OS, you should not use "match = inchikey". "match = "name" is more than enough in this"75- [readme] MOL folder consolidation and structure extraction: "Combine all mol files into a single sdf file for subsequent structure retrieval. Extract structure based on the sdf file exported before."76- [readme] Time and resource requirements for parallel processing: "The whole process is time-consuming (several hours, depending on the capability of your PC), so we suggests to use parallel computing."