private boolean addingStructures = false;
+ /**
+ *
+ * @param file
+ * @param id
+ * @param seq
+ * @param ap
+ * @param loadStatus
+ * @param bounds
+ * @deprecated defaults to AppJmol(String[] files, ... , viewid);
+ */
public AppJmol(String file, String id, SequenceI[] seq,
AlignmentPanel ap, String loadStatus, Rectangle bounds)
{
this(file, id, seq, ap, loadStatus, bounds, null);
}
+ /**
+ * @deprecated
+ */
public AppJmol(String file, String id, SequenceI[] seq,
AlignmentPanel ap, String loadStatus, Rectangle bounds,
String viewid)
{
- PDBEntry pdbentry = new PDBEntry();
- pdbentry.setFile(file);
- pdbentry.setId(id);
+ this(new String[]
+ { file }, new String[]
+ { id }, new SequenceI[][]
+ { seq }, ap, loadStatus, bounds, viewid);
+ }
+
+ /**
+ *
+ * @param files
+ * @param ids
+ * @param seqs
+ * @param ap
+ * @param loadStatus
+ * @param bounds
+ * @param viewid
+ */
+ public AppJmol(String[] files, String[] ids, SequenceI[][] seqs,
+ AlignmentPanel ap, String loadStatus, Rectangle bounds,
+ String viewid)
+ {
+ PDBEntry[] pdbentrys = new PDBEntry[files.length];
+ for (int i = 0; i < pdbentrys.length; i++)
+ {
+ PDBEntry pdbentry = new PDBEntry();
+ pdbentry.setFile(files[i]);
+ pdbentry.setId(ids[i]);
+ pdbentrys[i] = pdbentry;
+ }
// / TODO: check if protocol is needed to be set, and if chains are
// autodiscovered.
- jmb = new AppJmolBinding(this, new PDBEntry[]
- { pdbentry }, new SequenceI[][]
- { seq }, null, null);
+ jmb = new AppJmolBinding(this, pdbentrys, seqs, null, null);
jmb.setLoadingFromArchive(true);
this.ap = ap;
}
+ IProgressIndicator progressBar = null;
+
public AppJmol(PDBEntry pdbentry, SequenceI[] seq, String[] chains,
AlignmentPanel ap)
{
+ progressBar = ap.alignFrame;
// ////////////////////////////////
// Is the pdb file already loaded?
String alreadyMapped = StructureSelectionManager
JOptionPane.YES_NO_OPTION);
if (option == JOptionPane.YES_OPTION)
{
- topJmol.addStructure(pdbentry, seq, chains, true);
+ topJmol.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
return;
}
}
* @param pdbentry
* @param seq
* @param chains
+ * @param alignFrame
* @param align
* if true, new structure(s) will be align using associated alignment
*/
private void addStructure(final PDBEntry pdbentry, final SequenceI[] seq,
- final String[] chains, final boolean b)
+ final String[] chains, final boolean b, final IProgressIndicator alignFrame)
{
if (pdbentry.getFile() == null)
{
}
// and call ourselves again.
- addStructure(pdbentry, seq, chains, b);
+ addStructure(pdbentry, seq, chains, b, alignFrame);
}
}).start();
return;
{ chains });
addingStructures = true;
_started = false;
+ alignAddedStructures = b;
+ progressBar = alignFrame; // visual indication happens on caller frame.
(worker = new Thread(this)).start();
return;
}
{
// retrieve the pdb and store it locally
AlignmentI pdbseq = null;
+ pdbid = jmb.pdbentry[pi].getId();
+ long hdl=pdbid.hashCode()-System.currentTimeMillis();
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar("Fetching PDB " + pdbid,
+ hdl);
+ }
try
{
pdbseq = pdbclient.getSequenceRecords(pdbid = jmb.pdbentry[pi]
ex.printStackTrace();
errormsgs.append("'" + pdbid + "'");
}
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar("Finished.", hdl);
+ }
if (pdbseq != null)
{
// just transfer the file name from the first sequence's first
{
Cache.log.error("Couldn't open Jmol viewer!", ex);
}
- }
- else
- {
- StringBuffer cmd = new StringBuffer();
- cmd.append("load APPEND ");
- cmd.append(files.toString());
- cmd.append("\n");
- final String command = cmd.toString();
- cmd = null;
- try
- {
- jmb.evalStateCommand(command);
- } catch (OutOfMemoryError oomerror)
- {
- new OOMWarning("When trying to add structures to the Jmol viewer!",
- oomerror);
- Cache.log.debug("File locations are " + files);
- } catch (Exception ex)
- {
- Cache.log.error("Couldn't add files to Jmol viewer!", ex);
}
- if (alignAddedStructures)
+ else
{
- // may need to wait around until script has finished
- while (jmb.viewer.isScriptExecuting())
+ StringBuffer cmd = new StringBuffer();
+ cmd.append("loadingJalviewdata=true\nload APPEND ");
+ cmd.append(files.toString());
+ cmd.append("\nloadingJalviewdata=null");
+ final String command = cmd.toString();
+ cmd = null;
+ try
{
- try
- {
- Thread.sleep(20);
- } catch (Exception e)
- {
- }
- ;
- }
- javax.swing.SwingUtilities.invokeLater(new Runnable()
+ jmb.evalStateCommand(command);
+ } catch (OutOfMemoryError oomerror)
{
- public void run()
+ new OOMWarning(
+ "When trying to add structures to the Jmol viewer!",
+ oomerror);
+ Cache.log.debug("File locations are " + files);
+ } catch (Exception ex)
+ {
+ Cache.log.error("Couldn't add files to Jmol viewer!", ex);
+ }
+ long lastnotify=jmb.getLoadNotifiesHandled();
+ // need to wait around until script has finished
+ while (lastnotify>=jmb.getLoadNotifiesHandled());
{
- jmb.superposeStructures(ap.av.getAlignment(), -1, null);
+ try
+ {
+ Thread.sleep(35);
+ } catch (Exception e)
+ {
+ }
}
- });
- alignAddedStructures = false;
+ // refresh the sequence colours for the new structure(s)
+ jmb.updateColours(ap);
+ // do superposition if asked to
+ if (alignAddedStructures)
+ {
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
+ {
+ public void run()
+ {
+ jmb.superposeStructures(ap.av.getAlignment(), -1, null);
+ }
+ });
+ alignAddedStructures = false;
+ }
+ addingStructures = false;
}
- addingStructures = false;
- }
}
_started = false;
worker = null;