git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a135e75
)
Allows Jmol to share cached files
author
hansonr
<hansonr@STO24954W.ad.stolaf.edu>
Sun, 24 Mar 2019 03:46:57 +0000
(22:46 -0500)
committer
hansonr
<hansonr@STO24954W.ad.stolaf.edu>
Sun, 24 Mar 2019 03:47:12 +0000
(22:47 -0500)
src/jalview/datamodel/PDBEntry.java
patch
|
blob
|
history
src/jalview/gui/AppJmol.java
patch
|
blob
|
history
src/jalview/gui/AppJmolBinding.java
patch
|
blob
|
history
src/jalview/io/StructureFile.java
patch
|
blob
|
history
diff --git
a/src/jalview/datamodel/PDBEntry.java
b/src/jalview/datamodel/PDBEntry.java
index
c1dc77c
..
407f87d
100755
(executable)
--- a/
src/jalview/datamodel/PDBEntry.java
+++ b/
src/jalview/datamodel/PDBEntry.java
@@
-22,6
+22,7
@@
package jalview.datamodel;
import jalview.util.CaseInsensitiveString;
import jalview.util.CaseInsensitiveString;
+import java.io.File;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Collections;
import java.util.Enumeration;
import java.util.Hashtable;
@@
-38,7
+39,9
@@
public class PDBEntry
private static final int PDB_ID_LENGTH = 4;
private static final int PDB_ID_LENGTH = 4;
- private String file;
+ private String fileName;
+
+ private File file;
private String type;
private String type;
@@
-133,8
+136,8
@@
public class PDBEntry
*/
boolean idMatches = id == o.id
|| (id != null && id.equalsIgnoreCase(o.id));
*/
boolean idMatches = id == o.id
|| (id != null && id.equalsIgnoreCase(o.id));
- boolean fileMatches = file == o.file
- || (file != null && file.equals(o.file));
+ boolean fileMatches = fileName == o.fileName
+ || (fileName != null && fileName.equals(o.fileName));
boolean typeMatches = type == o.type
|| (type != null && type.equals(o.type));
if (idMatches && fileMatches && typeMatches)
boolean typeMatches = type == o.type
|| (type != null && type.equals(o.type));
if (idMatches && fileMatches && typeMatches)
@@
-164,12
+167,12
@@
public class PDBEntry
* @param entryType
* @param filePath
*/
* @param entryType
* @param filePath
*/
- void init(String pdbId, String chain, PDBEntry.Type entryType,
+ private void init(String pdbId, String chain, PDBEntry.Type entryType,
String filePath)
{
this.id = pdbId;
this.type = entryType == null ? null : entryType.toString();
String filePath)
{
this.id = pdbId;
this.type = entryType == null ? null : entryType.toString();
- this.file = filePath;
+ this.fileName = filePath;
setChainCode(chain);
}
setChainCode(chain);
}
@@
-180,7
+183,7
@@
public class PDBEntry
*/
public PDBEntry(PDBEntry entry)
{
*/
public PDBEntry(PDBEntry entry)
{
- file = entry.file;
+ fileName = entry.fileName;
type = entry.type;
id = entry.id;
if (entry.properties != null)
type = entry.type;
id = entry.id;
if (entry.properties != null)
@@
-220,12
+223,22
@@
public class PDBEntry
public void setFile(String f)
{
public void setFile(String f)
{
+ this.fileName = f;
+ }
+
+ public void setFile(File f)
+ {
this.file = f;
}
public String getFile()
{
this.file = f;
}
public String getFile()
{
- return file;
+ return (file != null ? file.getAbsolutePath() : fileName);
+ }
+
+ public File getFileF()
+ {
+ return (file == null ? new File(fileName) : file);
}
public void setType(String t)
}
public void setType(String t)
@@
-420,6
+433,7
@@
public class PDBEntry
{
setFile(newFile);
setType(newType);
{
setFile(newFile);
setType(newType);
+ setFile(newEntry.getFileF());
}
/*
}
/*
diff --git
a/src/jalview/gui/AppJmol.java
b/src/jalview/gui/AppJmol.java
index
7179a18
..
f937f22
100644
(file)
--- a/
src/jalview/gui/AppJmol.java
+++ b/
src/jalview/gui/AppJmol.java
@@
-140,7
+140,7
@@
public class AppJmol extends StructureViewerBase
closeViewer(false);
}
});
closeViewer(false);
}
});
- initJmol(loadStatus); // pdbentry, seq, JBPCHECK!
+ initJmol(loadStatus, null); // pdbentry, seq, JBPCHECK!
}
@Override
}
@Override
@@
-199,8
+199,6
@@
public class AppJmol extends StructureViewerBase
setSize(400, 400); // probably should be a configurable/dynamic default here
initMenus();
addingStructures = false;
setSize(400, 400); // probably should be a configurable/dynamic default here
initMenus();
addingStructures = false;
- worker = new Thread(this);
- worker.start();
this.addInternalFrameListener(new InternalFrameAdapter()
{
this.addInternalFrameListener(new InternalFrameAdapter()
{
@@
-212,6
+210,8
@@
public class AppJmol extends StructureViewerBase
}
});
}
});
+ worker = new Thread(this);
+ worker.start();
}
/**
}
/**
@@
-231,7
+231,7
@@
public class AppJmol extends StructureViewerBase
}
}
- void initJmol(String command)
+ private void initJmol(String command, List<File> files)
{
jmb.setFinishedInit(false);
renderPanel = new RenderPanel();
{
jmb.setFinishedInit(false);
renderPanel = new RenderPanel();
@@
-255,6
+255,8
@@
public class AppJmol extends StructureViewerBase
if (command == null)
{
command = "";
if (command == null)
{
command = "";
+ } else if (files != null) {
+ jmb.cacheFiles(files);
}
jmb.evalStateCommand(command);
jmb.evalStateCommand("set hoverDelay=0.1");
}
jmb.evalStateCommand(command);
jmb.evalStateCommand("set hoverDelay=0.1");
@@
-302,7
+304,7
@@
public class AppJmol extends StructureViewerBase
_started = true;
try
{
_started = true;
try
{
- List<String> files = fetchPdbFiles();
+ List<File> files = fetchPdbFiles();
if (files.size() > 0)
{
showFilesInViewer(files);
if (files.size() > 0)
{
showFilesInViewer(files);
@@
-321,12
+323,13
@@
public class AppJmol extends StructureViewerBase
* @param files
* list of absolute paths to structure files
*/
* @param files
* list of absolute paths to structure files
*/
- void showFilesInViewer(List<String> files)
+ void showFilesInViewer(List<File> files)
{
long lastnotify = jmb.getLoadNotifiesHandled();
StringBuilder fileList = new StringBuilder();
{
long lastnotify = jmb.getLoadNotifiesHandled();
StringBuilder fileList = new StringBuilder();
- for (String s : files)
+ for (File f : files)
{
{
+ String s = f.getAbsolutePath();
fileList.append(SPACE).append(QUOTE)
.append(Platform.escapeString(s)).append(QUOTE);
}
fileList.append(SPACE).append(QUOTE)
.append(Platform.escapeString(s)).append(QUOTE);
}
@@
-336,7
+339,7
@@
public class AppJmol extends StructureViewerBase
{
try
{
{
try
{
- initJmol("load FILES " + filesString);
+ initJmol("load FILES " + filesString, files);
} catch (OutOfMemoryError oomerror)
{
new OOMWarning("When trying to open the Jmol viewer!", oomerror);
} catch (OutOfMemoryError oomerror)
{
new OOMWarning("When trying to open the Jmol viewer!", oomerror);
@@
-359,6
+362,7
@@
public class AppJmol extends StructureViewerBase
try
{
try
{
+ jmb.cacheFiles(files);
jmb.evalStateCommand(command);
} catch (OutOfMemoryError oomerror)
{
jmb.evalStateCommand(command);
} catch (OutOfMemoryError oomerror)
{
@@
-453,12
+457,12
@@
public class AppJmol extends StructureViewerBase
*
* @return
*/
*
* @return
*/
- List<String> fetchPdbFiles()
+ List<File> fetchPdbFiles()
{
// todo - record which pdbids were successfully imported.
StringBuilder errormsgs = new StringBuilder();
{
// todo - record which pdbids were successfully imported.
StringBuilder errormsgs = new StringBuilder();
- List<String> files = new ArrayList<>();
+ List<File> files = new ArrayList<>();
String pdbid = "";
try
{
String pdbid = "";
try
{
@@
-468,7
+472,7
@@
public class AppJmol extends StructureViewerBase
Pdb pdbclient = new Pdb();
for (int pi = 0; pi < jmb.getPdbCount(); pi++)
{
Pdb pdbclient = new Pdb();
for (int pi = 0; pi < jmb.getPdbCount(); pi++)
{
- String file = jmb.getPdbEntry(pi).getFile();
+ File file = jmb.getPdbEntry(pi).getFileF();
if (file == null)
{
// todo: extract block as method and pull up (also ChimeraViewFrame)
if (file == null)
{
// todo: extract block as method and pull up (also ChimeraViewFrame)
@@
-506,7
+510,7
@@
public class AppJmol extends StructureViewerBase
// just transfer the file name from the first sequence's first
// PDBEntry
file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
// just transfer the file name from the first sequence's first
// PDBEntry
file = new File(pdbseq.getSequenceAt(0).getAllPDBEntries()
- .elementAt(0).getFile()).getAbsolutePath();
+ .elementAt(0).getFile());
jmb.getPdbEntry(pi).setFile(file);
files.add(file);
}
jmb.getPdbEntry(pi).setFile(file);
files.add(file);
}
@@
-520,9
+524,10
@@
public class AppJmol extends StructureViewerBase
if (filesInViewer != null && filesInViewer.length > 0)
{
addingStructures = true; // already files loaded.
if (filesInViewer != null && filesInViewer.length > 0)
{
addingStructures = true; // already files loaded.
+ String filename = file.getAbsolutePath();
for (int c = 0; c < filesInViewer.length; c++)
{
for (int c = 0; c < filesInViewer.length; c++)
{
- if (filesInViewer[c].equals(file))
+ if (filesInViewer[c].equals(filename))
{
file = null;
break;
{
file = null;
break;
diff --git
a/src/jalview/gui/AppJmolBinding.java
b/src/jalview/gui/AppJmolBinding.java
index
eeb4888
..
5c2addc
100644
(file)
--- a/
src/jalview/gui/AppJmolBinding.java
+++ b/
src/jalview/gui/AppJmolBinding.java
@@
-28,12
+28,16
@@
import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JalviewJmolBinding;
import jalview.io.DataSourceType;
import jalview.structure.StructureSelectionManager;
import jalview.ext.jmol.JalviewJmolBinding;
import jalview.io.DataSourceType;
import jalview.structure.StructureSelectionManager;
+import jalview.util.Platform;
import java.awt.Container;
import java.awt.Container;
+import java.io.File;
+import java.util.List;
import java.util.Map;
import org.jmol.api.JmolAppConsoleInterface;
import javajs.util.BS;
import java.util.Map;
import org.jmol.api.JmolAppConsoleInterface;
import javajs.util.BS;
+
import org.openscience.jmol.app.jmolpanel.console.AppConsole;
public class AppJmolBinding extends JalviewJmolBinding
import org.openscience.jmol.app.jmolpanel.console.AppConsole;
public class AppJmolBinding extends JalviewJmolBinding
@@
-215,4
+219,17
@@
public class AppJmolBinding extends JalviewJmolBinding
return null;
}
return null;
}
+
+ @SuppressWarnings("unused")
+public void cacheFiles(List<File> files) {
+ if (files == null)
+ return;
+ for (File f : files) {
+ String path = f.getAbsolutePath();
+ byte[] data = Platform.getFileBytes(f);
+ if (data != null) {
+ Platform.cacheFileData(path, data);
+ }
+ }
+ }
}
}
diff --git
a/src/jalview/io/StructureFile.java
b/src/jalview/io/StructureFile.java
index
084f886
..
5c8360c
100644
(file)
--- a/
src/jalview/io/StructureFile.java
+++ b/
src/jalview/io/StructureFile.java
@@
-120,6
+120,7
@@
public abstract class StructureFile extends AlignFile
PDBEntry entry = new PDBEntry();
entry.setId(getId());
entry.setType(getStructureFileType());
PDBEntry entry = new PDBEntry();
entry.setId(getId());
entry.setType(getStructureFileType());
+ entry.setFile(inFile);
if (chain.id != null)
{
entry.setChainCode(chain.id);
if (chain.id != null)
{
entry.setChainCode(chain.id);