JAL-2871 JAL-2877 hideous attempt at seeing if non-static configuration kjvdh/features/testing
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 21 Dec 2017 14:42:16 +0000 (14:42 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 21 Dec 2017 14:42:16 +0000 (14:42 +0000)
works

src/jalview/ext/archaeopteryx/AptxInit.java

index f6b028a..aa106c3 100644 (file)
@@ -53,29 +53,6 @@ import org.forester.util.ForesterUtil;
  */
 public final class AptxInit
 {
-  // yet to add user preferred config
-  private final static Configuration APTX_CONFIG = new Configuration(
-          Cache.getDefault("APTXCONFIG",
-                  Desktop.instance.getClass()
-                          .getResource(
-                                  "/_aptx_jalview_configuration_file.txt")
-                          .toString()),
-            false, false, false);
-
-  private final static boolean VALIDATE_PHYLOXML_XSD = APTX_CONFIG
-          .isValidatePhyloXmlAgainstSchema();
-
-  private final static boolean REPLACE_NHX_UNDERSCORES = APTX_CONFIG
-          .isReplaceUnderscoresInNhParsing();
-
-  private final static boolean INTERNAL_NUMBERS_AS_CONFIDENCE = APTX_CONFIG
-          .isInternalNumberAreConfidenceForNhParsing();
-
-  private final static boolean MIDPOINT_REROOT = APTX_CONFIG
-          .isMidpointReroot();
-
-  private final static NHXParser.TAXONOMY_EXTRACTION TAXONOMY_EXTRACTION = APTX_CONFIG
-          .getTaxonomyExtraction();
 
   private static Map<MainFrame, JalviewBinding> activeAptx = new HashMap<>();
 
@@ -108,6 +85,12 @@ public final class AptxInit
           AlignmentViewport viewport)
           throws FileNotFoundException, IOException
   {
+    Configuration APTX_CONFIG = new Configuration(Cache.getDefault(
+            "APTXCONFIG",
+            Desktop.instance.getClass()
+                    .getResource("/_aptx_jalview_configuration_file.txt")
+                    .toString()),
+            false, false, false);
     File treeFile = new File(filePath);
     final String err = ForesterUtil.isReadableFile(treeFile);
     if (!ForesterUtil.isEmpty(err))
@@ -123,25 +106,28 @@ public final class AptxInit
     }
     boolean nhx_or_nexus = false;
     final PhylogenyParser parser = ParserUtils.createParserDependingOnFileType(
-            treeFile, VALIDATE_PHYLOXML_XSD);
+                    treeFile,
+                    APTX_CONFIG.isValidatePhyloXmlAgainstSchema());
     if (parser instanceof NHXParser)
     {
       nhx_or_nexus = true;
       final NHXParser nhx = (NHXParser) parser;
-      nhx.setReplaceUnderscores(REPLACE_NHX_UNDERSCORES);
+      nhx.setReplaceUnderscores(
+              APTX_CONFIG.isReplaceUnderscoresInNhParsing());
       nhx.setIgnoreQuotes(false);
-      nhx.setTaxonomyExtraction(TAXONOMY_EXTRACTION);
+      nhx.setTaxonomyExtraction(APTX_CONFIG.getTaxonomyExtraction());
     }
     else if (parser instanceof NexusPhylogeniesParser)
     {
       nhx_or_nexus = true;
       final NexusPhylogeniesParser nex = (NexusPhylogeniesParser) parser;
-      nex.setReplaceUnderscores(REPLACE_NHX_UNDERSCORES);
+      nex.setReplaceUnderscores(
+              APTX_CONFIG.isReplaceUnderscoresInNhParsing());
       nex.setIgnoreQuotes(false);
     }
     else if (parser instanceof PhyloXmlParser)
     {
-      if (VALIDATE_PHYLOXML_XSD == false)
+      if (APTX_CONFIG.isValidatePhyloXmlAgainstSchema() == false)
       {
         JvOptionPane.showInternalMessageDialog(Desktop.desktop,
                 MessageManager.getString("error.phyloxml_validation"),
@@ -157,7 +143,8 @@ public final class AptxInit
       {
       Phylogeny tree = trees[i];
 
-      if (nhx_or_nexus && INTERNAL_NUMBERS_AS_CONFIDENCE)
+      if (nhx_or_nexus
+              && APTX_CONFIG.isInternalNumberAreConfidenceForNhParsing())
       {
         PhylogenyMethods.transferInternalNodeNamesToConfidence(tree, "");
       }
@@ -178,16 +165,23 @@ public final class AptxInit
           AlignmentViewport viewport)
           throws FileNotFoundException, IOException, RuntimeException
   {
-    
+    Configuration APTX_CONFIG = new Configuration(Cache.getDefault(
+            "APTXCONFIG",
+            Desktop.instance.getClass()
+                    .getResource("/_aptx_jalview_configuration_file.txt")
+                    .toString()),
+            false, false, false);
     String treeTitle = treeUrl.getFile();
     if (Desktop.instance != null)
     {
       Desktop.instance.startLoading(treeTitle);
     }
     Phylogeny[] trees = AptxUtil.readPhylogeniesFromUrl(treeUrl,
-            VALIDATE_PHYLOXML_XSD,
-             REPLACE_NHX_UNDERSCORES, INTERNAL_NUMBERS_AS_CONFIDENCE,
-            TAXONOMY_EXTRACTION, MIDPOINT_REROOT);
+            APTX_CONFIG.isValidatePhyloXmlAgainstSchema(),
+            APTX_CONFIG.isReplaceUnderscoresInNhParsing(),
+            APTX_CONFIG.isInternalNumberAreConfidenceForNhParsing(),
+            APTX_CONFIG.getTaxonomyExtraction(),
+            APTX_CONFIG.isMidpointReroot());
 
     MainFrame[] aptxFrames = new MainFrame[trees.length];
     for (int i = 0; i < trees.length; i++)
@@ -216,7 +210,12 @@ public final class AptxInit
           PhylogeniesWebserviceClient treeDbClient, String identifier,
           AlignmentViewport viewport)
   {
-
+    Configuration APTX_CONFIG = new Configuration(Cache.getDefault(
+            "APTXCONFIG",
+            Desktop.instance.getClass()
+                    .getResource("/_aptx_jalview_configuration_file.txt")
+                    .toString()),
+            false, false, false);
     URL url = null;
     Phylogeny[] trees = null;
 
@@ -482,6 +481,12 @@ public final class AptxInit
           final Phylogeny aptxTree,
           final AlignmentViewport jalviewAlignport, String treeTitle)
   {
+    Configuration APTX_CONFIG = new Configuration(Cache.getDefault(
+            "APTXCONFIG",
+            Desktop.instance.getClass()
+                    .getResource("/_aptx_jalview_configuration_file.txt")
+                    .toString()),
+            false, false, false);
     if (APTX_CONFIG == null || APTX_CONFIG.isCouldReadConfigFile() == false)
     {
       int keepGoing = JvOptionPane.showConfirmDialog(Desktop.desktop,