JAL-2847 if pfam id is detected in first sequence its shown in db query
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Tue, 5 Dec 2017 13:02:07 +0000 (13:02 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Tue, 5 Dec 2017 13:02:07 +0000 (13:02 +0000)
src/jalview/ext/archaeopteryx/AptxInit.java
src/jalview/gui/AlignFrame.java

index da18a60..3dc2e88 100644 (file)
@@ -203,7 +203,7 @@ public final class AptxInit
    * @return
    */
   public static MainFrame[] createInstancesFromDb(int databaseIndex,
-          AlignmentViewport viewport)
+          AlignmentViewport viewport, String defaultIdentifier)
   {
 
     URL url = null;
@@ -216,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))
     {
index 5654c54..c76ce56 100644 (file)
@@ -53,6 +53,7 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentOrder;
 import jalview.datamodel.AlignmentView;
 import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.DBRefEntry;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.HiddenSequences;
 import jalview.datamodel.PDBEntry;
@@ -90,6 +91,7 @@ import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ColourSchemes;
 import jalview.schemes.ResidueColourScheme;
 import jalview.schemes.TCoffeeColourScheme;
+import jalview.util.DBRefUtils;
 import jalview.util.MessageManager;
 import jalview.viewmodel.AlignmentViewport;
 import jalview.viewmodel.ViewportRanges;
@@ -3946,33 +3948,46 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
   @Override
   protected void loadTreeBaseStudy_actionPerformed(ActionEvent e)
   {
-    chooseTreeDb(0);
+    chooseTreeDb(0, null);
 
   }
 
   @Override
   protected void loadTreeBase_actionPerformed(ActionEvent e)
   {
-    chooseTreeDb(1);
+    chooseTreeDb(1, null);
 
   }
   @Override
   protected void loadTreePfam_actionPerformed(ActionEvent e)
   {
-    chooseTreeDb(2);
+
+    // only DBRefs of first sequence are checked for matching DB for now
+    SequenceI seq = viewport.getAlignment().getSequenceAt(0);
+    String dbId = null;
+    for (DBRefEntry pfamRef : DBRefUtils
+            .searchRefsForSource(seq.getDBRefs(), "pfam"))
+    {
+      if (pfamRef.getAccessionId().startsWith("PF"))
+      {
+        dbId = pfamRef.getAccessionId().replaceAll("[A-Za-z]", "");
+      }
+
+    }
+    chooseTreeDb(2, dbId);
 
   }
   @Override
   protected void loadTreeFam_actionPerformed(ActionEvent e)
   {
-    chooseTreeDb(3);
+    chooseTreeDb(3, null);
 
   }
 
   @Override
   protected void loadTreeOfLife_actionPerformed(ActionEvent e)
   {
-    chooseTreeDb(4);
+    chooseTreeDb(4, null);
 
   }
 
@@ -4082,9 +4097,10 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener,
    * 
    * @param databaseIndex
    */
-  public void chooseTreeDb(int databaseIndex)
+  public void chooseTreeDb(int databaseIndex, String defaultIdentifier)
   {
-    AptxInit.createInstancesFromDb(databaseIndex, viewport);
+    AptxInit.createInstancesFromDb(databaseIndex, viewport,
+            defaultIdentifier);
   }
 
   public TreePanel showNewickTree(NewickFile nf, String treeTitle)