JAL-2847 if pfam id is detected in first sequence its shown in db query
[jalview.git] / src / jalview / ext / archaeopteryx / AptxInit.java
index b9a7ae2..3dc2e88 100644 (file)
@@ -15,6 +15,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.HashMap;
 import java.util.Map;
 
 import org.forester.archaeopteryx.AptxUtil;
@@ -65,6 +66,8 @@ public final class AptxInit
   private final static NHXParser.TAXONOMY_EXTRACTION TAXONOMY_EXTRACTION = APTX_CONFIG
           .getTaxonomyExtraction();
 
+  private static Map<MainFrame, JalviewBinding> activeAptx = new HashMap<>();
+
 
 
   public static MainFrame createInstanceFromCalculation(
@@ -125,13 +128,20 @@ public final class AptxInit
       nex.setReplaceUnderscores(REPLACE_NHX_UNDERSCORES);
       nex.setIgnoreQuotes(false);
     }
-//    else if (p instanceof PhyloXmlParser)
-//    {
-//      MainFrameApplication.warnIfNotPhyloXmlValidation(APTX_CONFIG);
-//    }
+    else if (parser instanceof PhyloXmlParser)
+    {
+      if ( VALIDATE_PHYLOXML_XSD ) {
+        JvOptionPane.showInternalMessageDialog( null,
+                                       ForesterUtil.wordWrap(
+                                                              "phyloXML XSD-based validation is turned off [enable with line 'validate_against_phyloxml_xsd_schem: true' in configuration file]",
+                                                              80 ),
+                                       "Warning",
+                                       JvOptionPane.WARNING_MESSAGE );
+      }
+    }
     Phylogeny[] trees = PhylogenyMethods.readPhylogenies(parser, treeFile);
     MainFrame[] aptxFrames = new MainFrame[trees.length];
-    String treeTitle = treeFile.getName();
+
 
     for (int i = 0; i < trees.length; i++)
       {
@@ -141,6 +151,8 @@ public final class AptxInit
       {
         PhylogenyMethods.transferInternalNodeNamesToConfidence(tree, "");
       }
+      String treeTitle = treeFile.getName() + "[" + i + "]";
+      tree.setName(treeTitle);
       aptxFrames[i] = createAptxFrame(tree, viewport, treeTitle);
 
     }
@@ -191,7 +203,7 @@ public final class AptxInit
    * @return
    */
   public static MainFrame[] createInstancesFromDb(int databaseIndex,
-          AlignmentViewport viewport)
+          AlignmentViewport viewport, String defaultIdentifier)
   {
 
     URL url = null;
@@ -204,7 +216,8 @@ public final class AptxInit
             Desktop.desktop,
             client.getInstructions() + "\n(Reference: "
                     + client.getReference() + ")",
-            client.getDescription(), JvOptionPane.QUESTION_MESSAGE);
+            client.getDescription(), JvOptionPane.QUESTION_MESSAGE, null,
+            null, defaultIdentifier).toString();
 
     if ((identifier != null) && (identifier.trim().length() > 0))
     {
@@ -496,8 +509,11 @@ public final class AptxInit
           final Map<SequenceI, PhylogenyNode> alignMappedToNodes,
           final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
   {
-    return new JalviewBinding(aptxApp, jalviewAlignViewport,
+    JalviewBinding treeBinding = new JalviewBinding(aptxApp,
+            jalviewAlignViewport,
             alignMappedToNodes, nodesMappedToAlign);
+    activeAptx.put(aptxApp, treeBinding);
+    return treeBinding;
   }
 
 
@@ -509,14 +525,25 @@ public final class AptxInit
     aptxApp.setMinimumSize(new Dimension(width, height));
     // aptxApp.setFont(Desktop.instance.getFont());
     // aptxApp.getMainPanel().setFont(Desktop.instance.getFont());
-
-    Desktop.addInternalFrame(aptxApp, "Archaeopteryx Tree View", true,
-            width, height, true, true);
-
+    String frameTitle = MessageManager.getString("label.aptx_title");
+    File treeFile = aptxApp.getMainPanel().getCurrentTreePanel()
+            .getTreeFile();
+    if (treeFile != null)
+    {
+      frameTitle += MessageManager.formatMessage("label.aptx_title_append",
+              new String[]
+              { treeFile.getAbsolutePath() });
+    }
+    Desktop.addInternalFrame(aptxApp, frameTitle, true, width, height, true,
+            true);
     return aptxApp;
 
   }
 
+  public static Map<MainFrame, JalviewBinding> getAllAptxFrames()
+  {
+    return activeAptx;
+  }
 
 
 }