if(pdbentry.getFile()!=null)
{
+ // import structure data from pdbentry.getFile based on given protocol
if (protocol.equals(AppletFormatAdapter.PASTE))
+ {
loadInline(pdbentry.getFile());
- else
+ } else
+ if (protocol.equals(AppletFormatAdapter.FILE) || protocol.equals(AppletFormatAdapter.URL)){
viewer.openFile(pdbentry.getFile());
+ }
+ else
+ {
+ // probably CLASSLOADER based datasource..
+ // Try and get a reader on the datasource, and pass that to Jmol
+ try {
+ FileParse fparser = new jalview.io.FileParse(protocol, pdbentry.getFile());
+ if (!fparser.isValid())
+ {
+ throw new Exception("Invalid datasource. "+fparser.getWarningMessage());
+ }
+ viewer.openReader(pdbentry.getFile(), pdbentry.getId(), fparser.getReader());
+ } catch (Exception e)
+ {
+ // give up!
+ System.err.println("Couldn't access pdbentry id="+pdbentry.getId()+" and file="+pdbentry.getFile()+" using protocol="+protocol);
+ e.printStackTrace();
+ }
+ }
}
-
+
jalview.bin.JalviewLite.addFrame(this, "Jmol", 400,400);
}
class LoadingThread
extends Thread
{
- String file;
+ /**
+ * State variable: File source
+ */
+ String file;
+ /**
+ * State variable: protocol for access to file source
+ */
String protocol;
+ /**
+ * State variable: format of file source
+ */
String format;
JalviewLite applet;
-
- public LoadingThread(String _file,
- JalviewLite _applet)
+ private void dbgMsg(String msg)
{
if (applet.debug)
{
- System.err.println("Loading thread started with:\n>>file\n"+_file+">>endfile");
+ System.err.println(msg);
}
- file = _file;
+ }
+ /**
+ * update the protocol state variable for accessing the datasource
+ * located by file.
+ * @param file
+ * @return possibly updated datasource string
+ */
+ public String setProtocolState(String file)
+ {
if (file.startsWith("PASTE"))
{
file = file.substring(5);
file = addProtocol(file);
protocol = AppletFormatAdapter.URL;
}
- if (applet.debug)
- {
- System.err.println("Protocol identified as '"+protocol+"'");
- }
+ dbgMsg("Protocol identified as '"+protocol+"'");
+ return file;
+ }
+ public LoadingThread(String _file,
+ JalviewLite _applet)
+ {
+ dbgMsg("Loading thread started with:\n>>file\n"+_file+">>endfile");
+ file = setProtocolState(_file);
+
format = new jalview.io.IdentifyFile().Identify(file, protocol);
- if (applet.debug)
- {
- System.err.println("File identified as '"+format+"'");
- }
+ dbgMsg("File identified as '"+format+"'");
applet = _applet;
}
private void startLoading()
{
+ dbgMsg("Loading started.");
Alignment al = null;
try
{
}
catch (java.io.IOException ex)
{
+ dbgMsg("File load exception.");
ex.printStackTrace();
}
if ( (al != null) && (al.getHeight() > 0))
{
+ dbgMsg("Successfully loaded file.");
initialAlignFrame = new AlignFrame(al,
applet,
file,
{
try
{
- if (inArchive(treeFile))
+ treeFile = setProtocolState(treeFile);
+ /*if (inArchive(treeFile))
{
protocol = AppletFormatAdapter.CLASSLOADER;
}
protocol = AppletFormatAdapter.URL;
treeFile = addProtocol(treeFile);
}
-
+ */
jalview.io.NewickFile fin = new jalview.io.NewickFile(treeFile,
protocol);
if (fin.getTree() != null)
{
currentAlignFrame.loadTree(fin, treeFile);
+ dbgMsg("Successfuly imported tree.");
+ } else {
+ dbgMsg("Tree parameter did not resolve to a valid tree.");
}
}
catch (Exception ex)
String param = getParameter("features");
if (param != null)
{
- if (!inArchive(param))
- {
- param = addProtocol(param);
- }
-
+ param = setProtocolState(param);
+
currentAlignFrame.parseFeaturesFile(param, protocol);
}
param = getParameter("annotations");
if (param != null)
- {
- if (!inArchive(param))
- {
- param = addProtocol(param);
- }
-
- new AnnotationFile().readAnnotationFile(
+ {
+ param = setProtocolState(param);
+
+ if (new AnnotationFile().readAnnotationFile(
currentAlignFrame.viewport.getAlignment(),
param,
- protocol);
-
- currentAlignFrame.alignPanel.fontChanged();
- currentAlignFrame.alignPanel.setScrollValues(0, 0);
+ protocol))
+ {
+ currentAlignFrame.alignPanel.fontChanged();
+ currentAlignFrame.alignPanel.setScrollValues(0, 0);
+ } else {
+ System.err.println("Annotations were not added from annotation file '"+param+"'");
+ }
}
{
try
{
- if (inArchive(param))
- {
- protocol = AppletFormatAdapter.CLASSLOADER;
- }
- else
- {
- protocol = AppletFormatAdapter.URL;
- param = addProtocol(param);
- }
-
+ param = setProtocolState(param);
jalview.io.JPredFile predictions = new jalview.io.JPredFile(
param, protocol);
- new JnetAnnotationMaker().add_annotation(predictions,
+ JnetAnnotationMaker.add_annotation(predictions,
currentAlignFrame.viewport.getAlignment(),
- 0, false); // do not add sequence profile from concise output
+ 0, false); // false==do not add sequence profile from concise output
currentAlignFrame.alignPanel.fontChanged();
currentAlignFrame.alignPanel.setScrollValues(0, 0);
}
tmp2.copyInto(chains);
}
}
-
- if (inArchive(param) && !jmolAvailable)
- {
- protocol = AppletFormatAdapter.CLASSLOADER;
- }
- else
+ param = setProtocolState(param);
+
+ if (!jmolAvailable && protocol==AppletFormatAdapter.CLASSLOADER)
{
- protocol = AppletFormatAdapter.URL;
- param = addProtocol(param);
+ // TODO: pass PDB file in classloader on to Jmol
+ // This exception preserves the current behaviour where, even if the local pdb file was identified in the class loader
+ protocol = AppletFormatAdapter.URL; // this is probably NOT CORRECT!
+ param = addProtocol(param); //
}
pdb.setFile(param);
//Netscape Communicator for instance.
try
{
- return (getClass().getResourceAsStream("/" + file) != null);
+ boolean rtn = (getClass().getResourceAsStream("/" + file) != null);
+ if (debug)
+ { System.err.println("Resource '"+file+"' was "+(rtn ? "" : "not") +" located by classloader.");
+ }
+ return rtn;
}
catch (Exception ex)
{
if (file.indexOf("://") == -1)
{
file = getCodeBase() + file;
+ if (debug)
+ {
+ System.err.println("Prepended codebase for resource: '"+file+"'");
+ }
}
return file;