X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fdatamodel%2FSequenceGroup.java;h=871e4cf5d9410603870e2020da3ad3388deb3dca;hb=c16c1633e1a5acc9f44e4de40b9abbb8a59b99b4;hp=bb075aacc819152065b97558424878b47c8eff23;hpb=0942955908d861c8f85b3c6f9825fbcc49eac371;p=jalview.git diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index bb075aa..871e4cf 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) - * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1) + * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -47,6 +47,11 @@ public class SequenceGroup boolean colourText = false; /** + * after Olivier's non-conserved only character display + */ + boolean showUnconserved = false; + + /** * group members */ private Vector sequences = new Vector(); @@ -75,6 +80,24 @@ public class SequenceGroup public Color textColour2 = Color.white; /** + * consensus calculation property + */ + private boolean ignoreGapsInConsensus=true; + /** + * consensus calculation property + */ + private boolean showConsensusProfile=false; + + /** + * @return the includeAllConsSymbols + */ + public boolean isIncludeAllConsSymbols() + { + return showConsensusProfile; + } + + + /** * Creates a new SequenceGroup object. */ public SequenceGroup() @@ -110,6 +133,48 @@ public class SequenceGroup endRes = end; recalcConservation(); } + /** + * copy constructor + * @param seqsel + */ + public SequenceGroup(SequenceGroup seqsel) + { + if (seqsel!=null) + { + sequences=new Vector(); + Enumeration sq = seqsel.sequences.elements(); + while (sq.hasMoreElements()) { + sequences.addElement(sq.nextElement()); + }; + if (seqsel.groupName!=null) + { + groupName = new String(seqsel.groupName); + } + displayBoxes = seqsel.displayBoxes; + displayText = seqsel.displayText; + colourText = seqsel.colourText; + startRes = seqsel.startRes; + endRes = seqsel.endRes; + cs =seqsel.cs; + if (seqsel.description!=null) + description = new String(seqsel.description); + hidecols = seqsel.hidecols; + hidereps = seqsel.hidereps; + idColour = seqsel.idColour; + outlineColour = seqsel.outlineColour; + seqrep = seqsel.seqrep; + textColour = seqsel.textColour; + textColour2 = seqsel.textColour2; + thresholdTextColour = seqsel.thresholdTextColour; + width = seqsel.width; + ignoreGapsInConsensus = seqsel.ignoreGapsInConsensus; + if (seqsel.conserve!=null) + { + recalcConservation(); // safer than + // aaFrequency = (Vector) seqsel.aaFrequency.clone(); // ?? + } + } + } public SequenceI[] getSelectionAsNewSequences(AlignmentI align) { @@ -338,6 +403,7 @@ public class SequenceGroup public void setName(String name) { groupName = name; + // TODO: URGENT: update dependent objects (annotation row) } public void setDescription(String desc) @@ -388,39 +454,57 @@ public class SequenceGroup } /** - * calculate residue conservation for group + * Max Gaps Threshold for performing a conservation calculation + * TODO: make this a configurable property - or global to an alignment view + */ + private int consPercGaps=25; + /** + * calculate residue conservation for group - but only if necessary. */ public void recalcConservation() { - if (cs == null) + if (cs == null && consensus == null && conservation == null) { return; } - + try { - cs.setConsensus(AAFrequency - .calculate(sequences, startRes, endRes + 1)); - + Hashtable cnsns[] = AAFrequency.calculate(sequences, startRes, endRes + 1, showConsensusProfile); + if (consensus != null) + { + _updateConsensusRow(cnsns); + } + if (cs!=null) + { + cs.setConsensus(cnsns); + if (cs instanceof ClustalxColourScheme) { ((ClustalxColourScheme) cs).resetClustalX(sequences, getWidth()); } + } - if (cs.conservationApplied()) + if ((conservation!=null) || (cs!=null && cs.conservationApplied())) { Conservation c = new Conservation(groupName, ResidueProperties.propHash, 3, sequences, startRes, endRes + 1); c.calculate(); - c.verdict(false, 25); - - cs.setConservation(c); - + c.verdict(false, consPercGaps); + if (conservation!=null) + { + _updateConservationRow(c); + } + if (cs!=null) + { + cs.setConservation(c); + if (cs instanceof ClustalxColourScheme) { ((ClustalxColourScheme) cs).resetClustalX(sequences, getWidth()); } + } } } catch (java.lang.OutOfMemoryError err) { @@ -430,13 +514,43 @@ public class SequenceGroup } + private void _updateConservationRow(Conservation c) + { + if (conservation==null) + { + getConservation(); + } + // update Labels + conservation.label = "Conservation for "+getName(); + conservation.description = "Conservation for group "+getName()+" less than " + consPercGaps + + "% gaps"; + // preserve width if already set + int aWidth = (conservation.annotations!=null) ? (endRes=0) + { + seqs[index] = dummy[index]; + dummy[index] = null; + } + } return seqs; } @@ -753,4 +881,182 @@ public class SequenceGroup { return hidecols; } -} + /** + * create a new sequence group from the intersection of this group + * with an alignment Hashtable of hidden representatives + * + * @param alignment (may not be null) + * @param hashtable (may be null) + * @return new group containing sequences common to this group and alignment + */ + public SequenceGroup intersect(AlignmentI alignment, Hashtable hashtable) + { + SequenceGroup sgroup = new SequenceGroup(this); + SequenceI[] insect=getSequencesInOrder(alignment); + sgroup.sequences = new Vector(); + for (int s=0;insect!=null && s