/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
- * Copyright (C) 2014 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
*/
package jalview.gui;
+import java.awt.Rectangle;
+import java.io.BufferedReader;
+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.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.lang.reflect.InvocationTargetException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+
+import javax.swing.JInternalFrame;
+import javax.swing.JOptionPane;
+import javax.swing.SwingUtilities;
+
+import org.exolab.castor.xml.Unmarshaller;
+
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
+import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.StructureViewerModel;
import jalview.datamodel.StructureViewerModel.StructureData;
import jalview.schemabinding.version2.AlcodMap;
-import jalview.schemabinding.version2.Alcodon;
import jalview.schemabinding.version2.AlcodonFrame;
import jalview.schemabinding.version2.Annotation;
import jalview.schemabinding.version2.AnnotationColours;
import jalview.ws.params.AutoCalcSetting;
import jalview.ws.params.WsParamSetI;
-import java.awt.Rectangle;
-import java.io.BufferedReader;
-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.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.IdentityHashMap;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.Vector;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
-
-import javax.swing.JInternalFrame;
-import javax.swing.JOptionPane;
-import javax.swing.SwingUtilities;
-
-import org.exolab.castor.xml.Unmarshaller;
-
/**
* Write out the current jalview desktop state as a Jalview XML stream.
*
boolean raiseGUI = true; // whether errors are raised in dialog boxes or not
+ /*
+ * Map of reconstructed AlignFrame objects that appear to have come from
+ * SplitFrame objects (have a dna/protein complement view).
+ */
+ private Map<Viewport, AlignFrame> splitFrameCandidates = new HashMap<Viewport, AlignFrame>();
+
/**
* create/return unique hash string for sq
*
}
/**
- * This maintains a list of viewports, the key being the seqSetId. Important
- * to set historyItem and redoList for multiple views
+ * This maintains a map of viewports, the key being the seqSetId. Important to
+ * set historyItem and redoList for multiple views
*/
- Hashtable viewportsAdded;
+ Map<String, AlignViewport> viewportsAdded = new HashMap<String, AlignViewport>();
- Hashtable annotationIds = new Hashtable();
+ Map<String, AlignmentAnnotation> annotationIds = new HashMap<String, AlignmentAnnotation>();
String uniqueSetSuffix = "";
*/
public void saveState(JarOutputStream jout)
{
- JInternalFrame[] frames = Desktop.desktop.getAllFrames();
+ AlignFrame[] frames = Desktop.getAlignFrames(); // Desktop.desktop.getAllFrames();
if (frames == null)
{
// REVERSE ORDER
for (int i = frames.length - 1; i > -1; i--)
{
- if (frames[i] instanceof AlignFrame)
+ AlignFrame af = frames[i];
+ // skip ?
+ if (skipList != null
+ && skipList
+ .containsKey(af.getViewport().getSequenceSetId()))
{
- AlignFrame af = (AlignFrame) frames[i];
- // skip ?
- if (skipList != null
- && skipList.containsKey(af.getViewport()
- .getSequenceSetId()))
- {
- continue;
- }
+ continue;
+ }
+
+ String shortName = af.getTitle();
+
+ if (shortName.indexOf(File.separatorChar) > -1)
+ {
+ shortName = shortName.substring(shortName
+ .lastIndexOf(File.separatorChar) + 1);
+ }
- String shortName = af.getTitle();
+ int count = 1;
- if (shortName.indexOf(File.separatorChar) > -1)
+ while (shortNames.contains(shortName))
+ {
+ if (shortName.endsWith("_" + (count - 1)))
{
- shortName = shortName.substring(shortName
- .lastIndexOf(File.separatorChar) + 1);
+ shortName = shortName.substring(0, shortName.lastIndexOf("_"));
}
- int count = 1;
+ shortName = shortName.concat("_" + count);
+ count++;
+ }
- while (shortNames.contains(shortName))
- {
- if (shortName.endsWith("_" + (count - 1)))
- {
- shortName = shortName
- .substring(0, shortName.lastIndexOf("_"));
- }
+ shortNames.addElement(shortName);
- shortName = shortName.concat("_" + count);
- count++;
- }
+ if (!shortName.endsWith(".xml"))
+ {
+ shortName = shortName + ".xml";
+ }
- shortNames.addElement(shortName);
+ int ap, apSize = af.alignPanels.size();
- if (!shortName.endsWith(".xml"))
+ for (ap = 0; ap < apSize; ap++)
+ {
+ AlignmentPanel apanel = af.alignPanels.get(ap);
+ String fileName = apSize == 1 ? shortName : ap + shortName;
+ if (!fileName.endsWith(".xml"))
{
- shortName = shortName + ".xml";
+ fileName = fileName + ".xml";
}
- int ap, apSize = af.alignPanels.size();
+ saveState(apanel, fileName, jout);
- for (ap = 0; ap < apSize; ap++)
+ String dssid = getDatasetIdRef(af.getViewport().getAlignment()
+ .getDataset());
+ if (!dsses.containsKey(dssid))
{
- AlignmentPanel apanel = (AlignmentPanel) af.alignPanels
- .elementAt(ap);
- String fileName = apSize == 1 ? shortName : ap + shortName;
- if (!fileName.endsWith(".xml"))
- {
- fileName = fileName + ".xml";
- }
-
- saveState(apanel, fileName, jout);
-
- String dssid = getDatasetIdRef(af.getViewport().getAlignment()
- .getDataset());
- if (!dsses.containsKey(dssid))
- {
- dsses.put(dssid, af);
- }
-
+ dsses.put(dssid, af);
}
}
}
{
try
{
- int ap, apSize = af.alignPanels.size();
+ int ap = 0;
+ int apSize = af.alignPanels.size();
FileOutputStream fos = new FileOutputStream(jarFile);
JarOutputStream jout = new JarOutputStream(fos);
Hashtable<String, AlignFrame> dsses = new Hashtable<String, AlignFrame>();
- for (ap = 0; ap < apSize; ap++)
+ for (AlignmentPanel apanel : af.alignPanels)
{
- AlignmentPanel apanel = (AlignmentPanel) af.alignPanels
- .elementAt(ap);
String jfileName = apSize == 1 ? fileName : fileName + ap;
+ ap++;
if (!jfileName.endsWith(".xml"))
{
jfileName = jfileName + ".xml";
{
byte[] data = new byte[(int) file.length()];
jout.putNextEntry(new JarEntry(entry.getId()));
- dis = new DataInputStream(
- new FileInputStream(file));
+ dis = new DataInputStream(new FileInputStream(file));
dis.readFully(data);
DataOutputStream dout = new DataOutputStream(jout);
jal = av.getAlignment();
}
// SAVE MAPPINGS
- if (jal.getCodonFrames() != null && jal.getCodonFrames().length > 0)
+ if (jal.getCodonFrames() != null)
{
- jalview.datamodel.AlignedCodonFrame[] jac = jal.getCodonFrames();
- for (int i = 0; i < jac.length; i++)
+ Set<AlignedCodonFrame> jac = jal.getCodonFrames();
+ for (AlignedCodonFrame acf : jac)
{
AlcodonFrame alc = new AlcodonFrame();
vamsasSet.addAlcodonFrame(alc);
- for (int p = 0; p < jac[i].aaWidth; p++)
+ if (acf.getProtMappings() != null
+ && acf.getProtMappings().length > 0)
{
- Alcodon cmap = new Alcodon();
- if (jac[i].codons[p] != null)
- {
- // Null codons indicate a gapped column in the translated peptide
- // alignment.
- cmap.setPos1(jac[i].codons[p][0]);
- cmap.setPos2(jac[i].codons[p][1]);
- cmap.setPos3(jac[i].codons[p][2]);
- }
- alc.addAlcodon(cmap);
- }
- if (jac[i].getProtMappings() != null
- && jac[i].getProtMappings().length > 0)
- {
- SequenceI[] dnas = jac[i].getdnaSeqs();
- jalview.datamodel.Mapping[] pmaps = jac[i].getProtMappings();
+ SequenceI[] dnas = acf.getdnaSeqs();
+ jalview.datamodel.Mapping[] pmaps = acf.getProtMappings();
for (int m = 0; m < pmaps.length; m++)
{
AlcodMap alcmap = new AlcodMap();
alc.addAlcodMap(alcmap);
}
}
+
+// {
+// AlcodonFrame alc = new AlcodonFrame();
+// vamsasSet.addAlcodonFrame(alc);
+// for (int p = 0; p < acf.aaWidth; p++)
+// {
+// Alcodon cmap = new Alcodon();
+// if (acf.codons[p] != null)
+// {
+// // Null codons indicate a gapped column in the translated peptide
+// // alignment.
+// cmap.setPos1(acf.codons[p][0]);
+// cmap.setPos2(acf.codons[p][1]);
+// cmap.setPos3(acf.codons[p][2]);
+// }
+// alc.addAlcodon(cmap);
+// }
+// if (acf.getProtMappings() != null
+// && acf.getProtMappings().length > 0)
+// {
+// SequenceI[] dnas = acf.getdnaSeqs();
+// jalview.datamodel.Mapping[] pmaps = acf.getProtMappings();
+// for (int m = 0; m < pmaps.length; m++)
+// {
+// AlcodMap alcmap = new AlcodMap();
+// alcmap.setDnasq(seqHash(dnas[m]));
+// alcmap.setMapping(createVamsasMapping(pmaps[m], dnas[m], null,
+// false));
+// alc.addAlcodMap(alcmap);
+// }
+// }
}
}
view.setSequenceSetId(makeHashCode(av.getSequenceSetId(),
av.getSequenceSetId()));
view.setId(av.getViewId());
- view.setViewName(av.viewName);
- view.setGatheredViews(av.gatherViewsHere);
-
- if (ap.av.explodedPosition != null)
+ if (av.getCodingComplement() != null)
{
- view.setXpos(av.explodedPosition.x);
- view.setYpos(av.explodedPosition.y);
- view.setWidth(av.explodedPosition.width);
- view.setHeight(av.explodedPosition.height);
+ view.setComplementId(av.getCodingComplement().getViewId());
}
- else
+ view.setViewName(av.viewName);
+ view.setGatheredViews(av.isGatherViewsHere());
+
+ Rectangle position = ap.av.getExplodedGeometry();
+ if (position == null)
{
- view.setXpos(ap.alignFrame.getBounds().x);
- view.setYpos(ap.alignFrame.getBounds().y);
- view.setWidth(ap.alignFrame.getBounds().width);
- view.setHeight(ap.alignFrame.getBounds().height);
+ position = ap.alignFrame.getBounds();
}
+ view.setXpos(position.x);
+ view.setYpos(position.y);
+ view.setWidth(position.width);
+ view.setHeight(position.height);
view.setStartRes(av.startRes);
view.setStartSeq(av.startSeq);
view.setFontName(av.font.getName());
view.setFontSize(av.font.getSize());
view.setFontStyle(av.font.getStyle());
- view.setRenderGaps(av.renderGaps);
+ view.setRenderGaps(av.isRenderGaps());
view.setShowAnnotation(av.isShowAnnotation());
view.setShowBoxes(av.getShowBoxes());
view.setShowColourText(av.getColourText());
view.setShowText(av.getShowText());
view.setShowUnconserved(av.getShowUnconserved());
view.setWrapAlignment(av.getWrapAlignment());
- view.setTextCol1(av.textColour.getRGB());
- view.setTextCol2(av.textColour2.getRGB());
- view.setTextColThreshold(av.thresholdTextColour);
+ view.setTextCol1(av.getTextColour().getRGB());
+ view.setTextCol2(av.getTextColour2().getRGB());
+ view.setTextColThreshold(av.getThresholdTextColour());
view.setShowConsensusHistogram(av.isShowConsensusHistogram());
view.setShowSequenceLogo(av.isShowSequenceLogo());
view.setNormaliseSequenceLogo(av.isNormaliseSequenceLogo());
view.setShowGroupConsensus(av.isShowGroupConsensus());
view.setShowGroupConservation(av.isShowGroupConservation());
- view.setShowNPfeatureTooltip(av.isShowNpFeats());
- view.setShowDbRefTooltip(av.isShowDbRefs());
- view.setFollowHighlight(av.followHighlight);
+ view.setShowNPfeatureTooltip(av.isShowNPFeats());
+ view.setShowDbRefTooltip(av.isShowDBRefs());
+ view.setFollowHighlight(av.isFollowHighlight());
view.setFollowSelection(av.followSelection);
- view.setIgnoreGapsinConsensus(av.getIgnoreGapsConsensus());
+ view.setIgnoreGapsinConsensus(av.isIgnoreGapsConsensus());
if (av.getFeaturesDisplayed() != null)
{
jalview.schemabinding.version2.FeatureSettings fs = new jalview.schemabinding.version2.FeatureSettings();
- String[] renderOrder = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getRenderOrder().toArray(new String[0]);
+ String[] renderOrder = ap.getSeqPanel().seqCanvas
+ .getFeatureRenderer().getRenderOrder()
+ .toArray(new String[0]);
Vector settingsAdded = new Vector();
Object gstyle = null;
}
else
{
- setting.setColour(ap.getSeqPanel().seqCanvas.getFeatureRenderer()
+ setting.setColour(ap.getSeqPanel().seqCanvas
+ .getFeatureRenderer()
.getColour(renderOrder[ro]).getRGB());
}
settingsAdded.addElement(key);
}
// is groups actually supposed to be a map here ?
- en = ap.getSeqPanel().seqCanvas.getFeatureRenderer().getFeatureGroups()
- .iterator();
+ en = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
+ .getFeatureGroups().iterator();
Vector groupsAdded = new Vector();
while (en.hasNext())
{
for (int c = 0; c < av.getColumnSelection().getHiddenColumns()
.size(); c++)
{
- int[] region = av.getColumnSelection()
- .getHiddenColumns().get(c);
+ int[] region = av.getColumnSelection().getHiddenColumns()
+ .get(c);
HiddenColumns hc = new HiddenColumns();
hc.setStart(region[0]);
hc.setEnd(region[1]);
Pdbids pdb, PDBEntry entry, List<String> viewIds,
String matchedFile, StructureViewerBase viewFrame)
{
- final AAStructureBindingModel bindingModel = viewFrame
- .getBinding();
- for (int peid = 0; peid < bindingModel
- .getPdbCount(); peid++)
+ final AAStructureBindingModel bindingModel = viewFrame.getBinding();
+ for (int peid = 0; peid < bindingModel.getPdbCount(); peid++)
{
final PDBEntry pdbentry = bindingModel.getPdbEntry(peid);
final String pdbId = pdbentry.getId();
if (!pdbId.equals(entry.getId())
&& !(entry.getId().length() > 4 && entry.getId()
- .toLowerCase()
- .startsWith(pdbId.toLowerCase())))
+ .toLowerCase().startsWith(pdbId.toLowerCase())))
{
continue;
}
{
matchedFile = pdbentry.getFile();
}
- else if (!matchedFile.equals(pdbentry
- .getFile()))
+ 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): "
// 1QIP==1qipA)
String statestring = viewFrame.getStateInfo();
- for (int smap = 0; smap < viewFrame.getBinding()
- .getSequence()[peid].length; smap++)
+ for (int smap = 0; smap < viewFrame.getBinding().getSequence()[peid].length; smap++)
{
// if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1)
if (jds == viewFrame.getBinding().getSequence()[peid][smap])
final String viewId = viewFrame.getViewId();
state.setViewId(viewId);
state.setAlignwithAlignPanel(viewFrame.isUsedforaligment(ap));
- state.setColourwithAlignPanel(viewFrame
- .isUsedforcolourby(ap));
+ state.setColourwithAlignPanel(viewFrame.isUsedforcolourby(ap));
state.setColourByJmol(viewFrame.isColouredByViewer());
/*
* Only store each structure viewer's state once in each XML document.
return false;
}
}
- throw new Error(MessageManager.formatMessage("error.unsupported_version_calcIdparam", new String[]{calcIdParam.toString()}));
+ throw new Error(MessageManager.formatMessage(
+ "error.unsupported_version_calcIdparam", new Object[]
+ { calcIdParam.toString() }));
}
/**
mp = new Mapping();
jalview.util.MapList mlst = jmp.getMap();
- int r[] = mlst.getFromRanges();
- for (int s = 0; s < r.length; s += 2)
+ List<int[]> r = mlst.getFromRanges();
+ for (int[] range : r)
{
MapListFrom mfrom = new MapListFrom();
- mfrom.setStart(r[s]);
- mfrom.setEnd(r[s + 1]);
+ mfrom.setStart(range[0]);
+ mfrom.setEnd(range[1]);
mp.addMapListFrom(mfrom);
}
r = mlst.getToRanges();
- for (int s = 0; s < r.length; s += 2)
+ for (int[] range : r)
{
MapListTo mto = new MapListTo();
- mto.setStart(r[s]);
- mto.setEnd(r[s + 1]);
+ mto.setStart(range[0]);
+ mto.setEnd(range[1]);
mp.addMapListTo(mto);
}
mp.setMapFromUnit(mlst.getFromRatio());
errorMessage = null;
uniqueSetSuffix = null;
seqRefIds = null;
- viewportsAdded = null;
+ viewportsAdded.clear();
frefedSequence = null;
if (file.startsWith("http://"))
{
seqRefIds = new HashMap<String, SequenceI>();
}
- if (viewportsAdded == null)
- {
- viewportsAdded = new Hashtable();
- }
if (frefedSequence == null)
{
frefedSequence = new Vector();
}
- jalview.gui.AlignFrame af = null, _af = null;
- Hashtable gatherToThisFrame = new Hashtable();
+ AlignFrame af = null, _af = null;
+ Map<String, AlignFrame> gatherToThisFrame = new HashMap<String, AlignFrame>();
final String file = jprovider.getFilename();
try
{
if (object.getJalviewModelSequence().getViewportCount() > 0)
{
af = _af;
- if (af.viewport.gatherViewsHere)
+ if (af.viewport.isGatherViewsHere())
{
gatherToThisFrame.put(af.viewport.getSequenceSetId(), af);
}
Desktop.instance.stopLoading();
}
- Enumeration en = gatherToThisFrame.elements();
- while (en.hasMoreElements())
+ /*
+ * Regather multiple views (with the same sequence set id) to the frame (if
+ * any) that is flagged as the one to gather to, i.e. convert them to tabbed
+ * views instead of separate frames. Note this doesn't restore a state where
+ * some expanded views in turn have tabbed views - the last "first tab" read
+ * in will play the role of gatherer for all.
+ */
+ for (AlignFrame fr : gatherToThisFrame.values())
{
- Desktop.instance.gatherViews((AlignFrame) en.nextElement());
+ Desktop.instance.gatherViews(fr);
}
+
+ restoreSplitFrames();
+
if (errorMessage != null)
{
reportErrors();
}
/**
+ * Try to reconstruct and display SplitFrame windows, where each contains
+ * complementary dna and protein alignments. Done by pairing up AlignFrame
+ * objects (created earlier) which have complementary viewport ids associated.
+ */
+ protected void restoreSplitFrames()
+ {
+ List<SplitFrame> gatherTo = new ArrayList<SplitFrame>();
+ List<AlignFrame> addedToSplitFrames = new ArrayList<AlignFrame>();
+ Map<String, AlignFrame> dna = new HashMap<String, AlignFrame>();
+
+ /*
+ * Identify the DNA alignments
+ */
+ for (Entry<Viewport, AlignFrame> candidate : splitFrameCandidates
+ .entrySet())
+ {
+ AlignFrame af = candidate.getValue();
+ if (af.getViewport().getAlignment().isNucleotide())
+ {
+ dna.put(candidate.getKey().getId(), af);
+ }
+ }
+
+ /*
+ * Try to match up the protein complements
+ */
+ for (Entry<Viewport, AlignFrame> candidate : splitFrameCandidates
+ .entrySet())
+ {
+ AlignFrame af = candidate.getValue();
+ if (!af.getViewport().getAlignment().isNucleotide())
+ {
+ String complementId = candidate.getKey().getComplementId();
+ // only non-null complements should be in the Map
+ if (complementId != null && dna.containsKey(complementId))
+ {
+ final AlignFrame dnaFrame = dna.get(complementId);
+ SplitFrame sf = createSplitFrame(dnaFrame, af);
+ addedToSplitFrames.add(dnaFrame);
+ addedToSplitFrames.add(af);
+ if (af.viewport.isGatherViewsHere())
+ {
+ gatherTo.add(sf);
+ }
+ }
+ }
+ }
+
+ /*
+ * Open any that we failed to pair up (which shouldn't happen!) as
+ * standalone AlignFrame's.
+ */
+ for (Entry<Viewport, AlignFrame> candidate : splitFrameCandidates
+ .entrySet())
+ {
+ AlignFrame af = candidate.getValue();
+ if (!addedToSplitFrames.contains(af)) {
+ Viewport view = candidate.getKey();
+ Desktop.addInternalFrame(af, view.getTitle(), view.getWidth(),
+ view.getHeight());
+ System.err.println("Failed to restore view " + view.getTitle()
+ + " to split frame");
+ }
+ }
+
+ /*
+ * Gather back into tabbed views as flagged.
+ */
+ for (SplitFrame sf : gatherTo)
+ {
+ Desktop.instance.gatherViews(sf);
+ }
+
+ splitFrameCandidates.clear();
+ }
+
+ /**
+ * Construct and display one SplitFrame holding DNA and protein alignments.
+ *
+ * @param dnaFrame
+ * @param proteinFrame
+ * @return
+ */
+ protected SplitFrame createSplitFrame(AlignFrame dnaFrame,
+ AlignFrame proteinFrame)
+ {
+ SplitFrame splitFrame = new SplitFrame(dnaFrame, proteinFrame);
+ String title = MessageManager.getString("label.linked_view_title");
+ int width = (int) dnaFrame.getBounds().getWidth();
+ int height = (int) (dnaFrame.getBounds().getHeight()
+ + proteinFrame.getBounds().getHeight() + 50);
+ Desktop.addInternalFrame(splitFrame, title, width, height);
+
+ /*
+ * And compute cDNA consensus (couldn't do earlier with consensus as
+ * mappings were not yet present)
+ */
+ proteinFrame.viewport.alignmentChanged(proteinFrame.alignPanel);
+
+ return splitFrame;
+ }
+
+ /**
* check errorMessage for a valid error message and raise an error box in the
* GUI or write the current errorMessage to stderr and then clear the error
* state.
errorMessage = null;
}
- Hashtable<String, String> alreadyLoadedPDB;
+ Map<String, String> alreadyLoadedPDB = new HashMap<String, String>();
/**
* when set, local views will be updated from view stored in JalviewXML
String loadPDBFile(jarInputStreamProvider jprovider, String pdbId)
{
- if (alreadyLoadedPDB == null)
- {
- alreadyLoadedPDB = new Hashtable();
- }
-
if (alreadyLoadedPDB.containsKey(pdbId))
{
return alreadyLoadedPDB.get(pdbId).toString();
// ////////////////////////////////
// LOAD SEQUENCES
- Vector hiddenSeqs = null;
+ List<SequenceI> hiddenSeqs = null;
jalview.datamodel.Sequence jseq;
- ArrayList tmpseqs = new ArrayList();
+ List<SequenceI> tmpseqs = new ArrayList<SequenceI>();
boolean multipleView = false;
{
if (hiddenSeqs == null)
{
- hiddenSeqs = new Vector();
+ hiddenSeqs = new ArrayList<SequenceI>();
}
- hiddenSeqs.addElement(seqRefIds.get(seqId));
+ hiddenSeqs.add(seqRefIds.get(seqId));
}
}
// /
// Create the alignment object from the sequence set
// ///////////////////////////////
- jalview.datamodel.Sequence[] orderedSeqs = new jalview.datamodel.Sequence[tmpseqs
- .size()];
+ SequenceI[] orderedSeqs = tmpseqs
+ .toArray(new SequenceI[tmpseqs.size()]);
- tmpseqs.toArray(orderedSeqs);
-
- jalview.datamodel.Alignment al = new jalview.datamodel.Alignment(
- orderedSeqs);
+ Alignment al = new Alignment(orderedSeqs);
// / Add the alignment properties
for (int i = 0; i < vamsasSet.getSequenceSetPropertiesCount(); i++)
}
// ///////////////////////////////
- Hashtable pdbloaded = new Hashtable();
+ Hashtable pdbloaded = new Hashtable(); // TODO nothing writes to this??
if (!multipleView)
{
// load sequence features, database references and any associated PDB
}
}
StructureSelectionManager.getStructureSelectionManager(
- Desktop.instance)
- .registerPDBEntry(entry);
+ Desktop.instance).registerPDBEntry(entry);
al.getSequenceAt(i).getDatasetSequence().addPDBId(entry);
}
}
AlcodonFrame[] alc = vamsasSet.getAlcodonFrame();
for (int i = 0; i < alc.length; i++)
{
- jalview.datamodel.AlignedCodonFrame cf = new jalview.datamodel.AlignedCodonFrame(
- alc[i].getAlcodonCount());
- if (alc[i].getAlcodonCount() > 0)
- {
- Alcodon[] alcods = alc[i].getAlcodon();
- for (int p = 0; p < cf.codons.length; p++)
- {
- if (alcods[p].hasPos1() && alcods[p].hasPos2()
- && alcods[p].hasPos3())
- {
- // translated codons require three valid positions
- cf.codons[p] = new int[3];
- cf.codons[p][0] = (int) alcods[p].getPos1();
- cf.codons[p][1] = (int) alcods[p].getPos2();
- cf.codons[p][2] = (int) alcods[p].getPos3();
- }
- else
- {
- cf.codons[p] = null;
- }
- }
- }
+ AlignedCodonFrame cf = new AlignedCodonFrame();
if (alc[i].getAlcodMapCount() > 0)
{
AlcodMap[] maps = alc[i].getAlcodMap();
for (int m = 0; m < maps.length; m++)
{
- SequenceI dnaseq = seqRefIds
- .get(maps[m].getDnasq());
+ SequenceI dnaseq = seqRefIds.get(maps[m].getDnasq());
// Load Mapping
jalview.datamodel.Mapping mapping = null;
// attach to dna sequence reference.
}
al.addCodonFrame(cf);
}
-
}
// ////////////////////////////////
// LOAD ANNOTATIONS
- ArrayList<JvAnnotRow> autoAlan = new ArrayList<JvAnnotRow>();
+ List<JvAnnotRow> autoAlan = new ArrayList<JvAnnotRow>();
/**
* store any annotations which forward reference a group's ID
*/
if (an[i].getId() != null
&& annotationIds.containsKey(an[i].getId()))
{
- jalview.datamodel.AlignmentAnnotation jda = (jalview.datamodel.AlignmentAnnotation) annotationIds
- .get(an[i].getId());
+ AlignmentAnnotation jda = annotationIds.get(an[i].getId());
// in principle Visible should always be true for annotation displayed
// in multiple views
if (an[i].hasVisible())
for (int s = 0; s < groups[i].getSeqCount(); s++)
{
String seqId = groups[i].getSeq(s) + "";
- jalview.datamodel.SequenceI ts = seqRefIds
- .get(seqId);
+ jalview.datamodel.SequenceI ts = seqRefIds.get(seqId);
if (ts != null)
{
for (int s = 0; s < structureStateCount; s++)
{
// check to see if we haven't already created this structure view
- final StructureState structureState = ids[p].getStructureState(s);
+ final StructureState structureState = ids[p]
+ .getStructureState(s);
String sviewid = (structureState.getViewId() == null) ? null
- : structureState.getViewId()
- + uniqueSetSuffix;
+ : structureState.getViewId() + uniqueSetSuffix;
jalview.datamodel.PDBEntry jpdb = new jalview.datamodel.PDBEntry();
// Originally : ids[p].getFile()
// : TODO: verify external PDB file recovery still works in normal
// Desktop.desktop.getComponentAt(x, y);
// TODO: NOW: check that this recovers the PDB file correctly.
String pdbFile = loadPDBFile(jprovider, ids[p].getId());
- jalview.datamodel.SequenceI seq = seqRefIds
- .get(jseqs[i].getId() + "");
+ jalview.datamodel.SequenceI seq = seqRefIds.get(jseqs[i]
+ .getId() + "");
if (sviewid == null)
{
sviewid = "_jalview_pre2_4_" + x + "," + y + "," + width
}
if (!structureViewers.containsKey(sviewid))
{
- structureViewers.put(sviewid, new StructureViewerModel(x, y, width, height,
- false, false, true));
+ structureViewers.put(sviewid, new StructureViewerModel(x, y,
+ width, height, false, false, true));
// Legacy pre-2.7 conversion JAL-823 :
// do not assume any view has to be linked for colour by
// sequence
* pre-2.7 projects)
*/
boolean colourByViewer = jmoldat.isColourByViewer();
- colourByViewer &= structureState
- .hasColourByJmol() ? structureState
+ colourByViewer &= structureState.hasColourByJmol() ? structureState
.getColourByJmol() : true;
jmoldat.setColourByViewer(colourByViewer);
}
}
}
- // Instantiate the associated structure views
- for (Entry<String, StructureViewerModel> entry : structureViewers.entrySet())
+ // Instantiate the associated structure views
+ for (Entry<String, StructureViewerModel> entry : structureViewers
+ .entrySet())
{
- createOrLinkStructureViewer(entry, af, ap);
- }
+ createOrLinkStructureViewer(entry, af, ap);
+ }
}
/**
* @param viewerData
* @param af
*/
- protected void createChimeraViewer(Entry<String, StructureViewerModel> viewerData,
- AlignFrame af)
+ protected void createChimeraViewer(
+ Entry<String, StructureViewerModel> viewerData, AlignFrame af)
{
final StructureViewerModel data = viewerData.getValue();
String chimeraSession = data.getStateData();
boolean colourBySequence = data.isColourWithAlignPanel();
// TODO can/should this be done via StructureViewer (like Jmol)?
- final PDBEntry[] pdbArray = pdbs.toArray(new PDBEntry[pdbs
- .size()]);
- final SequenceI[][] seqsArray = allseqs.toArray(new SequenceI[allseqs.size()][]);
+ final PDBEntry[] pdbArray = pdbs.toArray(new PDBEntry[pdbs.size()]);
+ final SequenceI[][] seqsArray = allseqs.toArray(new SequenceI[allseqs
+ .size()][]);
new ChimeraViewFrame(chimeraSession, af.alignPanel, pdbArray,
- seqsArray,
- colourByChimera, colourBySequence);
+ seqsArray, colourByChimera, colourBySequence);
}
else
{
* @param af
*/
protected void createJmolViewer(
- final Entry<String, StructureViewerModel> viewerData, AlignFrame af)
+ final Entry<String, StructureViewerModel> viewerData,
+ AlignFrame af)
{
final StructureViewerModel svattrib = viewerData.getValue();
String state = svattrib.getStateData();
newFileLoc.append(Platform.escapeString(filedat.getFilePath()));
pdbfilenames.add(filedat.getFilePath());
pdbids.add(filedat.getPdbId());
- seqmaps.add(filedat.getSeqList()
- .toArray(new SequenceI[0]));
+ seqmaps.add(filedat.getSeqList().toArray(new SequenceI[0]));
newFileLoc.append("\"");
cp = ecp + 1; // advance beyond last \" and set cursor so we can
// look for next file statement.
newFileLoc.append(filedat.getFilePath());
pdbfilenames.add(filedat.getFilePath());
pdbids.add(filedat.getPdbId());
- seqmaps.add(filedat.getSeqList()
- .toArray(new SequenceI[0]));
+ seqmaps.add(filedat.getSeqList().toArray(new SequenceI[0]));
newFileLoc.append(" \"");
newFileLoc.append(filedat.getFilePath());
newFileLoc.append("\"");
(OutOfMemoryError) ex.getCause());
if (sview != null && sview.isVisible())
{
- sview.closeViewer();
+ sview.closeViewer(false);
sview.setVisible(false);
sview.dispose();
}
* Post jalview 2.4 schema includes structure view id
*/
if (sviewid != null
- && ((StructureViewerBase) frame).getViewId().equals(
- sviewid))
+ && ((StructureViewerBase) frame).getViewId()
+ .equals(sviewid))
{
comp = (AppJmol) frame;
// todo: break?
}
}
- AlignFrame loadViewport(String file, JSeq[] JSEQ, Vector hiddenSeqs,
- Alignment al, JalviewModelSequence jms, Viewport view,
- String uniqueSeqSetId, String viewId,
- ArrayList<JvAnnotRow> autoAlan)
+ AlignFrame loadViewport(String file, JSeq[] JSEQ,
+ List<SequenceI> hiddenSeqs, Alignment al,
+ JalviewModelSequence jms, Viewport view, String uniqueSeqSetId,
+ String viewId, List<JvAnnotRow> autoAlan)
{
AlignFrame af = null;
af = new AlignFrame(al, view.getWidth(), view.getHeight(),
.getSequenceAt(i), new java.awt.Color(JSEQ[i].getColour()));
}
- af.viewport.gatherViewsHere = view.getGatheredViews();
+ af.viewport.setGatherViewsHere(view.getGatheredViews());
if (view.getSequenceSetId() != null)
{
- jalview.gui.AlignViewport av = (jalview.gui.AlignViewport) viewportsAdded
- .get(uniqueSeqSetId);
+ AlignmentViewport av = viewportsAdded.get(uniqueSeqSetId);
af.viewport.setSequenceSetId(uniqueSeqSetId);
if (av != null)
{
// propagate shared settings to this new view
- af.viewport.historyList = av.historyList;
- af.viewport.redoList = av.redoList;
+ af.viewport.setHistoryList(av.getHistoryList());
+ af.viewport.setRedoList(av.getRedoList());
}
else
{
af.viewport.hideRepSequences(al.getSequenceAt(s), hidden);
}
- jalview.datamodel.SequenceI[] hseqs = new jalview.datamodel.SequenceI[hiddenSeqs
- .size()];
-
- for (int s = 0; s < hiddenSeqs.size(); s++)
- {
- hseqs[s] = (jalview.datamodel.SequenceI) hiddenSeqs.elementAt(s);
- }
+ // jalview.datamodel.SequenceI[] hseqs = new
+ // jalview.datamodel.SequenceI[hiddenSeqs
+ // .size()];
+ //
+ // for (int s = 0; s < hiddenSeqs.size(); s++)
+ // {
+ // hseqs[s] = (jalview.datamodel.SequenceI) hiddenSeqs.elementAt(s);
+ // }
+ SequenceI[] hseqs = hiddenSeqs.toArray(new SequenceI[hiddenSeqs
+ .size()]);
af.viewport.hideSequence(hseqs);
}
af.viewport.setConservationSelected(view.getConservationSelected());
af.viewport.setShowJVSuffix(view.getShowFullId());
af.viewport.setRightAlignIds(view.getRightAlignIds());
- af.viewport.setFont(new java.awt.Font(view.getFontName(), view
- .getFontStyle(), view.getFontSize()));
- af.alignPanel.fontChanged();
+ af.viewport.setFont(
+ new java.awt.Font(view.getFontName(), view.getFontStyle(), view
+ .getFontSize()), true);
+ // TODO: allow custom charWidth/Heights to be restored by updating them
+ // after setting font - which means set above to false
af.viewport.setRenderGaps(view.getRenderGaps());
af.viewport.setWrapAlignment(view.getWrapAlignment());
- af.alignPanel.setWrapAlignment(view.getWrapAlignment());
af.viewport.setShowAnnotation(view.getShowAnnotation());
- af.alignPanel.setAnnotationVisible(view.getShowAnnotation());
af.viewport.setShowBoxes(view.getShowBoxes());
af.viewport.setShowText(view.getShowText());
- af.viewport.textColour = new java.awt.Color(view.getTextCol1());
- af.viewport.textColour2 = new java.awt.Color(view.getTextCol2());
- af.viewport.thresholdTextColour = view.getTextColThreshold();
+ af.viewport.setTextColour(new java.awt.Color(view.getTextCol1()));
+ af.viewport.setTextColour2(new java.awt.Color(view.getTextCol2()));
+ af.viewport.setThresholdTextColour(view.getTextColThreshold());
af.viewport.setShowUnconserved(view.hasShowUnconserved() ? view
.isShowUnconserved() : false);
af.viewport.setStartRes(view.getStartRes());
af.viewport.setStartSeq(view.getStartSeq());
-
+ af.alignPanel.updateLayout();
ColourSchemeI cs = null;
// apply colourschemes
if (view.getBgColour() != null)
}
if (view.hasFollowHighlight())
{
- af.viewport.followHighlight = view.getFollowHighlight();
+ af.viewport.setFollowHighlight(view.getFollowHighlight());
}
if (view.hasFollowSelection())
{
}
if (view.hasShowDbRefTooltip())
{
- af.viewport.setShowDbRefs(view.getShowDbRefTooltip());
+ af.viewport.setShowDBRefs(view.getShowDbRefTooltip());
}
if (view.hasShowNPfeatureTooltip())
{
- af.viewport.setShowNpFeats(view.hasShowNPfeatureTooltip());
+ af.viewport.setShowNPFeats(view.hasShowNPfeatureTooltip());
}
if (view.hasShowGroupConsensus())
{
}
}
af.setMenusFromViewport(af.viewport);
+
// TODO: we don't need to do this if the viewport is aready visible.
- Desktop.addInternalFrame(af, view.getTitle(), view.getWidth(),
- view.getHeight());
- af.alignPanel.updateAnnotation(false, true); // recompute any autoannotation
- reorderAutoannotation(af, al, autoAlan);
- af.alignPanel.alignmentChanged();
+ /*
+ * Add the AlignFrame to the desktop (it may be 'gathered' later), unless it
+ * has a 'cdna/protein complement' view, in which case save it in order to
+ * populate a SplitFrame once all views have been read in.
+ */
+ String complementaryViewId = view.getComplementId();
+ if (complementaryViewId == null)
+ {
+ Desktop.addInternalFrame(af, view.getTitle(), view.getWidth(),
+ view.getHeight());
+ // recompute any autoannotation
+ af.alignPanel.updateAnnotation(false, true);
+ reorderAutoannotation(af, al, autoAlan);
+ af.alignPanel.alignmentChanged();
+ }
+ else
+ {
+ splitFrameCandidates.put(view, af);
+ }
return af;
}
}
private void reorderAutoannotation(AlignFrame af, Alignment al,
- ArrayList<JvAnnotRow> autoAlan)
+ List<JvAnnotRow> autoAlan)
{
// copy over visualization settings for autocalculated annotation in the
// view
+ auan.template.getCalcId()), auan);
}
int hSize = al.getAlignmentAnnotation().length;
- ArrayList<JvAnnotRow> reorder = new ArrayList<JvAnnotRow>();
+ List<JvAnnotRow> reorder = new ArrayList<JvAnnotRow>();
// work through any autoCalculated annotation already on the view
// removing it if it should be placed in a different location on the
// annotation panel.
- List<String> remains = new ArrayList(visan.keySet());
+ List<String> remains = new ArrayList<String>(visan.keySet());
for (int h = 0; h < hSize; h++)
{
jalview.datamodel.AlignmentAnnotation jalan = al
{
// JBP TODO: Check this is called for AlCodonFrames to support recovery of
// xRef Codon Maps
- jalview.datamodel.Sequence sq = (jalview.datamodel.Sequence) seqRefIds
- .get(vamsasSeq.getId());
- jalview.datamodel.SequenceI dsq = null;
+ SequenceI sq = seqRefIds.get(vamsasSeq.getId());
+ SequenceI dsq = null;
if (sq != null && sq.getDatasetSequence() != null)
{
dsq = sq.getDatasetSequence();
// if (pre || post)
if (sq != dsq)
{
- StringBuffer sb = new StringBuffer();
+ // StringBuffer sb = new StringBuffer();
String newres = jalview.analysis.AlignSeq.extractGaps(
jalview.util.Comparison.GapChars, sq.getSequenceAsString());
if (!newres.equalsIgnoreCase(dsq.getSequenceAsString())
* local sequence definition
*/
Sequence ms = mc.getSequence();
- jalview.datamodel.Sequence djs = null;
+ SequenceI djs = null;
String sqid = ms.getDsseqid();
if (sqid != null && sqid.length() > 0)
{
/*
* recover dataset sequence
*/
- djs = (jalview.datamodel.Sequence) seqRefIds.get(sqid);
+ djs = seqRefIds.get(sqid);
}
else
{
frefedSequence = new Vector();
}
- viewportsAdded = new Hashtable();
+ viewportsAdded.clear();
AlignFrame af = loadFromObject(jm, null, false, null);
af.alignPanels.clear();
}
else if (jvobj instanceof jalview.datamodel.AlignmentAnnotation)
{
- if (annotationIds == null)
- {
- annotationIds = new Hashtable();
- }
String anid;
- annotationIds.put(anid = jv2vobj.get(jvobj).toString(), jvobj);
- jalview.datamodel.AlignmentAnnotation jvann = (jalview.datamodel.AlignmentAnnotation) jvobj;
+ AlignmentAnnotation jvann = (AlignmentAnnotation) jvobj;
+ annotationIds.put(anid = jv2vobj.get(jvobj).toString(), jvann);
if (jvann.annotationId == null)
{
jvann.annotationId = anid;