import jalview.datamodel.SequenceI;
import jalview.jbgui.GStructureChooser;
import jalview.jbgui.PDBDocFieldPreferences;
+import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
import jalview.ws.dbsources.PDBRestClient;
import jalview.ws.dbsources.PDBRestClient.PDBDocField;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
+import java.util.Hashtable;
import java.util.LinkedHashSet;
import java.util.List;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
+import javax.swing.table.DefaultTableModel;
+
/**
* Provides the behaviors for the Structure chooser Panel
private boolean isValidPBDEntry;
+ private static Hashtable<String, PDBEntry> cachedEntryMap;
+
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap)
{
long startTime = System.currentTimeMillis();
String msg = MessageManager.getString("status.fetching_db_refs");
updateProgressIndicator(msg, startTime);
+ loadLocalCachedPDBEntries();
fetchStructuresMetaData();
populateFilterComboBox();
updateProgressIndicator(null, startTime);
+ " Found (" + totalTime + ")");
}
+ public void loadLocalCachedPDBEntries()
+ {
+ DefaultTableModel tableModel = new DefaultTableModel();
+ tableModel.addColumn("Sequence");
+ tableModel.addColumn("PDB Id");
+ tableModel.addColumn("Type");
+ tableModel.addColumn("File");
+ cachedEntryMap = new Hashtable<String, PDBEntry>();
+ for (SequenceI seq : selectedSequences)
+ {
+ if (seq.getDatasetSequence() != null
+ && seq.getDatasetSequence().getPDBId() != null)
+ {
+ for (PDBEntry pdbEntry : seq.getDatasetSequence().getPDBId())
+ {
+ String[] pdbEntryRowData = new String[]
+ { seq.getDisplayId(false), pdbEntry.getId(), pdbEntry.getType(),
+ pdbEntry.getFile() };
+ tableModel.addRow(pdbEntryRowData);
+ cachedEntryMap.put(seq.getDisplayId(false) + pdbEntry.getId(),
+ pdbEntry);
+ }
+ }
+ }
+ tbl_local_pdb.setModel(tableModel);
+ }
+
/**
* Update the DBRef entry for a given sequence with values retrieved from
* PDBResponseSummary
* the sequences to build a query for
* @return the built query string
*/
- @SuppressWarnings("unchecked")
+
public static String buildQuery(SequenceI seq)
{
String query = seq.getName();
VIEWS_ENTER_ID));
cmb_filterOption.addItem(new FilterOption("From File", "-",
VIEWS_FROM_FILE));
+ cmb_filterOption.addItem(new FilterOption("Cached PDB Entries", "-",
+ VIEWS_LOCAL_PDB));
}
/**
chk_invertFilter.setVisible(true);
filterResultSet(selectedFilterOpt.getValue());
}
- else
+ else if (selectedFilterOpt.getView() == VIEWS_ENTER_ID
+ || selectedFilterOpt.getView() == VIEWS_FROM_FILE)
{
idInputAssSeqPanel.loadCmbAssSeq();
fileChooserAssSeqPanel.loadCmbAssSeq();
btn_view.setEnabled(true);
}
}
+ else if (currentView == VIEWS_LOCAL_PDB)
+ {
+ if (tbl_local_pdb.getSelectedRows().length > 0)
+ {
+ btn_view.setEnabled(true);
+ }
+ }
else if (currentView == VIEWS_ENTER_ID)
{
validateAssociationEnterPdb();
pdbEntriesToView[count++] = pdbEntry;
}
- StructureViewer sViewer = new StructureViewer(
- ap.getStructureSelectionManager());
- if (pdbEntriesToView.length > 1)
- {
- sViewer.viewStructures(ap, pdbEntriesToView,
- ap.av.collateForPDB(pdbEntriesToView));
- }
- else
+ launchStructureViewer(ap.getStructureSelectionManager(),
+ pdbEntriesToView, ap, selectedSequences);
+ }
+ else if(currentView == VIEWS_LOCAL_PDB){
+ int[] selectedRows = tbl_local_pdb.getSelectedRows();
+ PDBEntry[] pdbEntriesToView = new PDBEntry[selectedRows.length];
+ int count = 0;
+ for (int row : selectedRows)
{
- sViewer.viewStructures(pdbEntriesToView[0], selectedSequences,
- null, ap);
+ String entryKey = tbl_local_pdb.getValueAt(row, 0).toString() + tbl_local_pdb.getValueAt(row, 1).toString();
+ pdbEntriesToView[count++] = cachedEntryMap.get(entryKey);
}
-
+ launchStructureViewer(ap.getStructureSelectionManager(),
+ pdbEntriesToView, ap, selectedSequences);
}
else if (currentView == VIEWS_ENTER_ID)
{
selectedSequence.getDatasetSequence().addPDBId(pdbEntry);
PDBEntry[] pdbEntriesToView = new PDBEntry[]
{ pdbEntry };
- new StructureViewer(ap.getStructureSelectionManager())
- .viewStructures(ap, pdbEntriesToView,
- ap.av.collateForPDB(pdbEntriesToView));
+ launchStructureViewer(ap.getStructureSelectionManager(),
+ pdbEntriesToView, ap, new SequenceI[]
+ { selectedSequence });
}
else if (currentView == VIEWS_FROM_FILE)
{
{
selectedSequence = userSelectedSeq;
}
- System.out.println(">>>>>>>>>>>>> Selected file >>>>>>>>>>>>>>> "
- + selectedPdbFileName);
- new AssociatePdbFileWithSeq().associatePdbWithSeq(
+ PDBEntry fileEntry = new AssociatePdbFileWithSeq()
+ .associatePdbWithSeq(
selectedPdbFileName, jalview.io.AppletFormatAdapter.FILE,
selectedSequence, true, Desktop.instance);
+
+ launchStructureViewer(ap.getStructureSelectionManager(),
+ new PDBEntry[]
+ { fileEntry }, ap, new SequenceI[]
+ { selectedSequence });
}
mainFrame.dispose();
}
+ private void launchStructureViewer(StructureSelectionManager ssm,
+ PDBEntry[] pdbEntriesToView, AlignmentPanel alignPanel,
+ SequenceI[] selectedSequences)
+ {
+ StructureViewer sViewer = new StructureViewer(ssm);
+ if (pdbEntriesToView.length > 1)
+ {
+ sViewer.viewStructures(alignPanel, pdbEntriesToView,
+ alignPanel.av.collateForPDB(pdbEntriesToView));
+ }
+ else
+ {
+ sViewer.viewStructures(pdbEntriesToView[0], selectedSequences, null,
+ alignPanel);
+ }
+ }
+
/**
* Populates the combo-box used in associating manually fetched structures to
* a unique sequence when more than one sequence selection is made.
import java.awt.event.ActionEvent;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import javax.swing.ImageIcon;
import javax.swing.JButton;
private JPanel pnl_actions = new JPanel();
- private JPanel pnl_filter = new JPanel();
+ private JPanel pnl_main = new JPanel();
private JPanel pnl_idInput = new JPanel(new FlowLayout());
private JPanel pnl_fileChooserBL = new JPanel(new BorderLayout());
+ private JPanel pnl_locPDB = new JPanel(new BorderLayout());
+
protected JPanel pnl_switchableViews = new JPanel(new CardLayout());
protected CardLayout layout_switchableViews = (CardLayout) (pnl_switchableViews
protected static final String VIEWS_ENTER_ID = "VIEWS_ENTER_ID";
+ protected static final String VIEWS_LOCAL_PDB = "VIEWS_LOCAL_PDB";
+
protected JTable tbl_summary = new JTable();
protected JScrollPane scrl_foundStructures = new JScrollPane(
tbl_summary);
- private JTabbedPane tabbedPane = new JTabbedPane();
+ protected JTable tbl_local_pdb = new JTable();
+
+ protected JScrollPane scrl_localPDB = new JScrollPane(tbl_local_pdb);
+
+ private JTabbedPane pnl_filter = new JTabbedPane();
private PDBDocFieldPreferences pdbDocFieldPrefs = new PDBDocFieldPreferences(
PreferenceSource.STRUCTURE_CHOOSER);
private void jbInit() throws Exception
{
tbl_summary.setAutoCreateRowSorter(true);
+ tbl_local_pdb.setAutoCreateRowSorter(true);
+ tbl_local_pdb.addMouseListener(new MouseAdapter()
+ {
+ public void mouseClicked(MouseEvent e)
+ {
+ updateCurrentView();
+ }
+ });
+
btn_view.setFont(new java.awt.Font("Verdana", 0, 12));
btn_view.setText(MessageManager.getString("action.view"));
btn_view.addActionListener(new java.awt.event.ActionListener()
scrl_foundStructures
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+ scrl_localPDB.setPreferredSize(new Dimension(500, 300));
+ scrl_localPDB
+ .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
+
cmb_filterOption.setFont(new java.awt.Font("Verdana", 0, 12));
chk_invertFilter.setFont(new java.awt.Font("Verdana", 0, 12));
chk_rememberSettings.setFont(new java.awt.Font("Verdana", 0, 12));
pnl_actions.add(btn_cancel);
// pnl_filter.add(lbl_result);
- pnl_filter.add(cmb_filterOption);
- pnl_filter.add(lbl_loading);
- pnl_filter.add(chk_invertFilter);
+ pnl_main.add(cmb_filterOption);
+ pnl_main.add(lbl_loading);
+ pnl_main.add(chk_invertFilter);
lbl_loading.setVisible(false);
- pnl_idInput.add(txt_search);
- pnl_idInput.add(lbl_pdbManualFetchStatus);
pnl_fileChooser.add(btn_pdbFromFile);
pnl_fileChooser.add(lbl_fromFileStatus);
-
pnl_fileChooserBL.add(fileChooserAssSeqPanel, BorderLayout.NORTH);
pnl_fileChooserBL.add(pnl_fileChooser, BorderLayout.CENTER);
+ pnl_idInput.add(txt_search);
+ pnl_idInput.add(lbl_pdbManualFetchStatus);
pnl_idInputBL.add(idInputAssSeqPanel, BorderLayout.NORTH);
pnl_idInputBL.add(pnl_idInput, BorderLayout.CENTER);
}
}
};
- tabbedPane.addChangeListener(changeListener);
- tabbedPane.setPreferredSize(new Dimension(500, 300));
- tabbedPane.add(foundStructureSummary, scrl_foundStructures);
- tabbedPane.add(
+ pnl_filter.addChangeListener(changeListener);
+ pnl_filter.setPreferredSize(new Dimension(500, 300));
+ pnl_filter.add(foundStructureSummary, scrl_foundStructures);
+ pnl_filter.add(
MessageManager.getString("label.configure_displayed_columns"),
pdbDocFieldPrefs);
+ pnl_locPDB.add(scrl_localPDB);
pnl_switchableViews.add(pnl_fileChooserBL, VIEWS_FROM_FILE);
pnl_switchableViews.add(pnl_idInputBL, VIEWS_ENTER_ID);
- pnl_switchableViews.add(tabbedPane, VIEWS_FILTER);
+ pnl_switchableViews.add(pnl_filter, VIEWS_FILTER);
+ pnl_switchableViews.add(pnl_locPDB, VIEWS_LOCAL_PDB);
this.setLayout(mainLayout);
- this.add(pnl_filter, java.awt.BorderLayout.NORTH);
+ this.add(pnl_main, java.awt.BorderLayout.NORTH);
this.add(pnl_switchableViews, java.awt.BorderLayout.CENTER);
this.add(pnl_actions, java.awt.BorderLayout.SOUTH);