for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)\r
{\r
StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]);\r
-\r
+ // RACE CONDITION - getMapping only returns Jmol loaded filenames once Jmol callback has completed. \r
if (mapping == null || mapping.length < 1)\r
continue;\r
\r
String mset[] = new String[viewer.getModelCount()];\r
_modelFileNameMap = new int[mset.length];\r
int j = 1;\r
- mset[0] = viewer.getModelFileName(0);\r
+ String m=viewer.getModelFileName(0);\r
+ if (m!=null)\r
+ {\r
+ mset[0] = new File(m).getAbsolutePath();\r
+ }\r
for (int i = 1; i < mset.length; i++)\r
{\r
- mset[j] = viewer.getModelFileName(i);\r
+ m=viewer.getModelFileName(i);\r
+ if (m!=null) {\r
+ mset[j] = new File(m).getAbsolutePath();\r
+ }\r
_modelFileNameMap[j] = i; // record the model index for the filename\r
// skip any additional models in the same file (NMR structures)\r
if ((mset[j] == null ? mset[j] != mset[j - 1]\r
try\r
{\r
// recover PDB filename for the model hovered over.\r
- pdbfilename = viewer\r
- .getModelFileName(new Integer(mdlId).intValue() - 1);\r
+ int _mp=_modelFileNameMap.length-1,\r
+ mnumber=new Integer(mdlId).intValue() - 1;\r
+ while(mnumber<_modelFileNameMap[_mp])\r
+ {\r
+ _mp--;\r
+ }\r
+ pdbfilename = modelFileNames[_mp];\r
+ if (pdbfilename==null) {pdbfilename=new File(viewer\r
+ .getModelFileName(mnumber)).getAbsolutePath();\r
+ }\r
+ \r
} catch (Exception e)\r
{\r
}\r
}\r
else\r
{\r
- if (matches = pdbentry[pe].getFile().equals(fileName))\r
+ File fl;\r
+ if (matches = (fl=new File(pdbentry[pe].getFile())).equals(new File(fileName)))\r
{\r
foundEntry = true;\r
// TODO: Jmol can in principle retrieve from CLASSLOADER but\r
String protocol = AppletFormatAdapter.URL;\r
try\r
{\r
- File fl = new java.io.File(pdbentry[pe].getFile());\r
if (fl.exists())\r
{\r
protocol = AppletFormatAdapter.FILE;\r
} catch (Error e)\r
{\r
}\r
- ;\r
+ //Explicitly map to the filename used by Jmol ;\r
pdb = ssm.setMapping(sequence[pe], chains[pe],\r
- pdbentry[pe].getFile(), protocol);\r
+ fileName, protocol);\r
+ //pdbentry[pe].getFile(), protocol);\r
\r
}\r
}\r
{\r
String chid = new String(pdb.id + ":"\r
+ ((MCview.PDBChain) pdb.chains.elementAt(i)).id);\r
- chainFile.put(chid, pdbentry[pe].getFile());\r
+ chainFile.put(chid, fileName);\r
chainNames.addElement(chid);\r
}\r
notifyLoaded = true;\r
import jalview.datamodel.PDBEntry;
import jalview.io.*;
import jalview.schemes.*;
+import jalview.util.Platform;
public class AppJmol extends GStructureViewer implements Runnable,
SequenceStructureBinding, ViewSetProvider
openNewJmol(ap, new PDBEntry[] { pdbentry }, new SequenceI[][] { seq });
}
private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys, SequenceI[][] seqs) {
- boolean promptUser=pdbentrys.length==1;
progressBar = ap.alignFrame;
jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
addAlignmentPanel(ap);
setSize(400, 400); // probably should be a configurable/dynamic default here
initMenus();
worker=null;
- String filelist="";
-// for (PDBEntry pe: pdbentrys)
-// {
-// if (pe.getFile()==null)
{
addingStructures = false;
worker = new Thread(this);
worker.start();
-// break;
}
-// filelist+=" \""+pe.getFile()+"\"";
-
-/* }
- if (worker==null)
- {
- initJmol("load"+(pdbentrys.length>1 ? " APPEND" : "") + filelist);
- }
-*/
this.addInternalFrameListener(new InternalFrameAdapter()
{
public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
{
// just transfer the file name from the first sequence's first
// PDBEntry
- jmb.pdbentry[pi].setFile(file = ((PDBEntry) pdbseq
- .getSequenceAt(0).getPDBId().elementAt(0)).getFile());
- files.append(" \"" + file + "\"");
+ file = new File(((PDBEntry) pdbseq
+ .getSequenceAt(0).getPDBId().elementAt(0)).getFile()).getAbsolutePath();
+ jmb.pdbentry[pi].setFile(file);
+
+ files.append(" \"" + Platform.escapeString(file) + "\"");
}
else
{
}
if (file != null)
{
- files.append(" \"" + file + "\"");
+ files.append(" \"" + Platform.escapeString(file) + "\"");
}
}
}
import jalview.schemabinding.version2.*;
import jalview.schemes.*;
import jalview.structure.StructureSelectionManager;
+import jalview.util.Platform;
import jalview.util.jarInputStreamProvider;
/**
for (int smap = 0; smap < jmol.jmb.sequence[peid].length; smap++)
{
- if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1)
+// if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1)
+ if (jds==jmol.jmb.sequence[peid][smap])
{
StructureState state = new StructureState();
state.setVisible(true);
}
;
out.close();
-
- alreadyLoadedPDB.put(pdbId, outFile.getAbsolutePath());
- return outFile.getAbsolutePath();
+ String t=outFile.getAbsolutePath();
+ alreadyLoadedPDB.put(pdbId, t);
+ return t;
}
else
{
}
if (ids[p].getFile() != null)
{
+ File mapkey=new File(ids[p].getFile());
Object[] seqstrmaps = (Object[]) ((Hashtable) jmoldat[2])
- .get(ids[p].getFile());
+ .get(mapkey);
if (seqstrmaps == null)
{
((Hashtable) jmoldat[2]).put(
- new File(ids[p].getFile()).toString(),
+ mapkey,
seqstrmaps = new Object[]
{ pdbFile, ids[p].getId(), new Vector(),
new Vector() });
Object[] svattrib = entry.getValue();
int[] geom = (int[]) svattrib[0];
String state = (String) svattrib[1];
- Hashtable<String, Object[]> oldFiles = (Hashtable<String, Object[]>) svattrib[2];
+ Hashtable<File, Object[]> oldFiles = (Hashtable<File, Object[]>) svattrib[2];
final boolean useinJmolsuperpos = ((boolean[]) svattrib[3])[0], usetoColourbyseq = ((boolean[]) svattrib[3])[1], jmolColouring = ((boolean[]) svattrib[3])[2];
int x = geom[0], y = geom[1], width = geom[2], height = geom[3];
// collate the pdbfile -> sequence mappings from this view
{
newFileLoc = new StringBuffer();
}
+ do {
+ // look for next filename in load statement
newFileLoc.append(state.substring(cp,
ncp = (state.indexOf("\"", ncp + 1) + 1)));
String oldfilenam = state.substring(ncp,
// recover the new mapping data for this old filename
// have to normalize filename - since Jmol and jalview do filename
// translation differently.
- Object[] filedat = oldFiles.get(new File(oldfilenam)
- .toString());
- newFileLoc.append(((String) filedat[0]));
+ Object[] filedat = oldFiles.get(new File(oldfilenam));
+ newFileLoc.append(Platform.escapeString((String) filedat[0]));
pdbfilenames.addElement((String) filedat[0]);
pdbids.addElement((String) filedat[1]);
seqmaps.addElement((SequenceI[]) ((Vector<SequenceI>) filedat[2])
newFileLoc.append("\"");
cp = ecp + 1; // advance beyond last \" and set cursor so we can
// look for next file statement.
+ } while ((ncp=state.indexOf("/*file*/",cp))>-1);
}
if (cp > 0)
{
.print("Ignoring incomplete Jmol state for PDB ids: ");
newFileLoc = new StringBuffer(state);
newFileLoc.append("; load append ");
- for (String id : oldFiles.keySet())
+ for (File id : oldFiles.keySet())
{
// add this and any other pdb files that should be present in
// the viewer
// add mapping for sequences in this view to an already open Jmol
// instance
- for (String id : oldFiles.keySet())
+ for (File id : oldFiles.keySet())
{
// add this and any other pdb files that should be present in the
// viewer
import javax.swing.JPanel;
import javax.swing.event.ListSelectionEvent;
-import com.sun.tools.corba.se.idl.InvalidArgument;
-
import net.miginfocom.swing.MigLayout;
import jalview.jbgui.GRestInputParamEditDialog;
// TODO: determine nominal limits for most platforms.\r
return 2046; // this is the max length for a windows NT system.\r
}\r
+\r
+ /**\r
+ * escape a string according to the local platform's escape character\r
+ * @param file\r
+ * @return escaped file\r
+ */\r
+ public static String escapeString(String file)\r
+ {\r
+ StringBuffer f=new StringBuffer();\r
+ int p=0,lastp=0;\r
+ while ((p=file.indexOf('\\',lastp))>-1)\r
+ {\r
+ f.append(file.subSequence(lastp,p));\r
+ f.append("\\\\");\r
+ lastp=p+1;\r
+ }\r
+ f.append(file.substring(lastp));\r
+ return f.toString();\r
+ }\r
}\r
import com.stevesoft.pat.Regex;
import com.sun.org.apache.xml.internal.serialize.OutputFormat.DTD;
-import com.sun.tools.doclets.internal.toolkit.util.DocFinder.Output;
public class RestServiceDescription
{