* @param pdbId
* @return
*/
- String loadPDBFile(jarInputStreamProvider jprovider, String pdbId)
+ String loadPDBFile(jarInputStreamProvider jprovider, String pdbId,
+ String origFile)
{
if (alreadyLoadedPDB.containsKey(pdbId))
{
return alreadyLoadedPDB.get(pdbId).toString();
}
- String tempFile = copyJarEntry(jprovider, pdbId, "jalview_pdb");
+ String tempFile = copyJarEntry(jprovider, pdbId, "jalview_pdb",
+ origFile);
if (tempFile != null)
{
alreadyLoadedPDB.put(pdbId, tempFile);
* @param prefix
* a prefix for the temporary file name, must be at least three
* characters long
+ * @param origFile
+ * null or original file - so new file can be given the same suffix
+ * as the old one
* @return
*/
protected String copyJarEntry(jarInputStreamProvider jprovider,
- String jarEntryName, String prefix)
+ String jarEntryName, String prefix, String origFile)
{
BufferedReader in = null;
PrintWriter out = null;
-
+ String suffix = ".tmp";
+ if (origFile == null)
+ {
+ origFile = jarEntryName;
+ }
+ int sfpos = origFile.lastIndexOf(".");
+ if (sfpos > -1 && sfpos < (origFile.length() - 3))
+ {
+ suffix = "." + origFile.substring(sfpos + 1);
+ }
try
{
JarInputStream jin = jprovider.getJarInputStream();
if (entry != null)
{
in = new BufferedReader(new InputStreamReader(jin, UTF_8));
- File outFile = File.createTempFile(prefix, ".tmp");
+ File outFile = File.createTempFile(prefix, suffix);
outFile.deleteOnExit();
out = new PrintWriter(new FileOutputStream(outFile));
String data;
{
if (!pdbloaded.containsKey(ids[p].getFile()))
{
- entry.setFile(loadPDBFile(jprovider, ids[p].getId()));
+ entry.setFile(loadPDBFile(jprovider, ids[p].getId(),
+ ids[p].getFile()));
}
else
{
String rnaTitle = ss.getTitle();
String sessionState = ss.getViewerState();
String tempStateFile = copyJarEntry(jprovider, sessionState,
- "varna");
+ "varna", null);
RnaModel rna = new RnaModel(rnaTitle, ann, seq, null, gapped);
appVarna.addModelSession(rna, rnaTitle, tempStateFile);
}
// Originally : ids[p].getFile()
// : TODO: verify external PDB file recovery still works in normal
// jalview project load
- jpdb.setFile(loadPDBFile(jprovider, ids[p].getId()));
+ jpdb.setFile(loadPDBFile(jprovider, ids[p].getId(),
+ ids[p].getFile()));
jpdb.setId(ids[p].getId());
int x = structureState.getXpos();
// Probably don't need to do this anymore...
// Desktop.desktop.getComponentAt(x, y);
// TODO: NOW: check that this recovers the PDB file correctly.
- String pdbFile = loadPDBFile(jprovider, ids[p].getId());
+ String pdbFile = loadPDBFile(jprovider, ids[p].getId(),
+ ids[p].getFile());
jalview.datamodel.SequenceI seq = seqRefIds.get(jseqs[i]
.getId() + "");
if (sviewid == null)
*/
String viewerJarEntryName = getViewerJarEntryName(data.getViewId());
chimeraSessionFile = copyJarEntry(jprovider, viewerJarEntryName,
- "chimera");
+ "chimera", null);
Set<Entry<File, StructureData>> fileData = data.getFileData()
.entrySet();