import jalview.analysis.AAFrequency;
import jalview.analysis.Conservation;
+import jalview.renderer.ResidueShader;
+import jalview.renderer.ResidueShaderI;
import jalview.schemes.ColourSchemeI;
import java.awt.Color;
import java.util.ArrayList;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
/**
* Collects a set contiguous ranges on a set of sequences
Conservation conserve;
- Vector aaFrequency;
-
boolean displayBoxes = true;
boolean displayText = true;
/**
* Colourscheme applied to group if any
*/
- public ColourSchemeI cs;
+ public ResidueShaderI cs;
// start column (base 0)
int startRes = 0;
public SequenceGroup()
{
groupName = "JGroup:" + this.hashCode();
+ cs = new ResidueShader();
}
/**
ColourSchemeI scheme, boolean displayBoxes, boolean displayText,
boolean colourText, int start, int end)
{
+ this();
this.sequences = sequences;
this.groupName = groupName;
this.displayBoxes = displayBoxes;
this.displayText = displayText;
this.colourText = colourText;
- this.cs = scheme;
+ this.cs = new ResidueShader(scheme);
startRes = start;
endRes = end;
recalcConservation();
*/
public SequenceGroup(SequenceGroup seqsel)
{
+ this();
if (seqsel != null)
{
sequences = new ArrayList<SequenceI>();
boolean upd = false;
try
{
- Hashtable cnsns[] = AAFrequency.calculate(sequences, startRes,
+ ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
endRes + 1, showSequenceLogo);
if (consensus != null)
{
if ((conservation != null)
|| (cs != null && cs.conservationApplied()))
{
- Conservation c = new Conservation(groupName, 3, sequences,
- startRes, endRes + 1);
+ Conservation c = new Conservation(groupName, sequences, startRes,
+ endRes + 1);
c.calculate();
c.verdict(false, consPercGaps);
if (conservation != null)
c.completeAnnotations(conservation, null, startRes, endRes + 1);
}
- public Hashtable[] consensusData = null;
+ public ProfilesI consensusData = null;
- private void _updateConsensusRow(Hashtable[] cnsns, long nseq)
+ private void _updateConsensusRow(ProfilesI cnsns, long nseq)
{
if (consensus == null)
{
@Override
public Iterable<AlignmentAnnotation> findAnnotation(String calcId)
{
- ArrayList<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
+ List<AlignmentAnnotation> aa = new ArrayList<AlignmentAnnotation>();
+ if (calcId == null)
+ {
+ return aa;
+ }
for (AlignmentAnnotation a : getAlignmentAnnotation())
{
- if (a.getCalcId() == calcId)
+ if (calcId.equals(a.getCalcId()))
{
aa.add(a);
}
private AnnotatedCollectionI context;
/**
- * set the alignment or group context for this group
+ * Sets the alignment or group context for this group
*
- * @param context
+ * @param ctx
+ * @throws IllegalArgumentException
+ * if setting the context would result in a circular reference chain
*/
- public void setContext(AnnotatedCollectionI context)
+ public void setContext(AnnotatedCollectionI ctx)
{
- this.context = context;
+ AnnotatedCollectionI ref = ctx;
+ while (ref != null)
+ {
+ if (ref == this)
+ {
+ throw new IllegalArgumentException(
+ "Circular reference in SequenceGroup.context");
+ }
+ ref = ref.getContext();
+ }
+ this.context = ctx;
}
/*
{
return context;
}
+
+ public void setColourScheme(ColourSchemeI scheme)
+ {
+ if (cs == null)
+ {
+ cs = new ResidueShader();
+ }
+ cs.setColourScheme(scheme);
+ }
+
+ public void setGroupColourScheme(ResidueShaderI scheme)
+ {
+ cs = scheme;
+ }
+
+ public ColourSchemeI getColourScheme()
+ {
+ return cs == null ? null : cs.getColourScheme();
+ }
+
+ public ResidueShaderI getGroupColourScheme()
+ {
+ return cs;
+ }
+
+ @Override
+ public boolean isNucleotide()
+ {
+ if (context != null) {
+ return context.isNucleotide();
+ }
+ return false;
+ }
+
+ /**
+ * @param seq
+ * @return true if seq is a member of the group
+ */
+
+ public boolean contains(SequenceI seq1)
+ {
+ return sequences.contains(seq1);
+ }
+
+ /**
+ * @param seq
+ * @param apos
+ * @return true if startRes<=apos and endRes>=apos and seq is in the group
+ */
+ public boolean contains(SequenceI seq, int apos)
+ {
+ return (startRes <= apos && endRes >= apos) && sequences.contains(seq);
+ }
}