import jalview.analysis.PCA;
import jalview.analysis.scoremodels.ScoreModels;
import jalview.analysis.scoremodels.SimilarityParams;
+import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureColourI;
import jalview.api.ViewStyleI;
import jalview.api.analysis.ScoreModelI;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.GeneLocus;
import jalview.datamodel.GraphLine;
+import jalview.datamodel.HiddenMarkovModel;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.Point;
import jalview.datamodel.RnaViewerModel;
import jalview.gui.AppVarna;
import jalview.gui.ChimeraViewFrame;
import jalview.gui.Desktop;
+import jalview.gui.FeatureRenderer;
import jalview.gui.JvOptionPane;
import jalview.gui.OOMWarning;
import jalview.gui.PCAPanel;
import jalview.io.BackupFiles;
import jalview.io.DataSourceType;
import jalview.io.FileFormat;
+import jalview.io.HMMFile;
import jalview.io.NewickFile;
import jalview.math.Matrix;
import jalview.math.MatrixI;
import jalview.schemes.FeatureColour;
import jalview.schemes.ResidueProperties;
import jalview.schemes.UserColourScheme;
-import jalview.structure.StructureSelectionManager;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.Format;
import jalview.util.MessageManager;
import jalview.viewmodel.seqfeatures.FeatureRendererModel;
import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
import jalview.viewmodel.seqfeatures.FeaturesDisplayed;
-import jalview.ws.jws2.Jws2Discoverer;
+import jalview.ws.api.ServiceWithParameters;
+import jalview.ws.jws2.PreferredServiceRegistry;
import jalview.ws.jws2.dm.AAConSettings;
-import jalview.ws.jws2.jabaws2.Jws2Instance;
import jalview.ws.params.ArgumentI;
import jalview.ws.params.AutoCalcSetting;
import jalview.ws.params.WsParamSetI;
import jalview.xml.binding.jalview.VAMSAS;
import java.awt.Color;
+import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
-import java.lang.reflect.InvocationTargetException;
import java.math.BigInteger;
import java.net.MalformedURLException;
import java.net.URL;
*/
public class Jalview2XML
{
+
+ // BH 2018 we add the .jvp binary extension to J2S so that
+ // it will declare that binary when we do the file save from the browser
+
+ static
+ {
+ Platform.addJ2SBinaryType(".jvp?");
+ }
+
private static final String VIEWER_PREFIX = "viewer_";
private static final String RNA_PREFIX = "rna_";
+ private static final String HMMER_PREFIX = "hmmer_";
+
private static final String UTF_8 = "UTF-8";
/**
private Map<RnaModel, String> rnaSessions = new HashMap<>();
/**
+ * contains last error message (if any) encountered by XML loader.
+ */
+ String errorMessage = null;
+
+ /**
+ * flag to control whether the Jalview2XML_V1 parser should be deferred to if
+ * exceptions are raised during project XML parsing
+ */
+ public boolean attemptversion1parse = false;
+
+ /*
+ * JalviewJS only -- to allow read file bytes to be saved in the
+ * created AlignFrame, allowing File | Reload of a project file to work
+ *
+ * BH 2019 JAL-3436
+ */
+ private File jarFile;
+
+ /**
* A helper method for safely using the value of an optional attribute that
* may be null if not present in the XML. Answers the boolean value, or false
* if null.
* @param _jmap
* @return
*/
- public SeqFref newMappingRef(final String sref,
+ protected SeqFref newMappingRef(final String sref,
final jalview.datamodel.Mapping _jmap)
{
SeqFref fref = new SeqFref(sref, "Mapping")
return fref;
}
- public SeqFref newAlcodMapRef(final String sref,
+ protected SeqFref newAlcodMapRef(final String sref,
final AlignedCodonFrame _cf,
final jalview.datamodel.Mapping _jmap)
{
public boolean isResolvable()
{
return super.isResolvable() && mp.getTo() != null;
- };
+ }
@Override
boolean resolve()
return fref;
}
- public void resolveFrefedSequences()
+ protected void resolveFrefedSequences()
{
Iterator<SeqFref> nextFref = frefedSequence.iterator();
int toresolve = frefedSequence.size();
* core method for storing state for a set of AlignFrames.
*
* @param frames
- * - frames involving all data to be exported (including containing
- * splitframes)
+ * - frames involving all data to be exported (including those
+ * contained in splitframes, though not the split frames themselves)
* @param jout
* - project output stream
*/
private void saveAllFrames(List<AlignFrame> frames, JarOutputStream jout)
{
+
Hashtable<String, AlignFrame> dsses = new Hashtable<>();
/*
for (int i = frames.size() - 1; i > -1; i--)
{
AlignFrame af = frames.get(i);
+ AlignViewport vp = af.getViewport();
// skip ?
if (skipList != null && skipList
- .containsKey(af.getViewport().getSequenceSetId()))
+ .containsKey(vp.getSequenceSetId()))
{
continue;
}
String shortName = makeFilename(af, shortNames);
- int apSize = af.getAlignPanels().size();
-
+ AlignmentI alignment = vp.getAlignment();
+ List<? extends AlignmentViewPanel> panels = af.getAlignPanels();
+ int apSize = panels.size();
for (int ap = 0; ap < apSize; ap++)
- {
- AlignmentPanel apanel = (AlignmentPanel) af.getAlignPanels()
- .get(ap);
+ {
+ AlignmentPanel apanel = (AlignmentPanel) panels.get(ap);
String fileName = apSize == 1 ? shortName : ap + shortName;
if (!fileName.endsWith(".xml"))
{
}
saveState(apanel, fileName, jout, viewIds);
-
- String dssid = getDatasetIdRef(
- af.getViewport().getAlignment().getDataset());
+ }
+ if (apSize > 0)
+ {
+ // BH moved next bit out of inner loop, not that it really matters.
+ // so we are testing to make sure we actually have an alignment,
+ // apparently.
+ String dssid = getDatasetIdRef(alignment.getDataset());
if (!dsses.containsKey(dssid))
{
+ // We have not already covered this data by reference from another
+ // frame.
dsses.put(dssid, af);
}
}
} catch (Exception foo)
{
}
- ;
jout.close();
} catch (Exception ex)
{
try
{
// create backupfiles object and get new temp filename destination
- BackupFiles backupfiles = new BackupFiles(jarFile);
- FileOutputStream fos = new FileOutputStream(
- backupfiles.getTempFilePath());
+ boolean doBackup = BackupFiles.getEnabled();
+ BackupFiles backupfiles = doBackup ? new BackupFiles(jarFile) : null;
+ FileOutputStream fos = new FileOutputStream(doBackup ?
+ backupfiles.getTempFilePath() : jarFile);
JarOutputStream jout = new JarOutputStream(fos);
List<AlignFrame> frames = new ArrayList<>();
} catch (Exception foo)
{
}
- ;
jout.close();
boolean success = true;
- backupfiles.setWriteSuccess(success);
- success = backupfiles.rollBackupsAndRenameTempFile();
+ if (doBackup)
+ {
+ backupfiles.setWriteSuccess(success);
+ success = backupfiles.rollBackupsAndRenameTempFile();
+ }
return success;
} catch (Exception ex)
}
}
+ /**
+ * Each AlignFrame has a single data set associated with it. Note that none of
+ * these frames are split frames, because Desktop.getAlignFrames() collects
+ * top and bottom separately here.
+ *
+ * @param dsses
+ * @param fileName
+ * @param jout
+ */
private void writeDatasetFor(Hashtable<String, AlignFrame> dsses,
String fileName, JarOutputStream jout)
{
+ // Note that in saveAllFrames we have associated each specific dataset to
+ // ONE of its associated frames.
+
for (String dssids : dsses.keySet())
{
AlignFrame _af = dsses.get(dssids);
* @param out
* jar entry name
*/
- public JalviewModel saveState(AlignmentPanel ap, String fileName,
+ protected JalviewModel saveState(AlignmentPanel ap, String fileName,
JarOutputStream jout, List<String> viewIds)
{
return saveState(ap, fileName, false, jout, viewIds);
* @param out
* jar entry name
*/
- public JalviewModel saveState(AlignmentPanel ap, String fileName,
+ protected JalviewModel saveState(AlignmentPanel ap, String fileName,
boolean storeDS, JarOutputStream jout, List<String> viewIds)
{
if (viewIds == null)
jseq.getFeatures().add(features);
}
+ /*
+ * save PDB entries for sequence
+ */
if (jdatasq.getAllPDBEntries() != null)
{
Enumeration<PDBEntry> en = jdatasq.getAllPDBEntries().elements();
* only view *should* be coped with sensibly.
*/
// This must have been loaded, is it still visible?
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
String matchedFile = null;
for (int f = frames.length - 1; f > -1; f--)
{
saveRnaViewers(jout, jseq, jds, viewIds, ap, storeDS);
+ if (jds.hasHMMProfile())
+ {
+ saveHmmerProfile(jout, jseq, jds);
+ }
+
// jms.addJSeq(jseq);
object.getJSeq().add(jseq);
}
{
// FIND ANY ASSOCIATED TREES
// NOT IMPLEMENTED FOR HEADLESS STATE AT PRESENT
- if (Desktop.desktop != null)
+ if (Desktop.getDesktopPane() != null)
{
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
for (int t = 0; t < frames.length; t++)
{
/*
* save PCA viewers
*/
- if (!storeDS && Desktop.desktop != null)
+ if (!storeDS && Desktop.getDesktopPane() != null)
{
- for (JInternalFrame frame : Desktop.desktop.getAllFrames())
+ for (JInternalFrame frame : Desktop.getDesktopPane().getAllFrames())
{
if (frame instanceof PCAPanel)
{
view.setFollowHighlight(av.isFollowHighlight());
view.setFollowSelection(av.followSelection);
view.setIgnoreGapsinConsensus(av.isIgnoreGapsConsensus());
+ view.setShowComplementFeatures(av.isShowComplementFeatures());
+ view.setShowComplementFeaturesOnTop(
+ av.isShowComplementFeaturesOnTop());
if (av.getFeaturesDisplayed() != null)
{
FeatureSettings fs = new FeatureSettings();
// using save and then load
try
{
+ fileName = fileName.replace('\\', '/');
System.out.println("Writing jar entry " + fileName);
JarEntry entry = new JarEntry(fileName);
jout.putNextEntry(entry);
}
return object;
}
+ /**
+ * Saves the HMMER profile associated with the sequence as a file in the jar,
+ * in HMMER format, and saves the name of the file as a child element of the
+ * XML sequence element
+ *
+ * @param jout
+ * @param xmlSeq
+ * @param seq
+ */
+ protected void saveHmmerProfile(JarOutputStream jout, JSeq xmlSeq,
+ SequenceI seq)
+ {
+ HiddenMarkovModel profile = seq.getHMM();
+ if (profile == null)
+ {
+ warn("Want to save HMM profile for " + seq.getName()
+ + " but none found");
+ return;
+ }
+ HMMFile hmmFile = new HMMFile(profile);
+ String hmmAsString = hmmFile.print();
+ String jarEntryName = HMMER_PREFIX + nextCounter();
+ try
+ {
+ writeJarEntry(jout, jarEntryName, hmmAsString.getBytes());
+ xmlSeq.setHmmerProfile(jarEntryName);
+ } catch (IOException e)
+ {
+ warn("Error saving HMM profile: " + e.getMessage());
+ }
+ }
+
/**
* Writes PCA viewer attributes and computed values to an XML model object and
* adds it to the JalviewModel. Any exceptions are reported by logging.
final SequenceI jds, List<String> viewIds, AlignmentPanel ap,
boolean storeDataset)
{
- if (Desktop.desktop == null)
+ if (Desktop.getDesktopPane() == null)
{
return;
}
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ JInternalFrame[] frames = Desktop.getDesktopPane().getAllFrames();
for (int f = frames.length - 1; f > -1; f--)
{
if (frames[f] instanceof AppVarna)
{
if (jout != null)
{
+ jarEntryName = jarEntryName.replace('\\','/');
System.out.println("Writing jar entry " + jarEntryName);
jout.putNextEntry(new JarEntry(jarEntryName));
DataOutputStream dout = new DataOutputStream(jout);
}
else if (!matchedFile.equals(pdbentry.getFile()))
{
- Cache.log.warn(
- "Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): "
- + pdbentry.getFile());
+ Cache.log.warn(
+ "Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): "
+ + pdbentry.getFile());
}
// record the
// file so we
if (calcIdParam.getVersion().equals("1.0"))
{
final String[] calcIds = calcIdParam.getServiceURL().toArray(new String[0]);
- Jws2Instance service = Jws2Discoverer.getDiscoverer()
+ ServiceWithParameters service = PreferredServiceRegistry.getRegistry()
.getPreferredServiceFor(calcIds);
if (service != null)
{
argList = parmSet.getArguments();
parmSet = null;
}
- AAConSettings settings = new AAConSettings(
+ AutoCalcSetting settings = new AAConSettings(
calcIdParam.isAutoUpdate(), service, parmSet, argList);
av.setCalcIdSettingsFor(calcIdParam.getCalcId(), settings,
calcIdParam.isNeedsUpdate());
}
else
{
- warn("Cannot resolve a service for the parameters used in this project. Try configuring a JABAWS server.");
+ warn("Cannot resolve a service for the parameters used in this project. Try configuring a server in the Web Services preferences tab.");
return false;
}
}
vamsasSeq.setName(jds.getName());
vamsasSeq.setSequence(jds.getSequenceAsString());
vamsasSeq.setDescription(jds.getDescription());
- jalview.datamodel.DBRefEntry[] dbrefs = null;
+ List<DBRefEntry> dbrefs = null;
if (jds.getDatasetSequence() != null)
{
vamsasSeq.setDsseqid(seqHash(jds.getDatasetSequence()));
*/
if (dbrefs != null)
{
- for (int d = 0; d < dbrefs.length; d++)
+ for (int d = 0, nd = dbrefs.size(); d < nd; d++)
{
DBRef dbref = new DBRef();
- DBRefEntry dbRefEntry = dbrefs[d];
- dbref.setSource(dbRefEntry.getSource());
- dbref.setVersion(dbRefEntry.getVersion());
- dbref.setAccessionId(dbRefEntry.getAccessionId());
- if (dbRefEntry instanceof GeneLocus)
+ DBRefEntry ref = dbrefs.get(d);
+ dbref.setSource(ref.getSource());
+ dbref.setVersion(ref.getVersion());
+ dbref.setAccessionId(ref.getAccessionId());
+ if (ref instanceof GeneLocus)
{
dbref.setLocus(true);
}
- if (dbRefEntry.hasMap())
+ if (ref.hasMap())
{
- Mapping mp = createVamsasMapping(dbRefEntry.getMap(), parentseq,
+ Mapping mp = createVamsasMapping(ref.getMap(), parentseq,
jds, recurse);
dbref.setMapping(mp);
}
}
/**
- * contains last error message (if any) encountered by XML loader.
- */
- String errorMessage = null;
-
- /**
- * flag to control whether the Jalview2XML_V1 parser should be deferred to if
- * exceptions are raised during project XML parsing
- */
- public boolean attemptversion1parse = false;
-
- /**
* Load a jalview project archive from a jar file
*
* @param file
* - HTTP URL or filename
*/
- public AlignFrame loadJalviewAlign(final String file)
+ public AlignFrame loadJalviewAlign(final Object file)
{
jalview.gui.AlignFrame af = null;
{
try
{
- SwingUtilities.invokeAndWait(new Runnable()
+// was invokeAndWait
+
+ // BH 2019 -- can't wait
+ SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
{
setLoadingFinishedForNewStructureViewers();
- };
+ }
});
} catch (Exception x)
{
System.err.println("Error loading alignment: " + x.getMessage());
}
}
+ this.jarFile = null;
return af;
}
+ @SuppressWarnings("unused")
private jarInputStreamProvider createjarInputStreamProvider(
- final String file) throws MalformedURLException
+ final Object ofile) throws MalformedURLException
{
- URL url = null;
- errorMessage = null;
- uniqueSetSuffix = null;
- seqRefIds = null;
- viewportsAdded.clear();
- frefedSequence = null;
-
- if (file.startsWith("http://"))
- {
- url = new URL(file);
- }
- final URL _url = url;
- return new jarInputStreamProvider()
+ try
{
+ String file = (ofile instanceof File
+ ? ((File) ofile).getCanonicalPath()
+ : ofile.toString());
+ byte[] bytes = Platform.isJS() ? Platform.getFileBytes((File) ofile)
+ : null;
+ if (bytes != null)
+ {
+ this.jarFile = (File) ofile;
+ }
+ errorMessage = null;
+ uniqueSetSuffix = null;
+ seqRefIds = null;
+ viewportsAdded.clear();
+ frefedSequence = null;
- @Override
- public JarInputStream getJarInputStream() throws IOException
+ URL url = file.startsWith("http://") ? new URL(file) : null;
+ return new jarInputStreamProvider()
{
- if (_url != null)
+ @Override
+ public JarInputStream getJarInputStream() throws IOException
{
- return new JarInputStream(_url.openStream());
+ InputStream is = bytes != null ? new ByteArrayInputStream(bytes)
+ : (url != null ? url.openStream()
+ : new FileInputStream(file));
+ return new JarInputStream(is);
}
- else
+
+ @Override
+ public File getFile()
{
- return new JarInputStream(new FileInputStream(file));
+ return jarFile;
}
- }
- @Override
- public String getFilename()
- {
- return file;
- }
- };
+ @Override
+ public String getFilename()
+ {
+ return file;
+ }
+ };
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
}
/**
AlignFrame af = null, _af = null;
IdentityHashMap<AlignmentI, AlignmentI> importedDatasets = new IdentityHashMap<>();
Map<String, AlignFrame> gatherToThisFrame = new HashMap<>();
- final String file = jprovider.getFilename();
+ String fileName = jprovider.getFilename();
+ File file = jprovider.getFile();
+ List<AlignFrame> alignFrames = new ArrayList<>();
+
try
{
JarInputStream jin = null;
JarEntry jarentry = null;
int entryCount = 1;
+
+ // Look for all the entry names ending with ".xml"
+ // This includes all panels and at least one frame.
+// Platform.timeCheck(null, Platform.TIME_MARK);
do
{
jin = jprovider.getJarInputStream();
{
jarentry = jin.getNextJarEntry();
}
+ String name = (jarentry == null ? null : jarentry.getName());
- if (jarentry != null && jarentry.getName().endsWith(".xml"))
+// System.out.println("Jalview2XML opening " + name);
+ if (name != null && name.endsWith(".xml"))
{
- InputStreamReader in = new InputStreamReader(jin, UTF_8);
- // JalviewModel object = new JalviewModel();
+ // DataSet for.... is read last.
+
+
+ // The question here is what to do with the two
+ // .xml files in the jvp file.
+ // Some number of them, "...Dataset for...", will be the
+ // Only AlignPanels and will have Viewport.
+ // One or more will be the source data, with the DBRefs.
+ //
+ // JVP file writing (above) ensures tha the AlignPanels are written
+ // first, then all relevant datasets (which are
+ // Jalview.datamodel.Alignment).
+ //
+
+// Platform.timeCheck("Jalview2XML JAXB " + name, Platform.TIME_MARK);
JAXBContext jc = JAXBContext
.newInstance("jalview.xml.binding.jalview");
XMLStreamReader streamReader = XMLInputFactory.newInstance()
javax.xml.bind.Unmarshaller um = jc.createUnmarshaller();
JAXBElement<JalviewModel> jbe = um
.unmarshal(streamReader, JalviewModel.class);
- JalviewModel object = jbe.getValue();
+ JalviewModel model = jbe.getValue();
- /*
- Unmarshaller unmar = new Unmarshaller(object);
- unmar.setValidation(false);
- object = (JalviewModel) unmar.unmarshal(in);
- */
if (true) // !skipViewport(object))
{
- _af = loadFromObject(object, file, true, jprovider);
- if (_af != null && object.getViewport().size() > 0)
- // getJalviewModelSequence().getViewportCount() > 0)
+ // Q: Do we have to load from the model, even if it
+ // does not have a viewport, could we discover that early on?
+ // Q: Do we need to load this object?
+ _af = loadFromObject(model, fileName, file, true, jprovider);
+// Platform.timeCheck("Jalview2XML.loadFromObject",
+ // Platform.TIME_MARK);
+
+ if (_af != null)
{
+ alignFrames.add(_af);
+ }
+ if (_af != null && model.getViewport().size() > 0)
+ {
+
+ // That is, this is one of the AlignmentPanel models
if (af == null)
{
// store a reference to the first view
} catch (IOException ex)
{
ex.printStackTrace();
- errorMessage = "Couldn't locate Jalview XML file : " + file;
+ errorMessage = "Couldn't locate Jalview XML file : " + fileName;
System.err.println(
"Exception whilst loading jalview XML file : " + ex + "\n");
} catch (Exception ex)
{
// used to attempt to parse as V1 castor-generated xml
}
- if (Desktop.instance != null)
+ if (Desktop.getInstance() != null)
{
- Desktop.instance.stopLoading();
+ Desktop.getInstance().stopLoading();
}
if (af != null)
{
errorMessage = "Out of memory loading jalview XML file";
System.err.println("Out of memory whilst loading jalview XML file");
e.printStackTrace();
+ } finally
+ {
+ for (AlignFrame alf : alignFrames)
+ {
+ alf.alignPanel.setHoldRepaint(false);
+ }
+
}
/*
*/
for (AlignFrame fr : gatherToThisFrame.values())
{
- Desktop.instance.gatherViews(fr);
+ Desktop.getInstance().gatherViews(fr);
}
restoreSplitFrames();
{
if (ds.getCodonFrames() != null)
{
- StructureSelectionManager
- .getStructureSelectionManager(Desktop.instance)
+ Desktop.getStructureSelectionManager()
.registerMappings(ds.getCodonFrames());
}
}
reportErrors();
}
- if (Desktop.instance != null)
+ if (Desktop.getInstance() != null)
{
- Desktop.instance.stopLoading();
+ Desktop.getInstance().stopLoading();
}
return af;
*/
for (SplitFrame sf : gatherTo)
{
- Desktop.instance.gatherViews(sf);
+ Desktop.getInstance().gatherViews(sf);
}
splitFrameCandidates.clear();
@Override
public void run()
{
- JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ JvOptionPane.showInternalMessageDialog(Desktop.getDesktopPane(),
finalErrorMessage,
"Error " + (saving ? "saving" : "loading")
+ " Jalview file",
}
/**
- * Load alignment frame from jalview XML DOM object
+ * Load alignment frame from jalview XML DOM object. For a DOM object that
+ * includes one or more Viewport elements (one with a title that does NOT
+ * contain "Dataset for"), create the frame.
*
* @param jalviewModel
* DOM
- * @param file
+ * @param fileName
* filename source string
+ * @param file
* @param loadTreesAndStructures
* when false only create Viewport
* @param jprovider
* data source provider
* @return alignment frame created from view stored in DOM
*/
- AlignFrame loadFromObject(JalviewModel jalviewModel, String file,
- boolean loadTreesAndStructures, jarInputStreamProvider jprovider)
+ AlignFrame loadFromObject(JalviewModel jalviewModel, String fileName,
+ File file, boolean loadTreesAndStructures, jarInputStreamProvider jprovider)
{
SequenceSet vamsasSet = jalviewModel.getVamsasModel().getSequenceSet().get(0);
List<Sequence> vamsasSeqs = vamsasSet.getSequence();
+
// JalviewModelSequence jms = object.getJalviewModelSequence();
// Viewport view = (jms.getViewportCount() > 0) ? jms.getViewport(0)
|| tmpSeq.getEnd() != jseq.getEnd())
{
System.err.println(
- "Warning JAL-2154 regression: updating start/end for sequence "
- + tmpSeq.toString() + " to " + jseq);
+ String.format("Warning JAL-2154 regression: updating start/end for sequence %s from %d/%d to %d/%d",
+ tmpSeq.getName(), tmpSeq.getStart(),
+ tmpSeq.getEnd(), jseq.getStart(),
+ jseq.getEnd()));
}
}
else
{
entry.setProperty(prop.getName(), prop.getValue());
}
- StructureSelectionManager
- .getStructureSelectionManager(Desktop.instance)
+ Desktop.getStructureSelectionManager()
.registerPDBEntry(entry);
// adds PDBEntry to datasequence's set (since Jalview 2.10)
if (al.getSequenceAt(i).getDatasetSequence() != null)
}
}
}
+
+ /*
+ * load any HMMER profile
+ */
+ // TODO fix this
+
+ String hmmJarFile = jseqs.get(i).getHmmerProfile();
+ if (hmmJarFile != null && jprovider != null)
+ {
+ loadHmmerProfile(jprovider, hmmJarFile, al.getSequenceAt(i));
+ }
}
} // end !multipleview
}
}
}
+ // create the new AlignmentAnnotation
jalview.datamodel.AlignmentAnnotation jaa = null;
if (annotation.isGraph())
jaa._linecolour = firstColour;
}
// register new annotation
+ // Annotation graphs such as Conservation will not have id.
if (annotation.getId() != null)
{
annotationIds.put(annotation.getId(), jaa);
// ///////////////////////////////
// LOAD VIEWPORT
- AlignFrame af = null;
- AlignViewport av = null;
// now check to see if we really need to create a new viewport.
if (multipleView && viewportsAdded.size() == 0)
{
boolean doGroupAnnColour = Jalview2XML.isVersionStringLaterThan("2.8.1",
jalviewModel.getVersion());
+ AlignFrame af = null;
AlignmentPanel ap = null;
- boolean isnewview = true;
+ AlignViewport av = null;
if (viewId != null)
{
// Check to see if this alignment already has a view id == viewId
{
for (int v = 0; v < views.length; v++)
{
- if (views[v].av.getViewId().equalsIgnoreCase(viewId))
+ ap = views[v];
+ av = ap.av;
+ if (av.getViewId().equalsIgnoreCase(viewId))
{
// recover the existing alignpanel, alignframe, viewport
- af = views[v].alignFrame;
- av = views[v].av;
- ap = views[v];
+ af = ap.alignFrame;
+ break;
// TODO: could even skip resetting view settings if we don't want to
// change the local settings from other jalview processes
- isnewview = false;
}
}
}
}
- if (isnewview)
+ if (af == null)
{
- af = loadViewport(file, jseqs, hiddenSeqs, al, jalviewModel, view,
+ af = loadViewport(fileName, file, jseqs, hiddenSeqs, al, jalviewModel, view,
uniqueSeqSetId, viewId, autoAlan);
av = af.getViewport();
+ // note that this only retrieves the most recently accessed
+ // tab of an AlignFrame.
ap = af.alignPanel;
}
*
* Not done if flag is false (when this method is used for New View)
*/
+ final AlignFrame af0 = af;
+ final AlignViewport av0 = av;
+ final AlignmentPanel ap0 = ap;
+// Platform.timeCheck("Jalview2XML.loadFromObject-beforetree",
+// Platform.TIME_MARK);
if (loadTreesAndStructures)
{
- loadTrees(jalviewModel, view, af, av, ap);
- loadPCAViewers(jalviewModel, ap);
- loadPDBStructures(jprovider, jseqs, af, ap);
- loadRnaViewers(jprovider, jseqs, ap);
+ if (!jalviewModel.getTree().isEmpty())
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+// Platform.timeCheck(null, Platform.TIME_MARK);
+ loadTrees(jalviewModel, view, af0, av0, ap0);
+// Platform.timeCheck("Jalview2XML.loadTrees", Platform.TIME_MARK);
+ }
+ });
+ }
+ if (!jalviewModel.getPcaViewer().isEmpty())
+ {
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+// Platform.timeCheck(null, Platform.TIME_MARK);
+ loadPCAViewers(jalviewModel, ap0);
+// Platform.timeCheck("Jalview2XML.loadPCA", Platform.TIME_MARK);
+ }
+ });
+ }
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+// Platform.timeCheck(null, Platform.TIME_MARK);
+ loadPDBStructures(jprovider, jseqs, af0, ap0);
+// Platform.timeCheck("Jalview2XML.loadPDB", Platform.TIME_MARK);
+ }
+ });
+ SwingUtilities.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ loadRnaViewers(jprovider, jseqs, ap0);
+ }
+ });
}
// and finally return.
+ // but do not set holdRepaint true just yet, because this could be the
+ // initial frame with just its dataset.
return af;
}
/**
+ * Loads a HMMER profile from a file stored in the project, and associates it
+ * with the specified sequence
+ *
+ * @param jprovider
+ * @param hmmJarFile
+ * @param seq
+ */
+ protected void loadHmmerProfile(jarInputStreamProvider jprovider,
+ String hmmJarFile, SequenceI seq)
+ {
+ try
+ {
+ String hmmFile = copyJarEntry(jprovider, hmmJarFile, "hmm", null);
+ HMMFile parser = new HMMFile(hmmFile, DataSourceType.FILE);
+ HiddenMarkovModel hmmModel = parser.getHMM();
+ hmmModel = new HiddenMarkovModel(hmmModel, seq);
+ seq.setHMM(hmmModel);
+ } catch (IOException e)
+ {
+ warn("Error loading HMM profile for " + seq.getName() + ": "
+ + e.getMessage());
+ }
+ }
+
+ /**
* Instantiate and link any saved RNA (Varna) viewers. The state of the Varna
* panel is restored from separate jar entries, two (gapped and trimmed) per
* sequence and secondary structure.
* @param jseqs
* @param ap
*/
- private void loadRnaViewers(jarInputStreamProvider jprovider,
+ protected void loadRnaViewers(jarInputStreamProvider jprovider,
List<JSeq> jseqs, AlignmentPanel ap)
{
/*
tree.getTitle(), safeInt(tree.getWidth()),
safeInt(tree.getHeight()), safeInt(tree.getXpos()),
safeInt(tree.getYpos()));
+ if (tp == null)
+ {
+ warn("There was a problem recovering stored Newick tree: \n"
+ + tree.getNewick());
+ continue;
+ }
if (tree.getId() != null)
{
// perhaps bind the tree id to something ?
tp.getTreeCanvas().setAssociatedPanel(ap); // af.alignPanel;
}
tp.getTreeCanvas().setApplyToAllViews(tree.isLinkToAllViews());
- if (tp == null)
- {
- warn("There was a problem recovering stored Newick tree: \n"
- + tree.getNewick());
- continue;
- }
-
tp.fitToWindow.setState(safeBoolean(tree.isFitToWindow()));
tp.fitToWindow_actionPerformed(null);
int height = safeInt(structureState.getHeight());
// Probably don't need to do this anymore...
- // Desktop.desktop.getComponentAt(x, y);
+ // Desktop.getDesktop().getComponentAt(x, y);
// TODO: NOW: check that this recovers the PDB file correctly.
String pdbFile = loadPDBFile(jprovider, pdbid.getId(),
pdbid.getFile());
*/
String viewerJarEntryName = getViewerJarEntryName(data.getViewId());
chimeraSessionFile = copyJarEntry(jprovider, viewerJarEntryName,
- "chimera", null);
+ "chimera", ".py");
Set<Entry<File, StructureData>> fileData = data.getFileData()
.entrySet();
String reformatedOldFilename = oldfilenam.replaceAll("/", "\\\\");
filedat = oldFiles.get(new File(reformatedOldFilename));
}
- newFileLoc.append(Platform.escapeBackslashes(filedat.getFilePath()));
+ newFileLoc
+ .append(Platform.escapeBackslashes(filedat.getFilePath()));
pdbfilenames.add(filedat.getFilePath());
pdbids.add(filedat.getPdbId());
seqmaps.add(filedat.getSeqList().toArray(new SequenceI[0]));
final AlignFrame alf = af;
final Rectangle rect = new Rectangle(svattrib.getX(), svattrib.getY(),
svattrib.getWidth(), svattrib.getHeight());
- try
- {
- javax.swing.SwingUtilities.invokeAndWait(new Runnable()
+
+ // BH again was invokeAndWait
+ // try
+ // {
+ javax.swing.SwingUtilities.invokeLater(new Runnable()
{
@Override
public void run()
}
}
});
- } catch (InvocationTargetException ex)
- {
- warn("Unexpected error when opening Jmol view.", ex);
-
- } catch (InterruptedException e)
- {
- // e.printStackTrace();
- }
+ // } catch (InvocationTargetException ex)
+ // {
+ // warn("Unexpected error when opening Jmol view.", ex);
+ //
+ // } catch (InterruptedException e)
+ // {
+ // // e.printStackTrace();
+ // }
}
{
try
{
- frames = Desktop.desktop.getAllFrames();
+ frames = Desktop.getDesktopPane().getAllFrames();
} catch (ArrayIndexOutOfBoundsException e)
{
// occasional No such child exceptions are thrown here...
}
}
- AlignFrame loadViewport(String file, List<JSeq> JSEQ,
- List<SequenceI> hiddenSeqs, AlignmentI al,
- JalviewModel jm, Viewport view, String uniqueSeqSetId,
- String viewId, List<JvAnnotRow> autoAlan)
+ AlignFrame loadViewport(String fileName, File file, List<JSeq> JSEQ,
+ List<SequenceI> hiddenSeqs, AlignmentI al, JalviewModel jm,
+ Viewport view, String uniqueSeqSetId, String viewId,
+ List<JvAnnotRow> autoAlan)
{
AlignFrame af = null;
af = new AlignFrame(al, safeInt(view.getWidth()),
- safeInt(view.getHeight()), uniqueSeqSetId, viewId);
-
- af.setFileName(file, FileFormat.Jalview);
+ safeInt(view.getHeight()), uniqueSeqSetId, viewId)
+ // {
+ //
+ // @Override
+ // protected void processKeyEvent(java.awt.event.KeyEvent e) {
+ // System.out.println("Jalview2XML AF " + e);
+ // super.processKeyEvent(e);
+ //
+ // }
+ //
+ // }
+ ;
+ af.alignPanel.setHoldRepaint(true);
+ af.setFile(fileName, file, null, FileFormat.Jalview);
+ af.setFileObject(jarFile); // BH 2019 JAL-3436
final AlignViewport viewport = af.getViewport();
for (int i = 0; i < JSEQ.size(); i++)
viewport.setColourText(safeBoolean(view.isShowColourText()));
- viewport
- .setConservationSelected(
- safeBoolean(view.isConservationSelected()));
+ viewport.setConservationSelected(
+ safeBoolean(view.isConservationSelected()));
viewport.setIncrement(safeInt(view.getConsThreshold()));
viewport.setShowJVSuffix(safeBoolean(view.isShowFullId()));
viewport.setRightAlignIds(safeBoolean(view.isRightAlignIds()));
viewport.setViewName(view.getViewName());
af.setInitialTabVisible();
}
- af.setBounds(safeInt(view.getXpos()), safeInt(view.getYpos()),
- safeInt(view.getWidth()), safeInt(view.getHeight()));
+ int x = safeInt(view.getXpos());
+ int y = safeInt(view.getYpos());
+ int w = safeInt(view.getWidth());
+ int h = safeInt(view.getHeight());
+ // // BH we cannot let the title bar go off the top
+ // if (Platform.isJS())
+ // {
+ // x = Math.max(50 - w, x);
+ // y = Math.max(0, y);
+ // }
+
+ af.setBounds(x, y, w, h);
// startSeq set in af.alignPanel.updateLayout below
af.alignPanel.updateLayout();
ColourSchemeI cs = null;
af.changeColour(cs);
viewport.setColourAppliesToAllGroups(true);
- viewport
- .setShowSequenceFeatures(
- safeBoolean(view.isShowSequenceFeatures()));
+ viewport.setShowSequenceFeatures(
+ safeBoolean(view.isShowSequenceFeatures()));
viewport.setCentreColumnLabels(view.isCentreColumnLabels());
viewport.setIgnoreGapsConsensus(view.isIgnoreGapsinConsensus(), null);
viewport.setShowNPFeats(safeBoolean(view.isShowNPfeatureTooltip()));
viewport.setShowGroupConsensus(view.isShowGroupConsensus());
viewport.setShowGroupConservation(view.isShowGroupConservation());
+ viewport.setShowComplementFeatures(view.isShowComplementFeatures());
+ viewport.setShowComplementFeaturesOnTop(
+ view.isShowComplementFeaturesOnTop());
// recover feature settings
if (jm.getFeatureSettings() != null)
{
- FeatureRendererModel fr = af.alignPanel.getSeqPanel().seqCanvas
+ FeatureRenderer fr = af.alignPanel.getSeqPanel().seqCanvas
.getFeatureRenderer();
FeaturesDisplayed fdi;
viewport.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
- String[] renderOrder = new String[jm.getFeatureSettings()
- .getSetting().size()];
+ String[] renderOrder = new String[jm.getFeatureSettings().getSetting()
+ .size()];
Map<String, FeatureColourI> featureColours = new Hashtable<>();
Map<String, Float> featureOrder = new Hashtable<>();
- for (int fs = 0; fs < jm.getFeatureSettings()
- .getSetting().size(); fs++)
+ for (int fs = 0; fs < jm.getFeatureSettings().getSetting()
+ .size(); fs++)
{
Setting setting = jm.getFeatureSettings().getSetting().get(fs);
String featureType = setting.getType();
.getMatcherSet();
if (filters != null)
{
- FeatureMatcherSetI filter = Jalview2XML
- .parseFilter(featureType, filters);
+ FeatureMatcherSetI filter = Jalview2XML.parseFilter(featureType,
+ filters);
if (!filter.isEmpty())
{
fr.setFeatureFilter(featureType, filter);
float max = setting.getMax() == null ? 1f
: setting.getMax().floatValue();
FeatureColourI gc = new FeatureColour(maxColour, minColour,
- maxColour,
- noValueColour, min, max);
+ maxColour, noValueColour, min, max);
if (setting.getAttributeName().size() > 0)
{
gc.setAttributeName(setting.getAttributeName().toArray(
}
else
{
- featureColours.put(featureType,
- new FeatureColour(maxColour));
+ featureColours.put(featureType, new FeatureColour(maxColour));
}
renderOrder[fs] = featureType;
if (setting.getOrder() != null)
String complementaryViewId = view.getComplementId();
if (complementaryViewId == null)
{
- Desktop.addInternalFrame(af, view.getTitle(),
+ Dimension dim = Platform.getDimIfEmbedded(af,
safeInt(view.getWidth()), safeInt(view.getHeight()));
+ Desktop.addInternalFrame(af, view.getTitle(), dim.width, dim.height);
// recompute any autoannotation
af.alignPanel.updateAnnotation(false, true);
reorderAutoannotation(af, al, autoAlan);
String id = object.getViewport().get(0).getSequenceSetId();
if (skipList.containsKey(id))
{
- if (Cache.log != null && Cache.log.isDebugEnabled())
- {
- Cache.log.debug("Skipping seuqence set id " + id);
- }
+ if (Cache.log != null && Cache.log.isDebugEnabled())
+ {
+ Cache.log.debug("Skipping seuqence set id " + id);
+ }
return true;
}
return false;
}
- public void addToSkipList(AlignFrame af)
+ protected void addToSkipList(AlignFrame af)
{
if (skipList == null)
{
skipList.put(af.getViewport().getSequenceSetId(), af);
}
- public void clearSkipList()
+ protected void clearSkipList()
{
if (skipList != null)
{
SequenceI[] dsseqs = new SequenceI[dseqs.size()];
dseqs.copyInto(dsseqs);
ds = new jalview.datamodel.Alignment(dsseqs);
- debug("Created new dataset " + vamsasSet.getDatasetId()
- + " for alignment " + System.identityHashCode(al));
+// debug("Jalview2XML Created new dataset " + vamsasSet.getDatasetId()
+// + " for alignment " + System.identityHashCode(al));
addDatasetRef(vamsasSet.getDatasetId(), ds);
}
// set the dataset for the newly imported alignment.
jmap.setTo(djs);
incompleteSeqs.put(sqid, djs);
seqRefIds.put(sqid, djs);
-
}
jalview.bin.Cache.log.debug("about to recurse on addDBRefs.");
addDBRefs(djs, ms);
viewportsAdded.clear();
- AlignFrame af = loadFromObject(jm, null, false, null);
+ AlignFrame af = loadFromObject(jm, null, null, false, null);
af.getAlignPanels().clear();
af.closeMenuItem_actionPerformed(true);
+ af.alignPanel.setHoldRepaint(false);
+ this.jarFile = null;
/*
* if(ap.av.getAlignment().getAlignmentAnnotation()!=null) { for(int i=0;
}
else
{
- Cache.log.debug("Ignoring " + jvobj.getClass() + " (ID = " + id);
+ Cache.log.debug("Ignoring " + jvobj.getClass() + " (ID = " + id);
}
}
}
axis.getXPos(), axis.getYPos(), axis.getZPos());
}
+ Dimension dim = Platform.getDimIfEmbedded(panel, 475, 450);
Desktop.addInternalFrame(panel, MessageManager.formatMessage(
- "label.calc_title", "PCA", modelName), 475, 450);
+ "label.calc_title", "PCA", modelName), dim.width,
+ dim.height);
}
} catch (Exception ex)
{
maxcol = new Color(Integer.parseInt(colourModel.getRGB(), 16));
} catch (Exception e)
{
- Cache.log.warn("Couldn't parse out graduated feature color.", e);
+ Cache.log.warn("Couldn't parse out graduated feature color.", e);
}
NoValueColour noCol = colourModel.getNoValueColour();