*/
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.Marshaller;
-import org.exolab.castor.xml.Unmarshaller;
-
+import jalview.api.FeatureColourI;
+import jalview.api.ViewStyleI;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.datamodel.AlignedCodonFrame;
import jalview.schemes.AnnotationColourGradient;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
-import jalview.schemes.GraduatedColor;
+import jalview.schemes.FeatureColour;
import jalview.schemes.ResidueColourScheme;
import jalview.schemes.ResidueProperties;
import jalview.schemes.UserColourScheme;
import jalview.structures.models.AAStructureBindingModel;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.util.StringUtils;
import jalview.util.jarInputStreamProvider;
import jalview.viewmodel.AlignmentViewport;
import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
import jalview.ws.params.AutoCalcSetting;
import jalview.ws.params.WsParamSetI;
+import java.awt.Color;
+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.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.Marshaller;
+import org.exolab.castor.xml.Unmarshaller;
+
/**
* Write out the current jalview desktop state as a Jalview XML stream.
*
*/
Map<String, SequenceI> seqRefIds = null;
- Vector frefedSequence = null;
+ Vector<Object[]> frefedSequence = null;
boolean raiseGUI = true; // whether errors are raised in dialog boxes or not
int r = 0, rSize = frefedSequence.size();
while (r < rSize)
{
- Object[] ref = (Object[]) frefedSequence.elementAt(r);
+ Object[] ref = frefedSequence.elementAt(r);
if (ref != null)
{
String sref = (String) ref[0];
object.setVersion(jalview.bin.Cache.getDefault("VERSION",
"Development Build"));
- jalview.datamodel.AlignmentI jal = av.getAlignment();
+ /**
+ * rjal is full height alignment, jal is actual alignment with full metadata
+ * but excludes hidden sequences.
+ */
+ jalview.datamodel.AlignmentI rjal = av.getAlignment(), jal = rjal;
if (av.hasHiddenRows())
{
- jal = jal.getHiddenSequences().getFullAlignment();
+ rjal = jal.getHiddenSequences().getFullAlignment();
}
SequenceSet vamsasSet = new SequenceSet();
{
// switch jal and the dataset
jal = jal.getDataset();
+ rjal = jal;
}
}
if (jal.getProperties() != null)
Set<String> calcIdSet = new HashSet<String>();
// SAVE SEQUENCES
- for (int i = 0; i < jal.getHeight(); i++)
+ for (final SequenceI jds : rjal.getSequences())
{
- final SequenceI jds = jal.getSequenceAt(i);
final SequenceI jdatasq = jds.getDatasetSequence() == null ? jds
- : jds
- .getDatasetSequence();
+ : jds.getDatasetSequence();
String id = seqHash(jds);
if (seqRefIds.get(id) != null)
// Store any sequences this sequence represents
if (av.hasHiddenRows())
{
+ // use rjal, contains the full height alignment
jseq.setHidden(av.getAlignment().getHiddenSequences()
.isHidden(jds));
- if (av.isHiddenRepSequence(jal.getSequenceAt(i)))
+ if (av.isHiddenRepSequence(jds))
{
jalview.datamodel.SequenceI[] reps = av
- .getRepresentedSequences(jal.getSequenceAt(i))
- .getSequencesInOrder(jal);
+ .getRepresentedSequences(jds)
+ .getSequencesInOrder(rjal);
for (int h = 0; h < reps.length; h++)
{
- if (reps[h] != jal.getSequenceAt(i))
+ if (reps[h] != jds)
{
- jseq.addHiddenSequences(jal.findIndex(reps[h]));
+ jseq.addHiddenSequences(rjal.findIndex(reps[h]));
}
}
}
}
+ // mark sequence as reference - if it is the reference for this view
+ if (jal.hasSeqrep())
+ {
+ jseq.setViewreference(jds == jal.getSeqrep());
+ }
}
+ // TODO: omit sequence features from each alignment view's XML dump if we
+ // are storing dataset
if (jds.getSequenceFeatures() != null)
{
- jalview.datamodel.SequenceFeature[] sf = jds
- .getSequenceFeatures();
+ jalview.datamodel.SequenceFeature[] sf = jds.getSequenceFeatures();
int index = 0;
while (index < sf.length)
{
if (sf[index].otherDetails != null)
{
String key;
- Enumeration keys = sf[index].otherDetails.keys();
- while (keys.hasMoreElements())
+ Iterator<String> keys = sf[index].otherDetails.keySet()
+ .iterator();
+ while (keys.hasNext())
{
- key = keys.nextElement().toString();
+ key = keys.next();
OtherData keyValue = new OtherData();
keyValue.setKey(key);
keyValue.setValue(sf[index].otherDetails.get(key).toString());
}
}
- if (jdatasq.getPDBId() != null)
+ if (jdatasq.getAllPDBEntries() != null)
{
- Enumeration en = jdatasq.getPDBId().elements();
+ Enumeration en = jdatasq.getAllPDBEntries().elements();
while (en.hasMoreElements())
{
Pdbids pdb = new Pdbids();
}
}
- saveRnaViewers(jout, jseq, jds, viewIds, storeDS);
+ saveRnaViewers(jout, jseq, jds, viewIds, ap, storeDS);
jms.addJSeq(jseq);
}
// SAVE MAPPINGS
if (jal.getCodonFrames() != null)
{
- Set<AlignedCodonFrame> jac = jal.getCodonFrames();
+ List<AlignedCodonFrame> jac = jal.getCodonFrames();
for (AlignedCodonFrame acf : jac)
{
AlcodonFrame alc = new AlcodonFrame();
- vamsasSet.addAlcodonFrame(alc);
if (acf.getProtMappings() != null
&& acf.getProtMappings().length > 0)
{
+ boolean hasMap = false;
SequenceI[] dnas = acf.getdnaSeqs();
jalview.datamodel.Mapping[] pmaps = acf.getProtMappings();
for (int m = 0; m < pmaps.length; m++)
alcmap.setMapping(createVamsasMapping(pmaps[m], dnas[m], null,
false));
alc.addAlcodMap(alcmap);
+ hasMap = true;
+ }
+ if (hasMap)
+ {
+ vamsasSet.addAlcodonFrame(alc);
}
}
-
-// {
-// 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);
-// }
-// }
+ // TODO: delete this ? dead code from 2.8.3->2.9 ?
+ // {
+ // 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);
+ // }
+ // }
}
}
if (sg.cs instanceof jalview.schemes.UserColourScheme)
{
- jGroup.setColour(setUserColourScheme(sg.cs, userColours,
- jms));
+ jGroup.setColour(setUserColourScheme(sg.cs, userColours, jms));
}
else
{
- jGroup
- .setColour(ColourSchemeProperty.getColourName(sg.cs));
+ jGroup.setColour(ColourSchemeProperty.getColourName(sg.cs));
}
}
else if (sg.cs instanceof jalview.schemes.AnnotationColourGradient)
}
else if (sg.cs instanceof jalview.schemes.UserColourScheme)
{
- jGroup
- .setColour(setUserColourScheme(sg.cs, userColours, jms));
+ jGroup.setColour(setUserColourScheme(sg.cs, userColours, jms));
}
else
{
view.setViewName(av.viewName);
view.setGatheredViews(av.isGatherViewsHere());
- Rectangle position = ap.av.getExplodedGeometry();
- if (position == null)
+ Rectangle size = ap.av.getExplodedGeometry();
+ Rectangle position = size;
+ if (size == null)
{
- position = ap.alignFrame.getBounds();
+ size = ap.alignFrame.getBounds();
+ if (av.getCodingComplement() != null)
+ {
+ position = ((SplitFrame) ap.alignFrame.getSplitViewContainer())
+ .getBounds();
+ }
+ else
+ {
+ position = size;
+ }
}
view.setXpos(position.x);
view.setYpos(position.y);
- view.setWidth(position.width);
- view.setHeight(position.height);
+
+ view.setWidth(size.width);
+ view.setHeight(size.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.setScaleProteinAsCdna(av.getViewStyle().isScaleProteinAsCdna());
view.setRenderGaps(av.isRenderGaps());
view.setShowAnnotation(av.isShowAnnotation());
view.setShowBoxes(av.getShowBoxes());
.getFeatureRenderer().getRenderOrder()
.toArray(new String[0]);
- Vector settingsAdded = new Vector();
- Object gstyle = null;
- GraduatedColor gcol = null;
+ Vector<String> settingsAdded = new Vector<String>();
if (renderOrder != null)
{
- for (int ro = 0; ro < renderOrder.length; ro++)
+ for (String featureType : renderOrder)
{
- gstyle = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getFeatureStyle(renderOrder[ro]);
+ FeatureColourI fcol = ap.getSeqPanel().seqCanvas
+ .getFeatureRenderer()
+ .getFeatureStyle(featureType);
Setting setting = new Setting();
- setting.setType(renderOrder[ro]);
- if (gstyle instanceof GraduatedColor)
+ setting.setType(featureType);
+ if (!fcol.isSimpleColour())
{
- gcol = (GraduatedColor) gstyle;
- setting.setColour(gcol.getMaxColor().getRGB());
- setting.setMincolour(gcol.getMinColor().getRGB());
- setting.setMin(gcol.getMin());
- setting.setMax(gcol.getMax());
- setting.setColourByLabel(gcol.isColourByLabel());
- setting.setAutoScale(gcol.isAutoScale());
- setting.setThreshold(gcol.getThresh());
- setting.setThreshstate(gcol.getThreshType());
+ setting.setColour(fcol.getMaxColour().getRGB());
+ setting.setMincolour(fcol.getMinColour().getRGB());
+ setting.setMin(fcol.getMin());
+ setting.setMax(fcol.getMax());
+ setting.setColourByLabel(fcol.isColourByLabel());
+ setting.setAutoScale(fcol.isAutoScaled());
+ setting.setThreshold(fcol.getThreshold());
+ // -1 = No threshold, 0 = Below, 1 = Above
+ setting.setThreshstate(fcol.isAboveThreshold() ? 1
+ : (fcol.isBelowThreshold() ? 0 : -1));
}
else
{
- setting.setColour(ap.getSeqPanel().seqCanvas
- .getFeatureRenderer()
- .getColour(renderOrder[ro]).getRGB());
+ setting.setColour(fcol.getColour().getRGB());
}
setting.setDisplay(av.getFeaturesDisplayed().isVisible(
- renderOrder[ro]));
+ featureType));
float rorder = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getOrder(renderOrder[ro]);
+ .getOrder(featureType);
if (rorder > -1)
{
setting.setOrder(rorder);
}
fs.addSetting(setting);
- settingsAdded.addElement(renderOrder[ro]);
+ settingsAdded.addElement(featureType);
}
}
- // Make sure we save none displayed feature settings
- Iterator en = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getFeatureColours().keySet().iterator();
- while (en.hasNext())
- {
- String key = en.next().toString();
- if (settingsAdded.contains(key))
- {
- continue;
- }
-
- Setting setting = new Setting();
- setting.setType(key);
- setting.setColour(ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getColour(key).getRGB());
-
- setting.setDisplay(false);
- float rorder = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
- .getOrder(key);
- if (rorder > -1)
- {
- setting.setOrder(rorder);
- }
- fs.addSetting(setting);
- settingsAdded.addElement(key);
- }
// is groups actually supposed to be a map here ?
- en = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
+ Iterator<String> en = ap.getSeqPanel().seqCanvas
+ .getFeatureRenderer()
.getFeatureGroups().iterator();
- Vector groupsAdded = new Vector();
+ Vector<String> groupsAdded = new Vector<String>();
while (en.hasNext())
{
- String grp = en.next().toString();
+ String grp = en.next();
if (groupsAdded.contains(grp))
{
continue;
groupsAdded.addElement(grp);
}
jms.setFeatureSettings(fs);
-
}
if (av.hasHiddenColumns())
* @param jseq
* @param jds
* @param viewIds
+ * @param ap
* @param storeDataset
*/
protected void saveRnaViewers(JarOutputStream jout, JSeq jseq,
- final SequenceI jds, List<String> viewIds, boolean storeDataset)
+ final SequenceI jds, List<String> viewIds, AlignmentPanel ap,
+ boolean storeDataset)
{
+ if (Desktop.desktop == null)
+ {
+ return;
+ }
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
for (int f = frames.length - 1; f > -1; f--)
{
if (frames[f] instanceof AppVarna)
{
AppVarna varna = (AppVarna) frames[f];
- if (varna.isListeningFor(jds))
+ /*
+ * link the sequence to every viewer that is showing it and is linked to
+ * its alignment panel
+ */
+ if (varna.isListeningFor(jds) && ap == varna.getAlignmentPanel())
{
- /*
- * link the sequence to every viewer that is showing it
- */
String viewId = varna.getViewId();
RnaViewer rna = new RnaViewer();
rna.setViewId(viewId);
{
String varnaStateFile = varna.getStateInfo(model.rna);
- jarEntryName = RNA_PREFIX + viewId + "_"
- + nextCounter();
+ jarEntryName = RNA_PREFIX + viewId + "_" + nextCounter();
copyFileToJar(jout, varnaStateFile, jarEntryName);
rnaSessions.put(model, jarEntryName);
}
private void storeAlignmentAnnotation(AlignmentAnnotation[] aa,
IdentityHashMap<SequenceGroup, String> groupRefs,
- AlignmentViewport av,
- Set<String> calcIdSet, boolean storeDS, SequenceSet vamsasSet)
+ AlignmentViewport av, Set<String> calcIdSet, boolean storeDS,
+ SequenceSet vamsasSet)
{
for (int i = 0; i < aa.length; i++)
if (groupIdr == null)
{
// make a locally unique String
- groupRefs.put(annotation.groupRef,
+ groupRefs.put(
+ annotation.groupRef,
groupIdr = ("" + System.currentTimeMillis()
- + annotation.groupRef.getName() + groupRefs.size()));
+ + annotation.groupRef.getName() + groupRefs
+ .size()));
}
an.setGroupRef(groupIdr.toString());
}
}
}
throw new Error(MessageManager.formatMessage(
- "error.unsupported_version_calcIdparam", new Object[]
- { calcIdParam.toString() }));
+ "error.unsupported_version_calcIdparam",
+ new Object[] { calcIdParam.toString() }));
}
/**
if (jds.getDatasetSequence() != null)
{
vamsasSeq.setDsseqid(seqHash(jds.getDatasetSequence()));
- if (jds.getDatasetSequence().getDBRef() != null)
+ if (jds.getDatasetSequence().getDBRefs() != null)
{
- dbrefs = jds.getDatasetSequence().getDBRef();
+ dbrefs = jds.getDatasetSequence().getDBRefs();
}
}
else
{
vamsasSeq.setDsseqid(id); // so we can tell which sequences really are
// dataset sequences only
- dbrefs = jds.getDBRef();
+ dbrefs = jds.getDBRefs();
}
if (dbrefs != null)
{
{
SwingUtilities.invokeAndWait(new Runnable()
{
+ @Override
public void run()
{
setLoadingFinishedForNewStructureViewers();
});
} catch (Exception x)
{
-
+ System.err.println("Error loading alignment: " + x.getMessage());
}
}
return af;
}
if (frefedSequence == null)
{
- frefedSequence = new Vector();
+ frefedSequence = new Vector<Object[]>();
}
AlignFrame af = null, _af = null;
.entrySet())
{
AlignFrame af = candidate.getValue();
- if (!addedToSplitFrames.contains(af)) {
+ if (!addedToSplitFrames.contains(af))
+ {
Viewport view = candidate.getKey();
Desktop.addInternalFrame(af, view.getTitle(), view.getWidth(),
view.getHeight());
int width = (int) dnaFrame.getBounds().getWidth();
int height = (int) (dnaFrame.getBounds().getHeight()
+ proteinFrame.getBounds().getHeight() + 50);
+
+ /*
+ * SplitFrame location is saved to both enclosed frames
+ */
+ splitFrame.setLocation(dnaFrame.getX(), dnaFrame.getY());
Desktop.addInternalFrame(splitFrame, title, width, height);
/*
// LOAD SEQUENCES
List<SequenceI> hiddenSeqs = null;
- jalview.datamodel.Sequence jseq;
+
List<SequenceI> tmpseqs = new ArrayList<SequenceI>();
boolean multipleView = false;
-
+ SequenceI referenceseqForView = null;
JSeq[] jseqs = object.getJalviewModelSequence().getJSeq();
int vi = 0; // counter in vamsasSeq array
for (int i = 0; i < jseqs.length; i++)
{
String seqId = jseqs[i].getId();
- if (seqRefIds.get(seqId) != null)
+ SequenceI tmpSeq = seqRefIds.get(seqId);
+ if (tmpSeq != null)
{
- tmpseqs.add(seqRefIds.get(seqId));
+ tmpSeq.setStart(jseqs[i].getStart());
+ tmpSeq.setEnd(jseqs[i].getEnd());
+ tmpseqs.add(tmpSeq);
multipleView = true;
}
else
{
- jseq = new jalview.datamodel.Sequence(vamsasSeq[vi].getName(),
+ tmpSeq = new jalview.datamodel.Sequence(vamsasSeq[vi].getName(),
vamsasSeq[vi].getSequence());
- jseq.setDescription(vamsasSeq[vi].getDescription());
- jseq.setStart(jseqs[i].getStart());
- jseq.setEnd(jseqs[i].getEnd());
- jseq.setVamsasId(uniqueSetSuffix + seqId);
- seqRefIds.put(vamsasSeq[vi].getId(), jseq);
- tmpseqs.add(jseq);
+ tmpSeq.setDescription(vamsasSeq[vi].getDescription());
+ tmpSeq.setStart(jseqs[i].getStart());
+ tmpSeq.setEnd(jseqs[i].getEnd());
+ tmpSeq.setVamsasId(uniqueSetSuffix + seqId);
+ seqRefIds.put(vamsasSeq[vi].getId(), tmpSeq);
+ tmpseqs.add(tmpSeq);
vi++;
}
+ if (jseqs[i].hasViewreference() && jseqs[i].getViewreference())
+ {
+ referenceseqForView = tmpseqs.get(tmpseqs.size() - 1);
+ }
+
if (jseqs[i].getHidden())
{
if (hiddenSeqs == null)
hiddenSeqs = new ArrayList<SequenceI>();
}
- hiddenSeqs.add(seqRefIds.get(seqId));
+ hiddenSeqs.add(tmpSeq);
}
-
}
// /
SequenceI[] orderedSeqs = tmpseqs
.toArray(new SequenceI[tmpseqs.size()]);
- Alignment al = new Alignment(orderedSeqs);
+ AlignmentI al = new Alignment(orderedSeqs);
+ if (referenceseqForView != null)
+ {
+ al.setSeqrep(referenceseqForView);
+ }
// / Add the alignment properties
for (int i = 0; i < vamsasSet.getSequenceSetPropertiesCount(); i++)
{
{
mapping = addMapping(maps[m].getMapping());
}
- if (dnaseq != null)
+ if (dnaseq != null && mapping.getTo() != null)
{
cf.addMap(dnaseq, mapping.getTo(), mapping.getMap());
}
else
{
// defer to later
- frefedSequence.add(new Object[]
- { maps[m].getDnasq(), cf, mapping });
+ frefedSequence.add(new Object[] { maps[m].getDnasq(), cf,
+ mapping });
}
}
+ al.addCodonFrame(cf);
}
- al.addCodonFrame(cf);
}
}
// set visiblity for other annotation in this view
String annotationId = annotation.getId();
- if (annotationId != null
- && annotationIds.containsKey(annotationId))
+ if (annotationId != null && annotationIds.containsKey(annotationId))
{
AlignmentAnnotation jda = annotationIds.get(annotationId);
// in principle Visible should always be true for annotation displayed
SequenceGroup sg = new SequenceGroup(seqs, jGroup.getName(), cs,
jGroup.getDisplayBoxes(), jGroup.getDisplayText(),
- jGroup.getColourText(), jGroup.getStart(),
- jGroup.getEnd());
+ jGroup.getColourText(), jGroup.getStart(), jGroup.getEnd());
sg.setOutlineColour(new java.awt.Color(jGroup.getOutlineColour()));
if (jGroup.getId() != null && groupAnnotRefs.size() > 0)
{
// re-instate unique group/annotation row reference
- List<AlignmentAnnotation> jaal = groupAnnotRefs
- .get(jGroup.getId());
+ List<AlignmentAnnotation> jaal = groupAnnotRefs.get(jGroup
+ .getId());
if (jaal != null)
{
for (AlignmentAnnotation jaa : jaal)
if (addAnnotSchemeGroup)
{
// reconstruct the annotation colourscheme
- sg.cs = constructAnnotationColour(
- jGroup.getAnnotationColours(), null, al, jms, false);
+ sg.cs = constructAnnotationColour(jGroup.getAnnotationColours(),
+ null, al, jms, false);
}
}
}
* indicate that annotation colours are applied across all groups (pre
* Jalview 2.8.1 behaviour)
*/
- boolean doGroupAnnColour = isVersionStringLaterThan("2.8.1",
- object.getVersion());
+ boolean doGroupAnnColour = Jalview2XML.isVersionStringLaterThan(
+ "2.8.1", object.getVersion());
AlignmentPanel ap = null;
boolean isnewview = true;
for (int i = 0; i < jseq.getRnaViewerCount(); i++)
{
RnaViewer viewer = jseq.getRnaViewer(i);
- AppVarna appVarna = findOrCreateVarnaViewer(viewer, uniqueSetSuffix,
- ap);
+ AppVarna appVarna = findOrCreateVarnaViewer(viewer,
+ uniqueSetSuffix, ap);
for (int j = 0; j < viewer.getSecondaryStructureCount(); j++)
{
String sessionState = ss.getViewerState();
String tempStateFile = copyJarEntry(jprovider, sessionState,
"varna");
- RnaModel rna = new RnaModel(rnaTitle, ann, seq, null, gapped,
- tempStateFile);
- appVarna.addModel(rna, rnaTitle);
+ RnaModel rna = new RnaModel(rnaTitle, ann, seq, null, gapped);
+ appVarna.addModelSession(rna, rnaTitle, tempStateFile);
}
- appVarna.setSelectedIndex(viewer.getSelectedRna());
+ appVarna.setInitialSelection(viewer.getSelectedRna());
}
}
}
* viewer not found - make it
*/
RnaViewerModel model = new RnaViewerModel(postLoadId,
- viewer.getTitle(), viewer.getXpos(),
- viewer.getYpos(), viewer.getWidth(), viewer.getHeight(),
+ viewer.getTitle(), viewer.getXpos(), viewer.getYpos(),
+ viewer.getWidth(), viewer.getHeight(),
viewer.getDividerLocation());
AppVarna varna = new AppVarna(model, ap);
* @param af
* @param jprovider
*/
- protected void createChimeraViewer(Entry<String, StructureViewerModel> viewerData,
- AlignFrame af,
+ protected void createChimeraViewer(
+ Entry<String, StructureViewerModel> viewerData, AlignFrame af,
jarInputStreamProvider jprovider)
{
StructureViewerModel data = viewerData.getValue();
- String chimeraSessionFile = data.getStateData();
+ String chimeraSessionFile = data.getStateData();
/*
* Copy Chimera session from jar entry "viewer_"+viewId to a temporary file
String newViewId = viewerData.getKey();
ChimeraViewFrame cvf = new ChimeraViewFrame(chimeraSessionFile,
- af.alignPanel, pdbArray,
- seqsArray, colourByChimera, colourBySequence, newViewId);
+ af.alignPanel, pdbArray, seqsArray, colourByChimera,
+ colourBySequence, newViewId);
cvf.setSize(data.getWidth(), data.getHeight());
cvf.setLocation(data.getX(), data.getY());
}
newFileLoc.append(";");
}
- if (newFileLoc.length() > 0)
+ if (newFileLoc.length() == 0)
+ {
+ return;
+ }
+ int histbug = newFileLoc.indexOf("history = ");
+ if (histbug > -1)
{
- int histbug = newFileLoc.indexOf("history = ");
+ /*
+ * change "history = [true|false];" to "history = [1|0];"
+ */
histbug += 10;
int diff = histbug == -1 ? -1 : newFileLoc.indexOf(";", histbug);
String val = (diff == -1) ? null : newFileLoc
.substring(histbug, diff);
if (val != null && val.length() >= 4)
{
- if (val.contains("e"))
+ if (val.contains("e")) // eh? what can it be?
{
if (val.trim().equals("true"))
{
newFileLoc.replace(histbug, diff, val);
}
}
+ }
- final String[] pdbf = pdbfilenames.toArray(new String[pdbfilenames
- .size()]);
- final String[] id = pdbids.toArray(new String[pdbids.size()]);
- final SequenceI[][] sq = seqmaps
- .toArray(new SequenceI[seqmaps.size()][]);
- final String fileloc = newFileLoc.toString();
- final String sviewid = viewerData.getKey();
- final AlignFrame alf = af;
- final Rectangle rect = new Rectangle(svattrib.getX(),
- svattrib.getY(), svattrib.getWidth(), svattrib.getHeight());
- try
+ final String[] pdbf = pdbfilenames.toArray(new String[pdbfilenames
+ .size()]);
+ final String[] id = pdbids.toArray(new String[pdbids.size()]);
+ final SequenceI[][] sq = seqmaps
+ .toArray(new SequenceI[seqmaps.size()][]);
+ final String fileloc = newFileLoc.toString();
+ final String sviewid = viewerData.getKey();
+ final AlignFrame alf = af;
+ final Rectangle rect = new Rectangle(svattrib.getX(), svattrib.getY(),
+ svattrib.getWidth(), svattrib.getHeight());
+ try
+ {
+ javax.swing.SwingUtilities.invokeAndWait(new Runnable()
{
- javax.swing.SwingUtilities.invokeAndWait(new Runnable()
+ @Override
+ public void run()
{
- @Override
- public void run()
+ JalviewStructureDisplayI sview = null;
+ try
{
- JalviewStructureDisplayI sview = null;
- try
- {
- sview = new StructureViewer(alf.alignPanel
- .getStructureSelectionManager()).createView(
- StructureViewer.ViewerType.JMOL, pdbf, id, sq,
- alf.alignPanel, svattrib, fileloc, rect, sviewid);
- addNewStructureViewer(sview);
- } catch (OutOfMemoryError ex)
+ sview = new StructureViewer(alf.alignPanel
+ .getStructureSelectionManager()).createView(
+ StructureViewer.ViewerType.JMOL, pdbf, id, sq,
+ alf.alignPanel, svattrib, fileloc, rect, sviewid);
+ addNewStructureViewer(sview);
+ } catch (OutOfMemoryError ex)
+ {
+ new OOMWarning("restoring structure view for PDB id " + id,
+ (OutOfMemoryError) ex.getCause());
+ if (sview != null && sview.isVisible())
{
- new OOMWarning("restoring structure view for PDB id " + id,
- (OutOfMemoryError) ex.getCause());
- if (sview != null && sview.isVisible())
- {
- sview.closeViewer(false);
- sview.setVisible(false);
- sview.dispose();
- }
+ sview.closeViewer(false);
+ sview.setVisible(false);
+ sview.dispose();
}
}
- });
- } catch (InvocationTargetException ex)
- {
- warn("Unexpected error when opening Jmol view.", ex);
+ }
+ });
+ } catch (InvocationTargetException ex)
+ {
+ warn("Unexpected error when opening Jmol view.", ex);
- } catch (InterruptedException e)
- {
- // e.printStackTrace();
- }
+ } catch (InterruptedException e)
+ {
+ // e.printStackTrace();
}
+
}
/**
}
/**
+ * Answers true if 'version' is equal to or later than 'supported', where each
+ * is formatted as major/minor versions like "2.8.3" or "2.3.4b1" for bugfix
+ * changes. Development and test values for 'version' are leniently treated
+ * i.e. answer true.
*
* @param supported
* - minimum version we are comparing against
* @param version
- * - version of data being processsed.
- * @return true if version is development/null or evaluates to the same or
- * later X.Y.Z (where X,Y,Z are like [0-9]+b?[0-9]*)
+ * - version of data being processsed
+ * @return
*/
- protected boolean isVersionStringLaterThan(String supported,
+ public static boolean isVersionStringLaterThan(String supported,
String version)
{
- if (version == null || version.equalsIgnoreCase("DEVELOPMENT BUILD")
+ if (supported == null || version == null
+ || version.equalsIgnoreCase("DEVELOPMENT BUILD")
|| version.equalsIgnoreCase("Test")
|| version.equalsIgnoreCase("AUTOMATED BUILD"))
{
}
else
{
- StringTokenizer currentV = new StringTokenizer(supported, "."), fileV = new StringTokenizer(
- version, ".");
- while (currentV.hasMoreTokens() && fileV.hasMoreTokens())
- {
- // convert b to decimal to catch bugfix releases within a series
- String curT = currentV.nextToken().toLowerCase().replace('b', '.');
- String fileT = fileV.nextToken().toLowerCase().replace('b', '.');
- try
- {
- if (Float.valueOf(curT) > Float.valueOf(fileT))
- {
- // current version is newer than the version that wrote the file
- return false;
- }
- } catch (NumberFormatException nfe)
- {
- System.err
- .println("** WARNING: Version comparison failed for tokens ("
- + curT
- + ") and ("
- + fileT
- + ")\n** Current: '"
- + supported + "' and Version: '" + version + "'");
- }
- }
- if (currentV.hasMoreElements())
- {
- // fileV has no minor version but identical series to current
- return false;
- }
+ return StringUtils.compareVersions(version, supported, "b") >= 0;
}
- return true;
}
Vector<JalviewStructureDisplayI> newStructureViewers = null;
}
AlignFrame loadViewport(String file, JSeq[] JSEQ,
- List<SequenceI> hiddenSeqs, Alignment al,
+ List<SequenceI> hiddenSeqs, AlignmentI al,
JalviewModelSequence jms, Viewport view, String uniqueSeqSetId,
String viewId, List<JvAnnotRow> autoAlan)
{
.getSequenceAt(i), new java.awt.Color(JSEQ[i].getColour()));
}
+ if (al.hasSeqrep())
+ {
+ af.getViewport().setColourByReferenceSeq(true);
+ af.getViewport().setDisplayReferenceSeq(true);
+ }
+
af.viewport.setGatherViewsHere(view.getGatheredViews());
if (view.getSequenceSetId() != null)
{
for (int s = 0; s < JSEQ.length; s++)
{
- jalview.datamodel.SequenceGroup hidden = new jalview.datamodel.SequenceGroup();
-
+ SequenceGroup hidden = new SequenceGroup();
+ boolean isRepresentative = false;
for (int r = 0; r < JSEQ[s].getHiddenSequencesCount(); r++)
{
- hidden.addSequence(
- al.getSequenceAt(JSEQ[s].getHiddenSequences(r)), false);
+ isRepresentative = true;
+ SequenceI sequenceToHide = al.getSequenceAt(JSEQ[s]
+ .getHiddenSequences(r));
+ hidden.addSequence(sequenceToHide, false);
+ // remove from hiddenSeqs list so we don't try to hide it twice
+ hiddenSeqs.remove(sequenceToHide);
+ }
+ if (isRepresentative)
+ {
+ SequenceI representativeSequence = al.getSequenceAt(s);
+ hidden.addSequence(representativeSequence, false);
+ af.viewport.hideRepSequences(representativeSequence, hidden);
}
- 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);
- // }
-
SequenceI[] hseqs = hiddenSeqs.toArray(new SequenceI[hiddenSeqs
.size()]);
af.viewport.hideSequence(hseqs);
af.viewport.setFont(
new java.awt.Font(view.getFontName(), view.getFontStyle(), view
.getFontSize()), true);
+ ViewStyleI vs = af.viewport.getViewStyle();
+ vs.setScaleProteinAsCdna(view.isScaleProteinAsCdna());
+ af.viewport.setViewStyle(vs);
// 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.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
String[] renderOrder = new String[jms.getFeatureSettings()
.getSettingCount()];
- Hashtable featureGroups = new Hashtable();
- Hashtable featureColours = new Hashtable();
- Hashtable featureOrder = new Hashtable();
+ Map<String, FeatureColourI> featureColours = new Hashtable<String, FeatureColourI>();
+ Map<String, Float> featureOrder = new Hashtable<String, Float>();
for (int fs = 0; fs < jms.getFeatureSettings().getSettingCount(); fs++)
{
Setting setting = jms.getFeatureSettings().getSetting(fs);
if (setting.hasMincolour())
{
- GraduatedColor gc = setting.hasMin() ? new GraduatedColor(
- new java.awt.Color(setting.getMincolour()),
- new java.awt.Color(setting.getColour()),
- setting.getMin(), setting.getMax()) : new GraduatedColor(
- new java.awt.Color(setting.getMincolour()),
- new java.awt.Color(setting.getColour()), 0, 1);
+ FeatureColourI gc = setting.hasMin() ? new FeatureColour(
+ new Color(setting.getMincolour()), new Color(
+ setting.getColour()), setting.getMin(),
+ setting.getMax()) : new FeatureColour(new Color(
+ setting.getMincolour()), new Color(setting.getColour()),
+ 0, 1);
if (setting.hasThreshold())
{
- gc.setThresh(setting.getThreshold());
- gc.setThreshType(setting.getThreshstate());
+ gc.setThreshold(setting.getThreshold());
+ int threshstate = setting.getThreshstate();
+ // -1 = None, 0 = Below, 1 = Above threshold
+ if (threshstate == 0)
+ {
+ gc.setBelowThreshold(true);
+ }
+ else if (threshstate == 1)
+ {
+ gc.setAboveThreshold(true);
+ }
}
gc.setAutoScaled(true); // default
if (setting.hasAutoScale())
}
else
{
- featureColours.put(setting.getType(),
- new java.awt.Color(setting.getColour()));
+ featureColours.put(setting.getType(), new FeatureColour(
+ new Color(setting.getColour())));
}
renderOrder[fs] = setting.getType();
if (setting.hasOrder())
fdi.setVisible(setting.getType());
}
}
- Hashtable fgtable = new Hashtable();
+ Map<String, Boolean> fgtable = new Hashtable<String, Boolean>();
for (int gs = 0; gs < jms.getFeatureSettings().getGroupCount(); gs++)
{
Group grp = jms.getFeatureSettings().getGroup(gs);
}
}
af.setMenusFromViewport(af.viewport);
-
+
// TODO: we don't need to do this if the viewport is aready visible.
/*
* Add the AlignFrame to the desktop (it may be 'gathered' later), unless it
}
private ColourSchemeI constructAnnotationColour(
- AnnotationColours viewAnnColour, AlignFrame af, Alignment al,
+ AnnotationColours viewAnnColour, AlignFrame af, AlignmentI al,
JalviewModelSequence jms, boolean checkGroupAnnColour)
{
boolean propagateAnnColour = false;
return cs;
}
- private void reorderAutoannotation(AlignFrame af, Alignment al,
+ private void reorderAutoannotation(AlignFrame af, AlignmentI al,
List<JvAnnotRow> autoAlan)
{
// copy over visualization settings for autocalculated annotation in the
/**
* Kludge for magic autoannotation names (see JAL-811)
*/
- String[] magicNames = new String[]
- { "Consensus", "Quality", "Conservation" };
+ String[] magicNames = new String[] { "Consensus", "Quality",
+ "Conservation" };
JvAnnotRow nullAnnot = new JvAnnotRow(-1, null);
Hashtable<String, JvAnnotRow> visan = new Hashtable<String, JvAnnotRow>();
for (String nm : magicNames)
}
}
- private void recoverDatasetFor(SequenceSet vamsasSet, Alignment al,
+ private void recoverDatasetFor(SequenceSet vamsasSet, AlignmentI al,
boolean ignoreUnrefed)
{
- jalview.datamodel.Alignment ds = getDatasetFor(vamsasSet.getDatasetId());
+ jalview.datamodel.AlignmentI ds = getDatasetFor(vamsasSet
+ .getDatasetId());
Vector dseqs = null;
if (ds == null)
{
* TODO use AlignmentI here and in related methods - needs
* AlignmentI.getDataset() changed to return AlignmentI instead of Alignment
*/
- Hashtable<String, Alignment> datasetIds = null;
+ Hashtable<String, AlignmentI> datasetIds = null;
- IdentityHashMap<Alignment, String> dataset2Ids = null;
+ IdentityHashMap<AlignmentI, String> dataset2Ids = null;
- private Alignment getDatasetFor(String datasetId)
+ private AlignmentI getDatasetFor(String datasetId)
{
if (datasetIds == null)
{
- datasetIds = new Hashtable<String, Alignment>();
+ datasetIds = new Hashtable<String, AlignmentI>();
return null;
}
if (datasetIds.containsKey(datasetId))
return null;
}
- private void addDatasetRef(String datasetId, Alignment dataset)
+ private void addDatasetRef(String datasetId, AlignmentI dataset)
{
if (datasetIds == null)
{
- datasetIds = new Hashtable<String, Alignment>();
+ datasetIds = new Hashtable<String, AlignmentI>();
}
datasetIds.put(datasetId, dataset);
}
* @param dataset
* @return
*/
- private String getDatasetIdRef(Alignment dataset)
+ private String getDatasetIdRef(AlignmentI dataset)
{
if (dataset.getDataset() != null)
{
// make a new datasetId and record it
if (dataset2Ids == null)
{
- dataset2Ids = new IdentityHashMap<Alignment, String>();
+ dataset2Ids = new IdentityHashMap<AlignmentI, String>();
}
else
{
}
else
{
- frefedSequence.add(new Object[]
- { dsfor, jmap });
+ frefedSequence.add(new Object[] { dsfor, jmap });
}
}
else
}
}
}
-
+
return result;
}