From: Jim Procter Date: Mon, 2 Sep 2013 17:07:42 +0000 (+0100) Subject: JAL-1373 pass size of sequence set to consensus rendering routines so appropriate... X-Git-Tag: Jalview_2_9~222^2~2 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=abeb1ce92e146611f2e7b57ff3e0f8169a216991;p=jalview.git JAL-1373 pass size of sequence set to consensus rendering routines so appropriate precision can be chosen --- diff --git a/src/jalview/analysis/AAFrequency.java b/src/jalview/analysis/AAFrequency.java index 50b1b4b..33660b5 100755 --- a/src/jalview/analysis/AAFrequency.java +++ b/src/jalview/analysis/AAFrequency.java @@ -194,14 +194,15 @@ public class AAFrequency * @param width * @param ignoreGapsInConsensusCalculation * @param includeAllConsSymbols + * @param nseq */ public static void completeConsensus(AlignmentAnnotation consensus, Hashtable[] hconsensus, int iStart, int width, boolean ignoreGapsInConsensusCalculation, - boolean includeAllConsSymbols) + boolean includeAllConsSymbols, long nseq) { completeConsensus(consensus, hconsensus, iStart, width, - ignoreGapsInConsensusCalculation, includeAllConsSymbols, null); // new + ignoreGapsInConsensusCalculation, includeAllConsSymbols, null, nseq); // new // char[] // { 'A', 'C', 'G', 'T', 'U' }); } @@ -209,7 +210,7 @@ public class AAFrequency public static void completeConsensus(AlignmentAnnotation consensus, Hashtable[] hconsensus, int iStart, int width, boolean ignoreGapsInConsensusCalculation, - boolean includeAllConsSymbols, char[] alphabet) + boolean includeAllConsSymbols, char[] alphabet, long nseq) { float tval, value; if (consensus == null || consensus.annotations == null diff --git a/src/jalview/analysis/StructureFrequency.java b/src/jalview/analysis/StructureFrequency.java index 08bb3fd..fe022c0 100644 --- a/src/jalview/analysis/StructureFrequency.java +++ b/src/jalview/analysis/StructureFrequency.java @@ -299,7 +299,7 @@ public class StructureFrequency public static void completeConsensus(AlignmentAnnotation consensus, Hashtable[] hconsensus, int iStart, int width, boolean ignoreGapsInConsensusCalculation, - boolean includeAllConsSymbols) + boolean includeAllConsSymbols, long nseq) { float tval, value; if (consensus == null || consensus.annotations == null diff --git a/src/jalview/datamodel/SequenceGroup.java b/src/jalview/datamodel/SequenceGroup.java index 65dc13f..5fcd2bf 100755 --- a/src/jalview/datamodel/SequenceGroup.java +++ b/src/jalview/datamodel/SequenceGroup.java @@ -493,7 +493,7 @@ public class SequenceGroup implements AnnotatedCollectionI endRes + 1, showSequenceLogo); if (consensus != null) { - _updateConsensusRow(cnsns); + _updateConsensusRow(cnsns, sequences.size()); } if (cs != null) { @@ -552,7 +552,7 @@ public class SequenceGroup implements AnnotatedCollectionI public Hashtable[] consensusData = null; - private void _updateConsensusRow(Hashtable[] cnsns) + private void _updateConsensusRow(Hashtable[] cnsns, long nseq) { if (consensus == null) { @@ -569,7 +569,7 @@ public class SequenceGroup implements AnnotatedCollectionI consensus.annotations = new Annotation[aWidth]; // should be alignment width AAFrequency.completeConsensus(consensus, cnsns, startRes, endRes + 1, - ignoreGapsInConsensus, showSequenceLogo); // TODO: setting container + ignoreGapsInConsensus, showSequenceLogo, nseq); // TODO: setting container // for // ignoreGapsInConsensusCalculation); } diff --git a/src/jalview/workers/ConsensusThread.java b/src/jalview/workers/ConsensusThread.java index 343e64d..c2b4d66 100644 --- a/src/jalview/workers/ConsensusThread.java +++ b/src/jalview/workers/ConsensusThread.java @@ -24,6 +24,7 @@ import jalview.api.AlignmentViewPanel; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; +import jalview.datamodel.SequenceI; import jalview.schemes.ColourSchemeI; import java.util.Hashtable; @@ -31,6 +32,8 @@ import java.util.Hashtable; public class ConsensusThread extends AlignCalcWorker implements AlignCalcWorkerI { + private long nseq=-1; + public ConsensusThread(AlignViewportI alignViewport, AlignmentViewPanel alignPanel) { @@ -94,7 +97,9 @@ public class ConsensusThread extends AlignCalcWorker implements hconsensus = new Hashtable[aWidth]; try { - AAFrequency.calculate(alignment.getSequencesArray(), 0, + SequenceI aseqs[] = alignment.getSequencesArray(); + nseq = aseqs.length; + AAFrequency.calculate(aseqs, 0, alignment.getWidth(), hconsensus, true); } catch (ArrayIndexOutOfBoundsException x) { @@ -150,7 +155,7 @@ public class ConsensusThread extends AlignCalcWorker implements { AAFrequency.completeConsensus(consensus, hconsensus, 0, hconsensus.length, alignViewport.getIgnoreGapsConsensus(), - alignViewport.isShowSequenceLogo()); + alignViewport.isShowSequenceLogo(), nseq); } } } diff --git a/src/jalview/workers/StrucConsensusThread.java b/src/jalview/workers/StrucConsensusThread.java index 86c3336..25e5cde 100644 --- a/src/jalview/workers/StrucConsensusThread.java +++ b/src/jalview/workers/StrucConsensusThread.java @@ -26,6 +26,7 @@ import jalview.api.AlignmentViewPanel; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; +import jalview.datamodel.SequenceI; public class StrucConsensusThread extends AlignCalcWorker implements AlignCalcWorkerI @@ -40,6 +41,8 @@ public class StrucConsensusThread extends AlignCalcWorker implements Hashtable[] hStrucConsensus; + private long nseq=-1; + @Override public void run() { @@ -107,8 +110,10 @@ public class StrucConsensusThread extends AlignCalcWorker implements try { - jalview.analysis.StructureFrequency.calculate( - alignment.getSequencesArray(), 0, alignment.getWidth(), + final SequenceI[] arr= + alignment.getSequencesArray(); + nseq = arr.length; + jalview.analysis.StructureFrequency.calculate(arr, 0, alignment.getWidth(), hStrucConsensus, true, rnaStruc); } catch (ArrayIndexOutOfBoundsException x) { @@ -159,7 +164,7 @@ public class StrucConsensusThread extends AlignCalcWorker implements StructureFrequency.completeConsensus(strucConsensus, hStrucConsensus, 0, hStrucConsensus.length, alignViewport.getIgnoreGapsConsensus(), - alignViewport.isShowSequenceLogo()); + alignViewport.isShowSequenceLogo(), nseq); } }