Skip to content

Loading MeSH datasets

filak edited this page Feb 10, 2026 · 119 revisions

Before any data loading

Jena assembler config file <MTW_HOME_DIR>/instance/conf/mesh.ttl MUST BE set up properly !

Jena 5 https://github.com/filak/MTW-MeSH/blob/master/flask-app/instance/conf/mesh_Jena5.ttl

Copy the file to <MTW_HOME_DIR>/instance/conf/ and rename it as mesh.ttl

Adjust the paths in mesh.ttl to your <FUSEKI_DATA_DIR>

Use forward slashes

    tdb2:location  "c:/<FUSEKI_DATA_DIR>/databases/mesh" ;

    text:directory "c:/<FUSEKI_DATA_DIR>/indexes/mesh" ;
  • Validate mesh.ttl

No output = file is OK

  riot --validate mesh.ttl
  • Copy the mesh.ttl file to:

    <FUSEKI_DATA_DIR>/configuration/

Get the official MeSH RDF dataset

URL for downloading of the official MeSH RDF datasets: https://nlmpubs.nlm.nih.gov/projects/mesh/rdf/

! IMPORTANT NOTICE !

As of this writing - January 2026 - the master dataset mesh.nt.gz seems outdated

You can follow the steps in this section or just skip it and download the complete MeSH datasets.

Step 1: Get the latest MeSH RDF

Download the https://nlmpubs.nlm.nih.gov/projects/mesh/rdf/2026/mesh2026.nt.gz and

  • update the namespace using MTW script tools/update-ns.py

    py tools/update-ns.py mesh2026.nt.gz http://id.nlm.nih.gov/mesh/2026/ http://id.nlm.nih.gov/mesh/ mesh.nt.gz
    

Step 2: Create the inactive items RDF datasets

Run this script tools/mesh-get-inactive.py to query and download the inactive triples from https://id.nlm.nih.gov/mesh/sparql endpoint:

  • output: mesh_inactive.ttl

     py tools/mesh-get-inactive.py
    

Run this script tools/mesh-extract-deleted.py to extract the inactive triples from your MTW backup and deleted_mh.txt report provided from Bethesda:

  • output: mesh_inactive_new.nt

     py tools/mesh-extract-deleted.py your-mtw-backup.nq.gz deleted_mh.txt
    

Step 3: Merge and gzip the RDF datasets

Move the mesh_inactive.ttl and mesh.nt.gz files into a directory and run:

 riot --output=TTL mesh.nt.gz mesh_inactive.ttl mesh_inactive_new.nt > mesh_complete.ttl | gzip > mesh_complete.ttl.gz

Copy the file mesh_complete.ttl.gz to your <IMPORT> directory

Continue to Import the RDF datasets section.

Get the translation RDF dataset for your language

If you have not translated MeSH before you can proceed to Import.

Convert the official UMLS TSV file

Use the trans_only_YYYY_extended.txt and convert it with the mesh-trx2nt tool.

The file MUST have the following columns/items:

DescriptorUI | ConceptUI | Language | TermType | String | TermUI | ScopeNote | Tree | Created | Relation | ParentCUI	
  • the header row is optional
  • the TermUI column is always empty
  • the Relation and ParentCUI need to be present at rows with Custom Concepts (ConceptUI starts with F...) and TermType PEP only

Display help - open CMD and run:

 mesh-trx2nt -h
usage: mesh-trx2nt inputFile langcode meshxPrefix [options]

Extracting translation dataset from NLM UMLS text file [trans_only_2023_expanded.txt]

positional arguments:
  inputFile    NLM UMLS text file name (plain or gzipped)
  langcode     Language code
  meshxPrefix  MeSH Translation namespace prefix ie. http://my.mesh.com/id/

options:
  -h, --help   show this help message and exit
  --out OUT    Output file name prefix

IMPORTANT

The langcode parameter MUST be the same as the TARGET_LANG value in your mtw.ini config file !

The meshxPrefix parameter MUST be the same as the TARGET_NS value in your mtw.ini config file !

Run the conversion - open CMD and run (just an example):

 mesh-trx2nt trans_only_2023_extended.txt fr http://id.mesh.fr/ 

Import the RDF datasets

  1. ALWAYS validate ALL the input files

    Run the validation:

    No output = dataset is OK

     riot --validate *.gz
    
  2. Move the input files into a versioned <IMPORT> directory ie. .../MeSH-data/2023/import/

  3. Load the MeSH datatset(s) into Apache Jena

    Stop Fuseki server instance (if running)

    Go to your <IMPORT> directory

    Run the import:

     tdb2_tdbloader --loc %FUSEKI_BASE%/databases/mesh mesh.nt.gz mtw-trx_ ...
    

    or if you do not have the translation then just:

     tdb2_tdbloader --loc %FUSEKI_BASE%/databases/mesh mesh.nt.gz
    
  4. Create Fuseki search index

    Run the indexation with Jena v5:

     java --add-modules jdk.incubator.vector -cp %FUSEKI_HOME%/fuseki-server.jar jena.textindexer --desc=%FUSEKI_BASE%/configuration/mesh.ttl
    
  5. Start Fuseki server instance

Load data from a backup

  1. Stop MTW services

  2. Stop your Fuseki instance

  3. Go to your <FUSEKI_DATA_DIR> and make sure the <mesh> directories under datatabases and indexes dirs are empty !

Run the import:

tdb2_tdbloader --loc %FUSEKI_BASE%/databases/mesh %FUSEKI_BASE%/backups/mesh_YYYY-MM-DD_....nq.gz

Create the search index - Jena v5 - run:

java --add-modules jdk.incubator.vector -cp %FUSEKI_HOME%/fuseki-server.jar jena.textindexer --desc=configuration/mesh.ttl
  1. Start your Fuseki instance

  2. Start MTW services

Continue to MeSH Annual Updates

Clone this wiki locally