JAL-98 ProfilesI container for profiles for columns
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 17 Nov 2016 16:01:43 +0000 (16:01 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 17 Nov 2016 16:01:43 +0000 (16:01 +0000)
13 files changed:
src/jalview/analysis/AAFrequency.java
src/jalview/api/AlignViewportI.java
src/jalview/datamodel/SequenceGroup.java
src/jalview/renderer/AnnotationRenderer.java
src/jalview/schemes/Blosum62ColourScheme.java
src/jalview/schemes/ColourSchemeI.java
src/jalview/schemes/FollowerColourScheme.java
src/jalview/schemes/PIDColourScheme.java
src/jalview/schemes/ResidueColourScheme.java
src/jalview/viewmodel/AlignmentViewport.java
src/jalview/workers/ConsensusThread.java
test/jalview/analysis/AAFrequencyTest.java
test/jalview/schemes/ResidueColourSchemeTest.java

index 6bdffe1..17874e6 100755 (executable)
@@ -26,9 +26,11 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.Profile;
 import jalview.datamodel.ProfileI;
+import jalview.datamodel.Profiles;
+import jalview.datamodel.ProfilesI;
 import jalview.datamodel.ResidueCount;
-import jalview.datamodel.SequenceI;
 import jalview.datamodel.ResidueCount.SymbolCounts;
+import jalview.datamodel.SequenceI;
 import jalview.ext.android.SparseIntArray;
 import jalview.util.Comparison;
 import jalview.util.Format;
@@ -65,13 +67,13 @@ public class AAFrequency
     }
   }
 
-  public static final ProfileI[] calculate(List<SequenceI> list,
+  public static final ProfilesI calculate(List<SequenceI> list,
           int start, int end)
   {
     return calculate(list, start, end, false);
   }
 
-  public static final ProfileI[] calculate(List<SequenceI> sequences,
+  public static final ProfilesI calculate(List<SequenceI> sequences,
           int start, int end, boolean profile)
   {
     SequenceI[] seqs = new SequenceI[sequences.size()];
@@ -81,20 +83,19 @@ public class AAFrequency
       for (int i = 0; i < sequences.size(); i++)
       {
         seqs[i] = sequences.get(i);
-        if (seqs[i].getLength() > width)
+        int length = seqs[i].getLength();
+        if (length > width)
         {
-          width = seqs[i].getLength();
+          width = length;
         }
       }
 
-      ProfileI[] reply = new ProfileI[width];
-
       if (end >= width)
       {
         end = width;
       }
 
-      calculate(seqs, start, end, reply, profile);
+      ProfilesI reply = calculate(seqs, width, start, end, profile);
       return reply;
     }
   }
@@ -103,17 +104,17 @@ public class AAFrequency
    * Calculate the consensus symbol(s) for each column in the given range.
    * 
    * @param sequences
+   * @param width
+   *          the full width of the alignment
    * @param start
    *          start column (inclusive, base zero)
    * @param end
    *          end column (exclusive)
-   * @param result
-   *          array in which to store profile per column
    * @param saveFullProfile
    *          if true, store all symbol counts
    */
-  public static final void calculate(final SequenceI[] sequences,
-          int start, int end, ProfileI[] result, boolean saveFullProfile)
+  public static final ProfilesI calculate(final SequenceI[] sequences,
+          int width, int start, int end, boolean saveFullProfile)
   {
     // long now = System.currentTimeMillis();
     int seqCount = sequences.length;
@@ -121,6 +122,8 @@ public class AAFrequency
     int nucleotideCount = 0;
     int peptideCount = 0;
 
+    ProfileI[] result = new ProfileI[width];
+
     for (int column = start; column < end; column++)
     {
       /*
@@ -183,6 +186,7 @@ public class AAFrequency
 
       result[column] = profile;
     }
+    return new Profiles(result);
     // long elapsed = System.currentTimeMillis() - now;
     // System.out.println(elapsed);
   }
@@ -221,10 +225,10 @@ public class AAFrequency
    *          the annotation row to add annotations to
    * @param profiles
    *          the source consensus data
-   * @param iStart
-   *          start column
-   * @param width
-   *          end column
+   * @param startCol
+   *          start column (inclusive)
+   * @param endCol
+   *          end column (exclusive)
    * @param ignoreGaps
    *          if true, normalise residue percentages ignoring gaps
    * @param showSequenceLogo
@@ -234,12 +238,12 @@ public class AAFrequency
    *          number of sequences
    */
   public static void completeConsensus(AlignmentAnnotation consensus,
-          ProfileI[] profiles, int iStart, int width, boolean ignoreGaps,
+          ProfilesI profiles, int startCol, int endCol, boolean ignoreGaps,
           boolean showSequenceLogo, long nseq)
   {
     // long now = System.currentTimeMillis();
     if (consensus == null || consensus.annotations == null
-            || consensus.annotations.length < width)
+            || consensus.annotations.length < endCol)
     {
       /*
        * called with a bad alignment annotation row 
@@ -248,21 +252,21 @@ public class AAFrequency
       return;
     }
 
-    final int dp = getPercentageDp(nseq);
-
-    for (int i = iStart; i < width; i++)
+    for (int i = startCol; i < endCol; i++)
     {
-      ProfileI profile;
-      if (i >= profiles.length || ((profile = profiles[i]) == null))
+      ProfileI profile = profiles.get(i);
+      if (profile == null)
       {
         /*
          * happens if sequences calculated over were 
          * shorter than alignment width
          */
         consensus.annotations[i] = null;
-        continue;
+        return;
       }
 
+      final int dp = getPercentageDp(nseq);
+
       float value = profile.getPercentageIdentity(ignoreGaps);
 
       String description = getTooltip(profile, value, showSequenceLogo,
@@ -277,8 +281,8 @@ public class AAFrequency
       {
         modalResidue = "+";
       }
-      consensus.annotations[i] = new Annotation(modalResidue,
-              description, ' ', value);
+      consensus.annotations[i] = new Annotation(modalResidue, description,
+              ' ', value);
     }
     // long elapsed = System.currentTimeMillis() - now;
     // System.out.println(-elapsed);
index e30a052..8b80531 100644 (file)
@@ -26,7 +26,7 @@ import jalview.datamodel.AlignmentI;
 import jalview.datamodel.AlignmentView;
 import jalview.datamodel.CigarArray;
 import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.ProfileI;
+import jalview.datamodel.ProfilesI;
 import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
@@ -82,7 +82,7 @@ public interface AlignViewportI extends ViewStyleI
 
   ColumnSelection getColumnSelection();
 
-  ProfileI[] getSequenceConsensusHash();
+  ProfilesI getSequenceConsensusHash();
 
   /**
    * Get consensus data table for the cDNA complement of this alignment (if any)
@@ -145,7 +145,7 @@ public interface AlignViewportI extends ViewStyleI
    * 
    * @param hconsensus
    */
-  void setSequenceConsensusHash(ProfileI[] hconsensus);
+  void setSequenceConsensusHash(ProfilesI hconsensus);
 
   /**
    * Set the cDNA complement consensus for the viewport
index ca90003..9245761 100755 (executable)
@@ -527,7 +527,7 @@ public class SequenceGroup implements AnnotatedCollectionI
     boolean upd = false;
     try
     {
-      ProfileI[] cnsns = AAFrequency.calculate(sequences, startRes,
+      ProfilesI cnsns = AAFrequency.calculate(sequences, startRes,
               endRes + 1, showSequenceLogo);
       if (consensus != null)
       {
@@ -599,9 +599,9 @@ public class SequenceGroup implements AnnotatedCollectionI
     c.completeAnnotations(conservation, null, startRes, endRes + 1);
   }
 
-  public ProfileI[] consensusData = null;
+  public ProfilesI consensusData = null;
 
-  private void _updateConsensusRow(ProfileI[] cnsns, long nseq)
+  private void _updateConsensusRow(ProfilesI cnsns, long nseq)
   {
     if (consensus == null)
     {
index d7ae950..a0e530c 100644 (file)
@@ -28,7 +28,7 @@ import jalview.api.AlignViewportI;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.ProfileI;
+import jalview.datamodel.ProfilesI;
 import jalview.schemes.ColourSchemeI;
 import jalview.schemes.ResidueProperties;
 import jalview.util.Platform;
@@ -74,7 +74,7 @@ public class AnnotationRenderer
 
   private ColumnSelection columnSelection;
 
-  private ProfileI[] hconsensus;
+  private ProfilesI hconsensus;
 
   private Hashtable[] complementConsensus;
 
@@ -352,7 +352,7 @@ public class AnnotationRenderer
       {
         // TODO? group consensus for cDNA complement
         return AAFrequency.extractProfile(
-                aa.groupRef.consensusData[column],
+                aa.groupRef.consensusData.get(column),
                 aa.groupRef.getIgnoreGapsConsensus());
       }
       // TODO extend annotation row to enable dynamic and static profile data to
@@ -366,7 +366,8 @@ public class AnnotationRenderer
         }
         else
         {
-          return AAFrequency.extractProfile(hconsensus[column],
+          return AAFrequency.extractProfile(
+hconsensus.get(column),
                   av_ignoreGapsConsensus);
         }
       }
index 37c31f9..c47f171 100755 (executable)
@@ -47,7 +47,7 @@ public class Blosum62ColourScheme extends ResidueColourScheme
       res -= ('a' - 'A');
     }
 
-    if (consensus == null || j >= consensus.length || consensus[j] == null
+    if (consensus == null || consensus.get(j) == null
             || (threshold != 0 && !aboveThreshold(res, j)))
     {
       return Color.white;
@@ -60,7 +60,7 @@ public class Blosum62ColourScheme extends ResidueColourScheme
       /*
        * test if this is the consensus (or joint consensus) residue
        */
-      String max = consensus[j].getModalResidue();
+      String max = consensus.get(j).getModalResidue();
 
       if (max.indexOf(res) > -1)
       {
index fb71686..da99a4a 100755 (executable)
@@ -21,7 +21,7 @@
 package jalview.schemes;
 
 import jalview.datamodel.AnnotatedCollectionI;
-import jalview.datamodel.ProfileI;
+import jalview.datamodel.ProfilesI;
 import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 
@@ -53,7 +53,7 @@ public interface ColourSchemeI
   /**
    * assign the given consensus profile for the colourscheme
    */
-  public void setConsensus(ProfileI[] hconsensus);
+  public void setConsensus(ProfilesI hconsensus);
 
   /**
    * assign the given conservation to the colourscheme
index 86fce4e..35be31b 100644 (file)
@@ -21,7 +21,7 @@
 package jalview.schemes;
 
 import jalview.analysis.Conservation;
-import jalview.datamodel.ProfileI;
+import jalview.datamodel.ProfilesI;
 
 /**
  * Colourscheme that takes its colours from some other colourscheme
@@ -40,7 +40,7 @@ public class FollowerColourScheme extends ResidueColourScheme
   }
 
   @Override
-  public void setConsensus(ProfileI[] consensus)
+  public void setConsensus(ProfilesI consensus)
   {
     if (colourScheme != null)
     {
index ccc69c2..0ad5b5c 100755 (executable)
@@ -20,6 +20,7 @@
  */
 package jalview.schemes;
 
+import jalview.datamodel.ProfileI;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
 import jalview.util.Comparison;
@@ -48,7 +49,7 @@ public class PIDColourScheme extends ResidueColourScheme
       c -= ('a' - 'A');
     }
 
-    if (consensus == null || j >= consensus.length || consensus[j] == null)
+    if (consensus == null || consensus.get(j) == null)
     {
       return Color.white;
     }
@@ -62,19 +63,16 @@ public class PIDColourScheme extends ResidueColourScheme
 
     double sc = 0;
 
-    if (consensus.length <= j)
-    {
-      return Color.white;
-    }
 
     /*
      * test whether this is the consensus (or joint consensus) residue
      */
-    boolean matchesConsensus = consensus[j].getModalResidue().contains(
+    ProfileI profile = consensus.get(j);
+    boolean matchesConsensus = profile.getModalResidue().contains(
             String.valueOf(c));
     if (matchesConsensus)
     {
-      sc = consensus[j].getPercentageIdentity(ignoreGaps);
+      sc = profile.getPercentageIdentity(ignoreGaps);
 
       if (!Comparison.isGap(c))
       {
index 31b8320..f6b7c5e 100755 (executable)
@@ -23,6 +23,7 @@ package jalview.schemes;
 import jalview.analysis.Conservation;
 import jalview.datamodel.AnnotatedCollectionI;
 import jalview.datamodel.ProfileI;
+import jalview.datamodel.ProfilesI;
 import jalview.datamodel.SequenceCollectionI;
 import jalview.datamodel.SequenceI;
 import jalview.util.ColorUtils;
@@ -54,7 +55,7 @@ public class ResidueColourScheme implements ColourSchemeI
   /*
    * Consensus data indexed by column
    */
-  ProfileI[] consensus;
+  ProfilesI consensus;
 
   /*
    * Conservation string as a char array 
@@ -182,19 +183,20 @@ public class ResidueColourScheme implements ColourSchemeI
       residue -= ('a' - 'A');
     }
 
-    if (consensus == null || consensus.length < column
-            || consensus[column] == null)
+    if (consensus == null)
     {
       return false;
     }
 
+    ProfileI profile = consensus.get(column);
+
     /*
      * test whether this is the consensus (or joint consensus) residue
      */
-    if (consensus[column].getModalResidue().contains(
-            String.valueOf(residue)))
+    if (profile != null
+            && profile.getModalResidue().contains(String.valueOf(residue)))
     {
-      if (consensus[column].getPercentageIdentity(ignoreGaps) >= threshold)
+      if (profile.getPercentageIdentity(ignoreGaps) >= threshold)
       {
         return true;
       }
@@ -234,7 +236,7 @@ public class ResidueColourScheme implements ColourSchemeI
    *          DOCUMENT ME!
    */
   @Override
-  public void setConsensus(ProfileI[] consensus)
+  public void setConsensus(ProfilesI consensus)
   {
     if (consensus == null)
     {
index 57258ef..438eaf8 100644 (file)
@@ -36,7 +36,7 @@ import jalview.datamodel.Annotation;
 import jalview.datamodel.CigarArray;
 import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.HiddenSequences;
-import jalview.datamodel.ProfileI;
+import jalview.datamodel.ProfilesI;
 import jalview.datamodel.SearchResults;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceCollectionI;
@@ -701,7 +701,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
   /**
    * results of alignment consensus analysis for visible portion of view
    */
-  protected ProfileI[] hconsensus = null;
+  protected ProfilesI hconsensus = null;
 
   /**
    * results of cDNA complement consensus visible portion of view
@@ -735,7 +735,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
   }
 
   @Override
-  public void setSequenceConsensusHash(ProfileI[] hconsensus)
+  public void setSequenceConsensusHash(ProfilesI hconsensus)
   {
     this.hconsensus = hconsensus;
   }
@@ -747,7 +747,7 @@ public abstract class AlignmentViewport implements AlignViewportI,
   }
 
   @Override
-  public ProfileI[] getSequenceConsensusHash()
+  public ProfilesI getSequenceConsensusHash()
   {
     return hconsensus;
   }
index 2b11477..b6c7a91 100644 (file)
@@ -26,7 +26,7 @@ import jalview.api.AlignmentViewPanel;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.Annotation;
-import jalview.datamodel.ProfileI;
+import jalview.datamodel.ProfilesI;
 import jalview.datamodel.SequenceI;
 import jalview.schemes.ColourSchemeI;
 
@@ -124,10 +124,11 @@ public class ConsensusThread extends AlignCalcWorker
    */
   protected void computeConsensus(AlignmentI alignment)
   {
-    ProfileI[] hconsensus = new ProfileI[alignment.getWidth()];
 
     SequenceI[] aseqs = getSequences();
-    AAFrequency.calculate(aseqs, 0, alignment.getWidth(), hconsensus, true);
+    int width = alignment.getWidth();
+    ProfilesI hconsensus = AAFrequency.calculate(aseqs, width, 0,
+            width, true);
 
     alignViewport.setSequenceConsensusHash(hconsensus);
     setColourSchemeConsensus(hconsensus);
@@ -144,7 +145,7 @@ public class ConsensusThread extends AlignCalcWorker
   /**
    * @param hconsensus
    */
-  protected void setColourSchemeConsensus(ProfileI[] hconsensus)
+  protected void setColourSchemeConsensus(ProfilesI hconsensus)
   {
     ColourSchemeI globalColourScheme = alignViewport
             .getGlobalColourScheme();
@@ -177,7 +178,7 @@ public class ConsensusThread extends AlignCalcWorker
   public void updateResultAnnotation(boolean immediate)
   {
     AlignmentAnnotation consensus = getConsensusAnnotation();
-    ProfileI[] hconsensus = (ProfileI[]) getViewportConsensus();
+    ProfilesI hconsensus = (ProfilesI) getViewportConsensus();
     if (immediate || !calcMan.isWorking(this) && consensus != null
             && hconsensus != null)
     {
@@ -195,11 +196,13 @@ public class ConsensusThread extends AlignCalcWorker
    *          the computed consensus data
    */
   protected void deriveConsensus(AlignmentAnnotation consensusAnnotation,
-          ProfileI[] hconsensus)
+          ProfilesI hconsensus)
   {
+
     long nseq = getSequences().length;
     AAFrequency.completeConsensus(consensusAnnotation, hconsensus, 0,
-            hconsensus.length, alignViewport.isIgnoreGapsConsensus(),
+            hconsensus.getEndColumn() + 1,
+            alignViewport.isIgnoreGapsConsensus(),
             alignViewport.isShowSequenceLogo(), nseq);
   }
 
@@ -208,7 +211,7 @@ public class ConsensusThread extends AlignCalcWorker
    * 
    * @return
    */
-  protected Object[] getViewportConsensus()
+  protected Object getViewportConsensus()
   {
     // TODO convert ComplementConsensusThread to use Profile
     return alignViewport.getSequenceConsensusHash();
index 1c04b8e..58601a9 100644 (file)
@@ -26,6 +26,7 @@ import static org.testng.AssertJUnit.assertNull;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
 import jalview.datamodel.ProfileI;
+import jalview.datamodel.ProfilesI;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceI;
 
@@ -41,12 +42,12 @@ public class AAFrequencyTest
     SequenceI seq3 = new Sequence("Seq3", "C---G");
     SequenceI seq4 = new Sequence("Seq4", "CA--t");
     SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 };
-    ProfileI[] result = new ProfileI[seq1.getLength()];
-
-    AAFrequency.calculate(seqs, 0, seq1.getLength(), result, false);
+    int width = seq1.getLength();
+    ProfilesI result = AAFrequency.calculate(seqs, width, 0, width,
+            false);
 
     // col 0 is 100% C
-    ProfileI col = result[0];
+    ProfileI col = result.get(0);
     assertEquals(100f, col.getPercentageIdentity(false));
     assertEquals(100f, col.getPercentageIdentity(true));
     assertEquals(4, col.getMaxCount());
@@ -54,28 +55,28 @@ public class AAFrequencyTest
     assertNull(col.getCounts());
 
     // col 1 is 75% A
-    col = result[1];
+    col = result.get(1);
     assertEquals(75f, col.getPercentageIdentity(false));
     assertEquals(100f, col.getPercentageIdentity(true));
     assertEquals(3, col.getMaxCount());
     assertEquals("A", col.getModalResidue());
 
     // col 2 is 50% G 50% C or 25/25 counting gaps
-    col = result[2];
+    col = result.get(2);
     assertEquals(25f, col.getPercentageIdentity(false));
     assertEquals(50f, col.getPercentageIdentity(true));
     assertEquals(1, col.getMaxCount());
     assertEquals("CG", col.getModalResidue());
 
     // col 3 is all gaps
-    col = result[3];
+    col = result.get(3);
     assertEquals(0f, col.getPercentageIdentity(false));
     assertEquals(0f, col.getPercentageIdentity(true));
     assertEquals(0, col.getMaxCount());
     assertEquals("", col.getModalResidue());
 
     // col 4 is 75% T 25% G
-    col = result[4];
+    col = result.get(4);
     assertEquals(75f, col.getPercentageIdentity(false));
     assertEquals(75f, col.getPercentageIdentity(true));
     assertEquals(3, col.getMaxCount());
@@ -90,26 +91,27 @@ public class AAFrequencyTest
     SequenceI seq3 = new Sequence("Seq3", "C--G");
     SequenceI seq4 = new Sequence("Seq4", "CA-t");
     SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 };
-    ProfileI[] result = new ProfileI[seq1.getLength()];
+    int width = seq1.getLength();
+    ProfilesI result = AAFrequency.calculate(seqs, width, 0, width,
+            true);
 
-    AAFrequency.calculate(seqs, 0, seq1.getLength(), result, true);
-    ProfileI profile = result[0];
+    ProfileI profile = result.get(0);
     assertEquals(4, profile.getCounts().getCount('C'));
     assertEquals(4, profile.getHeight());
     assertEquals(4, profile.getNonGapped());
 
-    profile = result[1];
+    profile = result.get(1);
     assertEquals(3, profile.getCounts().getCount('A'));
     assertEquals(4, profile.getHeight());
     assertEquals(3, profile.getNonGapped());
 
-    profile = result[2];
+    profile = result.get(2);
     assertEquals(1, profile.getCounts().getCount('C'));
     assertEquals(1, profile.getCounts().getCount('G'));
     assertEquals(4, profile.getHeight());
     assertEquals(2, profile.getNonGapped());
 
-    profile = result[3];
+    profile = result.get(3);
     assertEquals(3, profile.getCounts().getCount('T'));
     assertEquals(1, profile.getCounts().getCount('G'));
     assertEquals(4, profile.getHeight());
@@ -124,15 +126,16 @@ public class AAFrequencyTest
     SequenceI seq3 = new Sequence("Seq3", "C--G");
     SequenceI seq4 = new Sequence("Seq4", "CA-t");
     SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 };
-    ProfileI[] result = new ProfileI[seq1.getLength()];
 
-    // ensure class loaded and initialized
-    AAFrequency.calculate(seqs, 0, seq1.getLength(), result, true);
+    // ensure class loaded and initialised
+    int width = seq1.getLength();
+    AAFrequency.calculate(seqs, width, 0, width, true);
+
     int reps = 100000;
     long start = System.currentTimeMillis();
     for (int i = 0; i < reps; i++)
     {
-      AAFrequency.calculate(seqs, 0, seq1.getLength(), result, true);
+      AAFrequency.calculate(seqs, width, 0, width, true);
     }
     System.out.println(System.currentTimeMillis() - start);
   }
@@ -154,11 +157,11 @@ public class AAFrequencyTest
     SequenceI seq3 = new Sequence("Seq3", "C---G");
     SequenceI seq4 = new Sequence("Seq4", "CA--t");
     SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 };
-    ProfileI[] profiles = new ProfileI[seq1.getLength()];
-    AAFrequency.calculate(seqs, 0, seq1.getLength(), profiles, true);
+    int width = seq1.getLength();
+    ProfilesI profiles = AAFrequency.calculate(seqs, width, 0, width, true);
 
     AlignmentAnnotation consensus = new AlignmentAnnotation("Consensus",
-            "PID", new Annotation[seq1.getLength()]);
+            "PID", new Annotation[width]);
     AAFrequency
             .completeConsensus(consensus, profiles, 0, 5, false, true, 4);
 
@@ -195,11 +198,11 @@ public class AAFrequencyTest
     SequenceI seq3 = new Sequence("Seq3", "C---G");
     SequenceI seq4 = new Sequence("Seq4", "CA--t");
     SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 };
-    ProfileI[] profiles = new ProfileI[seq1.getLength()];
-    AAFrequency.calculate(seqs, 0, seq1.getLength(), profiles, true);
+    int width = seq1.getLength();
+    ProfilesI profiles = AAFrequency.calculate(seqs, width, 0, width, true);
   
     AlignmentAnnotation consensus = new AlignmentAnnotation("Consensus",
-            "PID", new Annotation[seq1.getLength()]);
+            "PID", new Annotation[width]);
     AAFrequency
             .completeConsensus(consensus, profiles, 0, 5, true, false, 4);
   
index 318ba3f..c7c558d 100644 (file)
@@ -6,6 +6,7 @@ import static org.testng.AssertJUnit.assertTrue;
 
 import jalview.datamodel.Profile;
 import jalview.datamodel.ProfileI;
+import jalview.datamodel.Profiles;
 
 import java.awt.Color;
 
@@ -23,13 +24,13 @@ public class ResidueColourSchemeTest
      * SR-T
      * SR-T
      */
-    ProfileI[] profiles = new ProfileI[4]; 
+    ProfileI[] profiles = new ProfileI[4];
     profiles[0] = new Profile(4, 0, 2, "AS");
     profiles[1] = new Profile(4, 0, 4, "R");
     profiles[2] = new Profile(4, 4, 0, "");
     profiles[3] = new Profile(4, 1, 2, "T");
     ResidueColourScheme rcs = new ResidueColourScheme();
-    rcs.setConsensus(profiles);
+    rcs.setConsensus(new Profiles(profiles));
     
     /*
      * no threshold