From: Jim Procter Date: Mon, 23 Jul 2018 07:56:57 +0000 (+0100) Subject: Merge branch 'features/mchmmer' into merge/wsinterfaces_mchmmer_JAL-3070_JAL-1950 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7692386ccfe778075dd83a753d30a7a27fe507be;hp=e0fd9965a1ffacf4ac034a79e7cb5f7e898ff69f;p=jalview.git Merge branch 'features/mchmmer' into merge/wsinterfaces_mchmmer_JAL-3070_JAL-1950 merging refactored wsui with mchmmer to get latest service parameters goodness. --- diff --git a/.classpath b/.classpath index 0cdc4b9..d32799b 100644 --- a/.classpath +++ b/.classpath @@ -36,7 +36,6 @@ - diff --git a/.gitignore b/.gitignore index 2a55560..86637df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ .project /dist +/clover /classes /tests /test-reports @@ -12,4 +13,4 @@ TESTNG /jalviewApplet.jar /benchmarking/lib -*.class \ No newline at end of file +*.class diff --git a/RELEASE b/RELEASE index c61d86c..1960368 100644 --- a/RELEASE +++ b/RELEASE @@ -1,2 +1,2 @@ -jalview.release=releases/Release_2_10_4_Branch -jalview.version=2.10.4b1 +jalview.release=releases/Release_2_11_Branch +jalview.version=2.11.0 diff --git a/THIRDPARTYLIBS b/THIRDPARTYLIBS index d0d9125..a0b8d94 100644 --- a/THIRDPARTYLIBS +++ b/THIRDPARTYLIBS @@ -30,7 +30,6 @@ httpclient-4.0.3.jar httpcore-4.0.1.jar httpmime-4.0.3.jar jaxrpc.jar -jdas-1.0.4.jar : Apache License - built from http://code.google.com/p/jdas/ (29th Feb 2012) jhall.jar jswingreader-0.3.jar : Apache license - built from http://jswingreader.sourceforge.net/ svn/trunk v12 log4j-1.2.8.jar @@ -39,8 +38,8 @@ miglayout-4.0-swing.jar BSD http://www.migcalendar.com/miglayout/versions/4.0/li min-jaba-client.jar regex.jar saaj.jar -spring-core-3.0.5.RELEASE.jar : Apache License: jdas runtime dependencies retrieved via maven -spring-web-3.0.5.RELEASE.jar : Apache License: jdas runtime dependencies retrieved via maven +spring-core-3.0.5.RELEASE.jar : Apache License: jdas runtime dependencies retrieved via maven - TODO: JAL-3035 remove if no longer needed ? +spring-web-3.0.5.RELEASE.jar : Apache License: jdas runtime dependencies retrieved via maven - TODO: JAL-3035 remove if no longer needed ? vamsas-client.jar wsdl4j.jar xercesImpl.jar diff --git a/build.xml b/build.xml index d826d83..7ae41f6 100755 --- a/build.xml +++ b/build.xml @@ -20,6 +20,9 @@ + + + @@ -40,6 +43,7 @@ + @@ -130,6 +134,8 @@ + + @@ -299,6 +305,7 @@ verbose="2"> + @@ -538,6 +545,9 @@ + + Ignoring request to build jalview distribution with clover-instrumented classes + diff --git a/help/help.jhm b/help/help.jhm index 6239272..ce8b25d 100755 --- a/help/help.jhm +++ b/help/help.jhm @@ -70,8 +70,6 @@ - - diff --git a/help/helpTOC.xml b/help/helpTOC.xml index ca86625..0bf615b 100755 --- a/help/helpTOC.xml +++ b/help/helpTOC.xml @@ -60,8 +60,6 @@ - - @@ -78,8 +76,7 @@ - - + diff --git a/help/html/editing/index.html b/help/html/editing/index.html index fd8c5a3..b3600c9 100755 --- a/help/html/editing/index.html +++ b/help/html/editing/index.html @@ -61,7 +61,7 @@ Undo / redo - editing of sequences (insertion/removal of gaps, removal of sequences, trimming sequences etc) may be undone or redone at any time using the appropriate menu items from the edit - menu. The undo history list only allows a maximum of 10 actions. + menu.

Trimming alignment - First select a column by clicking the scale indicator (above the sequences) The alignment may then be diff --git a/help/html/features/clarguments.html b/help/html/features/clarguments.html index e065494..fa273a5 100644 --- a/help/html/features/clarguments.html +++ b/help/html/features/clarguments.html @@ -122,30 +122,6 @@ -

-dasserver nickname=URL
- -
- Add and enable a DAS server - with given nickname (alphanumeric or underscores only) for - retrieval of features for all alignments
Sources that - also support the sequence command may be specified by - prepending the URL with 'sequence:'
e.g. - sequence:http://localdas.somewhere.org/das/source -
- - - - -
-fetchfrom nickname
- -
- Query a DAS source called - nickname for features for the alignments and display them -
- - - -
-groovy FILE/URL
Execute groovy script in FILE (where diff --git a/help/html/features/dasfeatures.html b/help/html/features/dasfeatures.html deleted file mode 100644 index 1965e70..0000000 --- a/help/html/features/dasfeatures.html +++ /dev/null @@ -1,77 +0,0 @@ - - - -DAS Features - - - -

- DAS Sequence Feature Retrieval -

-

Jalview includes a client for retrieving sequences and their - features via the Distributed Annotation System.

-
    -
  1. Open the Feature Settings panel by selecting "View - -> Feature Settings..."
  2. -
  3. Click on the "DAS - Settings" tabbed pane. -
  4. -
  5. Select the sources to use for DAS feature retrieval, then - click the "Fetch DAS Features" button. -
      -
    • Cancelling Feature Retrieval
      Press the Cancel - Fetch button to immediately stop feature retrieval. This - will not remove any features already added to the alignment, - but will halt any outstanding DAS requests.The cancel - fetch button is of particular use when one or more DAS - annotation servers are not responding! -
    -
  6. -
-

- If your DAS source selection contains sources which use UniProt - accession ids, you will be asked whether Jalview should find UniProt - Accession ids for the given sequence names. It is important to - realise that many DAS sources only use UniProt accession ids, rather - than Swissprot/UniProt sequence names.
The database - reference fetcher documentation describes how Jalview discovers - what database references are appropriate for the sequences in the - alignment. -

    -
  • Note
    Please remember to save your - alignment if either the start/end numbering, or the sequence IDs - were updated during the ID retrieval process.
  • -
-

  -

- DAS support was introduced in Jalview Version 2.1. -

-
-

- The DAS registry at http://www.dasregistry.org was - decommissioned early in 2015. An unmaintained mirror is currently - hosted at http://www.ebi.ac.uk/das-srv/registry/. -

-

  - - diff --git a/help/html/features/dassettings.html b/help/html/features/dassettings.html deleted file mode 100644 index 9600070..0000000 --- a/help/html/features/dassettings.html +++ /dev/null @@ -1,74 +0,0 @@ - - - -DAS Settings - - - -

- DAS Settings -

-

- Jalview can retrieve sequences and features from many DAS sources. The DAS sources - that it uses are discovered and selected via the DAS - settings panel, opened either from the View→Feature Settings dialog - box from the alignment window's menu bar, or the Tools→Preferences - dialog box opened from the Desktop menu bar. -

-

- -

The available sources are listed in the table using each - source's Nickname as its identifier. Clicking on a source's entry in - the table reveals more information about that service in the panel - to the right. Select the tickbox in the "Use Source" - column for a source to add it to the set Jalview queries for - alignment and sequence features.

-

You can filter the visible DAS sources by authority, type and - "label". You should read the DAS documentation to - understand more about these values. -

- Updating the list of sources -

-

- When the DAS Settings panel is first opened, and when the 'Refresh - source' buton is pressed, a list of DAS sources is retrieved from - the DAS registry URL. Note that the registry hosted at - http://www.dasregistry.org/das/ was retired at the start of 2015. An - alternative service is currently hosted at - http://www.ebi.ac.uk/das-srv/registry/das/. To connect to this - service, ensure your .jalview_properties file includes the following - line:
DAS_REGISTRY_URL=http\://www.ebi.ac.uk/das-srv/registry/das/ -

-

- Adding your own DAS Sources -

-

You can add your own DAS source to the list by clicking the - "Add Local Source" button. Enter the URL and nickname of - your additional service. It should be noted that Jalview 2.1 will - not query additional sources for more information, but this will be - implemented in future editions. -

  - - diff --git a/help/html/features/preferences.html b/help/html/features/preferences.html index 5bca358..cbbca28 100755 --- a/help/html/features/preferences.html +++ b/help/html/features/preferences.html @@ -67,10 +67,6 @@

  • The "HMMER" Preferences tab allows you to configure locally installed HMMER tools.
  • -
  • The "DAS - Settings" Preferences tab allows you to select which DAS - sources to use when fetching DAS Features. -
  • The "Web Service" Preferences tab allows you to configure the JABAWS diff --git a/help/html/features/search.html b/help/html/features/search.html index 72e5bdf..eec68ee 100755 --- a/help/html/features/search.html +++ b/help/html/features/search.html @@ -159,7 +159,7 @@ td {

    The search history keeps up to 99 queries by default. To clear the history, or modify the size of the history, right-click the text box.

    - +

    Other dialogs that provide a query history

    diff --git a/help/html/features/searchclearhist.png b/help/html/features/searchclearhist.png index 200c4d3..29cc34f 100644 Binary files a/help/html/features/searchclearhist.png and b/help/html/features/searchclearhist.png differ diff --git a/help/html/features/seqfeatures.html b/help/html/features/seqfeatures.html index 3c9d2b8..eeb63f6 100755 --- a/help/html/features/seqfeatures.html +++ b/help/html/features/seqfeatures.html @@ -87,10 +87,7 @@ href="featuresettings.html">Sequence Feature Settings dialog box. Feature colour schemes and display parameters are unique to a particular alignment, so it is possible to colour the same - sequence features differently in different alignment views.
    - Since Jalview 2.1, it is possible to add DAS - features to an alignment via the DAS tabbed pane of the feature - settings window. + sequence features differently in different alignment views.

    View→Sequence ID Tooltip→Show diff --git a/help/html/features/seqfetch.html b/help/html/features/seqfetch.html index 44aa1c2..e726c49 100755 --- a/help/html/features/seqfetch.html +++ b/help/html/features/seqfetch.html @@ -26,19 +26,13 @@

    Sequence Fetcher

    -

    - Jalview can retrieve sequences from certain databases using either - the DBFetch service provided by the EMBL European Bioinformatics - Institute, or, since Jalview 2.4, DAS servers capable of the sequence - command (configured in DAS settings). -

    -

    The Sequence Fetcher can be opened via the "File" +

    Jalview can retrieve sequences from a range of sequence, 3D + structure, genomic and domain family databases provided by EMBL-EBI.

    +

    The Sequence Fetcher can be opened via the "File" menu on the main desktop in order to retrieve sequences as a new alignment, or opened via the "File" menu of an existing alignment to import additional sequences. There may be a short delay - when the sequence fetcher is first opened, whilst Jalview compiles - the list of available sequence datasources from the currently - defined DAS server registry.

    + when the sequence fetcher is first opened, whilst Jalview contacts each database's web API.

    Every time a new fetcher is opened, you will need to select the database you want to retrieve sequences from the database @@ -51,11 +45,6 @@ tooltips are shown if you mouse over some sources, explaining what the database will retrieve. You can select one by using the up/down arrow keys and hitting return, or by double clicking with the mouse. -
    - If you have DAS sources enabled, then you may have several - sources for the same type of sequence identifier, and these will - be grouped together in a sub-branch branch labeled with the - identifier.

    Once you have selected a sequence database, its fetcher dialog will open. Jalview provides two types of dialog:

    @@ -82,17 +71,6 @@ currently selected database into the retrieval box. Finally, press "OK" to initiate the retrieval.
  • -

    - Only retrieving part of a sequence -

    -

    - When using DAS sources (indicated by a "(DAS)"), - you can append a range in addition to a sequence ID. For example, to - retrieve 50 residues starting at position 35 in UNIPROT sequence - P73137 using the UNIPROT DAS server, you would enter - "'P73137:35,84'.
    Full support for DAS range - queries was introduced in Jalview 2.8 -

    If you use the WSDBFetch sequence fetcher services (EMBL, UniProt, PFAM, and RFAM) in work for publication, please cite:

    diff --git a/help/html/menus/alignmentMenu.html b/help/html/menus/alignmentMenu.html index 00a2ec4..f3ab75d 100755 --- a/help/html/menus/alignmentMenu.html +++ b/help/html/menus/alignmentMenu.html @@ -314,9 +314,7 @@ href="../features/featuresettings.html">Sequence Feature Settings...

    Opens the Sequence Feature Settings dialog box to control the colour - and display of sequence features on the alignment, and - configure and retrieve features from DAS annotation - servers. + and display of sequence features on the alignment.
  • Sequence ID Tooltip (application only)
    This submenu's options allow the inclusion or exclusion of non-positional sequence features @@ -579,28 +577,26 @@ is dynamic, and may contain user-defined web service entries in addition to any of the following ones:
      -
    • Fetch DB References
      This - submenu contains options for accessing any of the database - services that Jalview is aware of (e.g. DAS sequence servers - and the WSDBFetch service provided by the EBI) to verify - sequence start/end positions and retrieve all database cross - references and PDB ids associated with all or just the - selected sequences in the alignment. -
        -
      • 'Trim Retrieved Sequences' - when checked, Jalview - will discard any additional sequence data for accessions - associated with sequences in the alignment.
        Note: - Disabling this could cause out of memory errors when - working with genomic sequence records !
        Added - in Jalview 2.8.1 -
      • -
      • 'Standard Databases' will check sequences against - the EBI databases plus any active DAS sequence sources
      • -
      Other sub-menus allow you to pick a specific source to query - - sources are listed alphabetically according to their - nickname. -

    • -
    +
  • Fetch DB References
    This + submenu contains options for accessing any of the database + services that Jalview is aware of (e.g. those provided by + EMBL-EBI) to verify sequence start/end positions and retrieve all + database cross references and PDB ids associated with all or just + the selected sequences in the alignment. +
      +
    • 'Trim Retrieved Sequences' - when checked, Jalview will + discard any additional sequence data for accessions associated + with sequences in the alignment.
      Note: + Disabling this could cause out of memory errors when working + with genomic sequence records !
      Added + in Jalview 2.8.1 +
    • +
    • 'Standard Databases' will check sequences against the + EBI databases.
    • +
    Other sub-menus allow you to pick a specific source to query - + sources are listed alphabetically according to their nickname. +

  • +

    Selecting items from the following submenus will start a remote service on compute facilities at the University of Dundee, or elsewhere. You need a continuous network connection in order to diff --git a/help/html/menus/alwview.html b/help/html/menus/alwview.html index 2028304..33ec77f 100755 --- a/help/html/menus/alwview.html +++ b/help/html/menus/alwview.html @@ -53,8 +53,7 @@

  • Sequence Feature Settings...
    Opens the Sequence Feature Settings dialog box to control the colour and display of - sequence features on the alignment, and configure and retrieve - features from DAS annotation servers.
  • + sequence features on the alignment.
  • Sequence ID Tooltip (application only)
    This submenu's options allow the inclusion or exclusion of non-positional sequence features or database cross diff --git a/help/html/menus/wsmenu.html b/help/html/menus/wsmenu.html index b71bc1a..b8b357e 100755 --- a/help/html/menus/wsmenu.html +++ b/help/html/menus/wsmenu.html @@ -29,14 +29,13 @@ dynamic, and may contain user-defined web service entries in addition to any of the following ones:
      -
    • Fetch DB References
      This - submenu contains options for accessing any of the database - services that Jalview is aware of (e.g. DAS sequence servers and - the WSDBFetch service provided by the EBI) to verify sequence - start/end positions and retrieve all database cross references - and PDB ids associated with all or just the selected sequences - in the alignment. -
        +
      • Fetch DB References
        This submenu + contains options for accessing any of the database services that + Jalview is aware of (e.g services provided by the EBI) to verify + sequence start/end positions and retrieve all database cross + references and PDB ids associated with all or just the selected + sequences in the alignment. +
        • 'Retrieve full Sequence' - when checked, Jalview will retrieve the full sequence for any accessions associated with sequences in the alignment.
          Note: @@ -45,7 +44,7 @@ in Jalview 2.8.1
        • 'Standard Databases' will check sequences against the - EBI databases plus any active DAS sequence sources<
        • + EBI databases
        Other submenus allow you to pick a specific source to query - sources are listed alphabetically according to their nickname.
      • diff --git a/help/html/releases.html b/help/html/releases.html index 3c1d73c..efe6520 100755 --- a/help/html/releases.html +++ b/help/html/releases.html @@ -67,6 +67,30 @@ li:before {
  • + + +
    + 2.11.0
    + 8/09/2018
    +
    + +
    + +
      +
    • + +
    • +
    +
    +
    + +
      +
    • + DAS sequence retrieval and annotation capabilities removed from the Jalview Desktop +
    • +
    +
    +
    diff --git a/help/html/webServices/dbreffetcher.html b/help/html/webServices/dbreffetcher.html index 83c80ba..1f61dea 100644 --- a/help/html/webServices/dbreffetcher.html +++ b/help/html/webServices/dbreffetcher.html @@ -30,8 +30,7 @@ ID, and can be viewed in full via the Sequence Details window. . Jalview also uses references for the retrieval of - PDB structures and DAS features, and for + PDB structures, and for retrieving sequence cross-references such as the protein products of a DNA sequence.

    @@ -40,21 +39,18 @@ application provides three ways to access the retrieval function. Either:
      -
    • select the Discover PDB IDs option from the - structure submenu of the sequence's popup menu -
    • -
    • Choose one of the options from the 'Fetch DB Refs' submenu in +
    • select the Structure Chooser... option from + the Sequence ID popup menu. +
    • +
    • Choose one of the options from the 'Fetch DB Refs' submenu in the alignment window's Web Services menu:
        -
      • Standard Databases will fetch references from - the EBI databases plus currently selected DAS sources
      • -
      • The other entries submenus leading to lists of individual +
      • Standard Databases will fetch references from EBI + databases appropriate for the sequence type (Nucleotide or Protein)
      • +
      • The other entries submenus leading to lists of individual database sources that Jalview can access.
    • -
    • Answer 'Yes' when asked if you wish to retrieve database - references for your sequences after initiating a DAS Sequence - Feature fetch.

    Jalview discovers references for a sequence by generating a set of ID queries from the ID string of each sequence in the alignment. It diff --git a/help/html/webServices/index.html b/help/html/webServices/index.html index d0b497c..8f36013 100755 --- a/help/html/webServices/index.html +++ b/help/html/webServices/index.html @@ -36,15 +36,11 @@ Institute (EBI) and Distributed Annotation System servers that are capable of serving sequences. -

  • The DAS Feature - Fetcher enables the retrieval and visualization of features from - DAS annotation sources -
  • -
  • The Database Reference - Fetcher transfers database references from records available - from DAS or the public sequence databases. -
  • -
  • The Web Services menu in each alignment +
  • The Database Reference + Fetcher transfers database references and annotation from the public + sequence databases. +
  • +
  • The Web Services menu in each alignment window also provides access to the following:
    • Programs for multiple diff --git a/lib/jdas-1.0.4.jar b/lib/jdas-1.0.4.jar deleted file mode 100644 index fb5d128..0000000 Binary files a/lib/jdas-1.0.4.jar and /dev/null differ diff --git a/nbbuild.xml b/nbbuild.xml index d6e4cf3..ca8a275 100644 --- a/nbbuild.xml +++ b/nbbuild.xml @@ -17,7 +17,7 @@ * You should have received a copy of the GNU General Public License along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. --> - diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index dcd6546..83bc810 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -28,8 +28,6 @@ import jalview.schemes.UserColourScheme; import jalview.structure.StructureImportSettings; import jalview.urls.IdOrgSettings; import jalview.util.ColorUtils; -import jalview.ws.dbsources.das.api.DasSourceRegistryI; -import jalview.ws.dbsources.das.datamodel.DasSourceRegistry; import jalview.ws.sifts.SiftsSettings; import java.awt.Color; @@ -982,22 +980,6 @@ public class Cache return null; } - private static DasSourceRegistryI sourceRegistry = null; - - /** - * initialise and .. - * - * @return instance of the das source registry - */ - public static DasSourceRegistryI getDasSourceRegistry() - { - if (sourceRegistry == null) - { - sourceRegistry = new DasSourceRegistry(); - } - return sourceRegistry; - } - /** * Set the specified value, or remove it if null or empty. Does not save the * properties file. diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 4c1e848..a992ace 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -149,7 +149,6 @@ public class Jalview af.setProgressBar(MessageManager .getString("status.das_features_being_retrived"), id); af.featureSettings_actionPerformed(null); - af.featureSettings.fetchDasFeatures(dasSources, true); af.setProgressBar(null, id); synchronized (us) { diff --git a/src/jalview/ext/ensembl/EnsemblLookup.java b/src/jalview/ext/ensembl/EnsemblLookup.java index 5f353f8..82690a3 100644 --- a/src/jalview/ext/ensembl/EnsemblLookup.java +++ b/src/jalview/ext/ensembl/EnsemblLookup.java @@ -131,7 +131,7 @@ public class EnsemblLookup extends EnsemblRestClient /** * Returns the gene id related to the given identifier (which may be for a - * gene, transcript or protein) + * gene, transcript or protein), or null if none is found * * @param identifier * @return @@ -143,7 +143,7 @@ public class EnsemblLookup extends EnsemblRestClient /** * Returns the gene id related to the given identifier (which may be for a - * gene, transcript or protein) + * gene, transcript or protein), or null if none is found * * @param identifier * @param objectType @@ -165,6 +165,10 @@ public class EnsemblLookup extends EnsemblRestClient */ protected String parseGeneId(JSONObject val) { + if (val == null) + { + return null; + } String geneId = null; String type = val.get(OBJECT_TYPE).toString(); if (OBJECT_TYPE_GENE.equalsIgnoreCase(type)) diff --git a/src/jalview/ext/ensembl/EnsemblMap.java b/src/jalview/ext/ensembl/EnsemblMap.java index 56657e0..8ca60de 100644 --- a/src/jalview/ext/ensembl/EnsemblMap.java +++ b/src/jalview/ext/ensembl/EnsemblMap.java @@ -257,7 +257,10 @@ public class EnsemblMap extends EnsemblRestClient { url = getIdMapUrl(domain, accession, start, end, cdsOrCdna); br = getHttpResponse(url, null); - return (parseIdMappingResponse(br, accession, domain)); + if (br != null) + { + return (parseIdMappingResponse(br, accession, domain)); + } } return null; } catch (Throwable t) diff --git a/src/jalview/ext/ensembl/EnsemblRestClient.java b/src/jalview/ext/ensembl/EnsemblRestClient.java index 92972eb..f36e111 100644 --- a/src/jalview/ext/ensembl/EnsemblRestClient.java +++ b/src/jalview/ext/ensembl/EnsemblRestClient.java @@ -259,7 +259,8 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher } /** - * Sends the HTTP request and gets the response as a reader + * Sends the HTTP request and gets the response as a reader. Returns null if + * the HTTP response code was not 200. * * @param url * @param ids @@ -268,7 +269,6 @@ abstract class EnsemblRestClient extends EnsemblSequenceFetcher * in milliseconds * @return * @throws IOException - * if response code was not 200, or other I/O error */ protected BufferedReader getHttpResponse(URL url, List ids, int readTimeout) throws IOException diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 5fa168d..2747384 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -4312,7 +4312,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, jws2servs.attachWSMenuEntry(webService, me); for (Jws2Instance sv : jws2servs.getServices()) { - if (sv.description.toLowerCase().contains("jpred")) + if (sv.getName().toLowerCase().contains("jpred")) { for (JMenuItem jmi : legacyItems) { diff --git a/src/jalview/gui/DasSourceBrowser.java b/src/jalview/gui/DasSourceBrowser.java deleted file mode 100644 index 8570ac3..0000000 --- a/src/jalview/gui/DasSourceBrowser.java +++ /dev/null @@ -1,864 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.gui; - -import jalview.jbgui.GDasSourceBrowser; -import jalview.util.MessageManager; -import jalview.util.TableSorter; -import jalview.ws.dbsources.das.api.DasSourceRegistryI; -import jalview.ws.dbsources.das.api.jalviewSourceI; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.StringTokenizer; -import java.util.Vector; - -import javax.swing.JCheckBox; -import javax.swing.JLabel; -import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JTextField; -import javax.swing.ListSelectionModel; -import javax.swing.SwingUtilities; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import javax.swing.table.AbstractTableModel; - -import org.biodas.jdas.schema.sources.CAPABILITY; -import org.biodas.jdas.schema.sources.COORDINATES; -import org.biodas.jdas.schema.sources.PROP; -import org.biodas.jdas.schema.sources.VERSION; - -public class DasSourceBrowser extends GDasSourceBrowser - implements Runnable, ListSelectionListener -{ - DasSourceRegistryI sourceRegistry = null; - - Vector selectedSources; - - public DasSourceBrowser(FeatureSettings featureSettings) - { - fs = featureSettings; - // TODO DasSourceRegistryProvider API - sourceRegistry = jalview.bin.Cache.getDasSourceRegistry(); - String registry = sourceRegistry.getDasRegistryURL(); - - registryURL.setText(registry); - - setSelectedFromProperties(); - - displayFullDetails(null); - table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - filter1.addListSelectionListener(this); - filter2.addListSelectionListener(this); - filter3.addListSelectionListener(this); - - // Ask to be notified of selection changes. - ListSelectionModel rowSM = table.getSelectionModel(); - rowSM.addListSelectionListener(new ListSelectionListener() - { - @Override - public void valueChanged(ListSelectionEvent e) - { - ListSelectionModel lsm = (ListSelectionModel) e.getSource(); - if (!lsm.isSelectionEmpty()) - { - int selectedRow = lsm.getMinSelectionIndex(); - displayFullDetails(table.getValueAt(selectedRow, 0).toString()); - } - } - }); - - table.addMouseListener(new MouseAdapter() - { - @Override - public void mouseClicked(MouseEvent evt) - { - if (evt.getClickCount() == 2 || evt.isPopupTrigger()) - { - editRemoveLocalSource(evt); - } - } - }); - - if (sourceRegistry.getSources() != null) - { - init(); - } - } - - FeatureSettings fs = null; - - private boolean loadingDasSources; - - public DasSourceBrowser() - { - this(null); - } - - @Override - public void paintComponent(java.awt.Graphics g) - { - if (sourceRegistry == null) - { - Thread worker = new Thread(this); - worker.start(); - } - } - - void init() - { - List sources = sourceRegistry.getSources(); - int dSize = sources.size(); - Object[][] data = new Object[dSize][2]; - for (int i = 0; i < dSize; i++) - { - data[i][0] = sources.get(i).getTitle(); // what's equivalent of nickname - data[i][1] = new Boolean( - selectedSources.contains(sources.get(i).getTitle())); - } - - refreshTableData(data); - setCapabilities(sourceRegistry); - - javax.swing.SwingUtilities.invokeLater(new Runnable() - { - @Override - public void run() - { - TableSorter sorter = (TableSorter) table.getModel(); - sorter.setSortingStatus(1, TableSorter.DESCENDING); - sorter.setSortingStatus(1, TableSorter.NOT_SORTED); - } - }); - - progressBar.setIndeterminate(false); - progressBar.setVisible(false); - addLocal.setVisible(true); - refresh.setVisible(true); - } - - public void refreshTableData(Object[][] data) - { - TableSorter sorter = new TableSorter(new DASTableModel(data)); - sorter.setTableHeader(table.getTableHeader()); - table.setModel(sorter); - } - - void displayFullDetails(String nickName) - { - - StringBuffer text = new StringBuffer( - ""); - - if (nickName == null) - { - fullDetails.setText(text + MessageManager - .getString("label.select_das_service_from_table")); - return; - } - - int dSize = sourceRegistry.getSources().size(); - for (jalviewSourceI ds : sourceRegistry.getSources()) - { - if (!ds.getTitle().equals(nickName)) - { - continue; - } - - VERSION latest = ds.getVersion(); - text.append( - "Id: " + ds.getUri() + "
      "); - text.append("Nickname: " - + ds.getTitle() + "
      "); - - text.append("URL:
      " + ds.getSourceURL() + "" - + "
      "); - if (!ds.isLocal()) - { - if (ds.getDocHref() != null && ds.getDocHref().length() > 0) - { - text.append("Site: " + ds.getDocHref() + "" - + "
      "); - } - - text.append("Description: " - + ds.getDescription() + "
      "); - - text.append( - "Admin Email: " + ds.getEmail() + "" - + "
      "); - - text.append("Registered at: " - + latest.getCreated() + "
      "); - - // TODO: Identify last successful test date - // text.append("Last successful test: " - // + latest.dasSources[i].getLeaseDate() + "
      "); - } - else - { - text.append("Source was added manually.
      "); - } - text.append("Labels: "); - boolean b = false; - for (PROP labl : latest.getPROP()) - { - if (labl.getName().equalsIgnoreCase("LABEL")) - { - if (b) - { - text.append(","); - } - text.append(" "); - - text.append(labl.getValue()); - b = true; - } - ; - } - text.append("
      "); - - text.append("Capabilities: "); - CAPABILITY[] scap = latest.getCAPABILITY().toArray(new CAPABILITY[0]); - for (int j = 0; j < scap.length; j++) - { - text.append(scap[j].getType()); - if (j < scap.length - 1) - { - text.append(", "); - } - } - text.append("
      "); - - text.append("Coordinates:"); - int i = 1; - for (COORDINATES dcs : latest.getCOORDINATES()) - { - text.append("
      " + i++ + ". "); - text.append(dcs.getAuthority() + " : " + dcs.getSource()); - if (dcs.getTaxid() != null && dcs.getTaxid().trim().length() > 0) - { - text.append(" [TaxId:" + dcs.getTaxid() + "]"); - } - if (dcs.getVersion() != null - && dcs.getVersion().trim().length() > 0) - { - { - text.append(" {v. " + dcs.getVersion() + "}"); - } - } - text.append(" (" + dcs.getUri() - + ")"); - } - text.append("
      "); - - break; - } - - fullDetails.setText(text.toString()); - javax.swing.SwingUtilities.invokeLater(new Runnable() - { - @Override - public void run() - { - fullDetailsScrollpane.getVerticalScrollBar().setValue(0); - } - }); - } - - @Override - public void run() - { - loadingDasSources = true; - - addLocal.setVisible(false); - refresh.setVisible(false); - progressBar.setVisible(true); - progressBar.setIndeterminate(true); - setParentGuiEnabled(false); - // Refresh the source list. - sourceRegistry.refreshSources(); - - init(); - - setParentGuiEnabled(true); - loadingDasSources = false; - - } - - private void setParentGuiEnabled(boolean b) - { - if (fs != null) - { - fs.fetchDAS.setEnabled(b); - fs.saveDAS.setEnabled(b); - } - } - - public Vector getSelectedSources() - { - // wait around if we're still loading. - while (sourceRegistry == null) - { - if (!loadingDasSources) - { - new Thread(this).start(); - try - { - Thread.sleep(5); - } catch (Exception e) - { - } - ; - while (loadingDasSources) - { - try - { - Thread.sleep(5); - } catch (Exception e) - { - } - ; - } - ; - } - } - - Vector selected = new Vector(); - for (String source : selectedSources) - { - jalviewSourceI srce = sourceRegistry.getSource(source); - if (srce != null) - { - selected.addElement(srce); - } - } - return selected; - } - - @Override - public void refresh_actionPerformed(ActionEvent e) - { - saveProperties(jalview.bin.Cache.applicationProperties); - - Thread worker = new Thread(this); - worker.start(); - } - - private void setCapabilities(DasSourceRegistryI sourceRegistry2) - { - Vector authority = new Vector(); - Vector type = new Vector(); - Vector label = new Vector(); - Vector taxIds = new Vector(); - authority.add("Any"); - type.add("Any"); - label.add("Any"); - - for (jalviewSourceI ds : sourceRegistry2.getSources()) - { - VERSION latest = ds.getVersion(); - - for (COORDINATES cs : latest.getCOORDINATES()) - { - if (!type.contains(cs.getSource())) - { - type.add(cs.getSource()); // source==category - } - - if (!authority.contains(cs.getAuthority())) - { - authority.add(cs.getAuthority()); - } - } - - for (PROP slabel : latest.getPROP()) - { - if (slabel.getName().equalsIgnoreCase("LABEL") - && !label.contains(slabel.getValue())) - { - label.add(slabel.getValue()); - } - } - - } - - filter1.setListData(authority); - filter2.setListData(type); - filter3.setListData(label); - // filter4 taxIds - - javax.swing.SwingUtilities.invokeLater(new Runnable() - { - @Override - public void run() - { - filter1.setSelectedIndex(0); - filter2.setSelectedIndex(0); - filter3.setSelectedIndex(0); - } - }); - } - - @Override - public void amendLocal(boolean newSource) - { - String url = "http://localhost:8080/", nickname = ""; - boolean seqsrc = false; - if (!newSource) - { - int selectedRow = table.getSelectionModel().getMinSelectionIndex(); - nickname = table.getValueAt(selectedRow, 0).toString(); - jalviewSourceI source = sourceRegistry.getSource(nickname); - url = source.getUri(); - seqsrc = source.isSequenceSource(); - } - - JTextField nametf = new JTextField(nickname, 40); - JTextField urltf = new JTextField(url, 40); - JCheckBox seqs = new JCheckBox( - MessageManager.getString("label.sequence_source")); - seqs.setSelected(seqsrc); - JPanel panel = new JPanel(new BorderLayout()); - JPanel pane12 = new JPanel(new BorderLayout()); - pane12.add(new JLabel(MessageManager.getString("label.name:")), - BorderLayout.CENTER); - pane12.add(nametf, BorderLayout.EAST); - panel.add(pane12, BorderLayout.NORTH); - pane12 = new JPanel(new BorderLayout()); - pane12.add(new JLabel(MessageManager.getString("label.url:")), - BorderLayout.NORTH); - pane12.add(seqs, BorderLayout.SOUTH); - pane12.add(urltf, BorderLayout.EAST); - panel.add(pane12, BorderLayout.SOUTH); - - int reply = JvOptionPane.showInternalConfirmDialog(Desktop.desktop, - panel, MessageManager.getString("label.enter_local_das_source"), - JvOptionPane.OK_CANCEL_OPTION); - - if (reply != JvOptionPane.OK_OPTION) - { - return; - } - - if (!urltf.getText().endsWith("/")) - { - urltf.setText(urltf.getText() + "/"); - } - - jalviewSourceI local = sourceRegistry.createLocalSource(urltf.getText(), - nametf.getText(), seqs.isSelected(), true); - List sources = sourceRegistry.getSources(); - int osize = sources.size(); - int size = osize + (newSource ? 1 : 0); - - Object[][] data = new Object[size][2]; - DASTableModel dtm = (table != null) - ? (DASTableModel) ((TableSorter) table.getModel()) - .getTableModel() - : null; - for (int i = 0; i < osize; i++) - { - String osrc = (dtm == null || i >= osize) ? null - : (String) dtm.getValueAt(i, 0); - if (!newSource && osrc != null - && dtm.getValueAt(i, 0).equals(nickname)) - { - data[i][0] = local.getTitle(); - data[i][1] = new Boolean(true); - } - else - { - data[i][0] = osrc; - data[i][1] = new Boolean(selectedSources.contains(osrc)); - } - } - // Always add a new source at the end - if (newSource) - { - data[osize][0] = local.getTitle(); - data[osize][1] = new Boolean(true); - selectedSources.add(local.getTitle()); - } - - refreshTableData(data); - - SwingUtilities.invokeLater(new Runnable() - { - @Override - public void run() - { - scrollPane.getVerticalScrollBar() - .setValue(scrollPane.getVerticalScrollBar().getMaximum()); - } - }); - - displayFullDetails(local.getTitle()); - } - - public void editRemoveLocalSource(MouseEvent evt) - { - int selectedRow = table.getSelectionModel().getMinSelectionIndex(); - if (selectedRow == -1) - { - return; - } - - String nickname = table.getValueAt(selectedRow, 0).toString(); - - if (!sourceRegistry.getSource(nickname).isLocal()) - { - JvOptionPane.showInternalMessageDialog(Desktop.desktop, - MessageManager.getString( - "label.you_can_only_edit_or_remove_local_das_sources"), - MessageManager.getString("label.public_das_source"), - JvOptionPane.WARNING_MESSAGE); - return; - } - - Object[] options = { "Edit", "Remove", "Cancel" }; - int choice = JvOptionPane.showInternalOptionDialog(Desktop.desktop, - "Do you want to edit or remove " + nickname + "?", - "Edit / Remove Local DAS Source", - JvOptionPane.YES_NO_CANCEL_OPTION, - JvOptionPane.QUESTION_MESSAGE, null, options, options[2]); - - switch (choice) - { - case 0: - amendLocal(false); - break; - case 1: - sourceRegistry.removeLocalSource(sourceRegistry.getSource(nickname)); - selectedSources.remove(nickname); - Object[][] data = new Object[sourceRegistry.getSources().size()][2]; - int index = 0, l = table.getRowCount(); - - for (int i = 0; i < l; i++) - { - String nm; - if ((nm = (String) table.getValueAt(i, 0)).equals(nickname)) - { - continue; - } - else - { - data[index][0] = nm; - data[index][1] = new Boolean(selectedSources.contains(nm)); - index++; - } - } - refreshTableData(data); - SwingUtilities.invokeLater(new Runnable() - { - @Override - public void run() - { - scrollPane.getVerticalScrollBar() - .setValue(scrollPane.getVerticalScrollBar().getMaximum()); - } - }); - - break; - } - } - - @Override - public void valueChanged(ListSelectionEvent evt) - { - // Called when the MainTable selection changes - if (evt.getValueIsAdjusting()) - { - return; - } - - displayFullDetails(null); - - // Filter the displayed data sources - - ArrayList names = new ArrayList(); - ArrayList selected = new ArrayList(); - - // The features filter is not visible, but we must still - // filter the das source list here. - // July 2006 - only 6 sources fo not serve features - Object[] dummyFeatureList = new Object[] { "features" }; - List srcs = sourceRegistry.getSources(); - for (jalviewSourceI ds : srcs) - { - - VERSION v = ds.getVersion(); - List coords = v.getCOORDINATES(); - if (ds.isLocal() || ((coords == null || coords.size() == 0) - && filter1.getSelectedIndex() == 0 - && filter2.getSelectedIndex() == 0 - && filter3.getSelectedIndex() == 0)) - { - // THIS IS A FIX FOR LOCAL SOURCES WHICH DO NOT - // HAVE COORDINATE SYSTEMS, INFO WHICH AT PRESENT - // IS ADDED FROM THE REGISTRY - names.add(ds.getTitle()); - selected.add(new Boolean(selectedSources.contains(ds.getTitle()))); - continue; - } - - if (!selectedInList(dummyFeatureList, ds.getCapabilityList(v)) - || !selectedInList(filter3.getSelectedValues(), - ds.getLabelsFor(v))) - { - continue; - } - - for (int j = 0; j < coords.size(); j++) - { - if (selectedInList(filter1.getSelectedValues(), - new String[] - { coords.get(j).getAuthority() }) - && selectedInList(filter2.getSelectedValues(), new String[] - { coords.get(j).getSource() })) - { - names.add(ds.getTitle()); - selected.add( - new Boolean(selectedSources.contains(ds.getTitle()))); - break; - } - } - } - - int dSize = names.size(); - Object[][] data = new Object[dSize][2]; - for (int d = 0; d < dSize; d++) - { - data[d][0] = names.get(d); - data[d][1] = selected.get(d); - } - - refreshTableData(data); - } - - private boolean selectedInList(Object[] selection, String[] items) - { - for (int i = 0; i < selection.length; i++) - { - if (selection[i].equals("Any")) - { - return true; - } - if (items == null || items.length == 0) - { - return false; - } - String sel = (items[0].startsWith("das1:") ? "das1:" : "") - + selection[i]; - for (int j = 0; j < items.length; j++) - { - if (sel.equals(items[j])) - { - return true; - } - } - } - - return false; - } - - void setSelectedFromProperties() - { - String active = jalview.bin.Cache.getDefault("DAS_ACTIVE_SOURCE", - "uniprot"); - StringTokenizer st = new StringTokenizer(active, "\t"); - selectedSources = new Vector(); - while (st.hasMoreTokens()) - { - selectedSources.addElement(st.nextToken()); - } - } - - @Override - public void reset_actionPerformed(ActionEvent e) - { - registryURL.setText(sourceRegistry.getDasRegistryURL()); - } - - /** - * set the DAS source settings in the given jalview properties. - * - * @param properties - */ - public void saveProperties(Properties properties) - { - if (registryURL.getText() == null || registryURL.getText().length() < 1) - { - properties.remove(jalview.bin.Cache.DAS_REGISTRY_URL); - } - else - { - properties.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL, - registryURL.getText()); - } - - StringBuffer sb = new StringBuffer(); - for (int r = 0; r < table.getModel().getRowCount(); r++) - { - if (((Boolean) table.getValueAt(r, 1)).booleanValue()) - { - sb.append(table.getValueAt(r, 0) + "\t"); - } - } - - properties.setProperty(jalview.bin.Cache.DAS_ACTIVE_SOURCE, - sb.toString()); - - String sourceprop = sourceRegistry.getLocalSourceString(); - properties.setProperty(jalview.bin.Cache.DAS_LOCAL_SOURCE, sourceprop); - } - - class DASTableModel extends AbstractTableModel - { - - public DASTableModel(Object[][] data) - { - this.data = data; - } - - private String[] columnNames = new String[] { - MessageManager.getString("label.nickname"), - MessageManager.getString("label.use_source") }; - - private Object[][] data; - - @Override - public int getColumnCount() - { - return columnNames.length; - } - - @Override - public int getRowCount() - { - return data.length; - } - - @Override - public String getColumnName(int col) - { - return columnNames[col]; - } - - @Override - public Object getValueAt(int row, int col) - { - return data[row][col]; - } - - /* - * JTable uses this method to determine the default renderer/ editor for - * each cell. If we didn't implement this method, then the last column would - * contain text ("true"/"false"), rather than a check box. - */ - @Override - public Class getColumnClass(int c) - { - return getValueAt(0, c).getClass(); - } - - /* - * Don't need to implement this method unless your table's editable. - */ - @Override - public boolean isCellEditable(int row, int col) - { - // Note that the data/cell address is constant, - // no matter where the cell appears onscreen. - return col == 1; - - } - - /* - * Don't need to implement this method unless your table's data can change. - */ - @Override - public void setValueAt(Object value, int row, int col) - { - data[row][col] = value; - fireTableCellUpdated(row, col); - - String name = getValueAt(row, 0).toString(); - boolean selected = ((Boolean) value).booleanValue(); - - if (selectedSources.contains(name) && !selected) - { - selectedSources.remove(name); - } - - if (!selectedSources.contains(name) && selected) - { - selectedSources.add(name); - } - } - } - - public void initDasSources() - { - - Thread thr = new Thread(new Runnable() - { - @Override - public void run() - { - // this actually initialises the das source list - paintComponent(null); // yuk - } - }); - thr.start(); - while (loadingDasSources || sourceRegistry == null) - { - try - { - Thread.sleep(10); - } catch (Exception e) - { - } - ; - } - } - - /** - * disable or enable the buttons on the source browser - * - * @param b - */ - public void setGuiEnabled(boolean b) - { - refresh.setEnabled(b); - addLocal.setEnabled(b); - } -} diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 821454f..78c1cac 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -36,10 +36,7 @@ import jalview.schemabinding.version2.MatcherSet; import jalview.schemes.FeatureColour; import jalview.util.MessageManager; import jalview.util.Platform; -import jalview.viewmodel.AlignmentViewport; import jalview.viewmodel.seqfeatures.FeatureRendererModel.FeatureSettingsBean; -import jalview.ws.DasSequenceFeatureFetcher; -import jalview.ws.dbsources.das.api.jalviewSourceI; import java.awt.BorderLayout; import java.awt.Color; @@ -74,7 +71,6 @@ import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Vector; import javax.help.HelpSetException; import javax.swing.AbstractCellEditor; @@ -96,7 +92,6 @@ import javax.swing.JSlider; import javax.swing.JTable; import javax.swing.ListSelectionModel; import javax.swing.SwingConstants; -import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import javax.swing.table.AbstractTableModel; @@ -127,12 +122,6 @@ public class FeatureSettings extends JPanel private static final int MIN_HEIGHT = 400; - DasSourceBrowser dassourceBrowser; - - DasSequenceFeatureFetcher dasFeatureFetcher; - - JPanel dasSettingsPane = new JPanel(); - final FeatureRenderer fr; public final AlignFrame af; @@ -325,9 +314,6 @@ public class FeatureSettings extends JPanel // MessageManager.getString("label.feature_settings_click_drag"))); scrollPane.setViewportView(table); - dassourceBrowser = new DasSourceBrowser(this); - dasSettingsPane.add(dassourceBrowser, BorderLayout.CENTER); - if (af.getViewport().isShowSequenceFeatures() || !fr.hasRenderOrder()) { fr.findAllFeatures(true); // display everything! @@ -376,7 +362,6 @@ public class FeatureSettings extends JPanel javax.swing.event.InternalFrameEvent evt) { fr.removePropertyChangeListener(change); - dassourceBrowser.fs = null; }; }); frame.setLayer(JLayeredPane.PALETTE_LAYER); @@ -1158,8 +1143,6 @@ public class FeatureSettings extends JPanel JPanel settingsPane = new JPanel(); settingsPane.setLayout(new BorderLayout()); - dasSettingsPane.setLayout(new BorderLayout()); - JPanel bigPanel = new JPanel(); bigPanel.setLayout(new BorderLayout()); @@ -1314,38 +1297,6 @@ public class FeatureSettings extends JPanel transparency.setMaximum(70); transparency.setToolTipText( MessageManager.getString("label.transparency_tip")); - fetchDAS.setText(MessageManager.getString("label.fetch_das_features")); - fetchDAS.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - fetchDAS_actionPerformed(e); - } - }); - saveDAS.setText(MessageManager.getString("action.save_as_default")); - saveDAS.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - saveDAS_actionPerformed(e); - } - }); - - JPanel dasButtonPanel = new JPanel(); - dasButtonPanel.setBorder(BorderFactory.createEtchedBorder()); - dasSettingsPane.setBorder(null); - cancelDAS.setEnabled(false); - cancelDAS.setText(MessageManager.getString("action.cancel_fetch")); - cancelDAS.addActionListener(new ActionListener() - { - @Override - public void actionPerformed(ActionEvent e) - { - cancelDAS_actionPerformed(e); - } - }); JPanel transPanel = new JPanel(new GridLayout(1, 2)); bigPanel.add(transPanel, BorderLayout.SOUTH); @@ -1365,172 +1316,11 @@ public class FeatureSettings extends JPanel buttonPanel.add(loadColours); buttonPanel.add(saveColours); bigPanel.add(scrollPane, BorderLayout.CENTER); - dasSettingsPane.add(dasButtonPanel, BorderLayout.SOUTH); - dasButtonPanel.add(fetchDAS); - dasButtonPanel.add(cancelDAS); - dasButtonPanel.add(saveDAS); settingsPane.add(bigPanel, BorderLayout.CENTER); settingsPane.add(buttonPanel, BorderLayout.SOUTH); this.add(settingsPane); } - public void fetchDAS_actionPerformed(ActionEvent e) - { - fetchDAS.setEnabled(false); - cancelDAS.setEnabled(true); - dassourceBrowser.setGuiEnabled(false); - Vector selectedSources = dassourceBrowser - .getSelectedSources(); - doDasFeatureFetch(selectedSources, true, true); - } - - /** - * get the features from selectedSources for all or the current selection - * - * @param selectedSources - * @param checkDbRefs - * @param promptFetchDbRefs - */ - private void doDasFeatureFetch(List selectedSources, - boolean checkDbRefs, boolean promptFetchDbRefs) - { - SequenceI[] dataset, seqs; - int iSize; - AlignmentViewport vp = af.getViewport(); - if (vp.getSelectionGroup() != null - && vp.getSelectionGroup().getSize() > 0) - { - iSize = vp.getSelectionGroup().getSize(); - dataset = new SequenceI[iSize]; - seqs = vp.getSelectionGroup().getSequencesInOrder(vp.getAlignment()); - } - else - { - iSize = vp.getAlignment().getHeight(); - seqs = vp.getAlignment().getSequencesArray(); - } - - dataset = new SequenceI[iSize]; - for (int i = 0; i < iSize; i++) - { - dataset[i] = seqs[i].getDatasetSequence(); - } - - cancelDAS.setEnabled(true); - dasFeatureFetcher = new jalview.ws.DasSequenceFeatureFetcher(dataset, - this, selectedSources, checkDbRefs, promptFetchDbRefs); - af.getViewport().setShowSequenceFeatures(true); - af.showSeqFeatures.setSelected(true); - } - - /** - * blocking call to initialise the das source browser - */ - public void initDasSources() - { - dassourceBrowser.initDasSources(); - } - - /** - * examine the current list of das sources and return any matching the given - * nicknames in sources - * - * @param sources - * Vector of Strings to resolve to DAS source nicknames. - * @return sources that are present in source list. - */ - public List resolveSourceNicknames(Vector sources) - { - return dassourceBrowser.sourceRegistry.resolveSourceNicknames(sources); - } - - /** - * get currently selected das sources. ensure you have called initDasSources - * before calling this. - * - * @return vector of selected das source nicknames - */ - public Vector getSelectedSources() - { - return dassourceBrowser.getSelectedSources(); - } - - /** - * properly initialise DAS fetcher and then initiate a new thread to fetch - * features from the named sources (rather than any turned on by default) - * - * @param sources - * @param block - * if true then runs in same thread, otherwise passes to the Swing - * executor - */ - public void fetchDasFeatures(Vector sources, boolean block) - { - initDasSources(); - List resolved = dassourceBrowser.sourceRegistry - .resolveSourceNicknames(sources); - if (resolved.size() == 0) - { - resolved = dassourceBrowser.getSelectedSources(); - } - if (resolved.size() > 0) - { - final List dassources = resolved; - fetchDAS.setEnabled(false); - // cancelDAS.setEnabled(true); doDasFetch does this. - Runnable fetcher = new Runnable() - { - - @Override - public void run() - { - doDasFeatureFetch(dassources, true, false); - - } - }; - if (block) - { - fetcher.run(); - } - else - { - SwingUtilities.invokeLater(fetcher); - } - } - } - - public void saveDAS_actionPerformed(ActionEvent e) - { - dassourceBrowser - .saveProperties(jalview.bin.Cache.applicationProperties); - } - - public void complete() - { - fetchDAS.setEnabled(true); - cancelDAS.setEnabled(false); - dassourceBrowser.setGuiEnabled(true); - - } - - public void cancelDAS_actionPerformed(ActionEvent e) - { - if (dasFeatureFetcher != null) - { - dasFeatureFetcher.cancel(); - } - complete(); - } - - public void noDasSourceActive() - { - complete(); - JvOptionPane.showInternalConfirmDialog(Desktop.desktop, - MessageManager.getString("label.no_das_sources_selected_warn"), - MessageManager.getString("label.no_das_sources_selected_title"), - JvOptionPane.DEFAULT_OPTION, JvOptionPane.INFORMATION_MESSAGE); - } - // /////////////////////////////////////////////////////////////////////// // http://java.sun.com/docs/books/tutorial/uiswing/components/table.html // /////////////////////////////////////////////////////////////////////// diff --git a/src/jalview/gui/JDatabaseTree.java b/src/jalview/gui/JDatabaseTree.java index 1018d6e..8d62433 100644 --- a/src/jalview/gui/JDatabaseTree.java +++ b/src/jalview/gui/JDatabaseTree.java @@ -20,7 +20,6 @@ */ package jalview.gui; -import jalview.bin.Cache; import jalview.util.MessageManager; import jalview.ws.seqfetcher.DbSourceProxy; @@ -42,7 +41,6 @@ import java.util.List; import java.util.Vector; import javax.swing.JButton; -import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; @@ -518,54 +516,6 @@ public class JDatabaseTree extends JalviewDialog implements KeyListener lstners.remove(actionListener); } - public static void main(String args[]) - { - Cache.getDasSourceRegistry(); - JDatabaseTree jdt = new JDatabaseTree(new jalview.ws.SequenceFetcher()); - JFrame foo = new JFrame(); - foo.setLayout(new BorderLayout()); - foo.add(jdt.getDatabaseSelectorButton(), BorderLayout.CENTER); - foo.pack(); - foo.setVisible(true); - int nultimes = 5; - final Thread us = Thread.currentThread(); - jdt.addActionListener(new ActionListener() - { - - @Override - public void actionPerformed(ActionEvent e) - { - us.interrupt(); - } - }); - do - { - try - { - Thread.sleep(50); - } catch (InterruptedException x) - { - nultimes--; - if (!jdt.hasSelection()) - { - System.out.println("No Selection"); - } - else - { - System.out.println("Selection: " + jdt.getSelectedItem()); - int s = 1; - for (DbSourceProxy pr : jdt.getSelectedSources()) - { - System.out.println("Source " + s++ + ": " + pr.getDbName() - + " (" + pr.getDbSource() + ") Version " - + pr.getDbVersion() + ". Test:\t" + pr.getTestQuery()); - } - System.out.println("Test queries: " + jdt.getExampleQueries()); - } - } - } while (nultimes > 0 && foo.isVisible()); - foo.setVisible(false); - } @Override public void keyPressed(KeyEvent arg0) diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 3259909..1339d05 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -188,8 +188,6 @@ public class Preferences extends GPreferences JInternalFrame frame; - DasSourceBrowser dasSource; - private WsPreferences wsPrefs; private OptionsParam promptEachTimeOpt = new OptionsParam( @@ -210,8 +208,6 @@ public class Preferences extends GPreferences super(); frame = new JInternalFrame(); frame.setContentPane(this); - dasSource = new DasSourceBrowser(); - dasTab.add(dasSource, BorderLayout.CENTER); wsPrefs = new WsPreferences(); wsTab.add(wsPrefs, BorderLayout.CENTER); int width = 500, height = 450; @@ -917,7 +913,6 @@ public class Preferences extends GPreferences Cache.applicationProperties.setProperty("PAD_GAPS", Boolean.toString(padGaps.isSelected())); - dasSource.saveProperties(Cache.applicationProperties); wsPrefs.updateAndRefreshWsMenuConfig(false); Cache.saveProperties(); Desktop.instance.doConfigureStructurePrefs(); diff --git a/src/jalview/gui/SequenceFetcher.java b/src/jalview/gui/SequenceFetcher.java index f545e70..8754fbb 100755 --- a/src/jalview/gui/SequenceFetcher.java +++ b/src/jalview/gui/SequenceFetcher.java @@ -34,7 +34,6 @@ import jalview.io.gff.SequenceOntologyI; import jalview.util.DBRefUtils; import jalview.util.MessageManager; import jalview.util.Platform; -import jalview.ws.dbsources.das.api.DasSourceRegistryI; import jalview.ws.seqfetcher.DbSourceProxy; import java.awt.BorderLayout; @@ -111,10 +110,6 @@ public class SequenceFetcher extends JPanel implements Runnable private static jalview.ws.SequenceFetcher sfetch = null; - private static long lastDasSourceRegistry = -3; - - private static DasSourceRegistryI dasRegistry = null; - private static boolean _initingFetcher = false; private static Thread initingThread = null; @@ -165,11 +160,7 @@ public class SequenceFetcher extends JPanel implements Runnable Thread.currentThread().hashCode()); } } - if (sfetch == null || dasRegistry != Cache.getDasSourceRegistry() - || lastDasSourceRegistry != (Cache.getDasSourceRegistry() - .getDasRegistryURL() - + Cache.getDasSourceRegistry().getLocalSourceString()) - .hashCode()) + if (sfetch == null) { _initingFetcher = true; initingThread = Thread.currentThread(); @@ -183,16 +174,12 @@ public class SequenceFetcher extends JPanel implements Runnable "status.init_sequence_database_fetchers"), Thread.currentThread().hashCode()); } - dasRegistry = Cache.getDasSourceRegistry(); - dasRegistry.refreshSources(); jalview.ws.SequenceFetcher sf = new jalview.ws.SequenceFetcher(); if (guiWindow != null) { guiWindow.setProgressBar(null, Thread.currentThread().hashCode()); } - lastDasSourceRegistry = (dasRegistry.getDasRegistryURL() - + dasRegistry.getLocalSourceString()).hashCode(); sfetch = sf; _initingFetcher = false; initingThread = null; @@ -564,15 +551,10 @@ public class SequenceFetcher extends JPanel implements Runnable dbeg.setText(MessageManager.formatMessage("label.example_query_param", new String[] { eq })); + // TODO this should be a property of the SequenceFetcher whether commas are and + // colons are allowed in the IDs... + boolean enablePunct = !(eq != null && eq.indexOf(",") > -1); - for (DbSourceProxy dbs : database.getSelectedSources()) - { - if (dbs instanceof jalview.ws.dbsources.das.datamodel.DasSequenceSource) - { - enablePunct = false; - break; - } - } replacePunctuation.setEnabled(enablePunct); } catch (Exception ex) diff --git a/src/jalview/gui/WsJobParameters.java b/src/jalview/gui/WsJobParameters.java index 8377a16..8543827 100644 --- a/src/jalview/gui/WsJobParameters.java +++ b/src/jalview/gui/WsJobParameters.java @@ -954,7 +954,7 @@ public class WsJobParameters extends JPanel implements ItemListener, for (Jws2Instance service : disc.getServices()) { lastserv = service; - if (p >= args.length || service.serviceType.equalsIgnoreCase(args[p])) + if (p >= args.length || service.getName().equalsIgnoreCase(args[p])) { if (lastserv != null) { diff --git a/src/jalview/io/cache/JvCacheableInputBox.java b/src/jalview/io/cache/JvCacheableInputBox.java index a837512..beef3e7 100644 --- a/src/jalview/io/cache/JvCacheableInputBox.java +++ b/src/jalview/io/cache/JvCacheableInputBox.java @@ -23,8 +23,6 @@ package jalview.io.cache; import jalview.bin.Cache; import jalview.util.MessageManager; -import java.awt.Color; -import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; @@ -36,37 +34,22 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Set; -import javax.swing.BorderFactory; import javax.swing.JComboBox; -import javax.swing.JLabel; import javax.swing.JMenuItem; -import javax.swing.JPanel; import javax.swing.JPopupMenu; -import javax.swing.JTextField; import javax.swing.SwingUtilities; -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.PlainDocument; public class JvCacheableInputBox extends JComboBox { private static final long serialVersionUID = 5774610435079326695L; - private static final int INPUT_LIMIT = 2; - private static final int LEFT_BOARDER_WIDTH = 16; private String cacheKey; private AppCache appCache; - private JPanel pnlDefaultCache = new JPanel(); - - private JLabel lblDefaultCacheSize = new JLabel(); - - private JTextField txtDefaultCacheSize = new JTextField(); - private JPopupMenu popup = new JPopupMenu(); private JMenuItem menuItemClearCache = new JMenuItem(); @@ -123,8 +106,8 @@ public class JvCacheableInputBox extends JComboBox } /** - * Method for initialising cache items for a given cache key and populating - * the in-memory cache with persisted cache items + * Method for initialising cache items for a given cache key and populating the + * in-memory cache with persisted cache items * * @param cacheKey */ @@ -144,7 +127,7 @@ public class JvCacheableInputBox extends JComboBox .getAllCachedItemsFor(cacheKey); if (foundCacheItems == null) { - foundCacheItems = new LinkedHashSet(); + foundCacheItems = new LinkedHashSet<>(); } // populate memory cache for (String cacheItem : persistedCacheItems) @@ -159,48 +142,7 @@ public class JvCacheableInputBox extends JComboBox */ private void initCachePopupMenu() { - pnlDefaultCache.setBackground(Color.WHITE); - // pad panel so as to align with other menu items - pnlDefaultCache.setBorder( - BorderFactory.createEmptyBorder(0, LEFT_BOARDER_WIDTH, 0, 0)); - txtDefaultCacheSize.setPreferredSize(new Dimension(45, 20)); - txtDefaultCacheSize.setFont(new java.awt.Font("Verdana", 0, 12)); - lblDefaultCacheSize - .setText(MessageManager.getString("label.default_cache_size")); - lblDefaultCacheSize.setFont(new java.awt.Font("Verdana", 0, 12)); - // Force input to accept only Integer entries up to length - INPUT_LIMIT - txtDefaultCacheSize.setDocument(new PlainDocument() - { - private static final long serialVersionUID = 1L; - - @Override - public void insertString(int offs, String str, AttributeSet a) - throws BadLocationException - { - if (getLength() + str.length() <= INPUT_LIMIT && isInteger(str)) - { - super.insertString(offs, str, a); - } - } - }); - txtDefaultCacheSize.addKeyListener(new java.awt.event.KeyAdapter() - { - @Override - public void keyPressed(KeyEvent e) - { - if (e.getKeyCode() == KeyEvent.VK_ENTER) - { - e.consume(); - updateCache(); - closePopup(); - } - } - }); - - txtDefaultCacheSize.setText(appCache.getCacheLimit(cacheKey)); - pnlDefaultCache.add(lblDefaultCacheSize); menuItemClearCache.setFont(new java.awt.Font("Verdana", 0, 12)); - pnlDefaultCache.add(txtDefaultCacheSize); menuItemClearCache .setText(MessageManager.getString("action.clear_cached_items")); menuItemClearCache.addActionListener(new ActionListener() @@ -215,18 +157,11 @@ public class JvCacheableInputBox extends JComboBox } }); - popup.insert(pnlDefaultCache, 0); popup.add(menuItemClearCache); setComponentPopupMenu(popup); add(popup); } - private void closePopup() - { - popup.setVisible(false); - popup.transferFocus(); - } - /** * Answers true if input text is an integer * @@ -255,10 +190,7 @@ public class JvCacheableInputBox extends JComboBox @Override public void run() { - int userLimit = txtDefaultCacheSize.getText().trim().isEmpty() - ? Integer.valueOf(AppCache.DEFAULT_LIMIT) - : Integer.valueOf(txtDefaultCacheSize.getText()); - int cacheLimit = appCache.updateCacheLimit(cacheKey, userLimit); + int cacheLimit = Integer.parseInt(appCache.getCacheLimit(cacheKey)); String userInput = getUserInput(); if (userInput != null && !userInput.isEmpty()) { @@ -277,7 +209,7 @@ public class JvCacheableInputBox extends JComboBox removeAllItems(); } Set cacheItems = appCache.getAllCachedItemsFor(cacheKey); - List reversedCacheItems = new ArrayList(); + List reversedCacheItems = new ArrayList<>(); reversedCacheItems.addAll(cacheItems); cacheItems = null; Collections.reverse(reversedCacheItems); @@ -326,10 +258,6 @@ public class JvCacheableInputBox extends JComboBox public void persistCache() { appCache.persistCache(cacheKey); - int userLimit = txtDefaultCacheSize.getText().trim().isEmpty() - ? Integer.valueOf(AppCache.DEFAULT_LIMIT) - : Integer.valueOf(txtDefaultCacheSize.getText()); - appCache.updateCacheLimit(cacheKey, userLimit); } /** diff --git a/src/jalview/jbgui/GPreferences.java b/src/jalview/jbgui/GPreferences.java index a3921f6..4e909f1 100755 --- a/src/jalview/jbgui/GPreferences.java +++ b/src/jalview/jbgui/GPreferences.java @@ -292,11 +292,6 @@ public class GPreferences extends JPanel protected JTextField cygwinPath; /* - * DAS Settings tab - */ - protected JPanel dasTab = new JPanel(); - - /* * Web Services tab */ protected JPanel wsTab = new JPanel(); @@ -357,12 +352,6 @@ public class GPreferences extends JPanel tabbedPane.add(initHMMERTab(), MessageManager.getString("label.hmmer")); /* - * See DasSourceBrowser for the real work of configuring this tab. - */ - dasTab.setLayout(new BorderLayout()); - tabbedPane.add(dasTab, MessageManager.getString("label.das_settings")); - - /* * See WsPreferences for the real work of configuring this tab. */ wsTab.setLayout(new BorderLayout()); diff --git a/src/jalview/ws/DBRefFetcher.java b/src/jalview/ws/DBRefFetcher.java index 1677eca..061e70c 100644 --- a/src/jalview/ws/DBRefFetcher.java +++ b/src/jalview/ws/DBRefFetcher.java @@ -28,15 +28,12 @@ import jalview.datamodel.DBRefSource; import jalview.datamodel.Mapping; import jalview.datamodel.SequenceI; import jalview.gui.CutAndPasteTransfer; -import jalview.gui.DasSourceBrowser; import jalview.gui.Desktop; import jalview.gui.FeatureSettings; import jalview.gui.IProgressIndicator; import jalview.gui.OOMWarning; import jalview.util.DBRefUtils; import jalview.util.MessageManager; -import jalview.ws.dbsources.das.api.jalviewSourceI; -import jalview.ws.dbsources.das.datamodel.DasSequenceSource; import jalview.ws.seqfetcher.DbSourceProxy; import java.util.ArrayList; @@ -119,7 +116,7 @@ public class DBRefFetcher implements Runnable DbSourceProxy[] sources, FeatureSettings featureSettings, boolean isNucleotide) { - listeners = new ArrayList(); + listeners = new ArrayList<>(); this.progressWindow = progressIndicatorFrame; alseqs = new SequenceI[seqs.length]; SequenceI[] ds = new SequenceI[seqs.length]; @@ -165,23 +162,7 @@ public class DBRefFetcher implements Runnable { // af.featureSettings_actionPerformed(null); String[] defdb = null; - List selsources = new ArrayList(); - Vector dasselsrc = (featureSettings != null) - ? featureSettings.getSelectedSources() - : new DasSourceBrowser().getSelectedSources(); - - for (jalviewSourceI src : dasselsrc) - { - List sp = src.getSequenceSourceProxies(); - if (sp != null) - { - selsources.addAll(sp); - if (sp.size() > 1) - { - Cache.log.debug("Added many Db Sources for :" + src.getTitle()); - } - } - } + List selsources = new ArrayList<>(); // select appropriate databases based on alignFrame context. if (forNucleotide) { @@ -191,7 +172,7 @@ public class DBRefFetcher implements Runnable { defdb = DBRefSource.PROTEINDBS; } - List srces = new ArrayList(); + List srces = new ArrayList<>(); for (String ddb : defdb) { List srcesfordb = sfetcher.getSourceProxy(ddb); @@ -235,30 +216,6 @@ public class DBRefFetcher implements Runnable } /** - * retrieve all the das sequence sources and add them to the list of db - * sources to retrieve from - */ - public void appendAllDasSources() - { - if (dbSources == null) - { - dbSources = new DbSourceProxy[0]; - } - // append additional sources - DbSourceProxy[] otherdb = sfetcher - .getDbSourceProxyInstances(DasSequenceSource.class); - if (otherdb != null && otherdb.length > 0) - { - DbSourceProxy[] newsrc = new DbSourceProxy[dbSources.length - + otherdb.length]; - System.arraycopy(dbSources, 0, newsrc, 0, dbSources.length); - System.arraycopy(otherdb, 0, newsrc, dbSources.length, - otherdb.length); - dbSources = newsrc; - } - } - - /** * start the fetcher thread * * @param waitTillFinished @@ -311,14 +268,14 @@ public class DBRefFetcher implements Runnable } else if (seqs == null) { - seqs = new Vector(); + seqs = new Vector<>(); seqs.addElement(seq); } } else { - seqs = new Vector(); + seqs = new Vector<>(); seqs.addElement(seq); } @@ -357,9 +314,9 @@ public class DBRefFetcher implements Runnable e.printStackTrace(); } - Vector sdataset = new Vector( + Vector sdataset = new Vector<>( Arrays.asList(dataset)); - List warningMessages = new ArrayList(); + List warningMessages = new ArrayList<>(); int db = 0; while (sdataset.size() > 0 && db < dbSources.length) @@ -371,8 +328,8 @@ public class DBRefFetcher implements Runnable SequenceI[] currSeqs = new SequenceI[sdataset.size()]; sdataset.copyInto(currSeqs);// seqs that are to be validated against // dbSources[db] - Vector queries = new Vector(); // generated queries curSeq - seqRefs = new Hashtable>(); + Vector queries = new Vector<>(); // generated queries curSeq + seqRefs = new Hashtable<>(); int seqIndex = 0; @@ -574,7 +531,7 @@ public class DBRefFetcher implements Runnable { // Work out which sequences this sequence matches, // taking into account all accessionIds and names in the file - Vector sequenceMatches = new Vector(); + Vector sequenceMatches = new Vector<>(); // look for corresponding accession ids DBRefEntry[] entryRefs = DBRefUtils .selectRefs(retrievedSeq.getDBRefs(), new String[] @@ -826,7 +783,7 @@ public class DBRefFetcher implements Runnable */ private SequenceI[] recoverDbSequences(SequenceI[] sequencesArray) { - Vector nseq = new Vector(); + Vector nseq = new Vector<>(); for (int i = 0; sequencesArray != null && i < sequencesArray.length; i++) { diff --git a/src/jalview/ws/DasSequenceFeatureFetcher.java b/src/jalview/ws/DasSequenceFeatureFetcher.java deleted file mode 100644 index c661e2c..0000000 --- a/src/jalview/ws/DasSequenceFeatureFetcher.java +++ /dev/null @@ -1,925 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.ws; - -import jalview.bin.Cache; -import jalview.datamodel.DBRefEntry; -import jalview.datamodel.DBRefSource; -import jalview.datamodel.SequenceFeature; -import jalview.datamodel.SequenceI; -import jalview.gui.AlignFrame; -import jalview.gui.Desktop; -import jalview.gui.FeatureSettings; -import jalview.gui.JvOptionPane; -import jalview.util.DBRefUtils; -import jalview.util.MessageManager; -import jalview.util.UrlLink; -import jalview.ws.dbsources.das.api.DasSourceRegistryI; -import jalview.ws.dbsources.das.api.jalviewSourceI; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.biodas.jdas.client.FeaturesClient; -import org.biodas.jdas.client.adapters.features.DasGFFAdapter; -import org.biodas.jdas.client.adapters.features.DasGFFAdapter.GFFAdapter; -import org.biodas.jdas.client.threads.FeaturesClientMultipleSources; -import org.biodas.jdas.schema.features.ERRORSEGMENT; -import org.biodas.jdas.schema.features.FEATURE; -import org.biodas.jdas.schema.features.LINK; -import org.biodas.jdas.schema.features.SEGMENT; -import org.biodas.jdas.schema.features.TYPE; -import org.biodas.jdas.schema.features.UNKNOWNFEATURE; -import org.biodas.jdas.schema.features.UNKNOWNSEGMENT; -import org.biodas.jdas.schema.sources.COORDINATES; - -/** - * DOCUMENT ME! - * - * @author $author$ - * @version $Revision$ - */ -public class DasSequenceFeatureFetcher -{ - SequenceI[] sequences; - - AlignFrame af; - - FeatureSettings fsettings; - - StringBuffer sbuffer = new StringBuffer(); - - List selectedSources; - - boolean cancelled = false; - - private void debug(String mesg) - { - debug(mesg, null); - } - - private void debug(String mesg, Exception e) - { - if (Cache.log != null) - { - Cache.log.debug(mesg, e); - } - else - { - System.err.println(mesg); - if (e != null) - { - e.printStackTrace(); - } - } - } - - long startTime; - - private DasSourceRegistryI sourceRegistry; - - private boolean useJDASMultiThread = true; - - /** - * Creates a new SequenceFeatureFetcher object. Uses default - * - * @param align - * DOCUMENT ME! - * @param ap - * DOCUMENT ME! - */ - public DasSequenceFeatureFetcher(SequenceI[] sequences, - FeatureSettings fsettings, Vector selectedSources) - { - this(sequences, fsettings, selectedSources, true, true, true); - } - - public DasSequenceFeatureFetcher(SequenceI[] oursequences, - FeatureSettings fsettings, List selectedSources2, - boolean checkDbrefs, boolean promptFetchDbrefs) - { - this(oursequences, fsettings, selectedSources2, checkDbrefs, - promptFetchDbrefs, true); - } - - public DasSequenceFeatureFetcher(SequenceI[] oursequences, - FeatureSettings fsettings, List selectedSources2, - boolean checkDbrefs, boolean promptFetchDbrefs, - boolean useJDasMultiThread) - { - this.useJDASMultiThread = useJDasMultiThread; - this.selectedSources = new ArrayList<>(); - // filter both sequences and sources to eliminate duplicates - for (jalviewSourceI src : selectedSources2) - { - if (!selectedSources.contains(src)) - { - selectedSources.add(src); - } - ; - } - Vector sqs = new Vector(); - for (int i = 0; i < oursequences.length; i++) - { - if (!sqs.contains(oursequences[i])) - { - sqs.addElement(oursequences[i]); - } - } - sequences = new SequenceI[sqs.size()]; - for (int i = 0; i < sequences.length; i++) - { - sequences[i] = (SequenceI) sqs.elementAt(i); - } - if (fsettings != null) - { - this.fsettings = fsettings; - this.af = fsettings.af; - af.setShowSeqFeatures(true); - } - int uniprotCount = 0; - for (jalviewSourceI source : selectedSources) - { - for (COORDINATES coords : source.getVersion().getCOORDINATES()) - { - // TODO: match UniProt coord system canonically (?) - does - // UniProt==uniprot==UNIPROT ? - if (coords.getAuthority().toLowerCase().equals("uniprot")) - { - uniprotCount++; - break; - } - } - } - - int refCount = 0; - for (int i = 0; i < sequences.length; i++) - { - DBRefEntry[] dbref = sequences[i].getDBRefs(); - if (dbref != null) - { - for (int j = 0; j < dbref.length; j++) - { - if (dbref[j].getSource().equals(DBRefSource.UNIPROT)) - { - refCount++; - break; - } - } - } - } - - if (checkDbrefs && refCount < sequences.length && uniprotCount > 0) - { - - int reply = JvOptionPane.YES_OPTION; - if (promptFetchDbrefs) - { - reply = JvOptionPane.showInternalConfirmDialog(Desktop.desktop, - MessageManager.getString( - "info.you_want_jalview_to_find_uniprot_accessions"), - MessageManager - .getString("label.find_uniprot_accession_ids"), - JvOptionPane.YES_NO_OPTION, JvOptionPane.QUESTION_MESSAGE); - } - - if (reply == JvOptionPane.YES_OPTION) - { - Thread thread = new Thread(new FetchDBRefs()); - thread.start(); - } - else - { - _startFetching(); - } - } - else - { - _startFetching(); - } - - } - - private void _startFetching() - { - running = true; - new Thread(new FetchSeqFeatures()).start(); - } - - class FetchSeqFeatures implements Runnable - { - @Override - public void run() - { - startFetching(); - setGuiFetchComplete(); - } - } - - class FetchDBRefs implements Runnable - { - @Override - public void run() - { - running = true; - boolean isNucleotide = af.getViewport().getAlignment().isNucleotide(); - new DBRefFetcher(sequences, af, null, af.featureSettings, - isNucleotide).fetchDBRefs(true); - - startFetching(); - setGuiFetchComplete(); - } - } - - /** - * Spawns Fetcher threads to add features to sequences in the dataset - */ - void startFetching() - { - running = true; - cancelled = false; - startTime = System.currentTimeMillis(); - if (af != null) - { - af.setProgressBar(MessageManager.getString( - "status.fetching_das_sequence_features"), startTime); - } - if (sourceRegistry == null) - { - sourceRegistry = Cache.getDasSourceRegistry(); - } - if (selectedSources == null || selectedSources.size() == 0) - { - try - { - jalviewSourceI[] sources = sourceRegistry.getSources() - .toArray(new jalviewSourceI[0]); - String active = Cache.getDefault("DAS_ACTIVE_SOURCE", "uniprot"); - StringTokenizer st = new StringTokenizer(active, "\t"); - selectedSources = new Vector(); - String token; - while (st.hasMoreTokens()) - { - token = st.nextToken(); - for (int i = 0; i < sources.length; i++) - { - if (sources[i].getTitle().equals(token)) - { - selectedSources.add(sources[i]); - break; - } - } - } - } catch (Exception ex) - { - debug("Exception whilst setting default feature sources from registry and local preferences.", - ex); - } - } - - if (selectedSources == null || selectedSources.size() == 0) - { - System.out.println("No DAS Sources active"); - cancelled = true; - setGuiNoDassourceActive(); - return; - } - - sourcesRemaining = selectedSources.size(); - FeaturesClientMultipleSources fc = new FeaturesClientMultipleSources(); - fc.setConnProps(sourceRegistry.getSessionHandler()); - // Now sending requests one at a time to each server - ArrayList srcobj = new ArrayList<>(); - ArrayList src = new ArrayList<>(); - List> ids = new ArrayList<>(); - List> idobj = new ArrayList<>(); - List> sqset = new ArrayList<>(); - for (jalviewSourceI _sr : selectedSources) - { - - Map slist = new HashMap<>(); - List idob = new ArrayList<>(); - List qset = new ArrayList<>(); - - for (SequenceI seq : sequences) - { - Object[] idset = nextSequence(_sr, seq); - if (idset != null) - { - List _idob = (List) idset[0]; - List _qset = (List) idset[1]; - if (_idob.size() > 0) - { - // add sequence's ref for each id derived from it - // (space inefficient, but most unambiguous) - // could replace with hash with _qset values as keys. - Iterator dbobj = _idob.iterator(); - for (String q : _qset) - { - SequenceI osq = slist.get(q); - DBRefEntry dr = dbobj.next(); - if (osq != null && osq != seq) - { - // skip - non-canonical query - } - else - { - idob.add(dr); - qset.add(q); - slist.put(q, seq); - } - } - } - } - } - if (idob.size() > 0) - { - srcobj.add(_sr); - src.add(_sr.getSourceURL()); - ids.add(qset); - idobj.add(idob); - sqset.add(slist); - } - } - Map, Exception>> errors = new HashMap<>(); - Map, DasGFFAdapter>> results = new HashMap<>(); - if (!useJDASMultiThread) - { - Iterator sources = src.iterator(); - // iterate over each query for each source and do each one individually - for (List idl : ids) - { - String source = sources.next(); - FeaturesClient featuresc = new FeaturesClient( - sourceRegistry.getSessionHandler() - .getConnectionPropertyProviderFor(source)); - for (String id : idl) - { - List qid = Arrays.asList(new String[] { id }); - try - { - DasGFFAdapter dga = featuresc.fetchData(source, qid); - Map, DasGFFAdapter> ers = results.get(source); - if (ers == null) - { - results.put(source, - ers = new HashMap<>()); - } - ers.put(qid, dga); - } catch (Exception ex) - { - Map, Exception> ers = errors.get(source); - if (ers == null) - { - errors.put(source, - ers = new HashMap<>()); - } - ers.put(qid, ex); - } - } - } - } - else - { - // pass them all at once - fc.fetchData(src, ids, false, results, errors); - fc.shutDown(); - while (!fc.isTerminated()) - { - try - { - Thread.sleep(200); - } catch (InterruptedException x) - { - - } - } - } - Iterator> idset = ids.iterator(); - Iterator> idobjset = idobj.iterator(); - Iterator> seqset = sqset.iterator(); - for (jalviewSourceI source : srcobj) - { - processResponse(seqset.next(), source, idset.next(), idobjset.next(), - results.get(source.getSourceURL()), - errors.get(source.getSourceURL())); - } - } - - private void processResponse(Map sequencemap, - jalviewSourceI jvsource, List ids, List idobj, - Map, DasGFFAdapter> results, - Map, Exception> errors) - { - Set sequences = new HashSet<>(); - String source = jvsource.getSourceURL(); - // process features - DasGFFAdapter result = (results == null) ? null : results.get(ids); - Exception error = (errors == null) ? null : errors.get(ids); - if (result == null) - { - debug("das source " + source + " could not be contacted. " - + (error == null ? "" : error.toString())); - } - else - { - - GFFAdapter gff = result.getGFF(); - List segments = gff.getSegments(); - List errorsegs = gff.getErrorSegments(); - List unkfeats = gff.getUnknownFeatures(); - List unksegs = gff.getUnknownSegments(); - debug("das source " + source + " returned " + gff.getTotal() - + " responses. " + (errorsegs != null ? errorsegs.size() : 0) - + " were incorrect segment queries, " - + (unkfeats != null ? unkfeats.size() : 0) - + " were unknown features " - + (unksegs != null ? unksegs.size() : 0) - + " were unknown segments and " - + (segments != null ? segments.size() : 0) - + " were segment responses."); - Iterator dbr = idobj.iterator(); - if (segments != null) - { - for (SEGMENT seg : segments) - { - String id = seg.getId(); - if (ids.indexOf(id) == -1) - { - id = id.toUpperCase(); - } - DBRefEntry dbref = idobj.get(ids.indexOf(id)); - SequenceI sequence = sequencemap.get(id); - boolean added = false; - sequences.add(sequence); - - for (FEATURE feat : seg.getFEATURE()) - { - // standard DAS feature-> jalview sequence feature transformation - SequenceFeature f = newSequenceFeature(feat, - jvsource.getTitle()); - if (!parseSeqFeature(sequence, f, feat, jvsource)) - { - if (dbref.getMap() != null && f.getBegin() > 0 - && f.getEnd() > 0) - { - debug("mapping from " + f.getBegin() + " - " + f.getEnd()); - SequenceFeature vf[] = null; - - try - { - vf = dbref.getMap().locateFeature(f); - } catch (Exception ex) - { - Cache.log.warn( - "Error in 'experimental' mapping of features. Please try to reproduce and then report info to jalview-discuss@jalview.org."); - Cache.log.warn("Mapping feature from " + f.getBegin() - + " to " + f.getEnd() + " in dbref " - + dbref.getAccessionId() + " in " - + dbref.getSource()); - Cache.log.warn("using das Source " + source); - Cache.log.warn("Exception", ex); - } - - if (vf != null) - { - for (int v = 0; v < vf.length; v++) - { - debug("mapping to " + v + ": " + vf[v].getBegin() - + " - " + vf[v].getEnd()); - sequence.addSequenceFeature(vf[v]); - } - } - } - else - { - sequence.addSequenceFeature(f); - } - } - } - } - featuresAdded(sequences); - } - else - { - // System.out.println("No features found for " + seq.getName() - // + " from: " + e.getDasSource().getNickname()); - } - } - } - - private void setGuiNoDassourceActive() - { - - if (af != null) - { - af.setProgressBar( - MessageManager.getString("status.no_das_sources_active"), - startTime); - } - if (getFeatSettings() != null) - { - fsettings.noDasSourceActive(); - } - } - - /** - * Update our fsettings dialog reference if we didn't have one when we were - * first initialised. - * - * @return fsettings - */ - private FeatureSettings getFeatSettings() - { - if (fsettings == null) - { - if (af != null) - { - fsettings = af.featureSettings; - } - } - return fsettings; - } - - public void cancel() - { - if (af != null) - { - af.setProgressBar(MessageManager.getString( - "status.das_feature_fetching_cancelled"), startTime); - } - cancelled = true; - } - - int sourcesRemaining = 0; - - private boolean running = false; - - private void setGuiFetchComplete() - { - running = false; - if (!cancelled && af != null) - { - // only update the progress bar if we've completed the fetch normally - af.setProgressBar(MessageManager.getString( - "status.das_feature_fetching_complete"), startTime); - } - - if (af != null && af.featureSettings != null) - { - af.featureSettings.discoverAllFeatureData(); - } - - if (getFeatSettings() != null) - { - fsettings.complete(); - } - } - - void featuresAdded(Set seqs) - { - if (af == null) - { - // no gui to update with features. - return; - } - af.getFeatureRenderer().featuresAdded(); - - int start = af.getViewport().getRanges().getStartSeq(); - int end = af.getViewport().getRanges().getEndSeq(); - int index; - for (index = start; index < end; index++) - { - for (SequenceI seq : seqs) - { - if (seq == af.getViewport().getAlignment().getSequenceAt(index) - .getDatasetSequence()) - { - af.alignPanel.paintAlignment(true, true); - index = end; - break; - } - } - } - } - - Object[] nextSequence(jalviewSourceI dasSource, SequenceI seq) - { - if (cancelled) - { - return null; - } - DBRefEntry[] uprefs = DBRefUtils.selectRefs(seq.getDBRefs(), - new String[] - { - // jalview.datamodel.DBRefSource.PDB, - DBRefSource.UNIPROT, - // jalview.datamodel.DBRefSource.EMBL - not tested on any EMBL coord - // sys sources - }); - // TODO: minimal list of DAS queries to make by querying with untyped ID if - // distinct from any typed IDs - - List ids = new ArrayList<>(); - List qstring = new ArrayList<>(); - boolean dasCoordSysFound = false; - - if (uprefs != null) - { - // do any of these ids match the source's coordinate system ? - for (int j = 0; !dasCoordSysFound && j < uprefs.length; j++) - { - - for (COORDINATES csys : dasSource.getVersion().getCOORDINATES()) - { - if (DBRefUtils.isDasCoordinateSystem(csys.getAuthority(), - uprefs[j])) - { - debug("Launched fetcher for coordinate system " - + csys.getAuthority()); - // Will have to pass any mapping information to the fetcher - // - the start/end for the DBRefEntry may not be the same as the - // sequence's start/end - - System.out.println( - seq.getName() + " " + (seq.getDatasetSequence() == null) - + " " + csys.getUri()); - - dasCoordSysFound = true; // break's out of the loop - ids.add(uprefs[j]); - qstring.add(uprefs[j].getAccessionId()); - } - else - { - System.out.println("IGNORE " + csys.getAuthority()); - } - } - } - } - - if (!dasCoordSysFound) - { - String id = null; - // try and use the name as the sequence id - if (seq.getName().indexOf("|") > -1) - { - id = seq.getName().substring(seq.getName().lastIndexOf("|") + 1); - if (id.trim().length() < 4) - { - // hack - we regard a significant ID as being at least 4 - // non-whitespace characters - id = seq.getName().substring(0, seq.getName().lastIndexOf("|")); - if (id.indexOf("|") > -1) - { - id = id.substring(id.lastIndexOf("|") + 1); - } - } - } - else - { - id = seq.getName(); - } - if (id != null) - { - DBRefEntry dbre = new DBRefEntry(); - dbre.setAccessionId(id); - // Should try to call a general feature fetcher that - // queries many sources with name to discover applicable ID references - ids.add(dbre); - qstring.add(dbre.getAccessionId()); - } - } - - return new Object[] { ids, qstring }; - } - - /** - * examine the given sequence feature to determine if it should actually be - * turned into sequence annotation or database cross references rather than a - * simple sequence feature. - * - * @param seq - * the sequence to annotate - * @param f - * the jalview sequence feature generated from the DAS feature - * @param map - * the sequence feature attributes - * @param source - * the source that emitted the feature - * @return true if feature was consumed as another kind of annotation. - */ - protected boolean parseSeqFeature(SequenceI seq, SequenceFeature f, - FEATURE feature, jalviewSourceI source) - { - SequenceI mseq = seq; - while (seq.getDatasetSequence() != null) - { - seq = seq.getDatasetSequence(); - } - if (f.getType() != null) - { - String type = f.getType(); - if (type.equalsIgnoreCase("protein_name")) - { - // parse name onto the alignment sequence or the dataset sequence. - if (seq.getDescription() == null - || seq.getDescription().trim().length() == 0) - { - // could look at the note series to pick out the first long name, for - // the moment just use the whole description string - seq.setDescription(f.getDescription()); - } - if (mseq.getDescription() == null - || mseq.getDescription().trim().length() == 0) - { - // could look at the note series to pick out the first long name, for - // the moment just use the whole description string - mseq.setDescription(f.getDescription()); - } - return true; - } - // check if source has biosapiens or other sequence ontology label - if (type.equalsIgnoreCase("DBXREF") || type.equalsIgnoreCase("DBREF")) - { - // try to parse the accession out - - DBRefEntry dbr = new DBRefEntry(); - dbr.setVersion(source.getTitle()); - StringTokenizer st = new StringTokenizer(f.getDescription(), ":"); - if (st.hasMoreTokens()) - { - dbr.setSource(st.nextToken()); - } - if (st.hasMoreTokens()) - { - dbr.setAccessionId(st.nextToken()); - } - seq.addDBRef(dbr); - - if (f.links != null && f.links.size() > 0) - { - // feature is also appended to enable links to be seen. - // TODO: consider extending dbrefs to have their own links ? - // TODO: new feature: extract dbref links from DAS servers and add the - // URL pattern to the list of DB name associated links in the user's - // preferences ? - // for the moment - just fix up the existing feature so it displays - // correctly. - // f.setType(dbr.getSource()); - // f.setDescription(); - f.setValue("linkonly", Boolean.TRUE); - // f.setDescription(""); - Vector newlinks = new Vector(); - Enumeration it = f.links.elements(); - while (it.hasMoreElements()) - { - String elm; - UrlLink urllink = new UrlLink(elm = (String) it.nextElement()); - if (urllink.isValid()) - { - urllink.setLabel(f.getDescription()); - newlinks.addElement(urllink.toString()); - } - else - { - // couldn't parse the link properly. Keep it anyway - just in - // case. - debug("couldn't parse link string - " + elm); - newlinks.addElement(elm); - } - } - f.links = newlinks; - seq.addSequenceFeature(f); - } - return true; - } - } - return false; - } - - /** - * creates a jalview sequence feature from a das feature document - * - * @param feat - * @return sequence feature object created using dasfeature information - */ - SequenceFeature newSequenceFeature(FEATURE feat, String nickname) - { - if (feat == null) - { - return null; - } - try - { - /** - * Different qNames for a DAS Feature - are string keys to the HashMaps in - * features "METHOD") || qName.equals("TYPE") || qName.equals("START") || - * qName.equals("END") || qName.equals("NOTE") || qName.equals("LINK") || - * qName.equals("SCORE") - */ - String desc = new String(); - if (feat.getNOTE() != null) - { - for (String note : feat.getNOTE()) - { - desc += note; - } - } - - int start = 0, end = 0; - float score = 0f; - - try - { - start = Integer.parseInt(feat.getSTART().toString()); - } catch (Exception ex) - { - } - try - { - end = Integer.parseInt(feat.getEND().toString()); - } catch (Exception ex) - { - } - try - { - Object scr = feat.getSCORE(); - if (scr != null) - { - score = (float) Double.parseDouble(scr.toString()); - - } - } catch (Exception ex) - { - } - - SequenceFeature f = new SequenceFeature(getTypeString(feat.getTYPE()), - desc, start, end, score, nickname); - - if (feat.getLINK() != null) - { - for (LINK link : feat.getLINK()) - { - // Do not put feature extent in link text for non-positional features - if (f.begin == 0 && f.end == 0) - { - f.addLink(f.getType() + " " + link.getContent() + "|" - + link.getHref()); - } - else - { - f.addLink(f.getType() + " " + f.begin + "_" + f.end + " " - + link.getContent() + "|" + link.getHref()); - } - } - } - - return f; - } catch (Exception e) - { - System.out.println("ERRR " + e); - e.printStackTrace(); - System.out.println("############"); - debug("Failed to parse " + feat.toString(), e); - return null; - } - } - - private String getTypeString(TYPE type) - { - return type.getContent(); - } - - public boolean isRunning() - { - return running; - } - -} diff --git a/src/jalview/ws/SequenceFetcher.java b/src/jalview/ws/SequenceFetcher.java index a0b77de..29d4ec7 100644 --- a/src/jalview/ws/SequenceFetcher.java +++ b/src/jalview/ws/SequenceFetcher.java @@ -29,12 +29,10 @@ import jalview.ws.dbsources.PfamFull; import jalview.ws.dbsources.PfamSeed; import jalview.ws.dbsources.RfamSeed; import jalview.ws.dbsources.Uniprot; -import jalview.ws.dbsources.das.api.jalviewSourceI; import jalview.ws.seqfetcher.ASequenceFetcher; import jalview.ws.seqfetcher.DbSourceProxy; import java.util.ArrayList; -import java.util.List; /** * This implements the run-time discovery of sequence database clients. @@ -50,11 +48,6 @@ public class SequenceFetcher extends ASequenceFetcher */ public SequenceFetcher() { - this(true); - } - - public SequenceFetcher(boolean addDas) - { addDBRefSourceImpl(EnsemblGene.class); addDBRefSourceImpl(EnsemblGenomes.class); addDBRefSourceImpl(EmblSource.class); @@ -64,26 +57,19 @@ public class SequenceFetcher extends ASequenceFetcher addDBRefSourceImpl(PfamFull.class); addDBRefSourceImpl(PfamSeed.class); addDBRefSourceImpl(RfamSeed.class); - - if (addDas) - { - registerDasSequenceSources(); - } } /** - * return an ordered list of database sources where non-das database classes - * appear before das database classes + * return an ordered list of database sources excluding alignment only databases */ public String[] getOrderedSupportedSources() { String[] srcs = this.getSupportedDb(); - ArrayList dassrc = new ArrayList(), - nondas = new ArrayList(); + ArrayList src = new ArrayList<>(); + for (int i = 0; i < srcs.length; i++) { - boolean das = false, skip = false; - String nm; + boolean skip = false; for (DbSourceProxy dbs : getSourceProxy(srcs[i])) { // Skip the alignment databases for the moment - they're not useful for @@ -92,86 +78,28 @@ public class SequenceFetcher extends ASequenceFetcher { skip = true; } - else - { - nm = dbs.getDbName(); - if (getSourceProxy( - srcs[i]) instanceof jalview.ws.dbsources.das.datamodel.DasSequenceSource) - { - if (nm.startsWith("das:")) - { - nm = nm.substring(4); - das = true; - } - break; - } - } } if (skip) { continue; } - if (das) { - dassrc.add(srcs[i]); - } - else - { - nondas.add(srcs[i]); + src.add(srcs[i]); } } - String[] tosort = nondas.toArray(new String[0]), - sorted = nondas.toArray(new String[0]); + String[] tosort = src.toArray(new String[0]), + sorted = src.toArray(new String[0]); for (int j = 0, jSize = sorted.length; j < jSize; j++) { tosort[j] = tosort[j].toLowerCase(); } jalview.util.QuickSort.sort(tosort, sorted); // construct array with all sources listed - - srcs = new String[sorted.length + dassrc.size()]; int i = 0; for (int j = sorted.length - 1; j >= 0; j--, i++) { srcs[i] = sorted[j]; - sorted[j] = null; - } - - sorted = dassrc.toArray(new String[0]); - tosort = dassrc.toArray(new String[0]); - for (int j = 0, jSize = sorted.length; j < jSize; j++) - { - tosort[j] = tosort[j].toLowerCase(); - } - jalview.util.QuickSort.sort(tosort, sorted); - for (int j = sorted.length - 1; j >= 0; j--, i++) - { - srcs[i] = sorted[j]; } return srcs; } - - /** - * query the currently defined DAS source registry for sequence sources and - * add a DasSequenceSource instance for each source to the SequenceFetcher - * source list. - */ - public void registerDasSequenceSources() - { - // TODO: define a context as a registry provider (either desktop, - // jalview.bin.cache, or something else). - for (jalviewSourceI source : jalview.bin.Cache.getDasSourceRegistry() - .getSources()) - { - if (source.isSequenceSource()) - { - List dassources = source.getSequenceSourceProxies(); - for (DbSourceProxy seqsrc : dassources) - { - addDbRefSourceImpl(seqsrc); - } - } - } - } - } diff --git a/src/jalview/ws/api/UIinfo.java b/src/jalview/ws/api/UIinfo.java new file mode 100644 index 0000000..cf44266 --- /dev/null +++ b/src/jalview/ws/api/UIinfo.java @@ -0,0 +1,123 @@ +package jalview.ws.api; + +/** + * Service UI Info { Action, Specific Name of Service, Brief Description } + */ + +public class UIinfo +{ + private String ServiceType; + + public UIinfo(String serviceType, String action, String name, + String description, String hosturl) + { + this.setServiceType(serviceType == null ? "" : serviceType); + this.Action = action == null ? "" : action; + this.description = description == null ? "" : description; + this.Name = name == null ? "" : name; + this.hostURL = hosturl; + } + + /** + * The type of analysis the service performs + */ + public String getServiceType() + { + return ServiceType; + } + + public void setServiceType(String serviceType) + { + ServiceType = serviceType; + } + + /** + * The action when the service performs the analysis + */ + public String getAction() + { + return Action; + } + + public void setAction(String action) + { + Action = action; + } + + /** + * name shown to user + * + * @return + */ + public String getName() + { + return Name; + } + + public void setName(String name) + { + Name = name; + } + + /** + * Detailed description (may include references, URLs, html,etc) + * + * @return + */ + public String getDescription() + { + return description; + } + + public void setDescription(String description) + { + this.description = description; + } + + @Override + public boolean equals(Object object) + { + if (object == null || !(object instanceof UIinfo)) + { + return false; + } + UIinfo other = (UIinfo) object; + + return (ServiceType == null && other.getServiceType() == null + || ServiceType != null && other.getServiceType() != null + && ServiceType.equals(other.getServiceType())) + && (hostURL == null && other.getHostURL() == null + || hostURL != null && other.getHostURL() != null + && hostURL.equals(other.getHostURL())) + && (Name == null && other.getName() == null + || Name != null && other.getName() != null + && Name.equals(other.getName())) + && (Action == null && other.getAction() == null + || Action != null && other.getAction() != null + && Action.equals(other.getAction())) + && (description == null && other.getDescription() == null + || description != null && other.getDescription() != null + && description.equals(other.getDescription())); + } + + /** + * @return short description of what the service will do + */ + public String getActionText() + { + return getAction() + " with " + getName(); + } + + String Action; + + String Name; + + String description; + + String hostURL; + + public String getHostURL() + { + return hostURL; + } +} \ No newline at end of file diff --git a/src/jalview/ws/dbsources/das/api/DasSourceRegistryI.java b/src/jalview/ws/dbsources/das/api/DasSourceRegistryI.java deleted file mode 100644 index 55c50b2..0000000 --- a/src/jalview/ws/dbsources/das/api/DasSourceRegistryI.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.ws.dbsources.das.api; - -import java.util.List; - -import org.biodas.jdas.client.threads.MultipleConnectionPropertyProviderI; - -/** - * API for a registry that provides datasources that jalview can access - * - * @author jprocter - * - */ -public interface DasSourceRegistryI -{ - - List getSources(); - - String getDasRegistryURL(); - - jalviewSourceI getSource(String nickname); - - // TODO: re JAL-424 - introduce form where local source is queried for - // metadata, rather than have it all provided by caller. - jalviewSourceI createLocalSource(String uri, String name, - boolean sequence, boolean features); - - boolean removeLocalSource(jalviewSourceI source); - - void refreshSources(); - - String getLocalSourceString(); - - List resolveSourceNicknames(List sources); - - // TODO: refactor to jDAS specific interface - MultipleConnectionPropertyProviderI getSessionHandler(); -} diff --git a/src/jalview/ws/dbsources/das/api/jalviewSourceI.java b/src/jalview/ws/dbsources/das/api/jalviewSourceI.java deleted file mode 100644 index bc3c8ea..0000000 --- a/src/jalview/ws/dbsources/das/api/jalviewSourceI.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.ws.dbsources.das.api; - -import jalview.ws.seqfetcher.DbSourceProxy; - -import java.util.List; - -import org.biodas.jdas.schema.sources.MAINTAINER; -import org.biodas.jdas.schema.sources.VERSION; - -public interface jalviewSourceI -{ - - String getTitle(); - - VERSION getVersion(); - - String getDocHref(); - - String getDescription(); - - String getUri(); - - MAINTAINER getMAINTAINER(); - - String getEmail(); - - boolean isLocal(); - - boolean isSequenceSource(); - - String[] getCapabilityList(VERSION v); - - String[] getLabelsFor(VERSION v); - - /** - * - * @return null if not a sequence source, otherwise a series of database - * sources that can be used to retrieve sequence data for particular - * database coordinate systems - */ - List getSequenceSourceProxies(); - - boolean isFeatureSource(); - - /** - * returns the base URL for the latest version of a source's DAS endpoint set - * - * @return - */ - String getSourceURL(); - - /** - * test to see if this source's latest version is older than the given source - * - * @param jalviewSourceI - * @return true if newer than given source - */ - boolean isNewerThan(jalviewSourceI jalviewSourceI); - - /** - * test if the source is a reference source for the authority - * - * @return - */ - boolean isReferenceSource(); - -} diff --git a/src/jalview/ws/dbsources/das/datamodel/DasSequenceSource.java b/src/jalview/ws/dbsources/das/datamodel/DasSequenceSource.java deleted file mode 100644 index 84f6d4d..0000000 --- a/src/jalview/ws/dbsources/das/datamodel/DasSequenceSource.java +++ /dev/null @@ -1,354 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.ws.dbsources.das.datamodel; - -import jalview.bin.Cache; -import jalview.datamodel.Alignment; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.DBRefEntry; -import jalview.datamodel.Sequence; -import jalview.datamodel.SequenceI; -import jalview.util.MessageManager; -import jalview.ws.dbsources.das.api.jalviewSourceI; -import jalview.ws.seqfetcher.DbSourceProxy; -import jalview.ws.seqfetcher.DbSourceProxyImpl; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.Vector; - -import org.biodas.jdas.client.SequenceClient; -import org.biodas.jdas.client.adapters.sequence.DasSequenceAdapter; -import org.biodas.jdas.client.threads.MultipleConnectionPropertyProviderI; -import org.biodas.jdas.client.threads.SequenceClientMultipleSources; -import org.biodas.jdas.schema.sequence.SEQUENCE; -import org.biodas.jdas.schema.sources.COORDINATES; -import org.biodas.jdas.schema.sources.SOURCE; -import org.biodas.jdas.schema.sources.VERSION; - -import com.stevesoft.pat.Regex; - -/** - * an instance of this class is created for each unique DAS Sequence source (ie - * one capable of handling the 'sequence' for a particular MapMaster) - * - * @author JimP - * - */ -public class DasSequenceSource extends DbSourceProxyImpl - implements DbSourceProxy -{ - private jalviewSourceI jsrc; - - protected SOURCE source = null; - - protected VERSION version = null; - - protected COORDINATES coordsys = null; - - protected String dbname = "DASCS"; - - protected String dbrefname = "das:source"; - - protected MultipleConnectionPropertyProviderI connprops = null; - - /** - * DAS sources are tier 1 - if we have a direct DB connection then we should - * prefer it - */ - private int tier = 1; - - /** - * create a new DbSource proxy for a DAS 1 source - * - * @param dbnbame - * Human Readable Name to use when fetching from this source - * @param dbrefname - * DbRefName for DbRefs attached to sequences retrieved from this - * source - * @param source - * Das1Source - * @param coordsys - * specific coordinate system to use for this source - * @throws Exception - * if source is not capable of the 'sequence' command - */ - public DasSequenceSource(String dbname, String dbrefname, SOURCE source, - VERSION version, COORDINATES coordsys, - MultipleConnectionPropertyProviderI connprops) throws Exception - { - if (!(jsrc = new JalviewSource(source, connprops, false)) - .isSequenceSource()) - { - throw new Exception(MessageManager.formatMessage( - "exception.das_source_doesnt_support_sequence_command", - new String[] - { source.getTitle() })); - } - this.tier = 1 + ((jsrc.isLocal() || jsrc.isReferenceSource()) ? 0 : 1); - this.source = source; - this.dbname = dbname; - this.dbrefname = dbrefname.toUpperCase(); - if (coordsys != null) - { - this.coordsys = coordsys; - } - this.connprops = connprops; - } - - public String getAccessionSeparator() - { - return "\t"; - } - - public Regex getAccessionValidator() - { - /** ? * */ - return Regex.perlCode("m/([^:]+)(:\\d+,\\d+)?/"); - } - - public String getDbName() - { - // TODO: map to - return dbname + " (DAS)"; - } - - public String getDbSource() - { - return dbrefname; - } - - public String getDbVersion() - { - return coordsys != null ? coordsys.getVersion() : ""; - } - - public AlignmentI getSequenceRecords(String queries) throws Exception - { - StringTokenizer st = new StringTokenizer(queries, "\t"); - List toks = new ArrayList(), - src = new ArrayList(), acIds = new ArrayList(); - while (st.hasMoreTokens()) - { - String t; - toks.add(t = st.nextToken()); - acIds.add(t.replaceAll(":[0-9,]+", "")); - } - src.add(jsrc.getSourceURL()); - Map, DasSequenceAdapter>> resultset = new HashMap, DasSequenceAdapter>>(); - Map, Exception>> errors = new HashMap, Exception>>(); - - // First try multiple sources - boolean multiple = true, retry = false; - do - { - if (!multiple) - { - retry = false; - // slow, fetch one at a time. - for (String sr : src) - { - System.err.println( - "Retrieving IDs individually from das source: " + sr); - org.biodas.jdas.client.SequenceClient sq = new SequenceClient( - connprops.getConnectionPropertyProviderFor(sr)); - for (String q : toks) - { - List qset = Arrays.asList(new String[] { q }); - try - { - DasSequenceAdapter s = sq.fetchData(sr, qset); - Map, DasSequenceAdapter> dss = resultset.get(sr); - if (dss == null) - { - resultset.put(sr, - dss = new HashMap, DasSequenceAdapter>()); - } - dss.put(qset, s); - } catch (Exception x) - { - Map, Exception> ers = errors.get(sr); - if (ers == null) - { - errors.put(sr, - ers = new HashMap, Exception>()); - } - ers.put(qset, x); - } - } - } - } - else - { - SequenceClientMultipleSources sclient; - sclient = new SequenceClientMultipleSources(); - sclient.fetchData(src, toks, resultset, errors); - sclient.shutDown(); - while (!sclient.isTerminated()) - { - try - { - Thread.sleep(200); - - } catch (InterruptedException x) - { - } - } - if (resultset.isEmpty() && !errors.isEmpty()) - { - retry = true; - multiple = false; - } - } - } while (retry); - - if (resultset.isEmpty()) - { - System.err.println("Sequence Query to " + jsrc.getTitle() + " with '" - + queries + "' returned no sequences."); - return null; - } - else - { - Vector seqs = null; - for (Map.Entry, DasSequenceAdapter>> resset : resultset - .entrySet()) - { - for (Map.Entry, DasSequenceAdapter> result : resset - .getValue().entrySet()) - { - DasSequenceAdapter dasseqresp = result.getValue(); - List accessions = result.getKey(); - for (SEQUENCE e : dasseqresp.getSequence()) - { - String lbl = e.getId(); - - if (acIds.indexOf(lbl) == -1) - { - System.err.println( - "Warning - received sequence event for strange accession code (" - + lbl + ")"); - } - else - { - if (seqs == null) - { - if (e.getContent().length() == 0) - { - System.err.println( - "Empty sequence returned for accession code (" - + lbl + ") from " + resset.getKey() - + " (source is " + getDbName()); - continue; - } - } - seqs = new java.util.Vector(); - // JDAS returns a sequence complete with any newlines and spaces - // in the XML - Sequence sq = new Sequence(lbl, - e.getContent().replaceAll("\\s+", "")); - sq.setStart(e.getStart().intValue()); - sq.addDBRef(new DBRefEntry(getDbSource(), - getDbVersion() + ":" + e.getVersion(), lbl)); - seqs.addElement(sq); - } - } - } - } - - if (seqs == null || seqs.size() == 0) - return null; - SequenceI[] sqs = new SequenceI[seqs.size()]; - for (int i = 0, iSize = seqs.size(); i < iSize; i++) - { - sqs[i] = (SequenceI) seqs.elementAt(i); - } - Alignment al = new Alignment(sqs); - if (jsrc.isFeatureSource()) - { - java.util.Vector srcs = new java.util.Vector(); - srcs.addElement(jsrc); - try - { - jalview.ws.DasSequenceFeatureFetcher dssf = new jalview.ws.DasSequenceFeatureFetcher( - sqs, null, srcs, false, false, multiple); - while (dssf.isRunning()) - { - try - { - Thread.sleep(200); - } catch (InterruptedException x) - { - - } - } - - } catch (Exception x) - { - Cache.log.error( - "Couldn't retrieve features for sequence from its source.", - x); - } - } - - return al; - } - } - - public String getTestQuery() - { - return coordsys == null ? "" : coordsys.getTestRange(); - } - - public boolean isValidReference(String accession) - { - // TODO try to validate an accession against source - // We don't really know how to do this without querying source - - return true; - } - - /** - * @return the source - */ - public SOURCE getSource() - { - return source; - } - - /** - * @return the coordsys - */ - public COORDINATES getCoordsys() - { - return coordsys; - } - - @Override - public int getTier() - { - return tier; - } -} diff --git a/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java b/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java deleted file mode 100644 index de7f380..0000000 --- a/src/jalview/ws/dbsources/das/datamodel/DasSourceRegistry.java +++ /dev/null @@ -1,484 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.ws.dbsources.das.datamodel; - -import jalview.bin.Cache; -import jalview.ws.dbsources.das.api.DasSourceRegistryI; -import jalview.ws.dbsources.das.api.jalviewSourceI; - -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Hashtable; -import java.util.List; -import java.util.StringTokenizer; - -import org.biodas.jdas.client.ConnectionPropertyProviderI; -import org.biodas.jdas.client.SourcesClient; -import org.biodas.jdas.client.threads.MultipleConnectionPropertyProviderI; -import org.biodas.jdas.dassources.Capabilities; -import org.biodas.jdas.schema.sources.CAPABILITY; -import org.biodas.jdas.schema.sources.SOURCE; -import org.biodas.jdas.schema.sources.SOURCES; -import org.biodas.jdas.schema.sources.VERSION; - -/** - * - */ -public class DasSourceRegistry - implements DasSourceRegistryI, MultipleConnectionPropertyProviderI -{ - // private org.biodas.jdas.schema.sources.SOURCE[] dasSources = null; - private List dasSources = null; - - private Hashtable sourceNames = null; - - private Hashtable localSources = null; - - // public static String DEFAULT_REGISTRY = "http://www.dasregistry.org/das/"; - public static String DEFAULT_REGISTRY = "http://www.ebi.ac.uk/das-srv/registry/das/"; - - /** - * true if thread is running and we are talking to DAS registry service - */ - private boolean loadingDasSources = false; - - public boolean isLoadingDasSources() - { - return loadingDasSources; - } - - @Override - public String getDasRegistryURL() - { - String registry = jalview.bin.Cache.getDefault("DAS_REGISTRY_URL", - DEFAULT_REGISTRY); - - if (registry.indexOf("/registry/das1/sources/") > -1) - { - jalview.bin.Cache.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL, - DEFAULT_REGISTRY); - registry = DEFAULT_REGISTRY; - } - if (registry.lastIndexOf("sources.xml") == registry.length() - 11) - { - // no trailing sources.xml document for registry in JDAS - jalview.bin.Cache.setProperty(jalview.bin.Cache.DAS_REGISTRY_URL, - registry = registry.substring(0, - registry.lastIndexOf("sources.xml"))); - } - return registry; - } - - /** - * query the default DAS Source Registry for sources. Uses value of jalview - * property DAS_REGISTRY_URL and the DasSourceBrowser.DEFAULT_REGISTRY if that - * doesn't exist. - * - * @return list of sources - */ - private List getDASSources() - { - - return getDASSources(getDasRegistryURL(), this); - } - - /** - * query the given URL for DasSources. - * - * @param registryURL - * return sources from registryURL - */ - private static List getDASSources(String registryURL, - MultipleConnectionPropertyProviderI registry) - { - try - { - URL url = new URL(registryURL); - org.biodas.jdas.client.SourcesClientInterface client = new SourcesClient(); - - SOURCES sources = client.fetchDataRegistry(registryURL, null, null, - null, null, null, null); - - List dassources = sources.getSOURCE(); - ArrayList dsrc = new ArrayList(); - HashMap latests = new HashMap(); - Integer latest; - for (SOURCE src : dassources) - { - JalviewSource jsrc = new JalviewSource(src, registry, false); - latest = latests.get(jsrc.getSourceURL()); - if (latest != null) - { - if (jsrc.isNewerThan(dsrc.get(latest.intValue()))) - { - dsrc.set(latest.intValue(), jsrc); - } - else - { - System.out.println( - "Debug: Ignored older source " + jsrc.getTitle()); - } - } - else - { - latests.put(jsrc.getSourceURL(), Integer.valueOf(dsrc.size())); - dsrc.add(jsrc); - } - } - return dsrc; - } catch (Exception ex) - { - System.out.println( - "DAS1 registry at " + registryURL + " no longer exists"); - return new ArrayList(); - } - } - - public void run() - { - getSources(); - } - - @Override - public List getSources() - { - if (dasSources == null) - { - dasSources = getDASSources(); - } - return appendLocalSources(); - } - - /** - * generate Sources from the local das source list - * - */ - private void addLocalDasSources() - { - if (localSources == null) - { - // get local sources from properties and initialise the local source list - String local = jalview.bin.Cache.getProperty("DAS_LOCAL_SOURCE"); - - if (local != null) - { - int n = 1; - StringTokenizer st = new StringTokenizer(local, "\t"); - while (st.hasMoreTokens()) - { - String token = st.nextToken(); - int bar = token.indexOf("|"); - if (bar == -1) - { - System.err.println( - "Warning: DAS user local source appears to have no nickname (expected a '|' followed by nickname)\nOffending definition: '" - + token + "'"); - } - String url = token.substring(bar + 1); - boolean features = true, sequence = false; - if (url.startsWith("sequence:")) - { - url = url.substring(9); - // this source also serves sequences as well as features - sequence = true; - } - try - { - if (bar > -1) - { - createLocalSource(url, token.substring(0, bar), sequence, - features); - } - else - { - createLocalSource(url, "User Source" + n, sequence, features); - } - } catch (Exception q) - { - System.err.println( - "Unexpected exception when creating local source from '" - + token + "'"); - q.printStackTrace(); - } - n++; - } - } - } - } - - private List appendLocalSources() - { - List srclist = new ArrayList(); - addLocalDasSources(); - sourceNames = new Hashtable(); - if (dasSources != null) - { - for (jalviewSourceI src : dasSources) - { - sourceNames.put(src.getTitle(), src); - srclist.add(src); - } - } - - if (localSources == null) - { - return srclist; - } - Enumeration en = localSources.keys(); - while (en.hasMoreElements()) - { - String key = en.nextElement().toString(); - jalviewSourceI jvsrc = localSources.get(key); - sourceNames.put(key, jvsrc); - srclist.add(jvsrc); - } - return srclist; - } - - /* - * - */ - - @Override - public jalviewSourceI createLocalSource(String url, String name, - boolean sequence, boolean features) - { - SOURCE local = _createLocalSource(url, name, sequence, features); - - if (localSources == null) - { - localSources = new Hashtable(); - } - jalviewSourceI src = new JalviewSource(local, this, true); - localSources.put(local.getTitle(), src); - return src; - } - - private SOURCE _createLocalSource(String url, String name, - boolean sequence, boolean features) - { - SOURCE local = new SOURCE(); - - local.setUri(url); - local.setTitle(name); - local.setVERSION(new ArrayList()); - VERSION v = new VERSION(); - List cp = new ArrayList(); - if (sequence) - { - /* - * Could try and synthesize a coordinate system for the source if needbe - * COORDINATES coord = new COORDINATES(); coord.setAuthority("NCBI"); - * coord.setSource("Chromosome"); coord.setTaxid("9606"); - * coord.setVersion("35"); version.getCOORDINATES().add(coord); - */ - CAPABILITY cap = new CAPABILITY(); - cap.setType("das1:" + Capabilities.SEQUENCE.getName()); - cap.setQueryUri(url + "/sequence"); - cp.add(cap); - } - if (features) - { - CAPABILITY cap = new CAPABILITY(); - cap.setType("das1:" + Capabilities.FEATURES.getName()); - cap.setQueryUri(url + "/features"); - cp.add(cap); - } - - v.getCAPABILITY().addAll(cp); - local.getVERSION().add(v); - - return local; - } - - @Override - public jalviewSourceI getSource(String nickname) - { - return sourceNames.get(nickname); - } - - @Override - public boolean removeLocalSource(jalviewSourceI source) - { - if (localSources.containsValue(source)) - { - localSources.remove(source.getTitle()); - sourceNames.remove(source.getTitle()); - dasSources.remove(source); - jalview.bin.Cache.setProperty("DAS_LOCAL_SOURCE", - getLocalSourceString()); - - return true; - } - return false; - } - - @Override - public void refreshSources() - { - dasSources = null; - sourceNames = null; - run(); - } - - @Override - public List resolveSourceNicknames(List sources) - { - ArrayList resolved = new ArrayList(); - if (sourceNames != null) - { - for (String src : sources) - { - jalviewSourceI dsrc = sourceNames.get(src); - if (dsrc != null) - { - resolved.add(dsrc); - } - } - } - return resolved; - } - - @Override - public String getLocalSourceString() - { - if (localSources != null) - { - StringBuffer sb = new StringBuffer(); - Enumeration en = localSources.keys(); - while (en.hasMoreElements()) - { - String token = en.nextElement().toString(); - jalviewSourceI srco = localSources.get(token); - sb.append(token + "|" + (srco.isSequenceSource() ? "sequence:" : "") - + srco.getUri() + "\t"); - } - return sb.toString(); - } - return ""; - } - - private static final Hashtable authStash; - static - { - authStash = new Hashtable(); - - try - { - // TODO: allow same credentials for https and http - authStash.put( - new URL("http://www.compbio.dundee.ac.uk/geneweb/das/myseq/"), - "Basic SmltOm1pSg=="); - } catch (MalformedURLException e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Override - public MultipleConnectionPropertyProviderI getSessionHandler() - { - return this; - } - - @Override - public ConnectionPropertyProviderI getConnectionPropertyProviderFor( - String arg0) - { - - final ConnectionPropertyProviderI conprov = new ConnectionPropertyProviderI() - { - boolean authed = false; - - @Override - public void setConnectionProperties(HttpURLConnection connection) - { - String auth = authStash.get(connection.getURL()); - if (auth != null && auth.length() > 0) - { - connection.setRequestProperty("Authorisation", auth); - authed = true; - } - else - { - authed = false; - } - } - - @Override - public boolean getResponseProperties(HttpURLConnection connection) - { - String auth = authStash.get(connection.getURL()); - if (auth != null && auth.length() == 0) - { - // don't attempt to check if we authed or not - user entered empty - // password - return false; - } - if (!authed) - { - if (auth != null) - { - // try and pass credentials. - return true; - } - // see if we should try and create a new auth record. - String ameth = connection.getHeaderField("X-DAS-AuthMethods"); - Cache.log.debug("Could authenticate to " + connection.getURL() - + " with : " + ameth); - // TODO: search auth string and raise login box - return if auth was - // provided - return false; - } - else - { - // check to see if auth was successful - String asuc = connection - .getHeaderField("X-DAS_AuthenticatedUser"); - if (asuc != null && asuc.trim().length() > 0) - { - // authentication was successful - Cache.log.debug("Authenticated successfully to " - + connection.getURL().toString()); - return false; - } - // it wasn't - so we should tell the user it failed and ask if they - // want to attempt authentication again. - authStash.remove(connection.getURL()); - // open a new login/password dialog with cancel button - // set new authStash content with password and return true - return true; // - // User cancelled auth - so put empty string in stash to indicate we - // don't want to auth with this server. - // authStash.put(connection.getURL(), ""); - // return false; - } - } - }; - return conprov; - } - -} diff --git a/src/jalview/ws/dbsources/das/datamodel/JalviewSource.java b/src/jalview/ws/dbsources/das/datamodel/JalviewSource.java deleted file mode 100644 index 07ba027..0000000 --- a/src/jalview/ws/dbsources/das/datamodel/JalviewSource.java +++ /dev/null @@ -1,384 +0,0 @@ -/* - * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors - * - * This file is part of Jalview. - * - * Jalview is free software: you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation, either version 3 - * of the License, or (at your option) any later version. - * - * Jalview is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Jalview. If not, see . - * The Jalview Authors are detailed in the 'AUTHORS' file. - */ -package jalview.ws.dbsources.das.datamodel; - -import jalview.util.MessageManager; -import jalview.ws.dbsources.das.api.jalviewSourceI; -import jalview.ws.seqfetcher.DbSourceProxy; - -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Date; -import java.util.Hashtable; -import java.util.List; -import java.util.Map; - -import org.biodas.jdas.client.threads.MultipleConnectionPropertyProviderI; -import org.biodas.jdas.dassources.Capabilities; -import org.biodas.jdas.dassources.utils.DasTimeFormat; -import org.biodas.jdas.schema.sources.CAPABILITY; -import org.biodas.jdas.schema.sources.COORDINATES; -import org.biodas.jdas.schema.sources.MAINTAINER; -import org.biodas.jdas.schema.sources.PROP; -import org.biodas.jdas.schema.sources.SOURCE; -import org.biodas.jdas.schema.sources.VERSION; - -public class JalviewSource implements jalviewSourceI -{ - SOURCE source; - - MultipleConnectionPropertyProviderI connprov; - - public JalviewSource(SOURCE local2, - MultipleConnectionPropertyProviderI connprov, boolean local) - { - this.connprov = connprov; - this.local = local; - source = local2; - } - - @Override - public String getTitle() - { - return source.getTitle(); - } - - @Override - public VERSION getVersion() - { - - return getVersionFor(source); - } - - @Override - public String getDocHref() - { - return source.getDocHref(); - } - - @Override - public String getDescription() - { - return source.getDescription(); - } - - @Override - public String getUri() - { - return source.getUri(); - } - - @Override - public MAINTAINER getMAINTAINER() - { - return source.getMAINTAINER(); - } - - @Override - public String getEmail() - { - return (local) ? null : source.getMAINTAINER().getEmail(); - } - - boolean local = false; - - @Override - public boolean isLocal() - { - return local; - } - - @Override - public boolean isSequenceSource() - { - String seqcap = "das1:" + Capabilities.SEQUENCE.getName(); - for (String cp : getCapabilityList(getVersionFor(source))) - { - if (cp.equals(seqcap)) - { - return true; - - } - } - return false; - } - - @Override - public boolean isFeatureSource() - { - String seqcap = "das1:" + Capabilities.FEATURES.getName(); - for (String cp : getCapabilityList(getVersionFor(source))) - { - if (cp.equals(seqcap)) - { - return true; - - } - } - return false; - } - - private VERSION getVersionFor(SOURCE ds) - { - VERSION latest = null; - for (VERSION v : ds.getVERSION()) - { - if (latest == null - || isLaterThan(latest.getCreated(), v.getCreated())) - { - // TODO: das 1.6 - should just get the first version - ignore other - // versions since not specified how to construct URL from version's URI - // + source URI - latest = v; - } - } - return latest; - } - - /** - * compare date strings. null or unparseable dates are assumed to be oldest - * - * @param ref - * @param newer - * @return true iff ref comes before newer - */ - private boolean isLaterThan(String ref, String newer) - { - Date refdate = null, newdate = null; - if (ref != null && ref.trim().length() > 0) - { - try - { - refdate = DasTimeFormat.fromDASString(ref.trim()); - - } catch (ParseException x) - { - } - } - if (newer != null && newer.trim().length() > 0) - { - try - { - newdate = DasTimeFormat.fromDASString(newer); - } catch (ParseException e) - { - } - } - if (refdate != null) - { - if (newdate != null) - { - return refdate.before(newdate); - } - return false; - } - if (newdate != null) - { - return true; - } - // assume first instance of source is newest in list. - TODO: check if - // natural ordering of source versions is newest first or oldest first - return false; - } - - public String[] getLabelsFor(VERSION v) - { - ArrayList labels = new ArrayList(); - for (PROP p : v.getPROP()) - { - if (p.getName().equalsIgnoreCase("LABEL")) - { - labels.add(p.getValue()); - } - } - return labels.toArray(new String[0]); - } - - private CAPABILITY getCapability(Capabilities capability) - { - for (CAPABILITY p : getVersion().getCAPABILITY()) - { - if (p.getType().equalsIgnoreCase(capability.getName()) || p.getType() - .equalsIgnoreCase("das1:" + capability.getName())) - { - return p; - } - } - return null; - } - - public String[] getCapabilityList(VERSION v) - { - - ArrayList labels = new ArrayList(); - for (CAPABILITY p : v.getCAPABILITY()) - { - // TODO: work out what to do with namespace prefix - // does SEQUENCE == das1:SEQUENCE and das2:SEQUENCE ? - // for moment, just show all capabilities... - if (p.getType().startsWith("das1:")) - { - labels.add(p.getType()); - } - } - return labels.toArray(new String[0]); - } - - @Override - public List getSequenceSourceProxies() - { - if (!isSequenceSource()) - { - return null; - } - ArrayList seqsources = new ArrayList(); - if (!local) - { - VERSION v = getVersion(); - Map latestc = new Hashtable(); - for (COORDINATES cs : v.getCOORDINATES()) - { - COORDINATES ltst = latestc.get(cs.getUri()); - if (ltst == null || ltst.getVersion() == null - || (ltst.getVersion() != null && cs.getVersion() != null - && isLaterThan(ltst.getVersion(), cs.getVersion()))) - { - latestc.put(cs.getUri(), cs); - } - } - for (COORDINATES cs : latestc.values()) - { - DasSequenceSource ds; - /* - * if (css == null || css.length == 0) { // TODO: query das source - * directly to identify coordinate system... or // have to make up a - * coordinate system css = new DasCoordinateSystem[] { new - * DasCoordinateSystem() }; css[0].setName(d1s.getNickname()); - * css[0].setUniqueId(d1s.getNickname()); } for (int c = 0; c < - * css.length; c++) { - */ - try - { - seqsources.add(ds = new DasSequenceSource( - getTitle() + " (" + cs.getAuthority() + " " - + cs.getSource() - + (cs.getVersion() != null ? " " + cs.getVersion() - : "") - + ")", - cs.getAuthority(), source, v, cs, connprov)); - if (seqsources.size() > 1) - { - System.err.println("Added another sequence DB source for " - + getTitle() + " (" + ds.getDbName() + ")"); - } - } catch (Exception e) - { - System.err.println("Ignoring sequence coord system " + cs + " (" - + cs.getContent() + ") for source " + getTitle() - + "- threw exception when constructing fetcher.\n"); - e.printStackTrace(); - } - } - } - else - { - try - { - seqsources.add(new DasSequenceSource(getTitle(), getTitle(), source, - getVersion(), null, connprov)); - } catch (Exception e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - if (seqsources.size() > 1) - { - // sort by name - DbSourceProxy[] tsort = seqsources.toArray(new DasSequenceSource[0]); - String[] nm = new String[tsort.length]; - for (int i = 0; i < nm.length; i++) - { - nm[i] = tsort[i].getDbName().toLowerCase(); - } - jalview.util.QuickSort.sort(nm, tsort); - seqsources.clear(); - for (DbSourceProxy ssrc : tsort) - { - seqsources.add(ssrc); - } - } - return seqsources; - } - - @Override - public String getSourceURL() - { - try - { - // kind of dumb, since - // org.biodas.jdas.dassources.utils.VersionAdapter.getSourceUriFromQueryUri() - // does this, - // but this way, we can access non DAS 1.6 compliant sources (which have - // to have a URL like /das/ and cause a validation exception) - - for (CAPABILITY cap : getVersion().getCAPABILITY()) - { - String capname = cap.getType() - .substring(cap.getType().indexOf(":") + 1); - int p = cap.getQueryUri().lastIndexOf(capname); - if (p < -1) - { - throw new Exception(MessageManager.formatMessage( - "exception.invalid_das_source", new String[] - { source.getUri() })); - } - if (cap.getQueryUri().charAt(p) == '/') - { - p--; - } - return cap.getQueryUri().substring(0, p); - } - } catch (Exception x) - { - System.err.println("Serious: Couldn't get the URL for source " - + source.getTitle()); - x.printStackTrace(); - } - return null; - } - - @Override - public boolean isNewerThan(jalviewSourceI other) - { - return isLaterThan(getVersion().getCreated(), - other.getVersion().getCreated()); - } - - @Override - public boolean isReferenceSource() - { - // TODO check source object for indication that we are the primary for a DAS - // coordinate system - return false; - } -} diff --git a/src/jalview/ws/jws2/AADisorderClient.java b/src/jalview/ws/jws2/AADisorderClient.java index 9a2316c..bd4e0ea 100644 --- a/src/jalview/ws/jws2/AADisorderClient.java +++ b/src/jalview/ws/jws2/AADisorderClient.java @@ -66,8 +66,8 @@ public class AADisorderClient extends JabawsCalcWorker { super(sh, alignFrame, thePreset, paramset); af = alignFrame; - typeName = sh.action; - methodName = sh.serviceType; + typeName = sh.getAction(); + methodName = sh.getName(); submitGaps = false; alignedSeqs = false; @@ -169,9 +169,9 @@ public class AADisorderClient extends JabawsCalcWorker if (immediate || !calcMan.isWorking(this) && scoremanager != null) { Map featureTypeMap = featureMap - .get(service.serviceType); + .get(service.getName()); Map> annotTypeMap = annotMap - .get(service.serviceType); + .get(service.getName()); boolean dispFeatures = false; Map fc = new Hashtable<>(); List ourAnnot = new ArrayList<>(); @@ -265,9 +265,9 @@ public class AADisorderClient extends JabawsCalcWorker String typename, calcName; AlignmentAnnotation annot = createAnnotationRowsForScores( ourAnnot, - typename = service.serviceType + " (" + typename = service.getName() + " (" + scr.getMethod() + ")", - calcName = service.getServiceTypeURI() + "/" + calcName = service.getNameURI() + "/" + scr.getMethod(), aseq, base + 1, scr); annot.graph = AlignmentAnnotation.LINE_GRAPH; diff --git a/src/jalview/ws/jws2/JabaParamStore.java b/src/jalview/ws/jws2/JabaParamStore.java index 10ec812..0257a76 100644 --- a/src/jalview/ws/jws2/JabaParamStore.java +++ b/src/jalview/ws/jws2/JabaParamStore.java @@ -47,7 +47,7 @@ import compbio.metadata.RunnerConfig; public class JabaParamStore implements ParamDatastoreI { - Hashtable editedParams = new Hashtable(); + Hashtable editedParams = new Hashtable<>(); private Jws2Instance service; @@ -101,7 +101,7 @@ public class JabaParamStore implements ParamDatastoreI List prefs = new ArrayList(); if (servicePresets == null) { - servicePresets = new Hashtable(); + servicePresets = new Hashtable<>(); PresetManager prman; if ((prman = service.getPresets()) != null) { @@ -148,8 +148,8 @@ public class JabaParamStore implements ParamDatastoreI public static List getJwsArgsfromJaba(List jabargs, boolean sortByOpt) { - List rgs = new ArrayList(); - List rgnames = new ArrayList(); + List rgs = new ArrayList<>(); + List rgnames = new ArrayList<>(); for (Object rg : jabargs) { ArgumentI narg = null; @@ -309,7 +309,7 @@ public class JabaParamStore implements ParamDatastoreI boolean found = false; for (String url : urls) { - if (service.getServiceTypeURI().equals(url) + if (service.getNameURI().equals(url) || service.getUri().equalsIgnoreCase(url)) { found = true; @@ -334,7 +334,7 @@ public class JabaParamStore implements ParamDatastoreI wsp.setDescription(descr); wsp.setApplicableUrls(urls.clone()); - List lines = new ArrayList(); + List lines = new ArrayList<>(); StringTokenizer st = new StringTokenizer(parameterfile, "\n"); while (st.hasMoreTokens()) { diff --git a/src/jalview/ws/jws2/Jws2Client.java b/src/jalview/ws/jws2/Jws2Client.java index 7d661a4..3e4cc97 100644 --- a/src/jalview/ws/jws2/Jws2Client.java +++ b/src/jalview/ws/jws2/Jws2Client.java @@ -28,6 +28,7 @@ import jalview.gui.JvSwingUtils; import jalview.gui.WebserviceInfo; import jalview.gui.WsJobParameters; import jalview.util.MessageManager; +import jalview.ws.api.UIinfo; import jalview.ws.jws2.dm.AAConSettings; import jalview.ws.jws2.dm.JabaWsParamSet; import jalview.ws.jws2.jabaws2.Jws2Instance; @@ -148,19 +149,20 @@ public abstract class Jws2Client extends jalview.ws.WSClient // anonymous constructor - used for headless method calls only } - protected WebserviceInfo setWebService(Jws2Instance serv, boolean b) + protected WebserviceInfo setWebService(UIinfo serv, boolean b) { - // serviceHandle = serv; - String serviceInstance = serv.action; // serv.service.getClass().getName(); - WebServiceName = serv.serviceType; + // TODO pullup + WebServiceName = serv.getName(); WebServiceJobTitle = serv.getActionText(); - WsURL = serv.hosturl; + WsURL = serv.getHostURL(); if (!b) { return new WebserviceInfo(WebServiceJobTitle, WebServiceJobTitle + " using service hosted at " - + serv.hosturl + "\n" - + (serv.description != null ? serv.description : ""), + + WsURL + "\n" + + (serv.getDescription() != null + ? serv.getDescription() + : ""), false); } return null; @@ -187,7 +189,7 @@ public abstract class Jws2Client extends jalview.ws.WSClient abstract void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service, final AlignFrame alignFrame); - protected boolean registerAAConWSInstance(final JMenu wsmenu, + static boolean registerAAConWSInstance(final JMenu wsmenu, final Jws2Instance service, final AlignFrame alignFrame) { final AlignAnalysisUIText aaui = service.getAlignAnalysisUI(); // null ; // @@ -220,7 +222,7 @@ public abstract class Jws2Client extends jalview.ws.WSClient { AbstractJabaCalcWorker worker = (AbstractJabaCalcWorker) aaconClient .get(0); - if (!worker.service.hosturl.equals(service.hosturl)) + if (!worker.service.getHostURL().equals(service.getHostURL())) { // javax.swing.SwingUtilities.invokeLater(new Runnable() { @@ -371,10 +373,11 @@ public abstract class Jws2Client extends jalview.ws.WSClient else { if (service != null - && !fave.getService().hosturl.equals(service.hosturl)) + && !fave.getService().getHostURL() + .equals(service.getHostURL())) { - Cache.log.debug("Changing AACon service to " + service.hosturl - + " from " + fave.getService().hosturl); + Cache.log.debug("Changing AACon service to " + service.getHostURL() + + " from " + fave.getService().getHostURL()); fave.setService(service); } } @@ -392,12 +395,12 @@ public abstract class Jws2Client extends jalview.ws.WSClient { if (service != null) { - if (!service.serviceType.toString() + if (!service.getServiceType() .equals(compbio.ws.client.Services.AAConWS.toString())) { Cache.log.warn( "Ignoring invalid preferred service for AACon calculations (service type was " - + service.serviceType + ")"); + + service.getServiceType() + ")"); service = null; } else diff --git a/src/jalview/ws/jws2/Jws2Discoverer.java b/src/jalview/ws/jws2/Jws2Discoverer.java index 5319eab..e4ff459 100644 --- a/src/jalview/ws/jws2/Jws2Discoverer.java +++ b/src/jalview/ws/jws2/Jws2Discoverer.java @@ -178,7 +178,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI running = true; // first set up exclusion list if needed - final Set ignoredServices = new HashSet(); + final Set ignoredServices = new HashSet<>(); for (String ignored : Cache .getDefault("IGNORED_JABAWS_SERVICETYPES", "").split("\\|")) { @@ -217,9 +217,9 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { validServiceUrls.removeAllElements(); } - ArrayList svctypes = new ArrayList(); + ArrayList svctypes = new ArrayList<>(); - List qrys = new ArrayList(); + List qrys = new ArrayList<>(); for (final String jwsserver : getServiceUrls()) { JabaWsServerQuery squery = new JabaWsServerQuery(this, jwsserver); @@ -281,14 +281,14 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI for (Jws2Instance svc : services) { svcs[ipos] = svc; - spos[ipos++] = 1000 * svcUrls.indexOf(svc.getHost()) + 1 - + svctypes.indexOf(svc.serviceType); + spos[ipos++] = 1000 * svcUrls.indexOf(svc.getHostURL()) + 1 + + svctypes.indexOf(svc.getName()); } jalview.util.QuickSort.sort(spos, svcs); - services = new Vector(); + services = new Vector<>(); for (Jws2Instance svc : svcs) { - if (!ignoredServices.contains(svc.serviceType)) + if (!ignoredServices.contains(svc.getName())) { services.add(svc); } @@ -312,7 +312,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (services == null) { - services = new Vector(); + services = new Vector<>(); } System.out.println( "Discovered service: " + jwsservers + " " + service.toString()); @@ -329,7 +329,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI service.hasParameters(); if (validServiceUrls == null) { - validServiceUrls = new Vector(); + validServiceUrls = new Vector<>(); } validServiceUrls.add(jwsservers); } @@ -363,13 +363,14 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI * for moment we keep them separate. */ JMenu atpoint; - List enumerableServices = new ArrayList(); + List enumerableServices = new ArrayList<>(); // jws2al.removeAll(); - Map preferredHosts = new HashMap(); - Map> alternates = new HashMap>(); + Map preferredHosts = new HashMap<>(); + Map> alternates = new HashMap<>(); for (Jws2Instance service : services.toArray(new Jws2Instance[0])) { - if (!isRecalculable(service.action)) + // TODO: check this behaves with refactored serviceType to getName + if (!isRecalculable(service.getName())) { // add 'one shot' services to be displayed using the classic menu // structure @@ -377,28 +378,28 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } else { - if (!preferredHosts.containsKey(service.serviceType)) + if (!preferredHosts.containsKey(service.getName())) { Jws2Instance preferredInstance = getPreferredServiceFor( - alignFrame, service.serviceType); + alignFrame, service.getName()); if (preferredInstance != null) { - preferredHosts.put(service.serviceType, preferredInstance); + preferredHosts.put(service.getName(), preferredInstance); } else { - preferredHosts.put(service.serviceType, service); + preferredHosts.put(service.getName(), service); } } - List ph = alternates.get(service.serviceType); - if (preferredHosts.get(service.serviceType) != service) + List ph = alternates.get(service.getName()); + if (preferredHosts.get(service.getName()) != service) { if (ph == null) { - ph = new ArrayList(); + ph = new ArrayList<>(); } ph.add(service); - alternates.put(service.serviceType, ph); + alternates.put(service.getName(), ph); } } @@ -409,14 +410,15 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI // and the instantaneous services for (final Jws2Instance service : preferredHosts.values()) { - atpoint = JvSwingUtils.findOrCreateMenu(jws2al, service.action); + atpoint = JvSwingUtils.findOrCreateMenu(jws2al, + service.getServiceType()); JMenuItem hitm; if (atpoint.getItemCount() > 1) { // previous service of this type already present atpoint.addSeparator(); } - atpoint.add(hitm = new JMenuItem(service.getHost())); + atpoint.add(hitm = new JMenuItem(service.getHostURL())); hitm.setForeground(Color.blue); hitm.addActionListener(new ActionListener() { @@ -424,23 +426,23 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI @Override public void actionPerformed(ActionEvent e) { - Desktop.showUrl(service.getHost()); + Desktop.showUrl(service.getHostURL()); } }); hitm.setToolTipText(JvSwingUtils.wrapTooltip(false, MessageManager.getString("label.open_jabaws_web_page"))); service.attachWSMenuEntry(atpoint, alignFrame); - if (alternates.containsKey(service.serviceType)) + if (alternates.containsKey(service.getName())) { atpoint.add(hitm = new JMenu( MessageManager.getString("label.switch_server"))); hitm.setToolTipText(JvSwingUtils.wrapTooltip(false, MessageManager.getString("label.choose_jabaws_server"))); - for (final Jws2Instance sv : alternates.get(service.serviceType)) + for (final Jws2Instance sv : alternates.get(service.getName())) { JMenuItem itm; - hitm.add(itm = new JMenuItem(sv.getHost())); + hitm.add(itm = new JMenuItem(sv.getHostURL())); itm.setForeground(Color.blue); itm.addActionListener(new ActionListener() { @@ -453,8 +455,8 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI @Override public void run() { - setPreferredServiceFor(alignFrame, sv.serviceType, - sv.action, sv); + setPreferredServiceFor(alignFrame, sv.getName(), + sv.getServiceType(), sv); changeSupport.firePropertyChange("services", new Vector(), services); }; @@ -483,18 +485,19 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI */ JMenu atpoint; - List hostLabels = new ArrayList(); - Hashtable lasthostFor = new Hashtable(); - Hashtable> hosts = new Hashtable>(); - ArrayList hostlist = new ArrayList(); + List hostLabels = new ArrayList<>(); + Hashtable lasthostFor = new Hashtable<>(); + Hashtable> hosts = new Hashtable<>(); + ArrayList hostlist = new ArrayList<>(); for (Jws2Instance service : enumerableServices) { - ArrayList hostservices = hosts.get(service.getHost()); + ArrayList hostservices = hosts + .get(service.getHostURL()); if (hostservices == null) { - hosts.put(service.getHost(), - hostservices = new ArrayList()); - hostlist.add(service.getHost()); + hosts.put(service.getHostURL(), + hostservices = new ArrayList<>()); + hostlist.add(service.getHostURL()); } hostservices.add(service); } @@ -506,13 +509,14 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI String sortbytype[] = new String[orderedsvcs.length]; for (int i = 0; i < sortbytype.length; i++) { - sortbytype[i] = orderedsvcs[i].serviceType; + sortbytype[i] = orderedsvcs[i].getName(); } jalview.util.QuickSort.sort(sortbytype, orderedsvcs); for (final Jws2Instance service : orderedsvcs) { - atpoint = JvSwingUtils.findOrCreateMenu(jws2al, service.action); - String type = service.serviceType; + atpoint = JvSwingUtils.findOrCreateMenu(jws2al, + service.getAction()); + String type = service.getName(); if (byhost) { atpoint = JvSwingUtils.findOrCreateMenu(atpoint, host); @@ -532,7 +536,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } } if (!byhost && !hostLabels.contains( - host + service.serviceType + service.getActionText())) + host + service.getName() + service.getActionText())) // !hostLabels.contains(host + (bytype ? // service.serviceType+service.getActionText() : ""))) { @@ -549,8 +553,8 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { hostLabels.add(host); } - if (lasthostFor.get(service.action) == null - || !lasthostFor.get(service.action).equals(host)) + if (lasthostFor.get(service.getAction()) == null + || !lasthostFor.get(service.getAction()).equals(host)) { atpoint.add(hitm = new JMenuItem(host)); hitm.setForeground(Color.blue); @@ -560,16 +564,16 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI @Override public void actionPerformed(ActionEvent e) { - Desktop.showUrl(service.getHost()); + Desktop.showUrl(service.getHostURL()); } }); hitm.setToolTipText( JvSwingUtils.wrapTooltip(true, MessageManager .getString("label.open_jabaws_web_page"))); - lasthostFor.put(service.action, host); + lasthostFor.put(service.getAction(), host); } hostLabels.add( - host + service.serviceType + service.getActionText()); + host + service.getName() + service.getActionText()); } service.attachWSMenuEntry(atpoint, alignFrame); @@ -581,7 +585,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (args.length > 0) { - testUrls = new ArrayList(); + testUrls = new ArrayList<>(); for (String url : args) { testUrls.add(url); @@ -603,7 +607,8 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI for (Jws2Instance instance : getDiscoverer().services) { System.out.println("Service " + i++ + " " - + instance.getClass() + "@" + instance.getHost() + + instance.getClass() + "@" + + instance.getHostURL() + ": " + instance.getActionText()); } @@ -685,7 +690,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI // return test urls, if there are any, instead of touching cache return testUrls; } - List urls = new ArrayList(); + List urls = new ArrayList<>(); if (this.preferredUrl != null) { @@ -733,8 +738,8 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI public Vector getServices() { - return (services == null) ? new Vector() - : new Vector(services); + return (services == null) ? new Vector<>() + : new Vector<>(services); } /** @@ -839,7 +844,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (urlsWithoutServices == null) { - urlsWithoutServices = new Vector(); + urlsWithoutServices = new Vector<>(); } if ((invalidServiceUrls == null @@ -859,7 +864,7 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI { if (invalidServiceUrls == null) { - invalidServiceUrls = new Vector(); + invalidServiceUrls = new Vector<>(); } if (!invalidServiceUrls.contains(jwsservers)) { @@ -947,14 +952,16 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI */ public Jws2Instance getPreferredServiceFor(String[] serviceURLs) { - HashSet urls = new HashSet(); + HashSet urls = new HashSet<>(); urls.addAll(Arrays.asList(serviceURLs)); Jws2Instance match = null; if (services != null) { for (Jws2Instance svc : services) { - if (urls.contains(svc.getServiceTypeURI())) + // TODO getNameURI Should return a versioned URI for the service, but + // doesn't as of 2.11 + if (urls.contains(svc.getNameURI())) { if (match == null) { @@ -974,20 +981,21 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI return match; } - Map> preferredServiceMap = new HashMap>();; + Map> preferredServiceMap = new HashMap<>();; /** - * get current preferred service of the given type, or global default + * get current preferred endpoint of the given Jabaws service, or global + * default * * @param af * null or a specific alignFrame - * @param serviceType - * Jws2Instance.serviceType for service + * @param serviceName + * Jws2Instance.getName() for service * @return null if no service of this type is available, the preferred service * for the serviceType and af if specified and if defined. */ public Jws2Instance getPreferredServiceFor(AlignFrame af, - String serviceType) + String serviceName) { String serviceurl = null; synchronized (preferredServiceMap) @@ -1001,16 +1009,16 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI } if (prefmap != null) { - serviceurl = prefmap.get(serviceType); + serviceurl = prefmap.get(serviceName); } } Jws2Instance response = null; for (Jws2Instance svc : services) { - if (svc.serviceType.equals(serviceType)) + if (svc.getName().equals(serviceName)) { - if (serviceurl == null || serviceurl.equals(svc.getHost())) + if (serviceurl == null || serviceurl.equals(svc.getHostURL())) { response = svc; break; @@ -1020,22 +1028,23 @@ public class Jws2Discoverer implements Runnable, WSMenuEntryProviderI return response; } - public void setPreferredServiceFor(AlignFrame af, String serviceType, + public void setPreferredServiceFor(AlignFrame af, String serviceName, String serviceAction, Jws2Instance selectedServer) { + // TODO: pull out and generalise for the selectedServer's attributes String afid = (af == null) ? "" : af.getViewport().getSequenceSetId(); if (preferredServiceMap == null) { - preferredServiceMap = new HashMap>(); + preferredServiceMap = new HashMap<>(); } Map prefmap = preferredServiceMap.get(afid); if (prefmap == null) { - prefmap = new HashMap(); + prefmap = new HashMap<>(); preferredServiceMap.put(afid, prefmap); } - prefmap.put(serviceType, selectedServer.getHost()); - prefmap.put(serviceAction, selectedServer.getHost()); + prefmap.put(serviceName, selectedServer.getHostURL()); + prefmap.put(serviceAction, selectedServer.getHostURL()); } public void setPreferredServiceFor(String serviceType, diff --git a/src/jalview/ws/jws2/MsaWSClient.java b/src/jalview/ws/jws2/MsaWSClient.java index 7e68d3b..bbeefc6 100644 --- a/src/jalview/ws/jws2/MsaWSClient.java +++ b/src/jalview/ws/jws2/MsaWSClient.java @@ -111,7 +111,7 @@ public class MsaWSClient extends Jws2Client MessageManager.formatMessage( "label.service_called_is_not_msa_service", new String[] - { sh.serviceType }), + { sh.getName() }), MessageManager.getString("label.internal_jalview_error"), JvOptionPane.WARNING_MESSAGE); @@ -122,7 +122,7 @@ public class MsaWSClient extends Jws2Client { JvOptionPane.showMessageDialog(Desktop.desktop, MessageManager .formatMessage("label.msa_service_is_unknown", new String[] - { sh.serviceType }), + { sh.getName() }), MessageManager.getString("label.internal_jalview_error"), JvOptionPane.WARNING_MESSAGE); diff --git a/src/jalview/ws/jws2/RNAalifoldClient.java b/src/jalview/ws/jws2/RNAalifoldClient.java index 80c9ce9..32ae38f 100644 --- a/src/jalview/ws/jws2/RNAalifoldClient.java +++ b/src/jalview/ws/jws2/RNAalifoldClient.java @@ -65,7 +65,7 @@ public class RNAalifoldClient extends JabawsCalcWorker { super(sh, alignFrame, preset, paramset); af = alignFrame; - methodName = sh.serviceType; + methodName = sh.getName(); alignedSeqs = true; submitGaps = true; nucleotidesAllowed = true; @@ -112,7 +112,7 @@ public class RNAalifoldClient extends JabawsCalcWorker if (immediate || !calcMan.isWorking(this) && scoremanager != null) { - List ourAnnot = new ArrayList(); + List ourAnnot = new ArrayList<>(); // Unpack the ScoreManager List structs = ((RNAStructScoreManager) scoremanager) @@ -231,7 +231,7 @@ public class RNAalifoldClient extends JabawsCalcWorker // The base pair probabilities are stored in a set in scoreholder. we want // a map - LinkedHashMap basePairs = new LinkedHashMap(); + LinkedHashMap basePairs = new LinkedHashMap<>(); for (Score score : data) { // The Score objects contain a set of size one containing the range and @@ -377,7 +377,7 @@ public class RNAalifoldClient extends JabawsCalcWorker private LinkedHashMap isContact( LinkedHashMap basePairs, int i) { - LinkedHashMap contacts = new LinkedHashMap(); + LinkedHashMap contacts = new LinkedHashMap<>(); for (Range contact : basePairs.keySet()) { diff --git a/src/jalview/ws/jws2/SequenceAnnotationWSClient.java b/src/jalview/ws/jws2/SequenceAnnotationWSClient.java index 45bddac..8befb2a 100644 --- a/src/jalview/ws/jws2/SequenceAnnotationWSClient.java +++ b/src/jalview/ws/jws2/SequenceAnnotationWSClient.java @@ -128,7 +128,7 @@ public class SequenceAnnotationWSClient extends Jws2Client worker.updateParameters(this.preset, paramset); } } - if (sh.action.toLowerCase().contains("disorder")) + if (sh.getAction().toLowerCase().contains("disorder")) { // build IUPred style client. take sequences, returns annotation per // sequence. @@ -156,6 +156,7 @@ public class SequenceAnnotationWSClient extends Jws2Client * @see jalview.ws.jws2.Jws2Client#attachWSMenuEntry(javax.swing.JMenu, * jalview.ws.jws2.jabaws2.Jws2Instance, jalview.gui.AlignFrame) */ + @Override public void attachWSMenuEntry(JMenu wsmenu, final Jws2Instance service, final AlignFrame alignFrame) { @@ -166,8 +167,8 @@ public class SequenceAnnotationWSClient extends Jws2Client } boolean hasparams = service.hasParameters(); // Assume name ends in WS - String calcName = service.serviceType.substring(0, - service.serviceType.length() - 2); + String calcName = service.getName().substring(0, + service.getName().length() - 2); JMenuItem annotservice = new JMenuItem(MessageManager.formatMessage( "label.calcname_with_default_settings", new String[] @@ -193,6 +194,7 @@ public class SequenceAnnotationWSClient extends Jws2Client annotservice.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { new SequenceAnnotationWSClient(service, alignFrame, null, true); @@ -217,6 +219,7 @@ public class SequenceAnnotationWSClient extends Jws2Client + "
      " + preset.getDescription())); methodR.addActionListener(new ActionListener() { + @Override public void actionPerformed(ActionEvent e) { new SequenceAnnotationWSClient(service, alignFrame, preset, diff --git a/src/jalview/ws/jws2/dm/AAConSettings.java b/src/jalview/ws/jws2/dm/AAConSettings.java index 708787e..5cc8f66 100644 --- a/src/jalview/ws/jws2/dm/AAConSettings.java +++ b/src/jalview/ws/jws2/dm/AAConSettings.java @@ -76,8 +76,8 @@ public class AAConSettings extends jalview.ws.params.AutoCalcSetting preset = pr; return; } - List oldargs = new ArrayList(), - newargs = new ArrayList(); + List oldargs = new ArrayList<>(), + newargs = new ArrayList<>(); oldargs.addAll(preset.getArguments()); // need to compare parameters for (ArgumentI newparg : pr.getArguments()) @@ -112,6 +112,7 @@ public class AAConSettings extends jalview.ws.params.AutoCalcSetting : JabaParamStore.getJwsArgsfromJaba(jobArgset); } + @Override public String getWsParamFile() { List