import jalview.datamodel.SequenceI;
import jalview.datamodel.StructureViewerModel;
import jalview.datamodel.StructureViewerModel.StructureData;
+import jalview.datamodel.features.FeatureMatcher;
+import jalview.datamodel.features.FeatureMatcherI;
+import jalview.datamodel.features.FeatureMatcherSet;
+import jalview.datamodel.features.FeatureMatcherSetI;
import jalview.ext.varna.RnaModel;
import jalview.gui.StructureViewer.ViewerType;
import jalview.io.DataSourceType;
import jalview.schemabinding.version2.AnnotationColours;
import jalview.schemabinding.version2.AnnotationElement;
import jalview.schemabinding.version2.CalcIdParam;
+import jalview.schemabinding.version2.Colour;
+import jalview.schemabinding.version2.CompoundMatcher;
import jalview.schemabinding.version2.DBRef;
import jalview.schemabinding.version2.Features;
import jalview.schemabinding.version2.Group;
import jalview.schemabinding.version2.MapListTo;
import jalview.schemabinding.version2.Mapping;
import jalview.schemabinding.version2.MappingChoice;
+import jalview.schemabinding.version2.MatchCondition;
+import jalview.schemabinding.version2.MatcherSet;
import jalview.schemabinding.version2.OtherData;
import jalview.schemabinding.version2.PdbentryItem;
import jalview.schemabinding.version2.Pdbids;
import jalview.schemabinding.version2.Tree;
import jalview.schemabinding.version2.UserColours;
import jalview.schemabinding.version2.Viewport;
+import jalview.schemabinding.version2.types.ColourThreshTypeType;
+import jalview.schemabinding.version2.types.FeatureMatcherByType;
+import jalview.schemabinding.version2.types.NoValueColour;
import jalview.schemes.AnnotationColourGradient;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ColourSchemeProperty;
import jalview.schemes.UserColourScheme;
import jalview.structure.StructureSelectionManager;
import jalview.structures.models.AAStructureBindingModel;
+import jalview.util.Format;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.util.StringUtils;
import jalview.util.jarInputStreamProvider;
+import jalview.util.matcher.Condition;
import jalview.viewmodel.AlignmentViewport;
import jalview.viewmodel.ViewportRanges;
import jalview.viewmodel.seqfeatures.FeatureRendererSettings;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
}
}
- void clearSeqRefs()
- {
- if (_cleartables)
- {
- if (seqRefIds != null)
- {
- seqRefIds.clear();
- }
- if (seqsToIds != null)
- {
- seqsToIds.clear();
- }
- if (incompleteSeqs != null)
- {
- incompleteSeqs.clear();
- }
- // seqRefIds = null;
- // seqsToIds = null;
- }
- else
- {
- // do nothing
- warn("clearSeqRefs called when _cleartables was not set. Doing nothing.");
- // seqRefIds = new Hashtable();
- // seqsToIds = new IdentityHashMap();
- }
- }
-
void initSeqRefs()
{
if (seqsToIds == null)
}
public SeqFref newAlcodMapRef(final String sref,
- final AlignedCodonFrame _cf, final jalview.datamodel.Mapping _jmap)
+ final AlignedCodonFrame _cf,
+ final jalview.datamodel.Mapping _jmap)
{
SeqFref fref = new SeqFref(sref, "Codon Frame")
}
} catch (Exception x)
{
- System.err
- .println("IMPLEMENTATION ERROR: Failed to resolve forward reference for sequence "
+ System.err.println(
+ "IMPLEMENTATION ERROR: Failed to resolve forward reference for sequence "
+ ref.getSref());
x.printStackTrace();
failedtoresolve++;
}
if (incompleteSeqs != null && incompleteSeqs.size() > 0)
{
- System.err.println("Jalview Project Import: There are "
- + incompleteSeqs.size()
- + " sequences which may have incomplete metadata.");
+ System.err.println(
+ "Jalview Project Import: There are " + incompleteSeqs.size()
+ + " sequences which may have incomplete metadata.");
if (incompleteSeqs.size() < 10)
{
for (SequenceI s : incompleteSeqs.values())
}
else
{
- System.err
- .println("Too many to report. Skipping output of incomplete sequences.");
+ System.err.println(
+ "Too many to report. Skipping output of incomplete sequences.");
}
}
}
{
AlignFrame af = frames.get(i);
// skip ?
- if (skipList != null
- && skipList
- .containsKey(af.getViewport().getSequenceSetId()))
+ if (skipList != null && skipList
+ .containsKey(af.getViewport().getSequenceSetId()))
{
continue;
}
saveState(apanel, fileName, jout, viewIds);
- String dssid = getDatasetIdRef(af.getViewport().getAlignment()
- .getDataset());
+ String dssid = getDatasetIdRef(
+ af.getViewport().getAlignment().getDataset());
if (!dsses.containsKey(dssid))
{
dsses.put(dssid, af);
if (shortName.indexOf(File.separatorChar) > -1)
{
- shortName = shortName.substring(shortName
- .lastIndexOf(File.separatorChar) + 1);
+ shortName = shortName
+ .substring(shortName.lastIndexOf(File.separatorChar) + 1);
}
int count = 1;
object.setVamsasModel(new jalview.schemabinding.version2.VamsasModel());
object.setCreationDate(new java.util.Date(System.currentTimeMillis()));
- object.setVersion(jalview.bin.Cache.getDefault("VERSION",
- "Development Build"));
+ object.setVersion(
+ jalview.bin.Cache.getDefault("VERSION", "Development Build"));
/**
* rjal is full height alignment, jal is actual alignment with full metadata
if (av.hasHiddenRows())
{
// use rjal, contains the full height alignment
- jseq.setHidden(av.getAlignment().getHiddenSequences()
- .isHidden(jds));
+ jseq.setHidden(
+ av.getAlignment().getHiddenSequences().isHidden(jds));
if (av.isHiddenRepSequence(jds))
{
}
if (sf.otherDetails != null)
{
- String key;
- Iterator<String> keys = sf.otherDetails.keySet().iterator();
- while (keys.hasNext())
+ /*
+ * save feature attributes, which may be simple strings or
+ * map valued (have sub-attributes)
+ */
+ for (Entry<String, Object> entry : sf.otherDetails.entrySet())
{
- key = keys.next();
- OtherData keyValue = new OtherData();
- keyValue.setKey(key);
- keyValue.setValue(sf.otherDetails.get(key).toString());
- features.addOtherData(keyValue);
+ String key = entry.getKey();
+ Object value = entry.getValue();
+ if (value instanceof Map<?, ?>)
+ {
+ for (Entry<String, Object> subAttribute : ((Map<String, Object>) value)
+ .entrySet())
+ {
+ OtherData otherData = new OtherData();
+ otherData.setKey(key);
+ otherData.setKey2(subAttribute.getKey());
+ otherData.setValue(subAttribute.getValue().toString());
+ features.addOtherData(otherData);
+ }
+ }
+ else
+ {
+ OtherData otherData = new OtherData();
+ otherData.setKey(key);
+ otherData.setValue(value.toString());
+ features.addOtherData(otherData);
+ }
}
}
if (frames[f] instanceof StructureViewerBase)
{
StructureViewerBase viewFrame = (StructureViewerBase) frames[f];
- matchedFile = saveStructureState(ap, jds, pdb, entry,
- viewIds, matchedFile, viewFrame);
+ matchedFile = saveStructureState(ap, jds, pdb, entry, viewIds,
+ matchedFile, viewFrame);
/*
* Only store each structure viewer's state once in the project
* jar. First time through only (storeDS==false)
viewerState.getBytes());
} catch (IOException e)
{
- System.err.println("Error saving viewer state: "
- + e.getMessage());
+ System.err.println(
+ "Error saving viewer state: " + e.getMessage());
}
}
}
{
AlcodMap alcmap = new AlcodMap();
alcmap.setDnasq(seqHash(dnas[m]));
- alcmap.setMapping(createVamsasMapping(pmaps[m], dnas[m], null,
- false));
+ alcmap.setMapping(
+ createVamsasMapping(pmaps[m], dnas[m], null, false));
alc.addAlcodMap(alcmap);
hasMap = true;
}
// SAVE TREES
// /////////////////////////////////
- if (!storeDS && av.currentTree != null)
+ if (!storeDS && av.getCurrentTree() != null)
{
// FIND ANY ASSOCIATED TREES
// NOT IMPLEMENTED FOR HEADLESS STATE AT PRESENT
{
Tree tree = new Tree();
tree.setTitle(tp.getTitle());
- tree.setCurrentTree((av.currentTree == tp.getTree()));
+ tree.setCurrentTree((av.getCurrentTree() == tp.getTree()));
tree.setNewick(tp.getTree().print());
tree.setThreshold(tp.treeCanvas.threshold);
ColourSchemeI colourScheme = sg.getColourScheme();
if (colourScheme != null)
{
- ResidueShaderI groupColourScheme = sg
- .getGroupColourScheme();
+ ResidueShaderI groupColourScheme = sg.getGroupColourScheme();
if (groupColourScheme.conservationApplied())
{
jGroup.setConsThreshold(groupColourScheme.getConservationInc());
if (colourScheme instanceof jalview.schemes.UserColourScheme)
{
- jGroup.setColour(setUserColourScheme(colourScheme,
- userColours, jms));
+ jGroup.setColour(
+ setUserColourScheme(colourScheme, userColours, jms));
}
else
{
}
else if (colourScheme instanceof jalview.schemes.UserColourScheme)
{
- jGroup.setColour(setUserColourScheme(colourScheme,
- userColours, jms));
+ jGroup.setColour(
+ setUserColourScheme(colourScheme, userColours, jms));
}
else
{
// /////////SAVE VIEWPORT
Viewport view = new Viewport();
view.setTitle(ap.alignFrame.getTitle());
- view.setSequenceSetId(makeHashCode(av.getSequenceSetId(),
- av.getSequenceSetId()));
+ view.setSequenceSetId(
+ makeHashCode(av.getSequenceSetId(), av.getSequenceSetId()));
view.setId(av.getViewId());
if (av.getCodingComplement() != null)
{
view.setBgColour(setUserColourScheme(av.getGlobalColourScheme(),
userColours, jms));
}
- else if (av.getGlobalColourScheme() instanceof jalview.schemes.AnnotationColourGradient)
+ else if (av
+ .getGlobalColourScheme() instanceof jalview.schemes.AnnotationColourGradient)
{
AnnotationColours ac = constructAnnotationColours(
(jalview.schemes.AnnotationColourGradient) av
}
else
{
- view.setBgColour(ColourSchemeProperty.getColourName(av
- .getGlobalColourScheme()));
+ view.setBgColour(ColourSchemeProperty
+ .getColourName(av.getGlobalColourScheme()));
}
ResidueShaderI vcs = av.getResidueShading();
{
jalview.schemabinding.version2.FeatureSettings fs = new jalview.schemabinding.version2.FeatureSettings();
- String[] renderOrder = ap.getSeqPanel().seqCanvas
- .getFeatureRenderer().getRenderOrder()
- .toArray(new String[0]);
+ FeatureRenderer fr = ap.getSeqPanel().seqCanvas
+ .getFeatureRenderer();
+ String[] renderOrder = fr.getRenderOrder().toArray(new String[0]);
Vector<String> settingsAdded = new Vector<>();
if (renderOrder != null)
{
for (String featureType : renderOrder)
{
- FeatureColourI fcol = ap.getSeqPanel().seqCanvas
- .getFeatureRenderer().getFeatureStyle(featureType);
Setting setting = new Setting();
setting.setType(featureType);
+
+ /*
+ * save any filter for the feature type
+ */
+ FeatureMatcherSetI filter = fr.getFeatureFilter(featureType);
+ if (filter != null) {
+ Iterator<FeatureMatcherI> filters = filter.getMatchers().iterator();
+ FeatureMatcherI firstFilter = filters.next();
+ setting.setMatcherSet(Jalview2XML.marshalFilter(
+ firstFilter, filters, filter.isAnded()));
+ }
+
+ /*
+ * save colour scheme for the feature type
+ */
+ FeatureColourI fcol = fr.getFeatureStyle(featureType);
if (!fcol.isSimpleColour())
{
setting.setColour(fcol.getMaxColour().getRGB());
setting.setMin(fcol.getMin());
setting.setMax(fcol.getMax());
setting.setColourByLabel(fcol.isColourByLabel());
+ if (fcol.isColourByAttribute())
+ {
+ setting.setAttributeName(fcol.getAttributeName());
+ }
setting.setAutoScale(fcol.isAutoScaled());
setting.setThreshold(fcol.getThreshold());
+ Color noColour = fcol.getNoColour();
+ if (noColour == null)
+ {
+ setting.setNoValueColour(NoValueColour.NONE);
+ }
+ else if (noColour.equals(fcol.getMaxColour()))
+ {
+ setting.setNoValueColour(NoValueColour.MAX);
+ }
+ else
+ {
+ setting.setNoValueColour(NoValueColour.MIN);
+ }
// -1 = No threshold, 0 = Below, 1 = Above
- setting.setThreshstate(fcol.isAboveThreshold() ? 1 : (fcol
- .isBelowThreshold() ? 0 : -1));
+ setting.setThreshstate(fcol.isAboveThreshold() ? 1
+ : (fcol.isBelowThreshold() ? 0 : -1));
}
else
{
setting.setColour(fcol.getColour().getRGB());
}
- setting.setDisplay(av.getFeaturesDisplayed().isVisible(
- featureType));
- float rorder = ap.getSeqPanel().seqCanvas.getFeatureRenderer()
+ setting.setDisplay(
+ av.getFeaturesDisplayed().isVisible(featureType));
+ float rorder = fr
.getOrder(featureType);
if (rorder > -1)
{
}
// is groups actually supposed to be a map here ?
- Iterator<String> en = ap.getSeqPanel().seqCanvas
- .getFeatureRenderer().getFeatureGroups().iterator();
+ Iterator<String> en = fr.getFeatureGroups().iterator();
Vector<String> groupsAdded = new Vector<>();
while (en.hasNext())
{
}
Group g = new Group();
g.setName(grp);
- g.setDisplay(((Boolean) ap.getSeqPanel().seqCanvas
- .getFeatureRenderer().checkGroupVisibility(grp, false))
- .booleanValue());
+ g.setDisplay(((Boolean) fr.checkGroupVisibility(grp, false))
+ .booleanValue());
fs.addGroup(g);
groupsAdded.addElement(grp);
}
}
else
{
- ArrayList<int[]> hiddenRegions = hidden
- .getHiddenColumnsCopy();
- for (int[] region : hiddenRegions)
+ Iterator<int[]> hiddenRegions = hidden.iterator();
+ while (hiddenRegions.hasNext())
{
+ int[] region = hiddenRegions.next();
HiddenColumns hc = new HiddenColumns();
hc.setStart(region[0]);
hc.setEnd(region[1]);
System.out.println("Writing jar entry " + fileName);
JarEntry entry = new JarEntry(fileName);
jout.putNextEntry(entry);
- PrintWriter pout = new PrintWriter(new OutputStreamWriter(jout,
- UTF_8));
+ PrintWriter pout = new PrintWriter(
+ new OutputStreamWriter(jout, UTF_8));
Marshaller marshaller = new Marshaller(pout);
marshaller.marshal(object);
pout.flush();
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())))
+ && !(entry.getId().length() > 4 && entry.getId().toLowerCase()
+ .startsWith(pdbId.toLowerCase())))
{
/*
* not interested in a binding to a different PDB entry here
}
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): "
+ Cache.log.warn(
+ "Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): "
+ pdbentry.getFile());
}
// record the
// match is ambiguous (e.g.
// 1QIP==1qipA)
- 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])
ac.setAnnotation(acg.getAnnotation().annotationId);
if (acg.getBaseColour() instanceof UserColourScheme)
{
- ac.setColourScheme(setUserColourScheme(acg.getBaseColour(),
- userColours, jms));
+ ac.setColourScheme(
+ setUserColourScheme(acg.getBaseColour(), userColours, jms));
}
else
{
- ac.setColourScheme(ColourSchemeProperty.getColourName(acg.getBaseColour()));
+ ac.setColourScheme(
+ ColourSchemeProperty.getColourName(acg.getBaseColour()));
}
ac.setMaxColour(acg.getMaxColour().getRGB());
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());
}
}
if (annotation.annotations[a].displayCharacter != null)
{
- ae.setDisplayCharacter(annotation.annotations[a].displayCharacter);
+ ae.setDisplayCharacter(
+ annotation.annotations[a].displayCharacter);
}
if (!Float.isNaN(annotation.annotations[a].value))
ae.setPosition(a);
if (annotation.annotations[a].secondaryStructure > ' ')
{
- ae.setSecondaryStructure(annotation.annotations[a].secondaryStructure
- + "");
+ ae.setSecondaryStructure(
+ annotation.annotations[a].secondaryStructure + "");
}
if (annotation.annotations[a].colour != null
// need to be able to recover 1) settings 2) user-defined presets or
// recreate settings from preset 3) predefined settings provided by
// service - or settings that can be transferred (or discarded)
- vCalcIdParam.setParameters(settings.getWsParamFile().replace("\n",
- "|\\n|"));
+ vCalcIdParam.setParameters(
+ settings.getWsParamFile().replace("\n", "|\\n|"));
vCalcIdParam.setAutoUpdate(settings.isAutoUpdate());
// todo - decide if updateImmediately is needed for any projects.
}
}
throw new Error(MessageManager.formatMessage(
- "error.unsupported_version_calcIdparam",
- new Object[] { calcIdParam.toString() }));
+ "error.unsupported_version_calcIdparam", new Object[]
+ { calcIdParam.toString() }));
}
/**
for (int i = 0; i < 24; i++)
{
- newColours[i] = new java.awt.Color(Integer.parseInt(colours
- .getUserColourScheme().getColour(i).getRGB(), 16));
+ newColours[i] = new java.awt.Color(Integer.parseInt(
+ colours.getUserColourScheme().getColour(i).getRGB(), 16));
}
jalview.schemes.UserColourScheme ucs = new jalview.schemes.UserColourScheme(
newColours = new java.awt.Color[23];
for (int i = 0; i < 23; i++)
{
- newColours[i] = new java.awt.Color(Integer.parseInt(colours
- .getUserColourScheme().getColour(i + 24).getRGB(), 16));
+ newColours[i] = new java.awt.Color(Integer.parseInt(
+ colours.getUserColourScheme().getColour(i + 24).getRGB(),
+ 16));
}
ucs.setLowerCaseColours(newColours);
}
jarInputStreamProvider jprovider = createjarInputStreamProvider(file);
af = loadJalviewAlign(jprovider);
+ af.setMenusForViewport();
} catch (MalformedURLException e)
{
if (true) // !skipViewport(object))
{
_af = loadFromObject(object, file, true, jprovider);
- if (_af != null
- && object.getJalviewModelSequence().getViewportCount() > 0)
+ if (_af != null && object.getJalviewModelSequence()
+ .getViewportCount() > 0)
{
if (af == null)
{
{
ex.printStackTrace();
errorMessage = "Couldn't locate Jalview XML file : " + file;
- System.err.println("Exception whilst loading jalview XML file : "
- + ex + "\n");
+ System.err.println(
+ "Exception whilst loading jalview XML file : " + ex + "\n");
} catch (Exception ex)
{
System.err.println("Parsing as Jalview Version 2 file failed.");
}
ex.printStackTrace();
- System.err.println("Exception whilst loading jalview XML file : "
- + ex + "\n");
+ System.err.println(
+ "Exception whilst loading jalview XML file : " + ex + "\n");
} catch (OutOfMemoryError e)
{
// Don't use the OOM Window here
{
if (ds.getCodonFrames() != null)
{
- StructureSelectionManager.getStructureSelectionManager(
- Desktop.instance).registerMappings(ds.getCodonFrames());
+ StructureSelectionManager
+ .getStructureSelectionManager(Desktop.instance)
+ .registerMappings(ds.getCodonFrames());
}
}
if (errorMessage != null)
@Override
public void run()
{
- JvOptionPane
- .showInternalMessageDialog(Desktop.desktop,
- finalErrorMessage, "Error "
- + (saving ? "saving" : "loading")
- + " Jalview file",
- JvOptionPane.WARNING_MESSAGE);
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop,
+ finalErrorMessage,
+ "Error " + (saving ? "saving" : "loading")
+ + " Jalview file",
+ JvOptionPane.WARNING_MESSAGE);
}
});
}
if (tmpSeq.getStart() != jseqs[i].getStart()
|| tmpSeq.getEnd() != jseqs[i].getEnd())
{
- System.err
- .println("Warning JAL-2154 regression: updating start/end for sequence "
+ System.err.println(
+ "Warning JAL-2154 regression: updating start/end for sequence "
+ tmpSeq.toString() + " to " + jseqs[i]);
}
}
}
else
{
- boolean isdsal = object.getJalviewModelSequence().getViewportCount() == 0;
+ boolean isdsal = object.getJalviewModelSequence()
+ .getViewportCount() == 0;
if (isdsal)
{
// we are importing a dataset record, so
features[f].getEnd(), features[f].getScore(),
features[f].getFeatureGroup());
sf.setStatus(features[f].getStatus());
+
+ /*
+ * load any feature attributes - include map-valued attributes
+ */
+ Map<String, Map<String, String>> mapAttributes = new HashMap<>();
for (int od = 0; od < features[f].getOtherDataCount(); od++)
{
OtherData keyValue = features[f].getOtherData(od);
- if (keyValue.getKey().startsWith("LINK"))
+ String attributeName = keyValue.getKey();
+ String attributeValue = keyValue.getValue();
+ if (attributeName.startsWith("LINK"))
{
- sf.addLink(keyValue.getValue());
+ sf.addLink(attributeValue);
}
else
{
- sf.setValue(keyValue.getKey(), keyValue.getValue());
+ String subAttribute = keyValue.getKey2();
+ if (subAttribute == null)
+ {
+ // simple string-valued attribute
+ sf.setValue(attributeName, attributeValue);
+ }
+ else
+ {
+ // attribute 'key' has sub-attribute 'key2'
+ if (!mapAttributes.containsKey(attributeName))
+ {
+ mapAttributes.put(attributeName, new HashMap<>());
+ }
+ mapAttributes.get(attributeName).put(subAttribute,
+ attributeValue);
+ }
}
-
}
+ for (Entry<String, Map<String, String>> mapAttribute : mapAttributes
+ .entrySet())
+ {
+ sf.setValue(mapAttribute.getKey(), mapAttribute.getValue());
+ }
+
// adds feature to datasequence's feature set (since Jalview 2.10)
al.getSequenceAt(i).addSequenceFeature(sf);
}
{
// adds dbrefs to datasequence's set (since Jalview 2.10)
addDBRefs(
- al.getSequenceAt(i).getDatasetSequence() == null ? al.getSequenceAt(i)
+ al.getSequenceAt(i).getDatasetSequence() == null
+ ? al.getSequenceAt(i)
: al.getSequenceAt(i).getDatasetSequence(),
vamsasSeq[i]);
}
}
}
}
- StructureSelectionManager.getStructureSelectionManager(
- Desktop.instance).registerPDBEntry(entry);
+ StructureSelectionManager
+ .getStructureSelectionManager(Desktop.instance)
+ .registerPDBEntry(entry);
// adds PDBEntry to datasequence's set (since Jalview 2.10)
if (al.getSequenceAt(i).getDatasetSequence() != null)
{
else
{
// defer to later
- frefedSequence.add(newAlcodMapRef(maps[m].getDnasq(), cf,
- mapping));
+ frefedSequence.add(
+ newAlcodMapRef(maps[m].getDnasq(), cf, mapping));
}
}
}
annotation.setAutoCalculated(true);
}
}
- if (autoForView
- || (annotation.hasAutoCalculated() && annotation
- .isAutoCalculated()))
+ if (autoForView || (annotation.hasAutoCalculated()
+ && annotation.isAutoCalculated()))
{
// remove ID - we don't recover annotation from other views for
// view-specific annotation
anot[anpos] = new jalview.datamodel.Annotation(
- ae[aa].getDisplayCharacter(), ae[aa].getDescription(),
- (ae[aa].getSecondaryStructure() == null || ae[aa]
- .getSecondaryStructure().length() == 0) ? ' '
- : ae[aa].getSecondaryStructure().charAt(0),
+ ae[aa].getDisplayCharacter(), ae[aa].getDescription(),
+ (ae[aa].getSecondaryStructure() == null
+ || ae[aa].getSecondaryStructure().length() == 0)
+ ? ' '
+ : ae[aa].getSecondaryStructure()
+ .charAt(0),
ae[aa].getValue()
);
jaa._linecolour = firstColour;
if (annotation.getThresholdLine() != null)
{
- jaa.setThreshold(new jalview.datamodel.GraphLine(annotation
- .getThresholdLine().getValue(), annotation
- .getThresholdLine().getLabel(), new java.awt.Color(
- annotation.getThresholdLine().getColour())));
+ jaa.setThreshold(new jalview.datamodel.GraphLine(
+ annotation.getThresholdLine().getValue(),
+ annotation.getThresholdLine().getLabel(),
+ new java.awt.Color(
+ annotation.getThresholdLine().getColour())));
}
if (autoForView || annotation.isAutoCalculated())
}
else
{
- cs = ColourSchemeProperty.getColourScheme(al, jGroup.getColour());
+ cs = ColourSchemeProperty.getColourScheme(al,
+ jGroup.getColour());
}
}
int pidThreshold = jGroup.getPidThreshold();
jGroup.getDisplayBoxes(), jGroup.getDisplayText(),
jGroup.getColourText(), jGroup.getStart(), jGroup.getEnd());
sg.getGroupColourScheme().setThreshold(pidThreshold, true);
- sg.getGroupColourScheme().setConservationInc(jGroup.getConsThreshold());
+ sg.getGroupColourScheme()
+ .setConservationInc(jGroup.getConsThreshold());
sg.setOutlineColour(new java.awt.Color(jGroup.getOutlineColour()));
sg.textColour = new java.awt.Color(jGroup.getTextCol1());
sg.textColour2 = new java.awt.Color(jGroup.getTextCol2());
- sg.setShowNonconserved(jGroup.hasShowUnconserved() ? jGroup
- .isShowUnconserved() : false);
+ sg.setShowNonconserved(
+ jGroup.hasShowUnconserved() ? jGroup.isShowUnconserved()
+ : false);
sg.thresholdTextColour = jGroup.getTextColThreshold();
if (jGroup.hasShowConsensusHistogram())
{
}
if (jGroup.getConsThreshold() != 0)
{
- Conservation c = new Conservation("All", sg.getSequences(null),
- 0, sg.getWidth() - 1);
+ Conservation c = new Conservation("All", sg.getSequences(null), 0,
+ sg.getWidth() - 1);
c.calculate();
c.verdict(false, 25);
sg.cs.setConservation(c);
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)
// to the same sequenceSet. We must modify this id on load
// so that each load of the file gives a unique id
String uniqueSeqSetId = view.getSequenceSetId() + uniqueSetSuffix;
- String viewId = (view.getId() == null ? null : view.getId()
- + uniqueSetSuffix);
+ String viewId = (view.getId() == null ? null
+ : view.getId() + uniqueSetSuffix);
AlignFrame af = null;
AlignViewport av = null;
// now check to see if we really need to create a new viewport.
// XML.
// and then recover its containing af to allow the settings to be applied.
// TODO: fix for vamsas demo
- System.err
- .println("About to recover a viewport for existing alignment: Sequence set ID is "
+ System.err.println(
+ "About to recover a viewport for existing alignment: Sequence set ID is "
+ uniqueSeqSetId);
Object seqsetobj = retrieveExistingObj(uniqueSeqSetId);
if (seqsetobj != null)
if (seqsetobj instanceof String)
{
uniqueSeqSetId = (String) seqsetobj;
- System.err
- .println("Recovered extant sequence set ID mapping for ID : New Sequence set ID is "
+ System.err.println(
+ "Recovered extant sequence set ID mapping for ID : New Sequence set ID is "
+ uniqueSeqSetId);
}
else
{
- System.err
- .println("Warning : Collision between sequence set ID string and existing jalview object mapping.");
+ System.err.println(
+ "Warning : Collision between sequence set ID string and existing jalview object mapping.");
}
}
* indicate that annotation colours are applied across all groups (pre
* Jalview 2.8.1 behaviour)
*/
- boolean doGroupAnnColour = Jalview2XML.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++)
{
SecondaryStructure ss = viewer.getSecondaryStructure(j);
SequenceI seq = seqRefIds.get(jseq.getId());
- AlignmentAnnotation ann = this.annotationIds.get(ss
- .getAnnotationId());
+ AlignmentAnnotation ann = this.annotationIds
+ .get(ss.getAnnotationId());
/*
* add the structure to the Varna display (with session state copied
/*
* viewer not found - make it
*/
- RnaViewerModel model = new RnaViewerModel(postLoadId,
- viewer.getTitle(), viewer.getXpos(), viewer.getYpos(),
- viewer.getWidth(), viewer.getHeight(),
- viewer.getDividerLocation());
+ RnaViewerModel model = new RnaViewerModel(postLoadId, viewer.getTitle(),
+ viewer.getXpos(), viewer.getYpos(), viewer.getWidth(),
+ viewer.getHeight(), viewer.getDividerLocation());
AppVarna varna = new AppVarna(model, ap);
return varna;
// TODO: should check if tp has been manipulated by user - if so its
// settings shouldn't be modified
tp.setTitle(tree.getTitle());
- tp.setBounds(new Rectangle(tree.getXpos(), tree.getYpos(), tree
- .getWidth(), tree.getHeight()));
+ tp.setBounds(new Rectangle(tree.getXpos(), tree.getYpos(),
+ tree.getWidth(), tree.getHeight()));
tp.av = av; // af.viewport; // TODO: verify 'associate with all
// views'
// works still
if (tree.getFontName() != null)
{
- tp.setTreeFont(new java.awt.Font(tree.getFontName(), tree
- .getFontStyle(), tree.getFontSize()));
+ tp.setTreeFont(new java.awt.Font(tree.getFontName(),
+ tree.getFontStyle(), tree.getFontSize()));
}
else
{
- tp.setTreeFont(new java.awt.Font(view.getFontName(), view
- .getFontStyle(), tree.getFontSize()));
+ tp.setTreeFont(new java.awt.Font(view.getFontName(),
+ view.getFontStyle(), tree.getFontSize()));
}
tp.showPlaceholders(tree.getMarkUnlinked());
// TODO: NOW: check that this recovers the PDB file correctly.
String pdbFile = loadPDBFile(jprovider, ids[p].getId(),
ids[p].getFile());
- 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
- + "," + height;
+ sviewid = "_jalview_pre2_4_" + x + "," + y + "," + width + ","
+ + height;
}
if (!structureViewers.containsKey(sviewid))
{
// linkAlignPanel,superposeWithAlignpanel}} from hash
StructureViewerModel jmoldat = structureViewers.get(sviewid);
jmoldat.setAlignWithPanel(jmoldat.isAlignWithPanel()
- | (structureState.hasAlignwithAlignPanel() ? structureState
- .getAlignwithAlignPanel() : false));
+ | (structureState.hasAlignwithAlignPanel()
+ ? structureState.getAlignwithAlignPanel()
+ : false));
/*
* Default colour by linked panel to false if not specified (e.g.
*/
boolean colourWithAlignPanel = jmoldat.isColourWithAlignPanel();
colourWithAlignPanel |= (structureState
- .hasColourwithAlignPanel() ? structureState
- .getColourwithAlignPanel() : false);
+ .hasColourwithAlignPanel()
+ ? structureState.getColourwithAlignPanel()
+ : false);
jmoldat.setColourWithAlignPanel(colourWithAlignPanel);
/*
* pre-2.7 projects)
*/
boolean colourByViewer = jmoldat.isColourByViewer();
- colourByViewer &= structureState.hasColourByJmol() ? structureState
- .getColourByJmol() : true;
+ colourByViewer &= structureState.hasColourByJmol()
+ ? structureState.getColourByJmol()
+ : true;
jmoldat.setColourByViewer(colourByViewer);
if (jmoldat.getStateData().length() < structureState
StructureData seqstrmaps = jmoldat.getFileData().get(mapkey);
if (seqstrmaps == null)
{
- jmoldat.getFileData().put(
- mapkey,
+ jmoldat.getFileData().put(mapkey,
seqstrmaps = jmoldat.new StructureData(pdbFile,
ids[p].getId()));
}
createOrLinkStructureViewer(entry, af, ap, jprovider);
} catch (Exception e)
{
- System.err.println("Error loading structure viewer: "
- + e.getMessage());
+ System.err.println(
+ "Error loading structure viewer: " + e.getMessage());
// failed - try the next one
}
}
// TODO use StructureViewer as a factory here, see JAL-1761
final PDBEntry[] pdbArray = pdbs.toArray(new PDBEntry[pdbs.size()]);
- final SequenceI[][] seqsArray = allseqs.toArray(new SequenceI[allseqs
- .size()][]);
+ final SequenceI[][] seqsArray = allseqs
+ .toArray(new SequenceI[allseqs.size()][]);
String newViewId = viewerData.getKey();
ChimeraViewFrame cvf = new ChimeraViewFrame(chimeraSessionFile,
*/
histbug += 10;
int diff = histbug == -1 ? -1 : newFileLoc.indexOf(";", histbug);
- String val = (diff == -1) ? null : newFileLoc
- .substring(histbug, diff);
+ String val = (diff == -1) ? null
+ : newFileLoc.substring(histbug, diff);
if (val != null && val.length() >= 4)
{
if (val.contains("e")) // eh? what can it be?
}
}
- final String[] pdbf = pdbfilenames.toArray(new String[pdbfilenames
- .size()]);
+ 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()][]);
JalviewStructureDisplayI sview = null;
try
{
- sview = new StructureViewer(alf.alignPanel
- .getStructureSelectionManager()).createView(
- StructureViewer.ViewerType.JMOL, pdbf, id, sq,
- alf.alignPanel, svattrib, fileloc, rect, sviewid);
+ sview = new StructureViewer(
+ alf.alignPanel.getStructureSelectionManager())
+ .createView(StructureViewer.ViewerType.JMOL,
+ pdbf, id, sq, alf.alignPanel, svattrib,
+ fileloc, rect, sviewid);
addNewStructureViewer(sview);
} catch (OutOfMemoryError ex)
{
/*
* Post jalview 2.4 schema includes structure view id
*/
- if (sviewid != null
- && ((StructureViewerBase) frame).getViewId()
- .equals(sviewid))
+ if (sviewid != null && ((StructureViewerBase) frame).getViewId()
+ .equals(sviewid))
{
comp = (StructureViewerBase) frame;
break; // break added in 2.9
StructureData filedat = oldFiles.get(id);
String pdbFile = filedat.getFilePath();
SequenceI[] seq = filedat.getSeqList().toArray(new SequenceI[0]);
- binding.getSsm().setMapping(seq, null, pdbFile, DataSourceType.FILE);
+ binding.getSsm().setMapping(seq, null, pdbFile, DataSourceType.FILE,
+ null);
binding.addSequenceForStructFile(pdbFile, seq);
}
// and add the AlignmentPanel's reference to the view panel
for (int i = 0; i < JSEQ.length; i++)
{
- af.viewport.setSequenceColour(af.viewport.getAlignment()
- .getSequenceAt(i), new java.awt.Color(JSEQ[i].getColour()));
+ af.viewport.setSequenceColour(
+ af.viewport.getAlignment().getSequenceAt(i),
+ new java.awt.Color(JSEQ[i].getColour()));
}
if (al.hasSeqrep())
for (int r = 0; r < JSEQ[s].getHiddenSequencesCount(); r++)
{
isRepresentative = true;
- SequenceI sequenceToHide = al.getSequenceAt(JSEQ[s]
- .getHiddenSequences(r));
+ 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);
}
}
- SequenceI[] hseqs = hiddenSeqs.toArray(new SequenceI[hiddenSeqs
- .size()]);
+ SequenceI[] hseqs = hiddenSeqs
+ .toArray(new SequenceI[hiddenSeqs.size()]);
af.viewport.hideSequence(hseqs);
}
af.viewport.setIncrement(view.getConsThreshold());
af.viewport.setShowJVSuffix(view.getShowFullId());
af.viewport.setRightAlignIds(view.getRightAlignIds());
- af.viewport.setFont(
- new java.awt.Font(view.getFontName(), view.getFontStyle(), view
- .getFontSize()), true);
+ 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);
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.setShowUnconserved(
+ view.hasShowUnconserved() ? view.isShowUnconserved() : false);
af.viewport.getRanges().setStartRes(view.getStartRes());
if (view.getViewName() != null)
}
af.viewport.setGlobalColourScheme(cs);
- af.viewport.getResidueShading().setThreshold(
- view.getPidThreshold(), true);
- af.viewport.getResidueShading().setConsensus(
- af.viewport.getSequenceConsensusHash());
+ af.viewport.getResidueShading().setThreshold(view.getPidThreshold(),
+ view.getIgnoreGapsinConsensus());
+ af.viewport.getResidueShading()
+ .setConsensus(af.viewport.getSequenceConsensusHash());
af.viewport.setColourAppliesToAllGroups(false);
if (view.getConservationSelected() && cs != null)
{
- af.viewport.getResidueShading().setConservationInc(
- view.getConsThreshold());
+ af.viewport.getResidueShading()
+ .setConservationInc(view.getConsThreshold());
}
af.changeColour(cs);
}
if (view.hasShowConsensusHistogram())
{
- af.viewport.setShowConsensusHistogram(view
- .getShowConsensusHistogram());
+ af.viewport
+ .setShowConsensusHistogram(view.getShowConsensusHistogram());
}
else
{
af.viewport.setShowGroupConservation(false);
}
- // recover featre settings
+ // recover feature settings
if (jms.getFeatureSettings() != null)
{
+ FeatureRenderer fr = af.alignPanel.getSeqPanel().seqCanvas
+ .getFeatureRenderer();
FeaturesDisplayed fdi;
af.viewport.setFeaturesDisplayed(fdi = new FeaturesDisplayed());
String[] renderOrder = new String[jms.getFeatureSettings()
Map<String, FeatureColourI> featureColours = new Hashtable<>();
Map<String, Float> featureOrder = new Hashtable<>();
- for (int fs = 0; fs < jms.getFeatureSettings().getSettingCount(); fs++)
+ for (int fs = 0; fs < jms.getFeatureSettings()
+ .getSettingCount(); fs++)
{
Setting setting = jms.getFeatureSettings().getSetting(fs);
+ String featureType = setting.getType();
+
+ /*
+ * restore feature filters (if any)
+ */
+ MatcherSet filters = setting.getMatcherSet();
+ if (filters != null)
+ {
+ FeatureMatcherSetI filter = Jalview2XML
+ .unmarshalFilter(featureType, filters);
+ if (!filter.isEmpty())
+ {
+ fr.setFeatureFilter(featureType, filter);
+ }
+ }
+
+ /*
+ * restore feature colour scheme
+ */
+ Color maxColour = new Color(setting.getColour());
if (setting.hasMincolour())
{
- 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);
+ /*
+ * minColour is always set unless a simple colour
+ * (including for colour by label though it doesn't use it)
+ */
+ Color minColour = new Color(setting.getMincolour());
+ Color noValueColour = minColour;
+ NoValueColour noColour = setting.getNoValueColour();
+ if (noColour == NoValueColour.NONE)
+ {
+ noValueColour = null;
+ }
+ else if (noColour == NoValueColour.MAX)
+ {
+ noValueColour = maxColour;
+ }
+ float min = setting.hasMin() ? setting.getMin() : 0f;
+ float max = setting.hasMin() ? setting.getMax() : 1f;
+ FeatureColourI gc = new FeatureColour(minColour, maxColour,
+ noValueColour, min, max);
+ if (setting.getAttributeNameCount() > 0)
+ {
+ gc.setAttributeName(setting.getAttributeName());
+ }
if (setting.hasThreshold())
{
gc.setThreshold(setting.getThreshold());
gc.setColourByLabel(setting.getColourByLabel());
}
// and put in the feature colour table.
- featureColours.put(setting.getType(), gc);
+ featureColours.put(featureType, gc);
}
else
{
- featureColours.put(setting.getType(), new FeatureColour(
- new Color(setting.getColour())));
+ featureColours.put(featureType,
+ new FeatureColour(maxColour));
}
- renderOrder[fs] = setting.getType();
+ renderOrder[fs] = featureType;
if (setting.hasOrder())
{
- featureOrder.put(setting.getType(), setting.getOrder());
+ featureOrder.put(featureType, setting.getOrder());
}
else
{
- featureOrder.put(setting.getType(), new Float(fs
- / jms.getFeatureSettings().getSettingCount()));
+ featureOrder.put(featureType, new Float(
+ fs / jms.getFeatureSettings().getSettingCount()));
}
if (setting.getDisplay())
{
- fdi.setVisible(setting.getType());
+ fdi.setVisible(featureType);
}
}
Map<String, Boolean> fgtable = new Hashtable<>();
// FeatureRendererSettings frs = new FeatureRendererSettings(renderOrder,
// fgtable, featureColours, jms.getFeatureSettings().hasTransparency() ?
// jms.getFeatureSettings().getTransparency() : 0.0, featureOrder);
- FeatureRendererSettings frs = new FeatureRendererSettings(
- renderOrder, fgtable, featureColours, 1.0f, featureOrder);
- af.alignPanel.getSeqPanel().seqCanvas.getFeatureRenderer()
- .transferSettings(frs);
-
+ FeatureRendererSettings frs = new FeatureRendererSettings(renderOrder,
+ fgtable, featureColours, 1.0f, featureOrder);
+ fr.transferSettings(frs);
}
if (view.getHiddenColumnsCount() > 0)
{
for (int c = 0; c < view.getHiddenColumnsCount(); c++)
{
- af.viewport.hideColumns(view.getHiddenColumns(c).getStart(), view
- .getHiddenColumns(c).getEnd() // +1
- );
+ af.viewport.hideColumns(view.getHiddenColumns(c).getStart(),
+ view.getHiddenColumns(c).getEnd() // +1
+ );
}
}
if (view.getCalcIdParam() != null)
/*
* pre 2.10.2: saved annotationId is AlignmentAnnotation.label
*/
- if (matchedAnnotation == null && annAlignment.getAlignmentAnnotation() != null)
+ if (matchedAnnotation == null
+ && annAlignment.getAlignmentAnnotation() != null)
{
for (int i = 0; i < annAlignment.getAlignmentAnnotation().length; i++)
{
}
if (matchedAnnotation.getThreshold() == null)
{
- matchedAnnotation.setThreshold(new GraphLine(viewAnnColour.getThreshold(),
- "Threshold", Color.black));
+ matchedAnnotation.setThreshold(new GraphLine(
+ viewAnnColour.getThreshold(), "Threshold", Color.black));
}
AnnotationColourGradient cs = null;
if (viewAnnColour.getColourScheme().equals("None"))
{
- cs = new AnnotationColourGradient(matchedAnnotation, new Color(
- viewAnnColour.getMinColour()), new Color(
- viewAnnColour.getMaxColour()),
+ cs = new AnnotationColourGradient(matchedAnnotation,
+ new Color(viewAnnColour.getMinColour()),
+ new Color(viewAnnColour.getMaxColour()),
viewAnnColour.getAboveThreshold());
}
else if (viewAnnColour.getColourScheme().startsWith("ucs"))
{
- cs = new AnnotationColourGradient(matchedAnnotation, getUserColourScheme(
- jms, viewAnnColour.getColourScheme()),
+ cs = new AnnotationColourGradient(matchedAnnotation,
+ getUserColourScheme(jms, viewAnnColour.getColourScheme()),
viewAnnColour.getAboveThreshold());
}
else
for (JvAnnotRow auan : autoAlan)
{
visan.put(auan.template.label
- + (auan.template.getCalcId() == null ? "" : "\t"
- + auan.template.getCalcId()), auan);
+ + (auan.template.getCalcId() == null ? ""
+ : "\t" + auan.template.getCalcId()),
+ auan);
}
int hSize = al.getAlignmentAnnotation().length;
List<JvAnnotRow> reorder = new ArrayList<>();
return false;
}
String id;
- if (skipList.containsKey(id = object.getJalviewModelSequence()
- .getViewport()[0].getSequenceSetId()))
+ if (skipList.containsKey(
+ id = object.getJalviewModelSequence().getViewport()[0]
+ .getSequenceSetId()))
{
if (Cache.log != null && Cache.log.isDebugEnabled())
{
private void recoverDatasetFor(SequenceSet vamsasSet, AlignmentI al,
boolean ignoreUnrefed)
{
- jalview.datamodel.AlignmentI ds = getDatasetFor(vamsasSet
- .getDatasetId());
+ jalview.datamodel.AlignmentI ds = getDatasetFor(
+ vamsasSet.getDatasetId());
Vector dseqs = null;
if (ds == null)
{
}
// TODO: merges will never happen if we 'know' we have the real dataset
// sequence - this should be detected when id==dssid
- System.err
- .println("DEBUG Notice: Merged dataset sequence (if you see this often, post at http://issues.jalview.org/browse/JAL-1474)"); // ("
+ System.err.println(
+ "DEBUG Notice: Merged dataset sequence (if you see this often, post at http://issues.jalview.org/browse/JAL-1474)"); // ("
// + (pre ? "prepended" : "") + " "
// + (post ? "appended" : ""));
}
{
DBRef dr = sequence.getDBRef(d);
jalview.datamodel.DBRefEntry entry = new jalview.datamodel.DBRefEntry(
- sequence.getDBRef(d).getSource(), sequence.getDBRef(d)
- .getVersion(), sequence.getDBRef(d).getAccessionId());
+ sequence.getDBRef(d).getSource(),
+ sequence.getDBRef(d).getVersion(),
+ sequence.getDBRef(d).getAccessionId());
if (dr.getMapping() != null)
{
entry.setMap(addMapping(dr.getMapping()));
fto[_i] = mf.getStart();
fto[_i + 1] = mf.getEnd();
}
- jalview.datamodel.Mapping jmap = new jalview.datamodel.Mapping(dsto,
- fr, fto, (int) m.getMapFromUnit(), (int) m.getMapToUnit());
+ jalview.datamodel.Mapping jmap = new jalview.datamodel.Mapping(dsto, fr,
+ fto, (int) m.getMapFromUnit(), (int) m.getMapToUnit());
if (m.getMappingChoice() != null)
{
MappingChoice mc = m.getMappingChoice();
}
else
{
- System.err
- .println("Warning - making up dataset sequence id for DbRef sequence map reference");
+ System.err.println(
+ "Warning - making up dataset sequence id for DbRef sequence map reference");
sqid = ((Object) ms).toString(); // make up a new hascode for
// undefined dataset sequence hash
// (unlikely to happen)
}
- public jalview.gui.AlignmentPanel copyAlignPanel(AlignmentPanel ap,
- boolean keepSeqRefs)
+ /**
+ * Provides a 'copy' of an alignment view (on action New View) by 'saving' the
+ * view as XML (but not to file), and then reloading it
+ *
+ * @param ap
+ * @return
+ */
+ public AlignmentPanel copyAlignPanel(AlignmentPanel ap)
{
initSeqRefs();
JalviewModel jm = saveState(ap, null, null, null);
- if (!keepSeqRefs)
- {
- clearSeqRefs();
- jm.getJalviewModelSequence().getViewport(0).setSequenceSetId(null);
- }
- else
- {
- uniqueSetSuffix = "";
- jm.getJalviewModelSequence().getViewport(0).setId(null); // we don't
- // overwrite the
- // view we just
- // copied
- }
+ uniqueSetSuffix = "";
+ jm.getJalviewModelSequence().getViewport(0).setId(null);
+ // we don't overwrite the view we just copied
+
if (this.frefedSequence == null)
{
- frefedSequence = new Vector();
+ frefedSequence = new Vector<>();
}
viewportsAdded.clear();
return af.alignPanel;
}
- /**
- * flag indicating if hashtables should be cleared on finalization TODO this
- * flag may not be necessary
- */
- private final boolean _cleartables = true;
-
private Hashtable jvids2vobj;
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#finalize()
- */
- @Override
- protected void finalize() throws Throwable
- {
- // really make sure we have no buried refs left.
- if (_cleartables)
- {
- clearSeqRefs();
- }
- this.seqRefIds = null;
- this.seqsToIds = null;
- super.finalize();
- }
-
private void warn(String msg)
{
warn(msg, null);
{
return counter++;
}
+
+ /**
+ * Populates an XML model of the feature colour scheme for one feature type
+ *
+ * @param featureType
+ * @param fcol
+ * @return
+ */
+ protected static jalview.schemabinding.version2.Colour marshalColour(
+ String featureType, FeatureColourI fcol)
+ {
+ jalview.schemabinding.version2.Colour col = new jalview.schemabinding.version2.Colour();
+ if (fcol.isSimpleColour())
+ {
+ col.setRGB(Format.getHexString(fcol.getColour()));
+ }
+ else
+ {
+ col.setRGB(Format.getHexString(fcol.getMaxColour()));
+ col.setMin(fcol.getMin());
+ col.setMax(fcol.getMax());
+ col.setMinRGB(jalview.util.Format.getHexString(fcol.getMinColour()));
+ col.setAutoScale(fcol.isAutoScaled());
+ col.setThreshold(fcol.getThreshold());
+ col.setColourByLabel(fcol.isColourByLabel());
+ col.setThreshType(fcol.isAboveThreshold() ? ColourThreshTypeType.ABOVE
+ : (fcol.isBelowThreshold() ? ColourThreshTypeType.BELOW
+ : ColourThreshTypeType.NONE));
+ if (fcol.isColourByAttribute())
+ {
+ col.setAttributeName(fcol.getAttributeName());
+ }
+ Color noColour = fcol.getNoColour();
+ if (noColour == null)
+ {
+ col.setNoValueColour(NoValueColour.NONE);
+ }
+ else if (noColour == fcol.getMaxColour())
+ {
+ col.setNoValueColour(NoValueColour.MAX);
+ }
+ else
+ {
+ col.setNoValueColour(NoValueColour.MIN);
+ }
+ }
+ col.setName(featureType);
+ return col;
+ }
+
+ /**
+ * Populates an XML model of the feature filter(s) for one feature type
+ *
+ * @param firstMatcher
+ * the first (or only) match condition)
+ * @param filter
+ * remaining match conditions (if any)
+ * @param and
+ * if true, conditions are and-ed, else or-ed
+ */
+ protected static MatcherSet marshalFilter(FeatureMatcherI firstMatcher,
+ Iterator<FeatureMatcherI> filters, boolean and)
+ {
+ MatcherSet result = new MatcherSet();
+
+ if (filters.hasNext())
+ {
+ /*
+ * compound matcher
+ */
+ CompoundMatcher compound = new CompoundMatcher();
+ compound.setAnd(and);
+ MatcherSet matcher1 = marshalFilter(firstMatcher,
+ Collections.emptyIterator(), and);
+ compound.addMatcherSet(matcher1);
+ FeatureMatcherI nextMatcher = filters.next();
+ MatcherSet matcher2 = marshalFilter(nextMatcher, filters, and);
+ compound.addMatcherSet(matcher2);
+ result.setCompoundMatcher(compound);
+ }
+ else
+ {
+ /*
+ * single condition matcher
+ */
+ MatchCondition matcherModel = new MatchCondition();
+ matcherModel.setCondition(
+ firstMatcher.getMatcher().getCondition().getStableName());
+ matcherModel.setValue(firstMatcher.getMatcher().getPattern());
+ if (firstMatcher.isByAttribute())
+ {
+ matcherModel.setBy(FeatureMatcherByType.BYATTRIBUTE);
+ matcherModel.setAttributeName(firstMatcher.getAttribute());
+ }
+ else if (firstMatcher.isByLabel())
+ {
+ matcherModel.setBy(FeatureMatcherByType.BYLABEL);
+ }
+ else if (firstMatcher.isByScore())
+ {
+ matcherModel.setBy(FeatureMatcherByType.BYSCORE);
+ }
+ result.setMatchCondition(matcherModel);
+ }
+
+ return result;
+ }
+
+ /**
+ * Loads one XML model of a feature filter to a Jalview object
+ *
+ * @param featureType
+ * @param matcherSetModel
+ * @return
+ */
+ protected static FeatureMatcherSetI unmarshalFilter(
+ String featureType, MatcherSet matcherSetModel)
+ {
+ FeatureMatcherSetI result = new FeatureMatcherSet();
+ try
+ {
+ unmarshalFilterConditions(result, matcherSetModel, true);
+ } catch (IllegalStateException e)
+ {
+ // mixing AND and OR conditions perhaps
+ System.err.println(
+ String.format("Error reading filter conditions for '%s': %s",
+ featureType, e.getMessage()));
+ // return as much as was parsed up to the error
+ }
+
+ return result;
+ }
+
+ /**
+ * Adds feature match conditions to matcherSet as unmarshalled from XML
+ * (possibly recursively for compound conditions)
+ *
+ * @param matcherSet
+ * @param matcherSetModel
+ * @param and
+ * if true, multiple conditions are AND-ed, else they are OR-ed
+ * @throws IllegalStateException
+ * if AND and OR conditions are mixed
+ */
+ protected static void unmarshalFilterConditions(
+ FeatureMatcherSetI matcherSet, MatcherSet matcherSetModel,
+ boolean and)
+ {
+ MatchCondition mc = matcherSetModel.getMatchCondition();
+ if (mc != null)
+ {
+ /*
+ * single condition
+ */
+ FeatureMatcherByType filterBy = mc.getBy();
+ Condition cond = Condition.fromString(mc.getCondition());
+ String pattern = mc.getValue();
+ FeatureMatcherI matchCondition = null;
+ if (filterBy == FeatureMatcherByType.BYLABEL)
+ {
+ matchCondition = FeatureMatcher.byLabel(cond, pattern);
+ }
+ else if (filterBy == FeatureMatcherByType.BYSCORE)
+ {
+ matchCondition = FeatureMatcher.byScore(cond, pattern);
+
+ }
+ else if (filterBy == FeatureMatcherByType.BYATTRIBUTE)
+ {
+ String[] attNames = mc.getAttributeName();
+ matchCondition = FeatureMatcher.byAttribute(cond, pattern,
+ attNames);
+ }
+
+ /*
+ * note this throws IllegalStateException if AND-ing to a
+ * previously OR-ed compound condition, or vice versa
+ */
+ if (and)
+ {
+ matcherSet.and(matchCondition);
+ }
+ else
+ {
+ matcherSet.or(matchCondition);
+ }
+ }
+ else
+ {
+ /*
+ * compound condition
+ */
+ MatcherSet[] matchers = matcherSetModel.getCompoundMatcher()
+ .getMatcherSet();
+ boolean anded = matcherSetModel.getCompoundMatcher().getAnd();
+ if (matchers.length == 2)
+ {
+ unmarshalFilterConditions(matcherSet, matchers[0], anded);
+ unmarshalFilterConditions(matcherSet, matchers[1], anded);
+ }
+ else
+ {
+ System.err.println("Malformed compound filter condition");
+ }
+ }
+ }
+
+ /**
+ * Loads one XML model of a feature colour to a Jalview object
+ *
+ * @param colourModel
+ * @return
+ */
+ protected static FeatureColourI unmarshalColour(
+ jalview.schemabinding.version2.Colour colourModel)
+ {
+ FeatureColourI colour = null;
+
+ if (colourModel.hasMax())
+ {
+ Color mincol = null;
+ Color maxcol = null;
+ Color noValueColour = null;
+
+ try
+ {
+ mincol = new Color(Integer.parseInt(colourModel.getMinRGB(), 16));
+ maxcol = new Color(Integer.parseInt(colourModel.getRGB(), 16));
+ } catch (Exception e)
+ {
+ Cache.log.warn("Couldn't parse out graduated feature color.", e);
+ }
+
+ NoValueColour noCol = colourModel.getNoValueColour();
+ if (noCol == NoValueColour.MIN)
+ {
+ noValueColour = mincol;
+ }
+ else if (noCol == NoValueColour.MAX)
+ {
+ noValueColour = maxcol;
+ }
+
+ colour = new FeatureColour(mincol, maxcol, noValueColour,
+ colourModel.getMin(),
+ colourModel.getMax());
+ String[] attributes = colourModel.getAttributeName();
+ if (attributes != null && attributes.length > 0)
+ {
+ colour.setAttributeName(attributes);
+ }
+ if (colourModel.hasAutoScale())
+ {
+ colour.setAutoScaled(colourModel.getAutoScale());
+ }
+ if (colourModel.hasColourByLabel())
+ {
+ colour.setColourByLabel(colourModel.getColourByLabel());
+ }
+ if (colourModel.hasThreshold())
+ {
+ colour.setThreshold(colourModel.getThreshold());
+ }
+ ColourThreshTypeType ttyp = colourModel.getThreshType();
+ if (ttyp != null)
+ {
+ if (ttyp == ColourThreshTypeType.ABOVE)
+ {
+ colour.setAboveThreshold(true);
+ }
+ else if (ttyp == ColourThreshTypeType.BELOW)
+ {
+ colour.setBelowThreshold(true);
+ }
+ }
+ }
+ else
+ {
+ Color color = new Color(Integer.parseInt(colourModel.getRGB(), 16));
+ colour = new FeatureColour(color);
+ }
+
+ return colour;
+ }
}