From 1cb8662ae0ce8b7c29fa510809a6e883c769dcdc Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 18 Sep 2018 15:40:39 +0100 Subject: [PATCH] JAL-3035 more dedasification --- src/jalview/bin/Cache.java | 9 - src/jalview/bin/Jalview.java | 127 +------------ src/jalview/gui/FeatureSettings.java | 6 - src/jalview/jbgui/GDasSourceBrowser.java | 256 --------------------------- src/jalview/util/DBRefUtils.java | 44 +---- test/jalview/bin/CommandLineOperations.java | 4 +- test/jalview/util/DBRefUtilsTest.java | 33 ---- 7 files changed, 11 insertions(+), 468 deletions(-) delete mode 100755 src/jalview/jbgui/GDasSourceBrowser.java diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 83bc810..274f7af 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -114,7 +114,6 @@ import org.apache.log4j.SimpleLayout; * service *
  • USAGESTATS (false - user prompted) Enable google analytics tracker for * collecting usage statistics
  • - *
  • DAS_LOCAL_SOURCE list of local das sources
  • *
  • SHOW_OVERVIEW boolean for overview window display
  • *
  • ANTI_ALIAS boolean for smooth fonts
  • *
  • RIGHT_ALIGN_IDS boolean
  • @@ -134,9 +133,7 @@ import org.apache.log4j.SimpleLayout; * sequence id (must be in SEQUENCE_LINKS or STORED_LINKS) *
  • GROUP_LINKS list of name|URL[|<separator>] tuples - see * jalview.utils.GroupURLLink for more info
  • - *
  • DAS_REGISTRY_URL the registry to query
  • *
  • DEFAULT_BROWSER for unix
  • - *
  • DAS_ACTIVE_SOURCE list of active sources
  • *
  • SHOW_MEMUSAGE boolean show memory usage and warning indicator on desktop * (false)
  • *
  • VERSION_CHECK (true) check for the latest release version from @@ -226,12 +223,6 @@ public class Cache */ public static final String JALVIEWLOGLEVEL = "logs.Jalview.level"; - public static final String DAS_LOCAL_SOURCE = "DAS_LOCAL_SOURCE"; - - public static final String DAS_REGISTRY_URL = "DAS_REGISTRY_URL"; - - public static final String DAS_ACTIVE_SOURCE = "DAS_ACTIVE_SOURCE"; - /** * Sifts settings */ diff --git a/src/jalview/bin/Jalview.java b/src/jalview/bin/Jalview.java index 3270144..cd7d1af 100755 --- a/src/jalview/bin/Jalview.java +++ b/src/jalview/bin/Jalview.java @@ -391,10 +391,7 @@ public class Jalview FileFormatI format = null; DataSourceType protocol = null; FileLoader fileLoader = new FileLoader(!headless); - Vector getFeatures = null; // vector of das source nicknames to - // fetch - // features from - // loading is done. + String groovyscript = null; // script to execute after all loading is // completed one way or another // extract groovy argument and execute if necessary @@ -625,27 +622,6 @@ public class Jalview // TODO - load PDB structure(s) to alignment JAL-629 // (associate with identical sequence in alignment, or a specified // sequence) - - getFeatures = checkDasArguments(aparser); - if (af != null && getFeatures != null) - { - FeatureFetcher ff = startFeatureFetching(getFeatures); - if (ff != null) - { - while (!ff.allFinished() || af.operationInProgress()) - { - // wait around until fetching is finished. - try - { - Thread.sleep(100); - } catch (Exception e) - { - - } - } - } - getFeatures = null; // have retrieved features - forget them now. - } if (groovyscript != null) { // Execute the groovy script after we've done all the rendering stuff @@ -787,20 +763,9 @@ public class Jalview startUpAlframe = fileLoader.LoadFileWaitTillLoaded(file, protocol, format); - getFeatures = checkDasArguments(aparser); // extract groovy arguments before anything else. } - // If the user has specified features to be retrieved, - // or a groovy script to be executed, do them if they - // haven't been done already - // fetch features for the default alignment - if (getFeatures != null) - { - if (startUpAlframe != null) - { - startFeatureFetching(getFeatures); - } - } + // Once all other stuff is done, execute any groovy scripts (in order) if (groovyscript != null) { @@ -1024,94 +989,6 @@ public class Jalview } } - /** - * Check commandline for any das server definitions or any fetchfrom switches - * - * @return vector of DAS source nicknames to retrieve from - */ - private static Vector checkDasArguments(ArgsParser aparser) - { - Vector source = null; - String data; - String locsources = Cache.getProperty(Cache.DAS_LOCAL_SOURCE); - while ((data = aparser.getValue("dasserver", true)) != null) - { - String nickname = null; - String url = null; - int pos = data.indexOf('='); - // determine capabilities - if (pos > 0) - { - nickname = data.substring(0, pos); - } - url = data.substring(pos + 1); - if (url != null && (url.startsWith("http:") - || url.startsWith("sequence:http:"))) - { - if (nickname == null) - { - nickname = url; - } - if (locsources == null) - { - locsources = ""; - } - else - { - locsources += "\t"; - } - locsources = locsources + nickname + "|" + url; - System.err.println( - "NOTE! dasserver parameter not yet really supported (got args of " - + nickname + "|" + url); - if (source == null) - { - source = new Vector<>(); - } - source.addElement(nickname); - } - System.out.println( - "CMD [-dasserver " + data + "] executed successfully!"); - } // loop until no more server entries are found. - if (locsources != null && locsources.indexOf('|') > -1) - { - Cache.log.debug("Setting local source list in properties file to:\n" - + locsources); - Cache.setProperty(Cache.DAS_LOCAL_SOURCE, locsources); - } - while ((data = aparser.getValue("fetchfrom", true)) != null) - { - System.out.println("adding source '" + data + "'"); - if (source == null) - { - source = new Vector<>(); - } - source.addElement(data); - } - return source; - } - - /** - * start a feature fetcher for every alignment frame - * - * @param dasSources - */ - private FeatureFetcher startFeatureFetching( - final Vector dasSources) - { - FeatureFetcher ff = new FeatureFetcher(); - AlignFrame afs[] = Desktop.getAlignFrames(); - if (afs == null || afs.length == 0) - { - return null; - } - for (int i = 0; i < afs.length; i++) - { - ff.addFetcher(afs[i], dasSources); - } - return ff; - } - public static boolean isHeadlessMode() { String isheadless = System.getProperty("java.awt.headless"); diff --git a/src/jalview/gui/FeatureSettings.java b/src/jalview/gui/FeatureSettings.java index 78c1cac..513ef24 100644 --- a/src/jalview/gui/FeatureSettings.java +++ b/src/jalview/gui/FeatureSettings.java @@ -152,12 +152,6 @@ public class FeatureSettings extends JPanel int selectedRow = -1; - JButton fetchDAS = new JButton(); - - JButton saveDAS = new JButton(); - - JButton cancelDAS = new JButton(); - boolean resettingTable = false; /* diff --git a/src/jalview/jbgui/GDasSourceBrowser.java b/src/jalview/jbgui/GDasSourceBrowser.java deleted file mode 100755 index a91769a..0000000 --- a/src/jalview/jbgui/GDasSourceBrowser.java +++ /dev/null @@ -1,256 +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.jbgui; - -import jalview.util.MessageManager; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.FlowLayout; -import java.awt.Font; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JEditorPane; -import javax.swing.JLabel; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.JProgressBar; -import javax.swing.JScrollPane; -import javax.swing.JTable; -import javax.swing.JTextField; -import javax.swing.SwingConstants; -import javax.swing.border.TitledBorder; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; - -public class GDasSourceBrowser extends JPanel -{ - public GDasSourceBrowser() - { - try - { - jbInit(); - } catch (Exception ex) - { - ex.printStackTrace(); - } - } - - private void jbInit() throws Exception - { - this.setLayout(gridBagLayout1); - refresh.setText( - MessageManager.getString("label.refresh_available_sources")); - refresh.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - refresh_actionPerformed(e); - } - }); - progressBar.setPreferredSize(new Dimension(450, 20)); - progressBar.setString(""); - scrollPane.setBorder(titledBorder1); - scrollPane.setBorder(BorderFactory.createEtchedBorder()); - fullDetailsScrollpane.setBorder(BorderFactory.createEtchedBorder()); - fullDetails.addHyperlinkListener(new HyperlinkListener() - { - public void hyperlinkUpdate(HyperlinkEvent e) - { - fullDetails_hyperlinkUpdate(e); - } - }); - fullDetails.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - fullDetails.setEditable(false); - registryLabel.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - registryLabel.setHorizontalAlignment(SwingConstants.TRAILING); - registryLabel.setText(MessageManager.getString("label.use_registry")); - addLocal.setText(MessageManager.getString("label.add_local_source")); - addLocal.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - amendLocal(true); - } - }); - jPanel1.setLayout(flowLayout1); - jPanel1.setMinimumSize(new Dimension(596, 30)); - jPanel1.setPreferredSize(new Dimension(596, 30)); - jScrollPane2.setBorder(titledBorder3); - jScrollPane3.setBorder(titledBorder4); - jScrollPane4.setBorder(titledBorder5); - titledBorder2 - .setTitleFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - titledBorder3 - .setTitleFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - titledBorder4 - .setTitleFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - filter1.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - filter2.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - filter3.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - table.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - reset.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - reset.setMargin(new Insets(2, 2, 2, 2)); - reset.setText(MessageManager.getString("action.reset")); - reset.addActionListener(new ActionListener() - { - public void actionPerformed(ActionEvent e) - { - reset_actionPerformed(e); - } - }); - jPanel2.setLayout(borderLayout1); - borderLayout1.setHgap(5); - registryURL.setFont(new java.awt.Font("Verdana", Font.PLAIN, 10)); - scrollPane.getViewport().add(table); - fullDetailsScrollpane.getViewport().add(fullDetails); - jScrollPane3.getViewport().add(filter2); - jScrollPane4.getViewport().add(filter3); - jPanel1.add(refresh, null); - jPanel1.add(addLocal, null); - jPanel1.add(progressBar, null); - jScrollPane2.getViewport().add(filter1); - this.add(jPanel1, new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0, - GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(0, 0, 0, 0), 0, 0)); - this.add(fullDetailsScrollpane, - new GridBagConstraints(1, 0, 2, 1, 1.0, 1.0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(3, 0, 0, 3), 240, 130)); - this.add(scrollPane, - new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(3, 2, 0, 0), 150, 130)); - jPanel2.add(registryLabel, java.awt.BorderLayout.WEST); - jPanel2.add(registryURL, java.awt.BorderLayout.CENTER); - jPanel2.add(reset, java.awt.BorderLayout.EAST); - this.add(jPanel2, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0, - GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, - new Insets(5, 10, 0, 10), 339, 0)); - this.add(jScrollPane2, - new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(0, 0, 0, 60), 80, 60)); - this.add(jScrollPane4, - new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(0, -80, 0, 0), 80, 60)); - this.add(jScrollPane3, - new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, - GridBagConstraints.CENTER, GridBagConstraints.BOTH, - new Insets(0, -60, 0, 80), 80, 60)); - } - - protected JTable table = new JTable(); - - protected JEditorPane fullDetails = new JEditorPane("text/html", ""); - - TitledBorder titledBorder1 = new TitledBorder( - MessageManager.getString("label.available_das_sources")); - - protected JButton refresh = new JButton(); - - protected JProgressBar progressBar = new JProgressBar(); - - protected JScrollPane scrollPane = new JScrollPane(); - - TitledBorder titledBorder2 = new TitledBorder( - MessageManager.getString("label.full_details")); - - protected JScrollPane fullDetailsScrollpane = new JScrollPane(); - - protected JList filter1 = new JList(); - - protected JList filter2 = new JList(); - - protected JList filter3 = new JList(); - - JScrollPane jScrollPane2 = new JScrollPane(); - - JScrollPane jScrollPane3 = new JScrollPane(); - - JScrollPane jScrollPane4 = new JScrollPane(); - - protected JTextField registryURL = new JTextField(); - - protected JLabel registryLabel = new JLabel(); - - protected JButton addLocal = new JButton(); - - JPanel jPanel1 = new JPanel(); - - FlowLayout flowLayout1 = new FlowLayout(); - - GridBagLayout gridBagLayout1 = new GridBagLayout(); - - TitledBorder titledBorder3 = new TitledBorder( - MessageManager.getString("label.authority") + ":"); - - TitledBorder titledBorder4 = new TitledBorder( - MessageManager.getString("label.type") + ":"); - - TitledBorder titledBorder5 = new TitledBorder( - MessageManager.getString("label.label") + ":"); - - JButton reset = new JButton(); - - JPanel jPanel2 = new JPanel(); - - BorderLayout borderLayout1 = new BorderLayout(); - - public void refresh_actionPerformed(ActionEvent e) - { - - } - - public void fullDetails_hyperlinkUpdate(HyperlinkEvent e) - { - try - { - - if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) - { - jalview.util.BrowserLauncher.openURL(e.getURL().toString()); - } - } catch (Exception ex) - { - System.out.println(e.getURL()); - ex.printStackTrace(); - } - } - - public void amendLocal(boolean newSource) - { - - } - - public void reset_actionPerformed(ActionEvent e) - { - - } - -} diff --git a/src/jalview/util/DBRefUtils.java b/src/jalview/util/DBRefUtils.java index 50a34fc..5afbca5 100755 --- a/src/jalview/util/DBRefUtils.java +++ b/src/jalview/util/DBRefUtils.java @@ -43,9 +43,8 @@ public class DBRefUtils /* * lookup from lower-case form of a name to its canonical (standardised) form */ - private static Map canonicalSourceNameLookup = new HashMap(); + private static Map canonicalSourceNameLookup = new HashMap<>(); - private static Map dasCoordinateSystemsLookup = new HashMap(); static { @@ -73,10 +72,6 @@ public class DBRefUtils canonicalSourceNameLookup.get(k)); } - dasCoordinateSystemsLookup.put("pdbresnum", DBRefSource.PDB); - dasCoordinateSystemsLookup.put("uniprot", DBRefSource.UNIPROT); - dasCoordinateSystemsLookup.put("embl", DBRefSource.EMBL); - // dasCoordinateSystemsLookup.put("embl", DBRefSource.EMBLCDS); } /** @@ -97,13 +92,13 @@ public class DBRefUtils { return dbrefs; } - HashSet srcs = new HashSet(); + HashSet srcs = new HashSet<>(); for (String src : sources) { srcs.add(src.toUpperCase()); } - List res = new ArrayList(); + List res = new ArrayList<>(); for (DBRefEntry dbr : dbrefs) { String source = getCanonicalName(dbr.getSource()); @@ -122,29 +117,6 @@ public class DBRefUtils } /** - * isDasCoordinateSystem - * - * @param string - * String - * @param dBRefEntry - * DBRefEntry - * @return boolean true if Source DBRefEntry is compatible with DAS - * CoordinateSystem name - */ - - public static boolean isDasCoordinateSystem(String string, - DBRefEntry dBRefEntry) - { - if (string == null || dBRefEntry == null) - { - return false; - } - String coordsys = dasCoordinateSystemsLookup.get(string.toLowerCase()); - return coordsys == null ? false - : coordsys.equals(dBRefEntry.getSource()); - } - - /** * look up source in an internal list of database reference sources and return * the canonical jalview name for the source, or the original string if it has * no canonical form. @@ -218,7 +190,7 @@ public class DBRefUtils static List searchRefs(DBRefEntry[] refs, DBRefEntry entry, DbRefComp comparator) { - List rfs = new ArrayList(); + List rfs = new ArrayList<>(); if (refs == null || entry == null) { return rfs; @@ -594,7 +566,7 @@ public class DBRefUtils public static List searchRefsForSource(DBRefEntry[] dbRefs, String source) { - List matches = new ArrayList(); + List matches = new ArrayList<>(); if (dbRefs != null && source != null) { for (DBRefEntry dbref : dbRefs) @@ -644,7 +616,7 @@ public class DBRefUtils // nothing to do return; } - List selfs = new ArrayList(); + List selfs = new ArrayList<>(); { DBRefEntry[] selfArray = selectDbRefs(!sequence.isProtein(), sequence.getDBRefs()); @@ -664,11 +636,11 @@ public class DBRefUtils selfs.remove(p); } } - List toPromote = new ArrayList(); + List toPromote = new ArrayList<>(); for (DBRefEntry p : pr) { - List promType = new ArrayList(); + List promType = new ArrayList<>(); if (sequence.isProtein()) { switch (getCanonicalName(p.getSource())) diff --git a/test/jalview/bin/CommandLineOperations.java b/test/jalview/bin/CommandLineOperations.java index 3ac8656..0424acc 100644 --- a/test/jalview/bin/CommandLineOperations.java +++ b/test/jalview/bin/CommandLineOperations.java @@ -279,8 +279,6 @@ public class CommandLineOperations "Failed command : -open examples/uniref50.fa" }, { "CMD [-nosortbytree] executed successfully!", "Failed command : -nosortbytree" }, - { "CMD [-dasserver nickname=www.test.com] executed successfully!", - "Failed command : -dasserver nickname=www.test.com" }, { "CMD [-features examples/testdata/plantfdx.features] executed successfully!", "Failed command : -features examples/testdata/plantfdx.features" }, @@ -294,7 +292,7 @@ public class CommandLineOperations { "CMD [-nousagestats] executed successfully!", "Failed command : -nousagestats" }, { "CMD [-noquestionnaire] executed successfully!", - "Failed command : -noquestionnaire nickname=www.test.com" } }; + "Failed command : -noquestionnaire" } }; } diff --git a/test/jalview/util/DBRefUtilsTest.java b/test/jalview/util/DBRefUtilsTest.java index 0ef3c25..0368d1e 100644 --- a/test/jalview/util/DBRefUtilsTest.java +++ b/test/jalview/util/DBRefUtilsTest.java @@ -21,7 +21,6 @@ package jalview.util; import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; @@ -121,38 +120,6 @@ public class DBRefUtilsTest assertEquals("pfam", DBRefUtils.getCanonicalName("pfam")); } - - @Test(groups = { "Functional" }) - public void testIsDasCoordinateSystem() - { - assertFalse(DBRefUtils.isDasCoordinateSystem(null, null)); - assertFalse(DBRefUtils.isDasCoordinateSystem("pdbresnum", null)); - assertFalse(DBRefUtils.isDasCoordinateSystem(null, new DBRefEntry( - "PDB", "v1", "a1"))); - - assertTrue(DBRefUtils.isDasCoordinateSystem("pdbresnum", - new DBRefEntry("PDB", "v1", "a1"))); - assertTrue(DBRefUtils.isDasCoordinateSystem("PDBRESNUM", - new DBRefEntry("PDB", "v1", "a1"))); - // "pdb" is converted to upper-case in DBRefEntry constructor - assertTrue(DBRefUtils.isDasCoordinateSystem("pdbresnum", - new DBRefEntry("pdb", "v1", "a1"))); - assertFalse(DBRefUtils.isDasCoordinateSystem("pdb", new DBRefEntry( - "pdb", "v1", "a1"))); - - assertTrue(DBRefUtils.isDasCoordinateSystem("UNIPROT", new DBRefEntry( - "Uniprot", "v1", "a1"))); - assertTrue(DBRefUtils.isDasCoordinateSystem("Uniprot", new DBRefEntry( - "UNIPROT", "v1", "a1"))); - assertFalse(DBRefUtils.isDasCoordinateSystem("UNIPROTKB", - new DBRefEntry("pdb", "v1", "a1"))); - - assertTrue(DBRefUtils.isDasCoordinateSystem("EMBL", new DBRefEntry( - "EMBL", "v1", "a1"))); - assertTrue(DBRefUtils.isDasCoordinateSystem("embl", new DBRefEntry( - "embl", "v1", "a1"))); - } - /** * Test 'parsing' a DBRef - non PDB case */ -- 1.7.10.2