import jalview.bin.Cache;
import jalview.bin.Jalview;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.AlignViewport;
import jalview.util.MessageManager;
import jalview.ws.utils.UrlDownloadClient;
-import java.nio.file.Files;
+import java.io.File;
+import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Vector;
// refer to it as.
return;
}
+ if (file != null
+ && file.indexOf(System.getProperty("java.io.tmpdir")) > -1)
+ {
+ // ignore files loaded from the system's temporary directory
+ return;
+ }
String type = protocol == DataSourceType.FILE ? "RECENT_FILE"
: "RECENT_URL";
if (downloadStructureFile)
{
String structExt = format.getExtensions().split(",")[0];
- String tempStructurefile = Files.createTempFile(".jalview_",
- "." + structExt).toString();
- UrlDownloadClient.download(file, tempStructurefile);
- file = tempStructurefile;
- protocol = DataSourceType.FILE;
+ String urlLeafName = file.substring(file.lastIndexOf(System
+ .getProperty("file.separator")), file
+ .lastIndexOf("."));
+ String tempStructureFileStr = createNamedJvTempFile(
+ urlLeafName, structExt);
+ UrlDownloadClient.download(file, tempStructureFileStr);
+ al = fa.readFile(tempStructureFileStr, DataSourceType.FILE,
+ format);
+ source = fa.getAlignFile();
+ }
+ else
+ {
+ al = fa.readFile(file, protocol, format);
+ source = fa.getAlignFile(); // keep reference for later if
+ // necessary.
}
- al = fa.readFile(file, protocol, format);
- source = fa.getAlignFile(); // keep reference for later if
- // necessary.
}
} catch (java.io.IOException ex)
{
}
// append to existing alignment
viewport.addAlignment(al, title);
+ if (source instanceof HMMFile)
+ {
+ AlignmentI alignment = viewport.getAlignment();
+ SequenceI seq = alignment
+ .getSequenceAt(alignment.getAbsoluteHeight() - 1);
+ alignment.deleteSequence(alignment.getAbsoluteHeight() - 1);
+ SequenceGroup sg = viewport.getSelectionGroup();
+ if (sg != null)
+ {
+ seq.insertCharAt(0, sg.getStartRes(), '-');
+ seq.insertCharAt(sg.getEndRes() + 1,
+ alignment.getWidth() - sg.getEndRes(), '-');
+ SequenceI topSeq = sg.getSequencesInOrder(alignment)[0];
+ int topIndex = alignment.findIndex(topSeq);
+ alignment.insertSequenceAt(topIndex, seq);
+ sg.setSeqrep(seq);
+ viewport.getSelectionGroup().addSequence(seq, false);
+ }
+ else
+ {
+ for (int i = 0; i < alignment.getAbsoluteHeight(); i++)
+ {
+ if (!alignment.getSequenceAt(i).isHMMConsensusSequence())
+ {
+ alignment.getSequences().add(i, seq);
+ break;
+ }
+ }
+ }
+ viewport.setAlignment(alignment);
+ viewport.initInformation();
+ viewport.updateInformation(viewport.getAlignPanel());
+ viewport.getAlignPanel().adjustAnnotationHeight();
+ viewport.updateSequenceIdColours();
+ viewport.getAlignPanel().paintAlignment(true);
+ viewport.alignmentChanged(viewport.getAlignPanel());
+ }
}
else
{
if (source instanceof ComplexAlignFile)
{
- ColumnSelection colSel = ((ComplexAlignFile) source)
- .getColumnSelection();
+ HiddenColumns colSel = ((ComplexAlignFile) source)
+ .getHiddenColumns();
SequenceI[] hiddenSeqs = ((ComplexAlignFile) source)
.getHiddenSequences();
String colourSchemeName = ((ComplexAlignFile) source)
}
+ /**
+ * This method creates the file -
+ * {tmpdir}/jalview/{current_timestamp}/fileName.exetnsion using the supplied
+ * file name and extension
+ *
+ * @param fileName
+ * the name of the temp file to be created
+ * @param extension
+ * the extension of the temp file to be created
+ * @return
+ */
+ private static String createNamedJvTempFile(String fileName,
+ String extension) throws IOException
+ {
+ String seprator = System.getProperty("file.separator");
+ String jvTempDir = System.getProperty("java.io.tmpdir") + "jalview"
+ + seprator + System.currentTimeMillis();
+ File tempStructFile = new File(jvTempDir + seprator + fileName + "."
+ + extension);
+ tempStructFile.mkdirs();
+ return tempStructFile.toString();
+ }
+
/*
* (non-Javadoc)
*