From 83ec09a7ac1410486035de9d91f80c5ce2ca7149 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Wed, 15 May 2019 18:46:44 +0200
Subject: [PATCH] new implementation of miriam connector (using identifiers.org
 API)

---
 .../annotation/services/MiriamConnector.java  |  89 +++--
 .../services/MiriamConnectorTest.java         |  19 +-
 .../lcsb/mapviewer/model/map/MiriamType.java  | 355 +++++++++++++-----
 .../V14.0.0.20190514__old_miriam_queries.sql  |   1 +
 4 files changed, 323 insertions(+), 141 deletions(-)
 create mode 100644 persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190514__old_miriam_queries.sql

diff --git a/annotation/src/main/java/lcsb/mapviewer/annotation/services/MiriamConnector.java b/annotation/src/main/java/lcsb/mapviewer/annotation/services/MiriamConnector.java
index c7f2ae3e65..7ee9e02149 100644
--- a/annotation/src/main/java/lcsb/mapviewer/annotation/services/MiriamConnector.java
+++ b/annotation/src/main/java/lcsb/mapviewer/annotation/services/MiriamConnector.java
@@ -1,6 +1,7 @@
 package lcsb.mapviewer.annotation.services;
 
 import java.io.IOException;
+import java.util.Map;
 
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
@@ -9,13 +10,14 @@ import org.springframework.stereotype.Service;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
+import com.google.gson.Gson;
+
 import lcsb.mapviewer.annotation.cache.CachableInterface;
 import lcsb.mapviewer.annotation.cache.GeneralCacheInterface;
 import lcsb.mapviewer.annotation.cache.SourceNotAvailable;
 import lcsb.mapviewer.annotation.cache.WebPageDownloader;
 import lcsb.mapviewer.common.XmlParser;
 import lcsb.mapviewer.common.exception.InvalidArgumentException;
-import lcsb.mapviewer.common.exception.NotImplementedException;
 import lcsb.mapviewer.model.map.MiriamData;
 import lcsb.mapviewer.model.map.MiriamRelationType;
 import lcsb.mapviewer.model.map.MiriamType;
@@ -35,11 +37,6 @@ public final class MiriamConnector extends CachableInterface implements IExterna
    */
   static final String LINK_DB_PREFIX = "Link: ";
 
-  /**
-   * String used to distinguish cached data for checking if uri is valid.
-   */
-  protected static final String VALID_URI_PREFIX = "Validity: ";
-
   /**
    * String describing invalid miriam entries that will be put into db (instead of
    * null).
@@ -79,23 +76,43 @@ public final class MiriamConnector extends CachableInterface implements IExterna
       }
       return result;
     }
-    String uri = miriamData.getDataType().getUris().get(0) + ":" + miriamData.getResource();
-    throw new NotImplementedException();
-//    String[] urls = getLink().getLocations(uri);
-//    if (urls == null) {
-//      result = null;
-//    } else if (urls.length > 0) {
-//      result = urls[0];
-//    }
-//    if (result != null) {
-//      setCacheValue(query, result);
-//      return result;
-//    } else {
-//      logger.warn("Cannot find url for miriam: " + miriamData);
-//      // if url cannot be found then mark miriam data as invalid for one day
-//      setCacheValue(query, INVALID_LINK, 1);
-//      return null;
-//    }
+    String id;
+    if (miriamData.getDataType().getNamespace().isEmpty()) {
+      id = miriamData.getResource();
+    } else {
+      id = miriamData.getDataType().getNamespace() + ":" + miriamData.getResource();
+    }
+
+    query = "https://identifiers.org/rest/identifiers/validate/" + id;
+    String page;
+    try {
+      page = getWebPageContent(query);
+      Gson gson = new Gson();
+      Map<?, ?> map = gson.fromJson(page, Map.class);
+      return (String) map.get("url");
+
+    } catch (Exception e) {
+      throw new AnnotationException("Problem with accessing identifiers.org", e);
+    }
+    // Document document = XmlParser.getXmlDocumentFromString(page);
+    // Node uri = XmlParser.getNode("uri", document.getChildNodes());
+    // return XmlParser.getNodeValue(uri);
+
+    // String[] urls = getLink().getLocations(uri);
+    // if (urls == null) {
+    // result = null;
+    // } else if (urls.length > 0) {
+    // result = urls[0];
+    // }
+    // if (result != null) {
+    // setCacheValue(query, result);
+    // return result;
+    // } else {
+    // logger.warn("Cannot find url for miriam: " + miriamData);
+    // // if url cannot be found then mark miriam data as invalid for one day
+    // setCacheValue(query, INVALID_LINK, 1);
+    // return null;
+    // }
   }
 
   @Override
@@ -151,9 +168,6 @@ public final class MiriamConnector extends CachableInterface implements IExterna
         MiriamType dataType = MiriamType.getTypeByUri(rows[0]);
         String resource = rows[1];
         result = getUrlString(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, dataType, resource));
-      } else if (name.startsWith(VALID_URI_PREFIX)) {
-        String tmp = name.substring(VALID_URI_PREFIX.length());
-        result = "" + isValid(tmp);
       } else if (name.startsWith("http")) {
         try {
           result = getWebPageContent(name);
@@ -171,23 +185,18 @@ public final class MiriamConnector extends CachableInterface implements IExterna
   }
 
   /**
-   * Checks if uri (like the one defined in {@link MiriamType#getUris()}) is valid.
+   * Checks if {@link MiriamType} is valid.
    * 
-   * @param uri
-   *          uri to check
-   * @return <code>true</code> if uri in parameter is valid, <code>false</code>
+   * @param type
+   *          type to be checked
+   * @return <code>true</code> if {@link MiriamType} is valid, <code>false</code>
    *         otherwise
    */
-  public boolean isValid(String uri) {
-    throw new NotImplementedException();
-//    boolean result = false;
-//    String name = getLink().getName(uri);
-//    if (name == null) {
-//      result = false;
-//    } else {
-//      result = !name.isEmpty();
-//    }
-//    return result;
+  public boolean isValidMiriamType(MiriamType type) {
+    if (type.getNamespace() == null || type.getExampleIdentifier() == null) {
+      return false;
+    }
+    return getUrlString(new MiriamData(type, type.getExampleIdentifier())) != null;
   }
 
   /**
diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiriamConnectorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiriamConnectorTest.java
index 0559af7dbf..3e4f83bfc3 100644
--- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiriamConnectorTest.java
+++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/MiriamConnectorTest.java
@@ -136,8 +136,7 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
     try {
       for (MiriamType mt : MiriamType.values()) {
         if (!MiriamType.UNKNOWN.equals(mt)) {
-          String uri = mt.getUris().get(0);
-          assertTrue("Invalid URI (" + uri + ") for MiriamType: " + mt, miriamConnector.isValid(mt.getUris().get(0)));
+          assertTrue("Invalid MiriamType (" + mt + ") for MiriamType: " + mt, miriamConnector.isValidMiriamType(mt));
         }
       }
 
@@ -147,18 +146,6 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
     }
   }
 
-  @Test
-  public void testRefresh() throws Exception {
-    String query = MiriamConnector.VALID_URI_PREFIX + MiriamType.HGNC.getUris().get(0);
-    try {
-      String res = miriamConnector.refreshCacheQuery(query);
-      assertNotNull(res);
-    } catch (Exception e) {
-      e.printStackTrace();
-      throw e;
-    }
-  }
-
   @Test
   public void testRefresh2() throws Exception {
     MiriamData md = TaxonomyBackend.HUMAN_TAXONOMY;
@@ -306,10 +293,10 @@ public class MiriamConnectorTest extends AnnotationTestFunctions {
   }
 
   @Test
-  public void testCheckValidyOfEmptyUri() throws Exception {
+  public void testCheckValidyOfUnknownMiriamType() throws Exception {
     try {
       // user connector without cache
-      boolean value = new MiriamConnector().isValid("");
+      boolean value = miriamConnector.isValidMiriamType(MiriamType.UNKNOWN);
       assertFalse(value);
     } catch (Exception e) {
       e.printStackTrace();
diff --git a/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java b/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java
index 5ffc194171..1aa56f17b4 100644
--- a/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java
+++ b/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java
@@ -26,22 +26,35 @@ public enum MiriamType {
   BiGG_COMPARTMENT("BiGG Compartment",
       "http://bigg.ucsd.edu/compartments/",
       new String[] { "urn:miriam:bigg.compartment" },
-      new Class<?>[] {}, "MIR:00000555"),
+      new Class<?>[] {},
+      "MIR:00000555",
+      new Class<?>[] {},
+      "bigg.compartment",
+      "c"),
 
   BiGG_METABOLITE("BiGG Metabolite",
       "http://bigg.ucsd.edu/universal/metabolites",
       new String[] { "urn:miriam:bigg.metabolite" },
-      new Class<?>[] {}, "MIR:00000556"),
+      new Class<?>[] {}, "MIR:00000556",
+      new Class<?>[] {},
+      "bigg.metabolite",
+      "12dgr161"),
 
   BiGG_REACTIONS("BiGG Reaction",
       "http://bigg.ucsd.edu/universal/reactions",
       new String[] { "urn:miriam:bigg.reaction" },
-      new Class<?>[] {}, "MIR:00000557"),
+      new Class<?>[] {}, "MIR:00000557",
+      new Class<?>[] {},
+      "bigg.reaction",
+      "13GS"),
 
   BIOMODELS_DATABASE("BioModels Database",
       "https://www.ebi.ac.uk/biomodels/",
       new String[] { "urn:miriam:biomodels.db", "http://identifiers.org/biomodels.db/" },
-      new Class<?>[] {}, "MIR:00000007"),
+      new Class<?>[] {}, "MIR:00000007",
+      new Class<?>[] {},
+      "biomodels.db",
+      "BIOMD0000000048"),
 
   /**
    * Brenda enzyme database: http://www.brenda-enzymes.org.
@@ -49,7 +62,10 @@ public enum MiriamType {
   BRENDA("BRENDA",
       "http://www.brenda-enzymes.org",
       new String[] { "urn:miriam:brenda" },
-      new Class<?>[] {}, "MIR:00100101"),
+      new Class<?>[] {}, "MIR:00000071",
+      new Class<?>[] {},
+      "brenda",
+      "1.1.1.1"),
 
   /**
    * Chemical Abstracts Service database: http://commonchemistry.org.
@@ -57,7 +73,10 @@ public enum MiriamType {
   CAS("Chemical Abstracts Service",
       "http://commonchemistry.org",
       new String[] { "urn:miriam:cas" },
-      new Class<?>[] {}, "MIR:00000237"),
+      new Class<?>[] {}, "MIR:00000237",
+      new Class<?>[] {},
+      "cas",
+      "50-00-0"),
 
   /**
    * The Carbohydrate-Active Enzyme (CAZy) database: http://www.cazy.org/.
@@ -65,7 +84,10 @@ public enum MiriamType {
   CAZY("CAZy",
       "http://commonchemistry.org",
       new String[] { "urn:miriam:cazy" },
-      new Class<?>[] {}, "MIR:00000195"),
+      new Class<?>[] {}, "MIR:00000195",
+      new Class<?>[] {},
+      "cazy",
+      "GT10"),
 
   /**
    * Consensus CDS: http://identifiers.org/ccds/.
@@ -73,7 +95,10 @@ public enum MiriamType {
   CCDS("Consensus CDS",
       "http://www.ncbi.nlm.nih.gov/CCDS/",
       new String[] { "urn:miriam:ccds" },
-      new Class<?>[] {}, "MIR:00000375"),
+      new Class<?>[] {}, "MIR:00000375",
+      new Class<?>[] {},
+      "ccds",
+      "CCDS13573.1"),
 
   /**
    * Chebi database:
@@ -84,7 +109,9 @@ public enum MiriamType {
       new String[] { "urn:miriam:obo.chebi", "urn:miriam:chebi",
           "http://identifiers.org/chebi/", "http://identifiers.org/obo.chebi/" },
       new Class<?>[] { Chemical.class, Drug.class, }, "MIR:00000002",
-      new Class<?>[] { Chemical.class }),
+      new Class<?>[] { Chemical.class },
+      "",
+      "CHEBI:36927"),
 
   /**
    * ChemSpider database:
@@ -93,7 +120,10 @@ public enum MiriamType {
   CHEMSPIDER("ChemSpider",
       "http://www.chemspider.com//",
       new String[] { "urn:miriam:chemspider" },
-      new Class<?>[] {}, "MIR:00000138"),
+      new Class<?>[] {}, "MIR:00000138",
+      new Class<?>[] {},
+      "chemspider",
+      "56586"),
 
   /**
    * Chembl database: https://www.ebi.ac.uk/chembldb/.
@@ -101,7 +131,10 @@ public enum MiriamType {
   CHEMBL_COMPOUND("ChEMBL",
       "https://www.ebi.ac.uk/chembldb/",
       new String[] { "urn:miriam:chembl.compound" },
-      new Class<?>[] { Drug.class }, "MIR:00000084"),
+      new Class<?>[] { Drug.class }, "MIR:00000084",
+      new Class<?>[] {},
+      "chembl.compound",
+      "CHEMBL308052"),
 
   /**
    * Target in chembl database: https://www.ebi.ac.uk/chembldb/.
@@ -109,12 +142,18 @@ public enum MiriamType {
   CHEMBL_TARGET("ChEMBL target",
       "https://www.ebi.ac.uk/chembldb/",
       new String[] { "urn:miriam:chembl.target" },
-      new Class<?>[] { Protein.class, Complex.class }, "MIR:00000085"),
+      new Class<?>[] { Protein.class, Complex.class }, "MIR:00000085",
+      new Class<?>[] {},
+      "chembl.target",
+      "CHEMBL3467"),
 
   CLINICAL_TRIALS_GOV("ClinicalTrials.gov",
       "https://clinicaltrials.gov/",
       new String[] { "urn:miriam:clinicaltrials" },
-      new Class<?>[] {}, "MIR:00000137"),
+      new Class<?>[] {}, "MIR:00000137",
+      new Class<?>[] {},
+      "clinicaltrials",
+      "NCT00222573"),
 
   /**
    * Clusters of Orthologous Groups: https://www.ncbi.nlm.nih.gov/COG/.
@@ -122,7 +161,10 @@ public enum MiriamType {
   COG("Clusters of Orthologous Groups",
       "https://www.ncbi.nlm.nih.gov/COG/",
       new String[] { "urn:miriam:cogs" },
-      new Class<?>[] { Reaction.class }, "MIR:00000296"),
+      new Class<?>[] { Reaction.class }, "MIR:00000296",
+      new Class<?>[] {},
+      "cogs",
+      "COG0001"),
 
   /**
    * Digital Object Identifier: http://www.doi.org/.
@@ -130,7 +172,10 @@ public enum MiriamType {
   DOI("Digital Object Identifier",
       "http://www.doi.org/",
       new String[] { "urn:miriam:doi", "http://identifiers.org/doi/" },
-      new Class<?>[] { Reaction.class }, "MIR:00000019"),
+      new Class<?>[] { Reaction.class }, "MIR:00000019",
+      new Class<?>[] {},
+      "doi",
+      "10.1038/nbt1156"),
 
   /**
    * Drugbank database: http://www.drugbank.ca/.
@@ -138,14 +183,21 @@ public enum MiriamType {
   DRUGBANK("DrugBank",
       "http://www.drugbank.ca/",
       new String[] { "urn:miriam:drugbank" },
-      new Class<?>[] { Drug.class }, "MIR:00000102"),
+      new Class<?>[] { Drug.class }, "MIR:00000102",
+      new Class<?>[] {},
+      "drugbank",
+      "DB00001"),
+
   /**
    * Drugbank targets: http://www.drugbank.ca/targets.
    */
   DRUGBANK_TARGET_V4("DrugBank Target v4",
       "http://www.drugbank.ca/targets",
       new String[] { "urn:miriam:drugbankv4.target" },
-      new Class<?>[] {}, "MIR:00000528"),
+      new Class<?>[] {}, "MIR:00000528",
+      new Class<?>[] {},
+      "drugbankv4.target",
+      "BE0000048"),
 
   /**
    * Enzyme Nomenclature: http://www.enzyme-database.org/.
@@ -153,7 +205,10 @@ public enum MiriamType {
   EC("Enzyme Nomenclature",
       "http://www.enzyme-database.org/",
       new String[] { "urn:miriam:ec-code" },
-      new Class<?>[] { Protein.class, Complex.class }, "MIR:00000004"),
+      new Class<?>[] { Protein.class, Complex.class }, "MIR:00000004",
+      new Class<?>[] {},
+      "ec-code",
+      "1.1.1.1"),
 
   /**
    * Ensembl: www.ensembl.org.
@@ -161,7 +216,10 @@ public enum MiriamType {
   ENSEMBL("Ensembl",
       "www.ensembl.org",
       new String[] { "urn:miriam:ensembl", "http://identifiers.org/ensembl/" },
-      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000003"),
+      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000003",
+      new Class<?>[] {},
+      "ensembl",
+      "ENSG00000139618"),
 
   /**
    * Ensembl Plants: http://plants.ensembl.org/.
@@ -169,7 +227,10 @@ public enum MiriamType {
   ENSEMBL_PLANTS("Ensembl Plants",
       "http://plants.ensembl.org/",
       new String[] { "urn:miriam:ensembl.plant" },
-      new Class<?>[] {}, "MIR:00000205"),
+      new Class<?>[] {}, "MIR:00000205",
+      new Class<?>[] {},
+      "ensembl.plant",
+      "AT1G73965"),
 
   /**
    * Entrez Gene: http://www.ncbi.nlm.nih.gov/gene.
@@ -177,7 +238,10 @@ public enum MiriamType {
   ENTREZ("Entrez Gene",
       "http://www.ncbi.nlm.nih.gov/gene",
       new String[] { "urn:miriam:ncbigene", "urn:miriam:entrez.gene" },
-      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000069"),
+      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000069",
+      new Class<?>[] {},
+      "ncbigene",
+      "100010"),
 
   /**
    * Gene Ontology: http://amigo.geneontology.org/amigo.
@@ -186,7 +250,10 @@ public enum MiriamType {
       "http://amigo.geneontology.org/amigo",
       new String[] { "urn:miriam:obo.go", "urn:miriam:go", "http://identifiers.org/go/",
           "http://identifiers.org/obo.go/" },
-      new Class<?>[] { Phenotype.class, Compartment.class, Complex.class }, "MIR:00000022"),
+      new Class<?>[] { Phenotype.class, Compartment.class, Complex.class }, "MIR:00000022",
+      new Class<?>[] {},
+      "",
+      "GO:0006915"),
 
   /**
    * HGNC: http://www.genenames.org.
@@ -195,7 +262,9 @@ public enum MiriamType {
       "http://www.genenames.org",
       new String[] { "urn:miriam:hgnc" },
       new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000080",
-      new Class<?>[] { Protein.class, Gene.class, Rna.class }),
+      new Class<?>[] { Protein.class, Gene.class, Rna.class },
+      "hgnc",
+      "2674"),
 
   /**
    * HGNC symbol: http://www.genenames.org.
@@ -204,7 +273,9 @@ public enum MiriamType {
       "http://www.genenames.org",
       new String[] { "urn:miriam:hgnc.symbol" },
       new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000362",
-      new Class<?>[] { Protein.class, Gene.class, Rna.class }),
+      new Class<?>[] { Protein.class, Gene.class, Rna.class },
+      "hgnc.symbol",
+      "DAPK1"),
 
   /**
    * HMDB: http://www.hmdb.ca/.
@@ -212,7 +283,10 @@ public enum MiriamType {
   HMDB("HMDB",
       "http://www.hmdb.ca/",
       "urn:miriam:hmdb",
-      new Class<?>[] { Chemical.class, Drug.class, }, "MIR:00000051"),
+      new Class<?>[] { Chemical.class, Drug.class, }, "MIR:00000051",
+      new Class<?>[] {},
+      "hmdb",
+      "HMDB00001"),
 
   /**
    * InterPro: http://www.ebi.ac.uk/interpro/.
@@ -220,7 +294,10 @@ public enum MiriamType {
   INTERPRO("InterPro",
       "http://www.ebi.ac.uk/interpro/",
       new String[] { "urn:miriam:interpro", "http://identifiers.org/interpro/" },
-      new Class<?>[] { Protein.class, Complex.class }, "MIR:00000011"),
+      new Class<?>[] { Protein.class, Complex.class }, "MIR:00000011",
+      new Class<?>[] {},
+      "interpro",
+      "IPR000100"),
 
   /**
    * KEGG Compound: http://www.genome.jp/kegg/ligand.html.
@@ -228,15 +305,21 @@ public enum MiriamType {
   KEGG_COMPOUND("Kegg Compound",
       "http://www.genome.jp/kegg/ligand.html",
       new String[] { "urn:miriam:kegg.compound", "http://identifiers.org/kegg.compound/" },
-      new Class<?>[] { Chemical.class }, "MIR:00000013"),
+      new Class<?>[] { Chemical.class }, "MIR:00000013",
+      new Class<?>[] {},
+      "kegg.compound",
+      "C12345"),
 
   /**
    * KEGG Genes: http://www.genome.jp/kegg/genes.html.
    */
   KEGG_GENES("Kegg Genes",
       "http://www.genome.jp/kegg/genes.html",
-      new String[] { "urn:miriam:kegg.genes"},
-      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000070"),
+      new String[] { "urn:miriam:kegg.genes" },
+      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000070",
+      new Class<?>[] {},
+      "kegg.genes",
+      "syn:ssr3451"),
 
   /**
    * KEGG Orthology: http://www.genome.jp/kegg/ko.html.
@@ -244,7 +327,10 @@ public enum MiriamType {
   KEGG_ORTHOLOGY("KEGG Orthology",
       "http://www.genome.jp/kegg/ko.html",
       new String[] { "urn:miriam:kegg.orthology" },
-      new Class<?>[] {}, "MIR:00000116"),
+      new Class<?>[] {}, "MIR:00000116",
+      new Class<?>[] {},
+      "kegg.orthology",
+      "K00001"),
 
   /**
    * KEGG Pathway: http://www.genome.jp/kegg/pathway.html.
@@ -252,7 +338,10 @@ public enum MiriamType {
   KEGG_PATHWAY("Kegg Pathway",
       "http://www.genome.jp/kegg/pathway.html",
       new String[] { "urn:miriam:kegg.pathway", "http://identifiers.org/kegg.pathway/" },
-      new Class<?>[] { Reaction.class }, "MIR:00000012"),
+      new Class<?>[] { Reaction.class }, "MIR:00000012",
+      new Class<?>[] {},
+      "kegg.pathway",
+      "hsa00620"),
 
   /**
    * KEGG Reaction: http://www.genome.jp/kegg/reaction/.
@@ -260,7 +349,10 @@ public enum MiriamType {
   KEGG_REACTION("Kegg Reaction",
       "http://www.genome.jp/kegg/reaction/",
       new String[] { "urn:miriam:kegg.reaction", "http://identifiers.org/kegg.reaction/" },
-      new Class<?>[] { Reaction.class }, "MIR:00000014"),
+      new Class<?>[] { Reaction.class }, "MIR:00000014",
+      new Class<?>[] {},
+      "kegg.reaction",
+      "R00100"),
 
   /**
    * MeSH 2012: http://www.nlm.nih.gov/mesh/.
@@ -268,7 +360,10 @@ public enum MiriamType {
   MESH_2012("MeSH",
       "http://www.nlm.nih.gov/mesh/",
       new String[] { "urn:miriam:mesh" },
-      new Class<?>[] { Phenotype.class, Compartment.class, Complex.class }, "MIR:00000270"),
+      new Class<?>[] { Phenotype.class, Compartment.class, Complex.class }, "MIR:00000560", 
+      new Class<?>[] {},
+      "mesh",
+      "D010300"),
 
   /**
    * miRBase Sequence: http://www.mirbase.org/.
@@ -276,7 +371,10 @@ public enum MiriamType {
   MI_R_BASE_SEQUENCE("miRBase Sequence Database",
       "http://www.mirbase.org/",
       new String[] { "urn:miriam:mirbase" },
-      new Class<?>[] {}, "MIR:00000078"),
+      new Class<?>[] {}, "MIR:00000078",
+      new Class<?>[] {},
+      "mirbase",
+      "MI0000001"),
 
   /**
    * miRBase Mature Sequence: http://www.mirbase.org/.
@@ -284,7 +382,10 @@ public enum MiriamType {
   MI_R_BASE_MATURE_SEQUENCE("miRBase Mature Sequence Database",
       "http://www.mirbase.org/",
       new String[] { "urn:miriam:mirbase.mature" },
-      new Class<?>[] {}, "MIR:00000235"),
+      new Class<?>[] {}, "MIR:00000235",
+      new Class<?>[] {},
+      "mirbase.mature",
+      "MIMAT0000001"),
 
   /**
    * miRTaRBase Mature Sequence: http://mirtarbase.mbc.nctu.edu.tw/.
@@ -292,7 +393,10 @@ public enum MiriamType {
   MIR_TAR_BASE_MATURE_SEQUENCE("miRTarBase Mature Sequence Database",
       "http://mirtarbase.mbc.nctu.edu.tw/",
       new String[] { "urn:miriam:mirtarbase" },
-      new Class<?>[] {}, "MIR:00100739"),
+      new Class<?>[] {}, "MIR:00000562",
+      new Class<?>[] {},
+      "mirtarbase",
+      "MIRT000002"),
 
   /**
    * Mouse Genome Database: http://www.informatics.jax.org/.
@@ -300,12 +404,18 @@ public enum MiriamType {
   MGD("Mouse Genome Database",
       "http://www.informatics.jax.org/",
       new String[] { "urn:miriam:mgd" },
-      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000037"),
+      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000037",
+      new Class<?>[] {},
+      "",
+      "MGI:2442292"),
 
   OBI("Ontology for Biomedical Investigations",
       "https://www.ebi.ac.uk/ols/ontologies/obi/",
       new String[] { "urn:miriam:obi", "http://identifiers.org/obi/" },
-      new Class<?>[] {}, "MIR:00000127"),
+      new Class<?>[] {}, "MIR:00000127",
+      new Class<?>[] {},
+      "obi",
+      "OBI:0000070"),
 
   /**
    * Online Mendelian Inheritance in Man: http://omim.org/.
@@ -313,7 +423,10 @@ public enum MiriamType {
   OMIM("Online Mendelian Inheritance in Man",
       "http://omim.org/",
       new String[] { "urn:miriam:omim", "http://identifiers.org/mim/" },
-      new Class<?>[] { Phenotype.class }, "MIR:00000016"),
+      new Class<?>[] { Phenotype.class }, "MIR:00000016",
+      new Class<?>[] {},
+      "mim",
+      "603903"),
 
   /**
    * PANTHER Family: http://www.pantherdb.org/.
@@ -321,7 +434,10 @@ public enum MiriamType {
   PANTHER("PANTHER Family",
       "http://www.pantherdb.org/",
       new String[] { "urn:miriam:panther.family", "urn:miriam:panther" },
-      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000060"),
+      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000060",
+      new Class<?>[] {},
+      "panther.family",
+      "PTHR12345"),
 
   /**
    * PDB: http://www.pdbe.org/.
@@ -329,7 +445,10 @@ public enum MiriamType {
   PDB("Protein Data Bank",
       "http://www.pdbe.org/",
       "urn:miriam:pdb",
-      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000020"),
+      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000020",
+      new Class<?>[] {},
+      "pdb",
+      "2gc4"),
 
   /**
    * Protein Family Database: http://pfam.xfam.org/.
@@ -337,7 +456,10 @@ public enum MiriamType {
   PFAM("Protein Family Database",
       "http://pfam.xfam.org//",
       "urn:miriam:pfam",
-      new Class<?>[] {}, "MIR:00000028"),
+      new Class<?>[] {}, "MIR:00000028",
+      new Class<?>[] {},
+      "pfam",
+      "PF01234"),
 
   /**
    * PharmGKB Pathways: http://www.pharmgkb.org/.
@@ -345,7 +467,10 @@ public enum MiriamType {
   PHARM("PharmGKB Pathways",
       "http://www.pharmgkb.org/",
       "urn:miriam:pharmgkb.pathways",
-      new Class<?>[] {}, "MIR:00000089"),
+      new Class<?>[] {}, "MIR:00000089",
+      new Class<?>[] {},
+      "pharmgkb.pathways",
+      "PA146123006"),
 
   /**
    * PubChem-compound: http://pubchem.ncbi.nlm.nih.gov/.
@@ -354,7 +479,9 @@ public enum MiriamType {
       "http://pubchem.ncbi.nlm.nih.gov/",
       new String[] { "urn:miriam:pubchem.compound" },
       new Class<?>[] { Chemical.class }, "MIR:00000034",
-      new Class<?>[] { Chemical.class }),
+      new Class<?>[] { Chemical.class },
+      "pubchem.compound",
+      "100101"),
 
   /**
    * PubChem-substance: http://pubchem.ncbi.nlm.nih.gov/.
@@ -363,7 +490,9 @@ public enum MiriamType {
       "http://pubchem.ncbi.nlm.nih.gov/",
       new String[] { "urn:miriam:pubchem.substance" },
       new Class<?>[] { Chemical.class }, "MIR:00000033",
-      new Class<?>[] { Chemical.class }),
+      new Class<?>[] { Chemical.class },
+      "pubchem.substance",
+      "100101"),
 
   /**
    * PubMed: http://www.ncbi.nlm.nih.gov/PubMed/.
@@ -372,7 +501,9 @@ public enum MiriamType {
       "http://www.ncbi.nlm.nih.gov/PubMed/",
       new String[] { "urn:miriam:pubmed", "http://identifiers.org/pubmed/" },
       new Class<?>[] { BioEntity.class }, "MIR:00000015",
-      new Class<?>[] { Reaction.class }),
+      new Class<?>[] { Reaction.class },
+      "pubmed",
+      "28725475"),
 
   /**
    * Reactome: http://www.reactome.org/.
@@ -380,7 +511,10 @@ public enum MiriamType {
   REACTOME("Reactome",
       "http://www.reactome.org/",
       new String[] { "urn:miriam:reactome", "http://identifiers.org/reactome/" },
-      new Class<?>[] { Reaction.class }, "MIR:00000018"),
+      new Class<?>[] { Reaction.class }, "MIR:00000018",
+      new Class<?>[] {},
+      "reactome",
+      "R-HSA-201451"),
 
   /**
    * RefSeq: http://www.ncbi.nlm.nih.gov/projects/RefSeq/.
@@ -388,7 +522,10 @@ public enum MiriamType {
   REFSEQ("RefSeq",
       "http://www.ncbi.nlm.nih.gov/projects/RefSeq/",
       "urn:miriam:refseq",
-      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000039"),
+      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000039",
+      new Class<?>[] {},
+      "refseq",
+      "NP_012345"),
 
   /**
    * Rhea: http://www.rhea-db.org/.
@@ -396,7 +533,10 @@ public enum MiriamType {
   RHEA("Rhea",
       "http://www.rhea-db.org/",
       "urn:miriam:rhea",
-      new Class<?>[] { Reaction.class }, "MIR:00000082"),
+      new Class<?>[] { Reaction.class }, "MIR:00000082",
+      new Class<?>[] {},
+      "rhea",
+      "12345"),
 
   /**
    * SGD: http://www.yeastgenome.org/.
@@ -404,7 +544,10 @@ public enum MiriamType {
   SGD("Saccharomyces Genome Database",
       "http://www.yeastgenome.org/",
       "urn:miriam:sgd",
-      new Class<?>[] {}, "MIR:00000023"),
+      new Class<?>[] {}, "MIR:00000023",
+      new Class<?>[] {},
+      "sgd",
+      "S000003909"),
 
   /**
    * STITCH: http://stitch.embl.de/.
@@ -412,7 +555,10 @@ public enum MiriamType {
   STITCH("STITCH",
       "http://stitch.embl.de/",
       "urn:miriam:stitch",
-      new Class<?>[] {}, "MIR:00100343"),
+      new Class<?>[] {}, "MIR:00000266",
+      new Class<?>[] {},
+      "stitch",
+      "BQJCRHHNABKAKU"),
 
   /**
    * STRING: http://string-db.org/.
@@ -420,7 +566,10 @@ public enum MiriamType {
   STRING("STRING",
       "http://string-db.org/",
       "urn:miriam:string",
-      new Class<?>[] {}, "MIR:00000265"),
+      new Class<?>[] {}, "MIR:00000265",
+      new Class<?>[] {},
+      "string",
+      "P53350"),
 
   /**
    * The Arabidopsis Information Resource (TAIR) maintains a database of genetic
@@ -431,7 +580,10 @@ public enum MiriamType {
   TAIR_LOCUS("TAIR Locus",
       "http://arabidopsis.org/index.jsp",
       "urn:miriam:tair.locus",
-      new Class<?>[] {}, "MIR:00000050"),
+      new Class<?>[] {}, "MIR:00000050",
+      new Class<?>[] {},
+      "tair.locus",
+      "2200950"),
 
   /**
    * Taxonomy: http://www.ncbi.nlm.nih.gov/taxonomy/.
@@ -439,7 +591,10 @@ public enum MiriamType {
   TAXONOMY("Taxonomy",
       "http://www.ncbi.nlm.nih.gov/taxonomy/",
       new String[] { "urn:miriam:taxonomy", "http://identifiers.org/taxonomy/" },
-      new Class<?>[] {}, "MIR:00000006"),
+      new Class<?>[] {}, "MIR:00000006",
+      new Class<?>[] {},
+      "taxonomy",
+      "9606"),
 
   /**
    * Toxicogenomic: Chemical: http://ctdbase.org/detail.go.
@@ -448,7 +603,10 @@ public enum MiriamType {
   TOXICOGENOMIC_CHEMICAL("Toxicogenomic Chemical",
       "http://ctdbase.org/",
       "urn:miriam:ctd.chemical",
-      new Class<?>[] {}, "MIR:00000098"),
+      new Class<?>[] {}, "MIR:00000098",
+      new Class<?>[] {},
+      "ctd.chemical",
+      "D001151"),
 
   /**
    * UniGene: http://www.ncbi.nlm.nih.gov/unigene.
@@ -456,7 +614,10 @@ public enum MiriamType {
   UNIGENE("UniGene",
       "http://www.ncbi.nlm.nih.gov/unigene",
       "urn:miriam:unigene",
-      new Class<?>[] {}, "MIR:00000346"),
+      new Class<?>[] {}, "MIR:00000346",
+      new Class<?>[] {},
+      "unigene",
+      "4900"),
 
   /**
    * Uniprot: http://www.uniprot.org/.
@@ -464,7 +625,10 @@ public enum MiriamType {
   UNIPROT("Uniprot",
       "http://www.uniprot.org/",
       new String[] { "urn:miriam:uniprot", "http://identifiers.org/uniprot/" },
-      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000005"),
+      new Class<?>[] { Protein.class, Gene.class, Rna.class }, "MIR:00000005",
+      new Class<?>[] {},
+      "uniprot",
+      "P0DP23"),
 
   /**
    * UniProt Isoform: http://www.uniprot.org/.
@@ -472,7 +636,10 @@ public enum MiriamType {
   UNIPROT_ISOFORM("UniProt Isoform",
       "http://www.uniprot.org/",
       "urn:miriam:uniprot.isoform",
-      new Class<?>[] { Protein.class }, "MIR:00000388"),
+      new Class<?>[] { Protein.class }, "MIR:00000388",
+      new Class<?>[] {},
+      "uniprot.isoform",
+      "Q5BJF6-3"),
 
   /**
    * Unknown reference type...
@@ -480,7 +647,10 @@ public enum MiriamType {
   UNKNOWN("Unknown",
       null,
       new String[] {},
-      new Class<?>[] {}, null),
+      new Class<?>[] {}, null,
+      new Class<?>[] {},
+      null,
+      null),
 
   /**
    * VMH metabolite: https://vmh.uni.lu/.
@@ -488,7 +658,10 @@ public enum MiriamType {
   VMH_METABOLITE("VMH metabolite",
       "https://vmh.uni.lu/",
       new String[] { "urn:miriam:vmhmetabolite", "http://identifiers.org/vmhmetabolite/" },
-      new Class<?>[] { Chemical.class }, "MIR:00000636"),
+      new Class<?>[] { Chemical.class }, "MIR:00000636",
+      new Class<?>[] {},
+      "vmhmetabolite",
+      "h2o"),
 
   /**
    * VMH reaction: https://vmh.uni.lu/.
@@ -496,7 +669,10 @@ public enum MiriamType {
   VMH_REACTION("VMH reaction",
       "https://vmh.uni.lu/",
       new String[] { "urn:miriam:vmhreaction", "http://identifiers.org/vmhreaction/" },
-      new Class<?>[] { Reaction.class }, "MIR:00000640"),
+      new Class<?>[] { Reaction.class }, "MIR:00000640",
+      new Class<?>[] {},
+      "vmhreaction",
+      "HEX1"),
 
   /**
    * Wikidata: https://www.wikidata.org/.
@@ -504,7 +680,10 @@ public enum MiriamType {
   WIKIDATA("Wikidata",
       "https://www.wikidata.org/",
       new String[] { "urn:miriam:wikidata" },
-      new Class<?>[] {}, "MIR:00000549"),
+      new Class<?>[] {}, "MIR:00000549",
+      new Class<?>[] {},
+      "wikidata",
+      "Q2207226"),
 
   /**
    * WikiPathways: http://www.wikipathways.org/.
@@ -512,7 +691,10 @@ public enum MiriamType {
   WIKIPATHWAYS("WikiPathways",
       "http://www.wikipathways.org/",
       new String[] { "urn:miriam:wikipathways" },
-      new Class<?>[] {}, "MIR:00000076"),
+      new Class<?>[] {}, "MIR:00000076",
+      new Class<?>[] {},
+      "wikipathways",
+      "WP100"),
 
   /**
    * Wikipedia: http://en.wikipedia.org/wiki/Main_Page.
@@ -520,7 +702,10 @@ public enum MiriamType {
   WIKIPEDIA("Wikipedia (English)",
       "http://en.wikipedia.org/wiki/Main_Page", // /
       new String[] { "urn:miriam:wikipedia.en" },
-      new Class<?>[] {}, "MIR:00000384"),
+      new Class<?>[] {}, "MIR:00000384",
+      new Class<?>[] {},
+      "wikipedia.en",
+      "SM_UB-81"),
 
   /**
    * WormBase: http://wormbase.bio2rdf.org/fct.
@@ -528,7 +713,10 @@ public enum MiriamType {
   WORM_BASE("WormBase",
       "http://wormbase.bio2rdf.org/fct", // /
       new String[] { "urn:miriam:wormbase" },
-      new Class<?>[] {}, "MIR:00000027");
+      new Class<?>[] {}, "MIR:00000027",
+      new Class<?>[] {},
+      "wb",
+      "WBGene00000001");
 
   /**
    * User friendly name.
@@ -561,23 +749,9 @@ public enum MiriamType {
    */
   private List<Class<? extends BioEntity>> requiredClass = new ArrayList<>();
 
-  /**
-   * Constructor that initialize enum object.
-   * 
-   * @param dbHomePage
-   *          home page of the resource {@link #dbHomepage}
-   * @param commonName
-   *          {@link #commonName}
-   * @param uris
-   *          {@link #uris}
-   * @param classes
-   *          {@link #validClass}
-   * @param registryIdentifier
-   *          {@link #registryIdentifier}
-   */
-  MiriamType(String commonName, String dbHomePage, String[] uris, Class<?>[] classes, String registryIdentifier) {
-    this(commonName, dbHomePage, uris, classes, registryIdentifier, new Class<?>[] {});
-  }
+  private String namespace;
+
+  private String exampleIdentifier;
 
   /**
    * Constructor that initialize enum object.
@@ -596,7 +770,7 @@ public enum MiriamType {
    *          {@link #requiredClasses}
    */
   MiriamType(String commonName, String dbHomePage, String[] uris, Class<?>[] classes, String registryIdentifier,
-      Class<?>[] requiredClasses) {
+      Class<?>[] requiredClasses, String namespace, String exampleIdentifier) {
     this.commonName = commonName;
     this.dbHomepage = dbHomePage;
     for (String string : uris) {
@@ -609,6 +783,8 @@ public enum MiriamType {
       this.requiredClass.add((Class<? extends BioEntity>) clazz);
     }
     this.registryIdentifier = registryIdentifier;
+    this.namespace = namespace;
+    this.exampleIdentifier = exampleIdentifier;
   }
 
   /**
@@ -625,8 +801,8 @@ public enum MiriamType {
    * @param classes
    *          {@link #validClass}
    */
-  MiriamType(String commonName, String dbHomePage, String uri, Class<?>[] classes, String registryIdentifier) {
-    this(commonName, dbHomePage, new String[] { uri }, classes, registryIdentifier);
+  MiriamType(String commonName, String dbHomePage, String uri, Class<?>[] classes, String registryIdentifier, Class<?>[] requiredClasses, String namespace, String exampleIdentifier) {
+    this(commonName, dbHomePage, new String[] { uri }, classes, registryIdentifier, requiredClasses, namespace, exampleIdentifier);
   }
 
   /**
@@ -780,4 +956,13 @@ public enum MiriamType {
     }
     throw new InvalidArgumentException("Invalid miriam uri: " + miriamUri);
   }
+
+  public String getNamespace() {
+    return namespace;
+  }
+
+  public String getExampleIdentifier() {
+    return exampleIdentifier;
+  }
+
 }
diff --git a/persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190514__old_miriam_queries.sql b/persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190514__old_miriam_queries.sql
new file mode 100644
index 0000000000..6861d29699
--- /dev/null
+++ b/persist/src/main/resources/db/migration/14.0.0~alpha.0/V14.0.0.20190514__old_miriam_queries.sql
@@ -0,0 +1 @@
+delete from cache_query_table where query like 'Validity:%';
\ No newline at end of file
-- 
GitLab