From: kiramt Date: Thu, 26 Jan 2017 11:27:08 +0000 (+0000) Subject: JAL-2316 Updated to use identifiers jalview service X-Git-Tag: Release_2_10_3b1~346^2~7 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=5a94e467b3bc46702d1a5ba4de7808461bb2326f;p=jalview.git JAL-2316 Updated to use identifiers jalview service --- diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 6764430..0dfd0d5 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -184,6 +184,8 @@ import org.apache.log4j.SimpleLayout; *
  • STRUCTURE_DISPLAY choose from JMOL (default) or CHIMERA for 3D structure * display
  • *
  • CHIMERA_PATH specify full path to Chimera program (if non-standard)
  • + *
  • ID_ORG_HOSTURL location of jalview service providing identifiers.org urls + *
  • * * * Deprecated settings: @@ -241,9 +243,7 @@ public class Cache * Identifiers.org download settings */ private static final String ID_ORG_FILE = System.getProperty("user.home") - + File.separatorChar + ".jalview_identifiers"; - - private static final String ID_ORG_URL = "http://identifiers.org/rest/collections/"; + + File.separatorChar + ".identifiers.org.ids.json"; /** * Allowed values are PDB or mmCIF @@ -456,7 +456,7 @@ public class Cache "sifts_cache_threshold_in_days", DEFAULT_CACHE_THRESHOLD_IN_DAYS)); - IdOrgSettings.setUrl(ID_ORG_URL); + IdOrgSettings.setUrl(getProperty("ID_ORG_HOSTURL")); IdOrgSettings.setDownloadLocation(ID_ORG_FILE); System.out diff --git a/src/jalview/urls/IdentifiersUrlProvider.java b/src/jalview/urls/IdentifiersUrlProvider.java index a966b07..c938666 100644 --- a/src/jalview/urls/IdentifiersUrlProvider.java +++ b/src/jalview/urls/IdentifiersUrlProvider.java @@ -52,6 +52,10 @@ import org.json.simple.parser.ParseException; public class IdentifiersUrlProvider extends UrlProviderImpl { + private static final String LOCAL_KEY = "Local"; + + private static final String ID_ORG_KEY = "identifiers.org"; + // map of string ids to urls private HashMap urls; @@ -83,8 +87,24 @@ public class IdentifiersUrlProvider extends UrlProviderImpl try { FileReader reader = new FileReader(idFileName); + String key = ""; + JSONObject obj = (JSONObject) parser.parse(reader); + if (obj.containsKey(ID_ORG_KEY)) + { + key = ID_ORG_KEY; + } + else if (obj.containsKey(LOCAL_KEY)) + { + key = LOCAL_KEY; + } + else + { + System.out + .println("Unexpected key returned from identifiers jalview service"); + return idData; + } - JSONArray jsonarray = (JSONArray) parser.parse(reader); + JSONArray jsonarray = (JSONArray) obj.get(key); // loop over each entry in JSON array and build HashMap entry for (int i = 0; i < jsonarray.size(); i++) @@ -100,12 +120,15 @@ public class IdentifiersUrlProvider extends UrlProviderImpl } catch (FileNotFoundException e) { e.printStackTrace(); + idData.clear(); } catch (IOException e) { e.printStackTrace(); + idData.clear(); } catch (ParseException e) { e.printStackTrace(); + idData.clear(); } return idData; } diff --git a/test/jalview/urls/DesktopUrlProviderFactoryTest.java b/test/jalview/urls/DesktopUrlProviderFactoryTest.java index 5610ca3..cc55034 100644 --- a/test/jalview/urls/DesktopUrlProviderFactoryTest.java +++ b/test/jalview/urls/DesktopUrlProviderFactoryTest.java @@ -35,8 +35,7 @@ import org.testng.annotations.Test; public class DesktopUrlProviderFactoryTest { - // Test identifiers.org download file - private static final String testIdOrgString = "[{\"id\":\"MIR:00000002\",\"name\":\"ChEBI\",\"pattern\":\"^CHEBI:\\d+$\"," + private static final String testIdOrgString = "{\"Local\": [{\"id\":\"MIR:00000002\",\"name\":\"ChEBI\",\"pattern\":\"^CHEBI:\\d+$\"," + "\"definition\":\"Chemical Entities of Biological Interest (ChEBI)\",\"prefix\":\"chebi\"," + "\"url\":\"http://identifiers.org/chebi\"},{\"id\":\"MIR:00000005\",\"name\":\"UniProt Knowledgebase\"," + "\"pattern\":\"^([A-N,R-Z][0-9]([A-Z][A-Z, 0-9][A-Z, 0-9][0-9]){1,2})|([O,P,Q][0-9][A-Z, 0-9][A-Z, 0-9][A-Z, 0-9][0-9])(\\.\\d+)?$\"," @@ -44,7 +43,7 @@ public class DesktopUrlProviderFactoryTest + "{\"id\":\"MIR:00000011\",\"name\":\"InterPro\",\"pattern\":\"^IPR\\d{6}$\",\"definition\":\"InterPro\",\"prefix\":\"interpro\"," + "\"url\":\"http://identifiers.org/interpro\"}," + "{\"id\":\"MIR:00000372\",\"name\":\"ENA\",\"pattern\":\"^[A-Z]+[0-9]+(\\.\\d+)?$\",\"definition\":\"The European Nucleotide Archive (ENA),\"" - + "\"prefix\":\"ena.embl\",\"url\":\"http://identifiers.org/ena.embl\"}]"; + + "\"prefix\":\"ena.embl\",\"url\":\"http://identifiers.org/ena.embl\"}]}"; @BeforeMethod(alwaysRun = true) public void setup() diff --git a/test/jalview/urls/IdentifiersUrlProviderTest.java b/test/jalview/urls/IdentifiersUrlProviderTest.java index 9c8c96a..eed58b0 100644 --- a/test/jalview/urls/IdentifiersUrlProviderTest.java +++ b/test/jalview/urls/IdentifiersUrlProviderTest.java @@ -38,8 +38,7 @@ import org.testng.annotations.Test; public class IdentifiersUrlProviderTest { - // Test identifiers.org download file - private static final String testIdOrgFile = "[{\"id\":\"MIR:00000002\",\"name\":\"ChEBI\",\"pattern\":\"^CHEBI:\\d+$\"," + private static final String testIdOrgFile = "{\"Local\": [{\"id\":\"MIR:00000002\",\"name\":\"ChEBI\",\"pattern\":\"^CHEBI:\\d+$\"," + "\"definition\":\"Chemical Entities of Biological Interest (ChEBI)\",\"prefix\":\"chebi\"," + "\"url\":\"http://identifiers.org/chebi\"},{\"id\":\"MIR:00000005\",\"name\":\"UniProt Knowledgebase\"," + "\"pattern\":\"^([A-N,R-Z][0-9]([A-Z][A-Z, 0-9][A-Z, 0-9][0-9]){1,2})|([O,P,Q][0-9][A-Z, 0-9][A-Z, 0-9][A-Z, 0-9][0-9])(\\.\\d+)?$\"," @@ -47,7 +46,7 @@ public class IdentifiersUrlProviderTest + "{\"id\":\"MIR:00000011\",\"name\":\"InterPro\",\"pattern\":\"^IPR\\d{6}$\",\"definition\":\"InterPro\",\"prefix\":\"interpro\"," + "\"url\":\"http://identifiers.org/interpro\"}," + "{\"id\":\"MIR:00000372\",\"name\":\"ENA\",\"pattern\":\"^[A-Z]+[0-9]+(\\.\\d+)?$\",\"definition\":\"The European Nucleotide Archive (ENA),\"" - + "\"prefix\":\"ena.embl\",\"url\":\"http://identifiers.org/ena.embl\"}]"; + + "\"prefix\":\"ena.embl\",\"url\":\"http://identifiers.org/ena.embl\"}]}"; private static final String[] dlinks = { "UniProt Knowledgebase|http://identifiers.org/uniprot/$DB_ACCESSION$|uniprot", diff --git a/test/jalview/urls/UrlLinkTableModelTest.java b/test/jalview/urls/UrlLinkTableModelTest.java index 4b2ea6e..ab190ef 100644 --- a/test/jalview/urls/UrlLinkTableModelTest.java +++ b/test/jalview/urls/UrlLinkTableModelTest.java @@ -52,8 +52,7 @@ public class UrlLinkTableModelTest { private static final String notinmenu = "Not1|http://not.in.menu/$DB_ACCESSION$|" + "Not2|http://not.in.menu.either/$DB_ACCESSION$"; - // Test identifiers.org download file - private static final String testIdOrgString = "[{\"id\":\"MIR:00000002\",\"name\":\"ChEBI\",\"pattern\":\"^CHEBI:\\d+$\"," + private static final String testIdOrgString = "{\"Local\": [{\"id\":\"MIR:00000002\",\"name\":\"ChEBI\",\"pattern\":\"^CHEBI:\\d+$\"," + "\"definition\":\"Chemical Entities of Biological Interest (ChEBI)\",\"prefix\":\"chebi\"," + "\"url\":\"http://identifiers.org/chebi\"},{\"id\":\"MIR:00000005\",\"name\":\"UniProt Knowledgebase\"," + "\"pattern\":\"^([A-N,R-Z][0-9]([A-Z][A-Z, 0-9][A-Z, 0-9][0-9]){1,2})|([O,P,Q][0-9][A-Z, 0-9][A-Z, 0-9][A-Z, 0-9][0-9])(\\.\\d+)?$\"," @@ -61,7 +60,7 @@ public class UrlLinkTableModelTest { + "{\"id\":\"MIR:00000011\",\"name\":\"InterPro\",\"pattern\":\"^IPR\\d{6}$\",\"definition\":\"InterPro\",\"prefix\":\"interpro\"," + "\"url\":\"http://identifiers.org/interpro\"}," + "{\"id\":\"MIR:00000372\",\"name\":\"ENA\",\"pattern\":\"^[A-Z]+[0-9]+(\\.\\d+)?$\",\"definition\":\"The European Nucleotide Archive (ENA),\"" - + "\"prefix\":\"ena.embl\",\"url\":\"http://identifiers.org/ena.embl\"}]"; + + "\"prefix\":\"ena.embl\",\"url\":\"http://identifiers.org/ena.embl\"}]}"; private UrlProviderI prov; diff --git a/test/jalview/urls/UrlProviderTest.java b/test/jalview/urls/UrlProviderTest.java index 29327d7..460ebe9 100644 --- a/test/jalview/urls/UrlProviderTest.java +++ b/test/jalview/urls/UrlProviderTest.java @@ -18,7 +18,7 @@ import org.testng.annotations.Test; public class UrlProviderTest { // Test identifiers.org download file - private static final String testIdOrgString = "[{\"id\":\"MIR:00000002\",\"name\":\"ChEBI\",\"pattern\":\"^CHEBI:\\d+$\"," + private static final String testIdOrgString = "{\"Local\": [{\"id\":\"MIR:00000002\",\"name\":\"ChEBI\",\"pattern\":\"^CHEBI:\\d+$\"," + "\"definition\":\"Chemical Entities of Biological Interest (ChEBI)\",\"prefix\":\"chebi\"," + "\"url\":\"http://identifiers.org/chebi\"},{\"id\":\"MIR:00000005\",\"name\":\"UniProt Knowledgebase\"," + "\"pattern\":\"^([A-N,R-Z][0-9]([A-Z][A-Z, 0-9][A-Z, 0-9][0-9]){1,2})|([O,P,Q][0-9][A-Z, 0-9][A-Z, 0-9][A-Z, 0-9][0-9])(\\.\\d+)?$\"," @@ -26,7 +26,7 @@ public class UrlProviderTest { + "{\"id\":\"MIR:00000011\",\"name\":\"InterPro\",\"pattern\":\"^IPR\\d{6}$\",\"definition\":\"InterPro\",\"prefix\":\"interpro\"," + "\"url\":\"http://identifiers.org/interpro\"}," + "{\"id\":\"MIR:00000372\",\"name\":\"ENA\",\"pattern\":\"^[A-Z]+[0-9]+(\\.\\d+)?$\",\"definition\":\"The European Nucleotide Archive (ENA),\"" - + "\"prefix\":\"ena.embl\",\"url\":\"http://identifiers.org/ena.embl\"}]"; + + "\"prefix\":\"ena.embl\",\"url\":\"http://identifiers.org/ena.embl\"}]}"; private UrlProviderI prov;