X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fdatamodel%2FSequenceGroup.java;h=0431708b7344400a3e7433313ae6f71cbd36e5e7;hb=ceba202c97c435a5a0f70307961ba74316bd8312;hp=cd2b1372b8635c2da2168dd65860719f2af70df2;hpb=b56ffac9f141b738ffcd5112ae305d21a1ade024;p=jalview.git diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index cd2b137..0431708 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -48,64 +48,82 @@ public class SequenceGroup implements AnnotatedCollectionI // a subclass of ViewportProperties similarly to ViewportRanges. // Done here as a quick fix for JAL-2665 public static final String SEQ_GROUP_CHANGED = "Sequence group changed"; + + protected PropertyChangeSupport changeSupport = new PropertyChangeSupport( + this); - private String groupName; + public void addPropertyChangeListener(PropertyChangeListener listener) + { + changeSupport.addPropertyChangeListener(listener); + } - private String description; + public void removePropertyChangeListener(PropertyChangeListener listener) + { + changeSupport.removePropertyChangeListener(listener); + } + // end of event notification functionality initialisation - private AnnotatedCollectionI context; + String groupName; - private Conservation conservationData; + String description; + + Conservation conserve; - private ProfilesI consensusProfiles; + Conservation conservationData; - private ProfilesI hmmProfiles; + ProfilesI consensusProfiles; - private boolean displayBoxes = true; + ProfilesI hmmProfiles; - private boolean displayText = true; + boolean displayBoxes = true; - private boolean colourText = false; + boolean displayText = true; + + boolean colourText = false; /* * true if the group is defined as a group on the alignment, false if it is * just a selection */ - private boolean isDefined; + boolean isDefined = false; /* * after Olivier's non-conserved only character display */ - private boolean showNonconserved; + boolean showNonconserved = false; /* * sequences in the group */ - private List sequences = new ArrayList<>(); + private List sequences; /* * representative sequence for this group (if any) */ - private SequenceI seqrep; + private SequenceI seqrep = null; - private int width = -1; + int width = -1; /* * colour scheme applied to group if any */ public ResidueShaderI cs; - // start column (base 0) - private int startRes; + /** + * start column (base 0) + */ + private int startRes = 0; - // end column (base 0) - private int endRes; + /** + * end column (base 0) + */ + private int endRes = 0; public Color outlineColour = Color.black; - public Color idColour; + public Color idColour = null; - public int thresholdTextColour; + public int thresholdTextColour = 0; public Color textColour = Color.black; @@ -116,12 +134,10 @@ public class SequenceGroup implements AnnotatedCollectionI */ private boolean ignoreGapsInConsensus = true; - private boolean showSequenceLogo; + private boolean showSequenceLogo = false; private boolean normaliseSequenceLogo; - private boolean showConsensusHistogram; - /* * properties for HMM information annotation */ @@ -138,18 +154,23 @@ public class SequenceGroup implements AnnotatedCollectionI /* * visibility of rows or represented rows covered by group */ - private boolean hidereps; + private boolean hidereps = false; /* * visibility of columns intersecting this group */ private boolean hidecols; - private AlignmentAnnotation consensus; + AlignmentAnnotation consensus = null; - private AlignmentAnnotation conservation; + AlignmentAnnotation conservation = null; private AlignmentAnnotation hmmInformation; + + private boolean showConsensusHistogram; + + private AnnotatedCollectionI context; + /** * Constructor, assigning a generated default name of "JGroup:" with object @@ -159,6 +180,7 @@ public class SequenceGroup implements AnnotatedCollectionI { groupName = "JGroup:" + this.hashCode(); cs = new ResidueShader(); + sequences = new ArrayList<>(); } /** @@ -195,10 +217,13 @@ public class SequenceGroup implements AnnotatedCollectionI * copy constructor * * @param seqsel + * @param keepsequences + * if false do not add sequences from seqsel to new instance */ public SequenceGroup(SequenceGroup seqsel) { this(); + if (seqsel != null) { sequences = new ArrayList<>(); @@ -210,6 +235,7 @@ public class SequenceGroup implements AnnotatedCollectionI displayBoxes = seqsel.displayBoxes; displayText = seqsel.displayText; colourText = seqsel.colourText; + startRes = seqsel.startRes; endRes = seqsel.endRes; cs = new ResidueShader((ResidueShader) seqsel.cs); @@ -236,25 +262,25 @@ public class SequenceGroup implements AnnotatedCollectionI ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus; hmmIgnoreBelowBackground = seqsel.hmmIgnoreBelowBackground; hmmUseInfoLetterHeight = seqsel.hmmUseInfoLetterHeight; - if (seqsel.conservationData != null) + if (seqsel.conserve != null) { + // todo avoid doing this if we don't actually want derived calculations + // ! recalcConservation(); // safer than // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ?? } } } - protected PropertyChangeSupport changeSupport = new PropertyChangeSupport( - this); - - public void addPropertyChangeListener(PropertyChangeListener listener) - { - changeSupport.addPropertyChangeListener(listener); - } - - public void removePropertyChangeListener(PropertyChangeListener listener) + /** + * Constructor that copies the given list of sequences + * + * @param seqs + */ + public SequenceGroup(List seqs) { - changeSupport.removePropertyChangeListener(listener); + this(); + this.sequences.addAll(seqs); } public boolean isShowSequenceLogo() @@ -262,8 +288,7 @@ public class SequenceGroup implements AnnotatedCollectionI return showSequenceLogo; } - public SequenceI[] getSelectionAsNewSequences(AlignmentI align, - boolean copyAnnotation) + public SequenceI[] getSelectionAsNewSequences(AlignmentI align) { int iSize = sequences.size(); SequenceI[] seqs = new SequenceI[iSize]; @@ -272,13 +297,18 @@ public class SequenceGroup implements AnnotatedCollectionI for (int i = 0, ipos = 0; i < inorder.length; i++) { SequenceI seq = inorder[i]; - - seqs[ipos] = seq.getSubSequence(startRes, endRes + 1); - if (seqs[ipos] != null) + SequenceI seqipos = seqs[ipos] = seq.getSubSequence(startRes, endRes + 1); + if (seqipos != null) { - seqs[ipos].setDescription(seq.getDescription()); + seqipos.setDescription(seq.getDescription()); + seqipos.setDBRefs(seq.getDBRefs()); + seqipos.setSequenceFeatures(seq.getSequenceFeatures()); + if (seq.getDatasetSequence() != null) + { + seqipos.setDatasetSequence(seq.getDatasetSequence()); + } - if (seq.getAnnotation() != null && copyAnnotation) + if (seq.getAnnotation() != null) { AlignmentAnnotation[] alann = align.getAlignmentAnnotation(); // Only copy annotation that is either a score or referenced by the @@ -289,7 +319,7 @@ public class SequenceGroup implements AnnotatedCollectionI if (alann != null) { boolean found = false; - for (int pos = 0; pos < alann.length; pos++) + for (int pos = 0, np = alann.length; pos < np; pos++) { if (alann[pos] == tocopy) { @@ -307,7 +337,7 @@ public class SequenceGroup implements AnnotatedCollectionI newannot.restrict(startRes, endRes); newannot.setSequenceRef(seqs[ipos]); newannot.adjustForAlignment(); - seqs[ipos].addAlignmentAnnotation(newannot); + seqipos.addAlignmentAnnotation(newannot); } } ipos++; @@ -502,7 +532,7 @@ public class SequenceGroup implements AnnotatedCollectionI */ public Conservation getConservation() { - return conservationData; + return conserve; } /** @@ -513,7 +543,7 @@ public class SequenceGroup implements AnnotatedCollectionI */ public void setConservation(Conservation c) { - conservationData = c; + conserve = c; } /** @@ -574,7 +604,7 @@ public class SequenceGroup implements AnnotatedCollectionI */ public boolean recalcConservation() { - return recalcAnnotations(false); + return recalcConservation(false); } /** @@ -586,7 +616,7 @@ public class SequenceGroup implements AnnotatedCollectionI * when set, colourschemes for this group are not refreshed after * recalculation */ - public boolean recalcAnnotations(boolean defer) + public boolean recalcConservation(boolean defer) { if (cs == null && consensus == null && conservation == null && hmmInformation == null) @@ -682,6 +712,8 @@ public class SequenceGroup implements AnnotatedCollectionI c.completeAnnotations(conservation, null, startRes, endRes + 1); } + public ProfilesI consensusData = null; + private void _updateConsensusRow(ProfilesI cnsns, long nseq) { if (consensus == null) @@ -690,7 +722,7 @@ public class SequenceGroup implements AnnotatedCollectionI } consensus.label = "Consensus for " + getName(); consensus.description = "Percent Identity"; - consensusProfiles = cnsns; + consensusData = cnsns; // preserve width if already set int aWidth = (consensus.annotations != null) ? (endRes < consensus.annotations.length @@ -803,13 +835,16 @@ public class SequenceGroup implements AnnotatedCollectionI /** * Set the first column selected by this group. Runs from 0<=i