From 075c1528d363ca18476cb9f0b12709158c78fa5e Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Tue, 5 Dec 2017 13:02:07 +0000 Subject: [PATCH] JAL-2847 if pfam id is detected in first sequence its shown in db query --- src/jalview/ext/archaeopteryx/AptxInit.java | 5 +++-- src/jalview/gui/AlignFrame.java | 30 ++++++++++++++++++++------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/jalview/ext/archaeopteryx/AptxInit.java b/src/jalview/ext/archaeopteryx/AptxInit.java index da18a60..3dc2e88 100644 --- a/src/jalview/ext/archaeopteryx/AptxInit.java +++ b/src/jalview/ext/archaeopteryx/AptxInit.java @@ -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)) { diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 5654c54..c76ce56 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -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) -- 1.7.10.2