diff --git a/jar/pb-ui-5.4.2.jar b/jar/pb-ui-5.4.2.jar index 5d3c383..795679c 100644 Binary files a/jar/pb-ui-5.4.2.jar and b/jar/pb-ui-5.4.2.jar differ diff --git a/src/bzh/plealog/blastviewer/BlastSummaryViewerPanel.java b/src/bzh/plealog/blastviewer/BlastSummaryViewerPanel.java index 0b671af..0b89c6c 100644 --- a/src/bzh/plealog/blastviewer/BlastSummaryViewerPanel.java +++ b/src/bzh/plealog/blastviewer/BlastSummaryViewerPanel.java @@ -67,6 +67,7 @@ import bzh.plealog.bioinfo.ui.util.TableSearcherComponentAPI; import bzh.plealog.bioinfo.ui.util.TableSearcherComponentAction; import bzh.plealog.blastviewer.actions.summary.ChooseClassificationAction; +import bzh.plealog.blastviewer.actions.summary.ViewQueryIprScanPredictionsAction; import bzh.plealog.blastviewer.actions.summary.GlobalFilterAction; import bzh.plealog.blastviewer.actions.summary.GlobalSaveAction; import bzh.plealog.blastviewer.actions.summary.ImportIprScanDomainsAction; @@ -95,6 +96,7 @@ public class BlastSummaryViewerPanel extends JPanel { private GlobalSaveAction _saveAction; private ChooseClassificationAction _classifSelectAction; private OpenBasicViewerAction _openBasicViewerAction; + private ViewQueryIprScanPredictionsAction _viewQueryIPRAction; private MyImportIprScanDomainsAction _importIprScan; private BlastSummaryViewerController _bvController; private JButton _startSearchBtn; @@ -122,7 +124,11 @@ public void setContent(QueryBase query, BlastEntry entry) { _importIprScan.setTable(_summaryTable); _importIprScan.SetQuery(query); _openBasicViewerAction.setTable(_summaryTable); - + _viewQueryIPRAction.setTable(_summaryTable); + + _openBasicViewerAction.setEnabled(false); + _viewQueryIPRAction.setEnabled(false); + QueryBaseUI qBaseUI; qBaseUI = new QueryBaseUI(query); SummaryTableModel resultTableModel = new SummaryTableModel(); @@ -330,8 +336,7 @@ private JToolBar getToolbar() { btn = tBar.add(_openBasicViewerAction); btn.setToolTipText(BVMessages.getString("BlastHitList.open.tip")); btn.setText(BVMessages.getString("BlastHitList.open.btn")); - - + icon = EZEnvironment.getImageIcon("filterRes.png"); if (icon != null) { _filterAction = new GlobalFilterAction("", icon); @@ -368,6 +373,17 @@ private JToolBar getToolbar() { btn.setToolTipText(BVMessages.getString("BlastHitList.iprscan.tip")); btn.setText(BVMessages.getString("BlastHitList.iprscan.btn")); + icon = EZEnvironment.getImageIcon("view_features.png"); + if (icon != null) { + _viewQueryIPRAction = new ViewQueryIprScanPredictionsAction("", icon); + } else { + _viewQueryIPRAction = new ViewQueryIprScanPredictionsAction(BVMessages.getString("BlastHitList.edit.btn")); + } + _viewQueryIPRAction.setEnabled(true); + btn = tBar.add(_viewQueryIPRAction); + btn.setToolTipText(BVMessages.getString("BlastHitList.edit.tip")); + btn.setText(BVMessages.getString("BlastHitList.edit.btn")); + icon = EZEnvironment.getImageIcon("meta_path_24_24.png"); if (icon != null) { _classifSelectAction = new ChooseClassificationAction("", icon); @@ -428,8 +444,13 @@ public void valueChanged(ListSelectionEvent event) { return; if (_summaryTable.getSelectedRowCount()!=1) { _hitListPane.resetDataModel(); + _openBasicViewerAction.setEnabled(false); + _viewQueryIPRAction.setEnabled(false); return; } + _openBasicViewerAction.setEnabled(true); + _viewQueryIPRAction.setEnabled(true); + int row = _summaryTable.getSelectedRow(); if (row<0) { _hitListPane.resetDataModel(); diff --git a/src/bzh/plealog/blastviewer/actions/summary/ViewQueryIprScanPredictionsAction.java b/src/bzh/plealog/blastviewer/actions/summary/ViewQueryIprScanPredictionsAction.java new file mode 100644 index 0000000..2e044f2 --- /dev/null +++ b/src/bzh/plealog/blastviewer/actions/summary/ViewQueryIprScanPredictionsAction.java @@ -0,0 +1,113 @@ +/* Copyright (C) 2021 Patrick G. Durand + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/agpl-3.0.txt + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + */ +package bzh.plealog.blastviewer.actions.summary; + +import java.awt.event.ActionEvent; + +import javax.swing.AbstractAction; +import javax.swing.Icon; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; + +import com.plealog.genericapp.api.EZEnvironment; +import com.plealog.genericapp.api.log.EZLogger; + +import bzh.plealog.bioinfo.api.data.searchresult.SROutput; +import bzh.plealog.bioinfo.ui.blast.resulttable.SummaryTable; +import bzh.plealog.bioinfo.ui.blast.resulttable.SummaryTableModel; +import bzh.plealog.blastviewer.resources.BVMessages; +import bzh.plealog.blastviewer.summary.ViewQueryIprScanPredictionsDialog; + +/** + * This class implements the action to view Interposcan predictions + * made on a query. + * + * @author Patrick G. Durand + */ +public class ViewQueryIprScanPredictionsAction extends AbstractAction { + private static final long serialVersionUID = -3984245135396746453L; + private SummaryTable _table; + private boolean _running = false; + + /** + * Action constructor. + * + * @param name + * the name of the action. + */ + public ViewQueryIprScanPredictionsAction(String name) { + super(name); + } + + /** + * Action constructor. + * + * @param name + * the name of the action. + * @param icon + * the icon of the action. + */ + public ViewQueryIprScanPredictionsAction(String name, Icon icon) { + super(name, icon); + } + + /** + * Set data object. + */ + public void setTable(SummaryTable table) { + _table = table; + } + + private void doAction() { + if (_running || _table==null || _table.getSelectedRowCount()!=1) + return; + + _running = true; + + //get selected SROuput + SROutput sro = (SROutput) _table.getValueAt( + _table.getSelectedRow(), + SummaryTableModel.RESULT_DATA_COL); + if (sro.isEmpty()) { + return; + } + + ViewQueryIprScanPredictionsDialog dlg = new ViewQueryIprScanPredictionsDialog( + JOptionPane.getFrameForComponent(_table), sro.getIteration(0).getIterationQueryID()); + + dlg.setData(sro.getIteration(0).getIterationQueryFeatureTable(), sro.getIteration(0).getIterationQueryLength()); + dlg.setVisible(true); + } + + public void actionPerformed(ActionEvent event) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + try { + doAction(); + } catch (Throwable t) { + EZLogger.warn(BVMessages.getString("OpenFileAction.err") + + t.toString()); + } finally { + _running = false; + EZEnvironment.setDefaultCursor(); + } + } + }); + } + +} diff --git a/src/bzh/plealog/blastviewer/resources/messages.properties b/src/bzh/plealog/blastviewer/resources/messages.properties index 6d51e7b..8627922 100755 --- a/src/bzh/plealog/blastviewer/resources/messages.properties +++ b/src/bzh/plealog/blastviewer/resources/messages.properties @@ -70,6 +70,8 @@ BlastHitList.save.btn=Save BlastHitList.save.tip=Save results in a file BlastHitList.open.btn=Open BlastHitList.open.tip=Open selected BLAST result to review details +BlastHitList.edit.btn=View IPRScan +BlastHitList.edit.tip=View Inteproscan predictions FilterEntryAction.msg1=Applying filter: %s FilterEntryAction.msg2=No results @@ -205,3 +207,8 @@ BlastSummaryViewerPanel.title=Query/hit table SRCOverviewPanel.show.btn=Show Hits SRCOverviewPanel.show.tip=Show selected classification entries on Hits Table + +EditQueryClassificationDialog.btnOk.text=OK +EditQueryClassificationDialog.btnCancel.text=Cancel +EditQueryClassificationDialog.btnAdd.text=Add +EditQueryClassificationDialog.this.title=Interproscan predictions on %s diff --git a/src/bzh/plealog/blastviewer/resources/view_features.png b/src/bzh/plealog/blastviewer/resources/view_features.png new file mode 100644 index 0000000..621ed91 Binary files /dev/null and b/src/bzh/plealog/blastviewer/resources/view_features.png differ diff --git a/src/bzh/plealog/blastviewer/summary/ViewQueryIprScanPredictionsDialog.java b/src/bzh/plealog/blastviewer/summary/ViewQueryIprScanPredictionsDialog.java new file mode 100755 index 0000000..798d010 --- /dev/null +++ b/src/bzh/plealog/blastviewer/summary/ViewQueryIprScanPredictionsDialog.java @@ -0,0 +1,113 @@ +/* Copyright (C) 2021 Patrick G. Durand + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * You may obtain a copy of the License at + * + * https://www.gnu.org/licenses/agpl-3.0.txt + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + */ +package bzh.plealog.blastviewer.summary; + +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; + +import bzh.plealog.bioinfo.api.data.feature.FeatureTable; +import bzh.plealog.bioinfo.api.data.sequence.BankSequenceDescriptor; +import bzh.plealog.bioinfo.data.sequence.EmptySequence; +import bzh.plealog.bioinfo.ui.feature.FeatureViewerFactory; +import bzh.plealog.bioinfo.ui.sequence.extended.CombinedAnnotatedSequenceViewer; +import bzh.plealog.bioinfo.util.DAlphabetUtils; +import bzh.plealog.blastviewer.resources.BVMessages; + +/** + * Dialogue box to display Interprosan predictions. + * + * @author Patrick G. Durand + */ +public class ViewQueryIprScanPredictionsDialog extends JDialog { + private static final long serialVersionUID = 5928719684421848123L; + + private CombinedAnnotatedSequenceViewer _viewer; + private JPanel _resultPanel; + private Dimension _startingSize = new Dimension(840,480); + + /** + * Constructor. + * + * @param parent parent frame + * @param queryID query ID shown in dialogue header + */ + public ViewQueryIprScanPredictionsDialog(Frame parent, String queryID) { + super(parent); + setLocationByPlatform(true); + setPreferredSize(_startingSize); + setSize(_startingSize); + setTitle(String.format( + BVMessages.getString("EditQueryClassificationDialog.this.title"), queryID)); + + _resultPanel = new JPanel(new BorderLayout()); + _viewer = new CombinedAnnotatedSequenceViewer( + null, BVMessages.class.getResourceAsStream("featureWebLink.conf"), + false, false, false, false, false, true, false, false, + FeatureViewerFactory.TYPE.COMBO); + _resultPanel.add(_viewer); + getContentPane().add(_resultPanel, BorderLayout.CENTER); + + JPanel panel = new JPanel(); + getContentPane().add(panel, BorderLayout.SOUTH); + panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); + + JButton btnOk = new JButton( + BVMessages.getString("EditQueryClassificationDialog.btnOk.text")); + btnOk.setPreferredSize(new Dimension(65, 23)); + btnOk.setMinimumSize(new Dimension(65, 23)); + btnOk.setMaximumSize(new Dimension(65, 23)); + btnOk.addActionListener(new OkListener()); + panel.add(btnOk); + + this.setModal(true); + this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + // to center + this.setLocationRelativeTo(null); + } + + /** + * Set data. + * + * @param ft feature table + * @param seqsize size of query sequence + */ + public void setData(FeatureTable ft, int seqsize) { + BankSequenceDescriptor sd = new BankSequenceDescriptor( + ft, null, new EmptySequence(DAlphabetUtils.getIUPAC_DNA_Alphabet(), seqsize)); + _viewer.setData(sd); + } + + private void close() { + dispose(); + } + + private class OkListener implements ActionListener { + + @Override + public void actionPerformed(ActionEvent e) { + close(); + } + } +} diff --git a/src/bzh/plealog/blastviewer/version.properties b/src/bzh/plealog/blastviewer/version.properties index 48510c1..2a6372a 100644 --- a/src/bzh/plealog/blastviewer/version.properties +++ b/src/bzh/plealog/blastviewer/version.properties @@ -3,9 +3,9 @@ prg.name=blastviewer # UI name prg.app.name=BLAST-Viewer # release prior to 5: KoriBlast/ngKLAST suite of software -prg.version=5.4.1 +prg.version=5.4.2 # Who did what and when -prg.copyright=(c) 2003-2020, Patrick G. Durand +prg.copyright=(c) 2003-2021, Patrick G. Durand prg.provider=Plealog # Place of the source code prg.url=https://github.com/pgdurand/BlastViewer