import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
+import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
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 jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
+import jalview.bin.Console;
import jalview.bin.Jalview;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
{
private static final String AUTOSUPERIMPOSE = "AUTOSUPERIMPOSE";
+ /**
+ * warn user if need to fetch more than this many uniprot records at once
+ */
+ private static final int THRESHOLD_WARN_UNIPROT_FETCH_NEEDED = 20;
+
private SequenceI selectedSequence;
private SequenceI[] selectedSequences;
List<SequenceI> seqsWithoutSourceDBRef = null;
+ private boolean noChooserGUI = false;
+
private static StructureViewer lastTargetedView = null;
public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
AlignmentPanel ap)
{
+ this(selectedSeqs, selectedSeq, ap, false);
+ }
+
+ public StructureChooser(SequenceI[] selectedSeqs, SequenceI selectedSeq,
+ AlignmentPanel ap, boolean noChooserGUI)
+ {
// which FTS engine to use
data = StructureChooserQuerySource.getQuerySourceFor(selectedSeqs);
initDialog();
this.selectedSequence = selectedSeq;
this.selectedSequences = selectedSeqs;
this.progressIndicator = (ap == null) ? null : ap.alignFrame;
+ this.noChooserGUI = noChooserGUI;
init();
}
Executors.defaultThreadFactory().newThread(new Runnable()
{
+ @Override
public void run()
{
populateSeqsWithoutSourceDBRef();
populateFilterComboBox(isStructuresDiscovered(), cachedPDBExists);
discoverStructureViews();
updateProgressIndicator(null, startTime);
- mainFrame.setVisible(true);
+ mainFrame.setVisible(noChooserGUI);
updateCurrentView();
}
progressBar.setProgressBar(
MessageManager.getString("status.searching_3d_beacons"),
progressId);
+ btn_queryTDB.setEnabled(false);
// TODO: warn if no accessions discovered
populateSeqsWithoutSourceDBRef();
// redo initial discovery - this time with 3d beacons
btn_queryTDB.setToolTipText(MessageManager.getString(
"status.no_structures_discovered_from_3d_beacons"));
btn_queryTDB.setEnabled(false);
+ pnl_queryTDB.setVisible(false);
}
else
{
cmb_filterOption.setSelectedIndex(0); // select 'best'
btn_queryTDB.setVisible(false);
+ pnl_queryTDB.setVisible(false);
progressBar.setProgressBar(null, progressId);
}
mainFrame.setEnabled(true);
@Override
public void run()
{
+ btn_queryTDB.setEnabled(false);
populateSeqsWithoutSourceDBRef();
final int y = seqsWithoutSourceDBRef.size();
{ new jalview.ws.dbsources.Uniprot() }, null, false);
dbRefFetcher.addListener(afterDbRefFetch);
// ideally this would also gracefully run with callbacks
+
dbRefFetcher.fetchDBRefs(true);
}
else
};
final Runnable revertview = new Runnable()
{
+ @Override
public void run()
{
if (lastSelected != null)
}
};
};
- if (ignoreGui)
+ int threshold = Cache.getDefault("UNIPROT_AUTOFETCH_THRESHOLD",
+ THRESHOLD_WARN_UNIPROT_FETCH_NEEDED);
+ Console.debug("Using Uniprot fetch threshold of " + threshold);
+ if (ignoreGui || seqsWithoutSourceDBRef.size() < threshold)
{
Executors.defaultThreadFactory().newThread(discoverCanonicalDBrefs)
.start();
}
// need cancel and no to result in the discoverPDB action - mocked is
// 'cancel' TODO: mock should be OK
- JvOptionPane.newOptionDialog(this)
+
+ StructureChooser thisSC = this;
+ JvOptionPane.newOptionDialog(thisSC.getFrame())
.setResponseHandler(JvOptionPane.OK_OPTION,
discoverCanonicalDBrefs)
.setResponseHandler(JvOptionPane.CANCEL_OPTION, revertview)
null, new Object[]
{ MessageManager.getString("action.ok"),
MessageManager.getString("action.cancel") },
- MessageManager.getString("action.ok"));
+ MessageManager.getString("action.ok"), false);
}
/**
if (canQueryTDB && notQueriedTDBYet)
{
btn_queryTDB.setVisible(true);
+ pnl_queryTDB.setVisible(true);
}
if (cachedPDBExist)
popup.add(viewUrl);
SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
popup.show(getResultTable(), x, y);
{
if (selectedSequences != null)
{
+ lbl_loading.setVisible(true);
Thread refreshThread = new Thread(new Runnable()
{
@Override
filterResultSet(
((FilterOption) cmb_filterOption.getSelectedItem())
.getValue());
+ lbl_loading.setVisible(false);
}
});
refreshThread.start();
{
return notQueriedTDBYet;
}
+
+ /**
+ * Open a single structure file for a given sequence
+ */
+ public static void openStructureFileForSequence(AlignmentPanel ap,
+ SequenceI seq, File sFile)
+ {
+ StructureChooser sc = new StructureChooser(new SequenceI[] { seq }, seq,
+ ap, true);
+ StructureSelectionManager ssm = ap.getStructureSelectionManager();
+ PDBEntry fileEntry = null;
+ try
+ {
+ fileEntry = new AssociatePdbFileWithSeq().associatePdbWithSeq(
+ sFile.getAbsolutePath(), DataSourceType.FILE, seq, true,
+ Desktop.instance);
+ } catch (Exception e)
+ {
+ Console.error("Could not open structure file '"
+ + sFile.getAbsolutePath() + "'");
+ return;
+ }
+
+ StructureViewer sViewer = sc.launchStructureViewer(ssm,
+ new PDBEntry[]
+ { fileEntry }, ap, new SequenceI[] { seq });
+
+ sc.mainFrame.dispose();
+ sc.noChooserGUI = false;
+ }
}