git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-3878 update branch from 2.12 merge from 2.11.2
[jalview.git]
/
src
/
jalview
/
datamodel
/
SequenceGroup.java
diff --git
a/src/jalview/datamodel/SequenceGroup.java
b/src/jalview/datamodel/SequenceGroup.java
index
cffe0d9
..
0a68792
100755
(executable)
--- 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";
// 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);
+
+ public void addPropertyChangeListener(PropertyChangeListener listener)
+ {
+ changeSupport.addPropertyChangeListener(listener);
+ }
- private String groupName;
+ public void removePropertyChangeListener(PropertyChangeListener listener)
+ {
+ changeSupport.removePropertyChangeListener(listener);
+ }
+ // end of event notification functionality initialisation
- private String description;
+ String groupName;
- private AnnotatedCollectionI context;
+ String description;
+
+ Conservation conserve;
- private Conservation conservationData;
+ Conservation conservationData;
- private ProfilesI consensusProfiles;
+ ProfilesI consensusProfiles;
- private ProfilesI hmmProfiles;
+ ProfilesI hmmProfiles;
- private boolean displayBoxes = true;
+ boolean displayBoxes = true;
- private boolean displayText = true;
+ boolean displayText = true;
- private boolean colourText = false;
+ boolean colourText = false;
/*
* true if the group is defined as a group on the alignment, false if it is
* just a selection
*/
/*
* 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
*/
/*
* after Olivier's non-conserved only character display
*/
- private boolean showNonconserved;
+ boolean showNonconserved = false;
/*
* sequences in the group
*/
/*
* sequences in the group
*/
- private List<SequenceI> sequences = new ArrayList<>();
+ private List<SequenceI> sequences;
/*
* representative sequence for this group (if any)
*/
/*
* 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;
/*
* 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 outlineColour = Color.black;
- public Color idColour;
+ public Color idColour = null;
- public int thresholdTextColour;
+ public int thresholdTextColour = 0;
public Color textColour = Color.black;
public Color textColour = Color.black;
@@
-116,12
+134,10
@@
public class SequenceGroup implements AnnotatedCollectionI
*/
private boolean ignoreGapsInConsensus = true;
*/
private boolean ignoreGapsInConsensus = true;
- private boolean showSequenceLogo;
+ private boolean showSequenceLogo = false;
private boolean normaliseSequenceLogo;
private boolean normaliseSequenceLogo;
- private boolean showConsensusHistogram;
-
/*
* properties for HMM information annotation
*/
/*
* properties for HMM information annotation
*/
@@
-138,18
+154,23
@@
public class SequenceGroup implements AnnotatedCollectionI
/*
* visibility of rows or represented rows covered by group
*/
/*
* 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;
/*
* 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 AlignmentAnnotation hmmInformation;
+
+ private boolean showConsensusHistogram;
+
+ private AnnotatedCollectionI context;
+
/**
* Constructor, assigning a generated default name of "JGroup:" with object
/**
* 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();
{
groupName = "JGroup:" + this.hashCode();
cs = new ResidueShader();
+ sequences = new ArrayList<>();
}
/**
}
/**
@@
-195,30
+217,17
@@
public class SequenceGroup implements AnnotatedCollectionI
* copy constructor
*
* @param seqsel
* copy constructor
*
* @param seqsel
- */
- public SequenceGroup(SequenceGroup seqsel)
- {
- this(seqsel, true);
- }
-
- /**
- * copy constructor
- *
- * @param seqsel
* @param keepsequences
* if false do not add sequences from seqsel to new instance
*/
* @param keepsequences
* if false do not add sequences from seqsel to new instance
*/
- public SequenceGroup(SequenceGroup seqsel, boolean keepsequences)
+ public SequenceGroup(SequenceGroup seqsel)
{
this();
if (seqsel != null)
{
sequences = new ArrayList<>();
{
this();
if (seqsel != null)
{
sequences = new ArrayList<>();
- if (keepsequences)
- {
- sequences.addAll(seqsel.sequences);
- }
+ sequences.addAll(seqsel.sequences);
if (seqsel.groupName != null)
{
groupName = new String(seqsel.groupName);
if (seqsel.groupName != null)
{
groupName = new String(seqsel.groupName);
@@
-226,6
+235,7
@@
public class SequenceGroup implements AnnotatedCollectionI
displayBoxes = seqsel.displayBoxes;
displayText = seqsel.displayText;
colourText = seqsel.colourText;
displayBoxes = seqsel.displayBoxes;
displayText = seqsel.displayText;
colourText = seqsel.colourText;
+
startRes = seqsel.startRes;
endRes = seqsel.endRes;
cs = new ResidueShader((ResidueShader) seqsel.cs);
startRes = seqsel.startRes;
endRes = seqsel.endRes;
cs = new ResidueShader((ResidueShader) seqsel.cs);
@@
-252,7
+262,7
@@
public class SequenceGroup implements AnnotatedCollectionI
ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
hmmIgnoreBelowBackground = seqsel.hmmIgnoreBelowBackground;
hmmUseInfoLetterHeight = seqsel.hmmUseInfoLetterHeight;
ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus;
hmmIgnoreBelowBackground = seqsel.hmmIgnoreBelowBackground;
hmmUseInfoLetterHeight = seqsel.hmmUseInfoLetterHeight;
- if (keepsequences && seqsel.conservationData != null)
+ if (seqsel.conserve != null)
{
// todo avoid doing this if we don't actually want derived calculations
// !
{
// todo avoid doing this if we don't actually want derived calculations
// !
@@
-262,17
+272,15
@@
public class SequenceGroup implements AnnotatedCollectionI
}
}
}
}
- 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<SequenceI> seqs)
{
{
- changeSupport.removePropertyChangeListener(listener);
+ this();
+ this.sequences.addAll(seqs);
}
public boolean isShowSequenceLogo()
}
public boolean isShowSequenceLogo()
@@
-280,8
+288,7
@@
public class SequenceGroup implements AnnotatedCollectionI
return showSequenceLogo;
}
return showSequenceLogo;
}
- public SequenceI[] getSelectionAsNewSequences(AlignmentI align,
- boolean copyAnnotation)
+ public SequenceI[] getSelectionAsNewSequences(AlignmentI align)
{
int iSize = sequences.size();
SequenceI[] seqs = new SequenceI[iSize];
{
int iSize = sequences.size();
SequenceI[] seqs = new SequenceI[iSize];
@@
-290,13
+297,19
@@
public class SequenceGroup implements AnnotatedCollectionI
for (int i = 0, ipos = 0; i < inorder.length; i++)
{
SequenceI seq = inorder[i];
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
{
AlignmentAnnotation[] alann = align.getAlignmentAnnotation();
// Only copy annotation that is either a score or referenced by the
@@
-307,7
+320,7
@@
public class SequenceGroup implements AnnotatedCollectionI
if (alann != null)
{
boolean found = false;
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)
{
{
if (alann[pos] == tocopy)
{
@@
-325,7
+338,7
@@
public class SequenceGroup implements AnnotatedCollectionI
newannot.restrict(startRes, endRes);
newannot.setSequenceRef(seqs[ipos]);
newannot.adjustForAlignment();
newannot.restrict(startRes, endRes);
newannot.setSequenceRef(seqs[ipos]);
newannot.adjustForAlignment();
- seqs[ipos].addAlignmentAnnotation(newannot);
+ seqipos.addAlignmentAnnotation(newannot);
}
}
ipos++;
}
}
ipos++;
@@
-520,7
+533,7
@@
public class SequenceGroup implements AnnotatedCollectionI
*/
public Conservation getConservation()
{
*/
public Conservation getConservation()
{
- return conservationData;
+ return conserve;
}
/**
}
/**
@@
-531,7
+544,7
@@
public class SequenceGroup implements AnnotatedCollectionI
*/
public void setConservation(Conservation c)
{
*/
public void setConservation(Conservation c)
{
- conservationData = c;
+ conserve = c;
}
/**
}
/**
@@
-592,7
+605,7
@@
public class SequenceGroup implements AnnotatedCollectionI
*/
public boolean recalcConservation()
{
*/
public boolean recalcConservation()
{
- return recalcAnnotations(false);
+ return recalcConservation(false);
}
/**
}
/**
@@
-604,7
+617,7
@@
public class SequenceGroup implements AnnotatedCollectionI
* when set, colourschemes for this group are not refreshed after
* recalculation
*/
* 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)
{
if (cs == null && consensus == null && conservation == null
&& hmmInformation == null)
@@
-700,6
+713,8
@@
public class SequenceGroup implements AnnotatedCollectionI
c.completeAnnotations(conservation, null, startRes, endRes + 1);
}
c.completeAnnotations(conservation, null, startRes, endRes + 1);
}
+ public ProfilesI consensusData = null;
+
private void _updateConsensusRow(ProfilesI cnsns, long nseq)
{
if (consensus == null)
private void _updateConsensusRow(ProfilesI cnsns, long nseq)
{
if (consensus == null)
@@
-708,7
+723,7
@@
public class SequenceGroup implements AnnotatedCollectionI
}
consensus.label = "Consensus for " + getName();
consensus.description = "Percent Identity";
}
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
// preserve width if already set
int aWidth = (consensus.annotations != null)
? (endRes < consensus.annotations.length
@@
-821,13
+836,15
@@
public class SequenceGroup implements AnnotatedCollectionI
/**
* Set the first column selected by this group. Runs from 0<=i<N_cols
*
/**
* Set the first column selected by this group. Runs from 0<=i<N_cols
*
- * @param i
+ * @param newStart
*/
*/
- public void setStartRes(int i)
+ public void setStartRes(int newStart)
{
int before = startRes;
{
int before = startRes;
- startRes = i;
+ startRes = Math.max(0, newStart); // sanity check for negative start column
+ // positions
changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
changeSupport.firePropertyChange(SEQ_GROUP_CHANGED, before, startRes);
+
}
/**
}
/**
@@
-1303,7
+1320,7
@@
public class SequenceGroup implements AnnotatedCollectionI
ignoreGapsInConsensus = state;
}
ignoreGapsInConsensus = state;
}
- public boolean isIgnoreGapsConsensus()
+ public boolean getIgnoreGapsConsensus()
{
return ignoreGapsInConsensus;
}
{
return ignoreGapsInConsensus;
}