X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FSequenceGroup.java;h=cffe0d9208fe0ce0382069e98850a97f6c7e9033;hb=3490e38574052242c9440d162a427f7c59234a0a;hp=b7ec9f95da131f0803a0ff70acf4238d36ea1216;hpb=4306800413a28da102c15fe7301bcac7816445fe;p=jalview.git diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index b7ec9f9..cffe0d9 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -88,11 +88,6 @@ public class SequenceGroup implements AnnotatedCollectionI */ private SequenceI seqrep; - /* - * HMM consensus sequence for group (if any) - */ - private SequenceI hmmConsensus; - private int width = -1; /* @@ -134,7 +129,7 @@ public class SequenceGroup implements AnnotatedCollectionI private boolean hmmUseInfoLetterHeight; - private boolean showHMMSequenceLogo; + private boolean hmmShowSequenceLogo; private boolean hmmNormaliseSequenceLogo; @@ -203,11 +198,27 @@ public class SequenceGroup implements AnnotatedCollectionI */ public SequenceGroup(SequenceGroup seqsel) { + this(seqsel, true); + } + + /** + * copy constructor + * + * @param seqsel + * @param keepsequences + * if false do not add sequences from seqsel to new instance + */ + public SequenceGroup(SequenceGroup seqsel, boolean keepsequences) + { this(); + if (seqsel != null) { sequences = new ArrayList<>(); - sequences.addAll(seqsel.sequences); + if (keepsequences) + { + sequences.addAll(seqsel.sequences); + } if (seqsel.groupName != null) { groupName = new String(seqsel.groupName); @@ -228,7 +239,7 @@ public class SequenceGroup implements AnnotatedCollectionI showSequenceLogo = seqsel.showSequenceLogo; normaliseSequenceLogo = seqsel.normaliseSequenceLogo; showConsensusHistogram = seqsel.showConsensusHistogram; - showHMMSequenceLogo = seqsel.showHMMSequenceLogo; + hmmShowSequenceLogo = seqsel.hmmShowSequenceLogo; hmmNormaliseSequenceLogo = seqsel.hmmNormaliseSequenceLogo; hmmShowHistogram = seqsel.hmmShowHistogram; idColour = seqsel.idColour; @@ -241,8 +252,10 @@ public class SequenceGroup implements AnnotatedCollectionI ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus; hmmIgnoreBelowBackground = seqsel.hmmIgnoreBelowBackground; hmmUseInfoLetterHeight = seqsel.hmmUseInfoLetterHeight; - if (seqsel.conservationData != null) + if (keepsequences && seqsel.conservationData != null) { + // todo avoid doing this if we don't actually want derived calculations + // ! recalcConservation(); // safer than // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ?? } @@ -267,7 +280,8 @@ public class SequenceGroup implements AnnotatedCollectionI return showSequenceLogo; } - public SequenceI[] getSelectionAsNewSequences(AlignmentI align) + public SequenceI[] getSelectionAsNewSequences(AlignmentI align, + boolean copyAnnotation) { int iSize = sequences.size(); SequenceI[] seqs = new SequenceI[iSize]; @@ -281,15 +295,8 @@ public class SequenceGroup implements AnnotatedCollectionI if (seqs[ipos] != null) { seqs[ipos].setDescription(seq.getDescription()); - seqs[ipos].setDBRefs(seq.getDBRefs()); - seqs[ipos].setSequenceFeatures(seq.getSequenceFeatures()); - seqs[ipos].setIsHMMConsensusSequence(seq.isHMMConsensusSequence()); - if (seq.getDatasetSequence() != null) - { - seqs[ipos].setDatasetSequence(seq.getDatasetSequence()); - } - if (seq.getAnnotation() != null) + if (seq.getAnnotation() != null && copyAnnotation) { AlignmentAnnotation[] alann = align.getAlignmentAnnotation(); // Only copy annotation that is either a score or referenced by the @@ -617,9 +624,8 @@ public class SequenceGroup implements AnnotatedCollectionI ProfilesI info = AAFrequency.calculateHMMProfiles(hmm, (endRes + 1) - startRes, startRes, endRes + 1, - showHMMSequenceLogo, hmmIgnoreBelowBackground, - hmmUseInfoLetterHeight); - _updateInformationRow(info, sequences.size()); + hmmIgnoreBelowBackground, hmmUseInfoLetterHeight); + _updateInformationRow(info); upd = true; } if (consensus != null) @@ -720,12 +726,11 @@ public class SequenceGroup implements AnnotatedCollectionI } /** - * Recalculates the information content on the HMM annotation. + * Recalculates the information content on the HMM annotation * * @param cnsns - * @param nseq */ - private void _updateInformationRow(ProfilesI cnsns, long nseq) + private void _updateInformationRow(ProfilesI cnsns) { if (hmmInformation == null) { @@ -744,7 +749,7 @@ public class SequenceGroup implements AnnotatedCollectionI // width hmmInformation.setCalcId(InformationThread.HMM_CALC_ID); AAFrequency.completeInformation(hmmInformation, cnsns, startRes, - endRes + 1, nseq, 0f); + endRes + 1); } /** @@ -1580,18 +1585,16 @@ public class SequenceGroup implements AnnotatedCollectionI // recalcConservation(); TODO don't know what to do here next } this.hmmShowHistogram = state; - } public boolean isShowHMMSequenceLogo() { - return showHMMSequenceLogo; + return hmmShowSequenceLogo; } - public void setshowHMMSequenceLogo(boolean state) + public void setShowHMMSequenceLogo(boolean state) { - showHMMSequenceLogo = state; - + hmmShowSequenceLogo = state; } public boolean isNormaliseHMMSequenceLogo() @@ -1601,19 +1604,7 @@ public class SequenceGroup implements AnnotatedCollectionI public void setNormaliseHMMSequenceLogo(boolean state) { - normaliseSequenceLogo = state; - } - - @Override - public SequenceI getHmmConsensus() - { - return hmmConsensus; - } - - @Override - public void setHmmConsensus(SequenceI hmmSeq) - { - this.hmmConsensus = hmmSeq; + hmmNormaliseSequenceLogo = state; } public ProfilesI getConsensusData() @@ -1631,4 +1622,19 @@ public class SequenceGroup implements AnnotatedCollectionI this.hmmProfiles = hmmProfiles; } + @Override + public List getHmmSequences() + { + List result = new ArrayList<>(); + for (int i = 0; i < sequences.size(); i++) + { + SequenceI seq = sequences.get(i); + if (seq.hasHMMProfile()) + { + result.add(seq); + } + } + return result; + } + }