label.standard_databases = Standard Databases
label.fetch_embl_uniprot = Fetch from EMBL/EMBLCDS or Uniprot/PDB and any selected DAS sources
label.fetch_uniprot_references = Fetch Uniprot references
-label.search_3dbeacons = Find models with 3D-Beacons
+label.search_3dbeacons = 3D-Beacons Search
+label.find_models_from_3dbeacons = Search 3D-Beacons for 3D structures and models
label.3dbeacons = 3D-Beacons
label.fetch_references_for = Fetch database references for {0} sequences ?
label.fetch_references_for_3dbeacons = 3D Beacons needs Uniprot References. Fetch database references for {0} sequences ?
--- /dev/null
+package jalview.fts.service.threedbeacons;
+
+import java.util.Map;
+import java.util.Objects;
+
+import jalview.fts.api.FTSData;
+
+/**
+ * TDB result bean - holds filtered fields for GUI and essential metadata fields
+ * for back end
+ *
+ * @author jprocter
+ *
+ */
+public class TDB_FTSData implements FTSData
+{
+ String primaryKey;
+
+ Object[] summaryRowData;
+
+ /*
+ * fields in the JSON object
+ */
+ public static String Uniprot_Id= "id";
+ public static String Uniprot_Start= "uniprot_start";
+ public static String Uniprot_End= "uniprot_end";
+ public static String Provider= "provider";
+ public static String Model_id= "model_identifier";
+ public static String Model_Category= "model_category";
+ public static String Model_Type= "model_type";
+ public static String Model_Title="model_title";
+ public static String Resolution= "resolution";
+ public static String Confidence= "confidence_avg_local_score";
+ public static String Confidence_Score_Type= "confidence_type";
+ public static String Confidence_Score_Version= "confidence_version";
+ public static String Coverage= "coverage";
+ public static String Sequence_Identity= "sequence_identity";
+ public static String Created_Date= "created";
+ public static String UniProt_Accession= "uniprot_accession";
+ public static String Url= "model_url";
+ public static String Page_URL= "model_page_url";
+ public static String Ensemble_Sample_Url= "ensembl_sample_url";
+
+ /**
+ * original response from server
+ */
+ Map<String, Object> tdb_entry;
+
+ public TDB_FTSData(String primaryKey,
+ Map<String, Object> tdbJsonStructure, Object[] summaryData)
+ {
+ this.primaryKey = primaryKey;
+ tdb_entry = tdbJsonStructure;
+ this.summaryRowData = summaryData;
+ }
+
+ public Object getField(String key)
+ {
+ return tdb_entry.get(key);
+ }
+
+ @Override
+ public Object[] getSummaryData()
+ {
+ return summaryRowData;
+ }
+
+ @Override
+ public Object getPrimaryKey()
+ {
+ return primaryKey;
+ }
+
+ /**
+ * Returns a string representation of this object;
+ */
+ @Override
+ public String toString()
+ {
+ StringBuilder summaryFieldValues = new StringBuilder();
+ for (Object summaryField : summaryRowData)
+ {
+ summaryFieldValues
+ .append(summaryField == null ? " " : summaryField.toString())
+ .append("\t");
+ }
+ return summaryFieldValues.toString();
+ }
+
+ /**
+ * Returns hash code value for this object
+ */
+ @Override
+ public int hashCode()
+ {
+ return Objects.hash(primaryKey, this.toString());
+ }
+
+ @Override
+ public boolean equals(Object that)
+ {
+ return this.toString().equals(that.toString());
+ }
+
+ public String getProvider()
+ {
+ return (String) getField(Provider);
+ }
+
+ public String getModelViewUrl()
+ {
+ return (String) getField(Page_URL);
+ }
+
+ public String getModelId()
+ {
+ return (String) getField(Model_id);
+ }
+
+}
private static FTSData getFTSData(Map<String, Object> tdbJsonStructure,
FTSRestRequest tdbRequest)
{
- // TODO: consider reusing PDBFTSRestClient.getFTSData ?
-
String primaryKey = null;
Object[] summaryRowData;
final String primaryKey1 = primaryKey;
final Object[] summaryRowData1 = summaryRowData;
- return new FTSData()
- {
-
- @Override
- public Object[] getSummaryData()
- {
- return summaryRowData1;
- }
-
- @Override
- public Object getPrimaryKey()
- {
- return primaryKey1;
- }
-
- /**
- * Returns a string representation of this object;
- */
- @Override
- public String toString()
- {
- StringBuilder summaryFieldValues = new StringBuilder();
- for (Object summaryField : summaryRowData1)
- {
- summaryFieldValues.append(
- summaryField == null ? " " : summaryField.toString())
- .append("\t");
- }
- return summaryFieldValues.toString();
- }
-
- /**
- * Returns hash code value for this object
- */
- @Override
- public int hashCode()
- {
- return Objects.hash(primaryKey1, this.toString());
- }
-
- @Override
- public boolean equals(Object that)
- {
- return this.toString().equals(that.toString());
- }
- };
+ return new TDB_FTSData(primaryKey, tdbJsonStructure, summaryRowData1);
}
// private static FTSData getFTSData(Map<String, Object> doc,
package jalview.gui;
-import java.util.Locale;
-
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Locale;
import java.util.concurrent.Executors;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JPopupMenu;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.AbstractTableModel;
import jalview.fts.core.FTSRestRequest;
import jalview.fts.core.FTSRestResponse;
import jalview.fts.service.pdb.PDBFTSRestClient;
+import jalview.fts.service.threedbeacons.TDB_FTSData;
import jalview.gui.structurechooser.PDBStructureChooserQuerySource;
import jalview.gui.structurechooser.StructureChooserQuerySource;
import jalview.gui.structurechooser.ThreeDBStructureChooserQuerySource;
{
private static final String AUTOSUPERIMPOSE = "AUTOSUPERIMPOSE";
- /**
- * transient combo box choice for initiating 3db fetch
- */
- private static final String VIEWS_QUERYING_TDB = "QUERY_3DB";
-
private SequenceI selectedSequence;
private SequenceI[] selectedSequences;
}
chk_superpose.setSelected(Cache.getDefault(AUTOSUPERIMPOSE, true));
+ btn_queryTDB.addActionListener(new ActionListener()
+ {
+
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ promptForTDBFetch();
+ }
+ });
Executors.defaultThreadFactory().newThread(new Runnable()
{
@Override
public void run()
{
- progressBar.setProgressBar("status.searching_3d_beacons", progressId);
+ mainFrame.setEnabled(false);
+ cmb_filterOption.setEnabled(false);
+ progressBar.setProgressBar(MessageManager.getString("status.searching_3d_beacons"), progressId);
// TODO: warn if no accessions discovered
populateSeqsWithoutSourceDBRef();
// redo initial discovery - this time with 3d beacons
initialStructureDiscovery();
if (!isStructuresDiscovered())
{
- progressBar.setProgressBar("status.no_structures_discovered_from_3d_beacons", progressId);
+ progressBar.setProgressBar(MessageManager.getString("status.no_structures_discovered_from_3d_beacons"), progressId);
+ btn_queryTDB.setToolTipText(MessageManager.getString("status.no_structures_discovered_from_3d_beacons"));
+ btn_queryTDB.setEnabled(false);
} else {
+ btn_queryTDB.setVisible(false);
progressBar.setProgressBar(null, progressId);
}
+ mainFrame.setEnabled(true);
+ cmb_filterOption.setEnabled(true);
}
};
"-", VIEWS_FROM_FILE, false, null));
if (canQueryTDB && notQueriedTDBYet)
{
- FilterOption queryTDBOption = new FilterOption(
- MessageManager.getString("label.search_3dbeacons"), "-",
- VIEWS_QUERYING_TDB, false, null);
- cmb_filterOption.addItem(queryTDBOption);
+ btn_queryTDB.setVisible(true);
}
if (cachedPDBExist)
FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
.getSelectedItem());
- // first check if we need to rebuild dialog
- if (selectedFilterOpt.getView() == VIEWS_QUERYING_TDB)
- {
- promptForTDBFetch();
- return;
- }
if (lastSelected == selectedFilterOpt)
{
// don't need to do anything, probably
.setEnabled(selectedCount > 1 || targetView.getItemCount() > 0);
}
+ @Override
+ protected boolean showPopupFor(int selectedRow, int x, int y)
+ {
+ FilterOption selectedFilterOpt = ((FilterOption) cmb_filterOption
+ .getSelectedItem());
+ String currentView = selectedFilterOpt.getView();
+
+ if (currentView == VIEWS_FILTER && data instanceof ThreeDBStructureChooserQuerySource)
+ {
+
+ TDB_FTSData row=((ThreeDBStructureChooserQuerySource)data).getFTSDataFor(getResultTable(), selectedRow, discoveredStructuresSet);
+ String pageUrl = row.getModelViewUrl();
+ JPopupMenu popup = new JPopupMenu("3D Beacons");
+ JMenuItem viewUrl = new JMenuItem("View model web page");
+ viewUrl.addActionListener(
+ new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ Desktop.showUrl(pageUrl);
+ }
+ }
+ );
+ popup.add(viewUrl);
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() { popup.show(getResultTable(), x, y); }
+ });
+ return true;
+ }
+ // event not handled by us
+ return false;
+ }
/**
* Validates inputs from the Manual PDB entry panel
*/
import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
import jalview.fts.core.FTSRestRequest;
import jalview.fts.core.FTSRestResponse;
+import jalview.fts.service.threedbeacons.TDB_FTSData;
import jalview.fts.service.threedbeacons.TDBeaconsFTSRestClient;
import jalview.jbgui.FilterOption;
{
int prov_idx = lastTdbRequest.getFieldIndex("Provider");
boolean hasPDBe=false;
- for (FTSData row : tdbEntries)
+ for (FTSData _row : tdbEntries)
{
- String provider = (String) row.getSummaryData()[prov_idx];
+ // tdb returns custom object
+ TDB_FTSData row = (TDB_FTSData) _row;
+ String provider = (String) row.getProvider();
FilterOption providerOpt = new FilterOption(
"3DB Provider - " + provider,
FILTER_SOURCE_PREFIX + provider, VIEWS_FILTER, false, this);
return upResponse;
}
+ public TDB_FTSData getFTSDataFor(JTable restable, int selectedRow,
+ Collection<FTSData> discoveredStructuresSet)
+ {
+ int idColumnIndex = restable.getColumn("Model id").getModelIndex();
+
+ String modelId = (String) restable.getValueAt(selectedRow, idColumnIndex);
+ for (FTSData row:discoveredStructuresSet)
+ {
+ if (row instanceof TDB_FTSData && ((TDB_FTSData)row).getModelId().equals(modelId))
+ {
+ return ((TDB_FTSData)row);
+ }
+ }
+ return null;
+ }
+
}
\ No newline at end of file
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
+import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import javax.swing.JTextField;
import javax.swing.ListCellRenderer;
import javax.swing.Timer;
+import javax.swing.UIManager;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
protected JButton btn_newView;
protected JButton btn_pdbFromFile = new JButton();
+
+ protected JButton btn_queryTDB = new JButton();
protected JCheckBox chk_superpose = new JCheckBox(
MessageManager.getString("label.superpose_structures"));
protected ImageIcon warningImage = new ImageIcon(
getClass().getResource("/images/warning.gif"));
+ protected ImageIcon tdbImage = new ImageIcon(
+ getClass().getResource("/images/3d-beacons-logo-transparent.png"));
+
protected JLabel lbl_loading = new JLabel(loadingImage);
protected JLabel lbl_pdbManualFetchStatus = new JLabel(errorImage);
+ "...\"")
: JvSwingUtils.wrapTooltip(true, toolTipText)));
return toolTipText;
- }
+ }
};
public GStructureChooser()
tbl_summary.addMouseListener(new MouseAdapter()
{
@Override
+ public void mousePressed(MouseEvent e)
+ {
+ if (!popupAction(e))
+ {
+ super.mousePressed(e);
+ }
+ }
+ @Override
public void mouseClicked(MouseEvent e)
{
- validateSelections();
+ if (!popupAction(e))
+ {
+ validateSelections();
+ }
}
@Override
public void mouseReleased(MouseEvent e)
{
+ if (!popupAction(e))
+ {
validateSelections();
+ }
+ }
+ boolean popupAction(MouseEvent e)
+ {
+ if (e.isPopupTrigger())
+ {
+ Point pt = e.getPoint();
+ int selectedRow = tbl_summary.rowAtPoint(pt);
+ if (showPopupFor(selectedRow,pt.x,pt.y))
+ {
+ return true;
+ }
+ }
+ return false;
}
});
tbl_summary.addKeyListener(new KeyAdapter()
});
chk_invertFilter.addItemListener(this);
+ btn_queryTDB.setFont(VERDANA_12);
+ //btn_queryTDB.setPreferredSize(new Dimension(200,22));
+ btn_queryTDB.setText(MessageManager.getString("label.search_3dbeacons"));
+ btn_queryTDB.setToolTipText(MessageManager.getString("label.find_models_from_3dbeacons"));
+ btn_queryTDB.setIcon(tdbImage);
+ btn_queryTDB.setVisible(false);
targetView.setVisible(false);
actionsPanel.add(btn_newView);
actionsPanel.add(btn_cancel, "right");
- JPanel pnl_main = new JPanel();
- pnl_main.add(cmb_filterOption);
- pnl_main.add(lbl_loading);
- pnl_main.add(chk_invertFilter);
+ JPanel pnl_main = new JPanel(new BorderLayout());
+ JPanel pnl_controls = new JPanel();
+ pnl_main.add(btn_queryTDB,BorderLayout.NORTH);
+ pnl_controls.add(cmb_filterOption);
+ pnl_controls.add(lbl_loading);
+ pnl_controls.add(chk_invertFilter);
+ pnl_main.add(pnl_controls,BorderLayout.CENTER);
lbl_loading.setVisible(false);
JPanel pnl_fileChooser = new JPanel(new FlowLayout());
}
+protected abstract boolean showPopupFor(int selectedRow, int x, int y);
protected void closeAction(int preferredHeight)
{
// System.out.println(">>>>>>>>>> closing internal frame!!!");