goslin

Goslin

Goslin logo: a gosling

Check Grammars Latest tag DOI License: MIT

Goslin, the Grammar of Succinct Lipid Nomenclature, is a set of ANTLR 4 grammars for lipid shorthand names. They cover the updated shorthand nomenclature of Liebisch et al. (2020), the naming styles of LIPID MAPS, SwissLipids and HMDB, systematic fatty acid names and sum formulas. With them come shared tables of lipid classes and functional groups, and the test files that all Goslin implementations run against.

This repository does not parse lipid names by itself. To parse, validate or normalise lipid names, use the web application or one of the implementations below. They all read the grammars and tables from this repository.

Parse lipid names

Implementation Language Get it
Goslin web application (source) Web, REST API use it online
pygoslin Python pip install pygoslin (PyPI)
jgoslin Java, command line org.lifs-tools:jgoslin-parsers and jgoslin-cli (Maven Central)
rgoslin R BiocManager::install("rgoslin") (Bioconductor)
cppgoslin C++ build from source with make
csgoslin C# build from source with dotnet

All implementations normalise a parsed name to the shorthand nomenclature of Liebisch et al. (2020), at the most specific structural level the name supports.

Grammars and data

Grammar Reads Railroad diagram
Shorthand2020.g4 the updated lipid shorthand nomenclature (Liebisch et al. 2020), on all structural levels view
Goslin.g4 Goslin’s dialect of the earlier shorthand notation, with adducts view
GoslinFragments.g4 Goslin names followed by ` - ` and a fragment name view
LipidMaps.g4 LIPID MAPS abbreviations, for example PC(16:0/18:1(9Z)) view
SwissLipids.g4 SwissLipids abbreviations view
HMDB.g4 HMDB lipid names view
FattyAcids.g4 systematic fatty acid names, for example hexadecanoic acid (FA 16:0) view
SumFormula.g4 molecular sum formulas, for example C42H82NO8P view
Systematic.g4 systematic lipid names; experimental, not yet ANTLR 4 compatible (#42) view
Data file Contents
lipid-list.csv the lipid classes: name, category, description, number of fatty acyl chains, head group sum formula and synonyms
functional-groups.csv the functional groups: name, elements, double bonds and synonyms
trivial_mediators.csv trivial names of lipid mediators with their double bond positions, for example 10-HDoHE

How the grammars reach the implementations

The implementations do not use code generated by ANTLR. Each has its own generic parser that reads the .g4 files and the data tables from a copy of this repository, kept as a git subtree:

Implementation Copy of this repository
pygoslin pygoslin/data/goslin
jgoslin parsers/src/main/goslin
cppgoslin data/goslin, compiled into KnownGrammars.h
csgoslin data/goslin
rgoslin src/cppgoslin/data/goslin, through cppgoslin

A change here takes effect in an implementation only after that implementation pulls the subtree and makes a release, and the implementations may lag behind this repository. Releases are made by hand for each implementation. Keeping them in sync is tracked in #57.

Documentation

Contributing

Contributions are welcome. Please follow the LIFS Tools contribution guidelines and the code of conduct.

To change a grammar or a data table:

  1. Open an issue with the names that are not parsed, or are parsed wrongly, and the result you expect. Name the implementation and version you used.
  2. Change the grammar. A new lipid class also goes into lipid-list.csv, a new functional group into functional-groups.csv.
  3. Add test rows to the matching file in testfiles/.
  4. Check the grammars with ./gradlew build (see below).
  5. Run at least one implementation’s test suite against your branch, for example by pulling it into the pygoslin subtree.
  6. Optionally, look at the railroad diagrams of your grammar (see below).
  7. Open a pull request.

Checking the grammars

The grammars are checked with ANTLR 4.13.2 through the Gradle wrapper in this repository. You need a JDK 17 or newer; Gradle itself is downloaded by the wrapper.

./gradlew build

On Windows, use gradlew.bat build. Each grammar listed in build.gradle gets its own task, for example ./gradlew antlr-Shorthand2020.g4 checks only that grammar. The build fails if a grammar has an error, or if a listed grammar file is missing. Add --continue to see the errors of all grammars, not only of the first one. When you add a new grammar, also add it to the list in build.gradle. Systematic.g4 is not in the list yet, as it does not compile with ANTLR 4 (#42).

This only checks that ANTLR accepts the grammars. The implementations read the grammars with their own parsers, so a grammar change should also be tested with at least one implementation’s test suite.

The same check runs on GitHub Actions for every push to master and every pull request. On a push to master, the workflow also publishes the documentation to GitHub Pages.

Test files

testfiles/README.md lists the test files, their format and the implementations that use them.

Railroad diagrams

The railroad diagrams are generated from the grammars by ebnf-convert, which converts a grammar to W3C EBNF, and RR, which draws a diagram for each rule, with its EBNF and the rules that reference it. The diagrams keep the rules and alternatives as written in the grammar. The pages are styled like the implementation and user guide, with the stylesheet docs/railroad-diagrams.css.

./gradlew railroadDiagrams

This writes one page per grammar to docs/grammars/<Grammar>/<Grammar>.html; for a single grammar, run for example ./gradlew railroad-Shorthand2020.g4. The pages are not committed. The workflow generates them for every pull request, where they can be downloaded as the railroad-diagrams artifact of the run, publishes them to GitHub Pages on every push to master, and attaches them as a zip to each published release.

Versions and releases

Versions are git tags of the form vX.Y.Z; see the tags. Up to v2.2.0, each version also has a GitHub release, archived on Zenodo. The implementations have their own version numbers.

Getting help

Citing Goslin

If you use Goslin or one of its implementations in your work, please cite:

If you use the updated shorthand nomenclature or other features of Goslin 2.0 and later, please also cite:

A preprint of the first paper is available on bioRxiv. GitHub’s “Cite this repository” button uses CITATION.cff.

License

The Goslin grammars and data files are licensed under the terms of the MIT license; see LICENSE.