import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
import jalview.datamodel.Profile;
+import jalview.datamodel.ProfileI;
import jalview.datamodel.ResidueCount;
import jalview.datamodel.SequenceI;
import jalview.datamodel.ResidueCount.SymbolCounts;
}
}
- public static final Profile[] calculate(List<SequenceI> list,
+ public static final ProfileI[] calculate(List<SequenceI> list,
int start, int end)
{
return calculate(list, start, end, false);
}
- public static final Profile[] calculate(List<SequenceI> sequences,
+ public static final ProfileI[] calculate(List<SequenceI> sequences,
int start, int end, boolean profile)
{
SequenceI[] seqs = new SequenceI[sequences.size()];
}
}
- Profile[] reply = new Profile[width];
+ ProfileI[] reply = new ProfileI[width];
if (end >= width)
{
* if true, store all symbol counts
*/
public static final void calculate(final SequenceI[] sequences,
- int start, int end, Profile[] result, boolean saveFullProfile)
+ int start, int end, ProfileI[] result, boolean saveFullProfile)
{
// long now = System.currentTimeMillis();
int seqCount = sequences.length;
int maxCount = residueCounts.getModalCount();
String maxResidue = residueCounts.getResiduesForCount(maxCount);
int gapCount = residueCounts.getGapCount();
- Profile profile = new Profile(seqCount, gapCount, maxCount,
+ ProfileI profile = new Profile(seqCount, gapCount, maxCount,
maxResidue);
if (saveFullProfile)
* number of sequences
*/
public static void completeConsensus(AlignmentAnnotation consensus,
- Profile[] profiles, int iStart, int width, boolean ignoreGaps,
+ ProfileI[] profiles, int iStart, int width, boolean ignoreGaps,
boolean showSequenceLogo, long nseq)
{
// long now = System.currentTimeMillis();
for (int i = iStart; i < width; i++)
{
- Profile profile;
+ ProfileI profile;
if (i >= profiles.length || ((profile = profiles[i]) == null))
{
/*
* the number of decimal places to format percentages to
* @return
*/
- static String getTooltip(Profile profile, float pid,
+ static String getTooltip(ProfileI profile, float pid,
boolean showSequenceLogo, boolean ignoreGaps, int dp)
{
ResidueCount counts = profile.getCounts();
* calculations
* @return
*/
- public static int[] extractProfile(Profile profile,
+ public static int[] extractProfile(ProfileI profile,
boolean ignoreGaps)
{
int[] rtnval = new int[64];
import jalview.datamodel.AlignmentView;
import jalview.datamodel.CigarArray;
import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.Profile;
+import jalview.datamodel.ProfileI;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceGroup;
import jalview.datamodel.SequenceI;
ColumnSelection getColumnSelection();
- Profile[] getSequenceConsensusHash();
+ ProfileI[] getSequenceConsensusHash();
/**
* Get consensus data table for the cDNA complement of this alignment (if any)
*
* @param hconsensus
*/
- void setSequenceConsensusHash(Profile[] hconsensus);
+ void setSequenceConsensusHash(ProfileI[] hconsensus);
/**
* Set the cDNA complement consensus for the viewport
/**
- * A data bean to hold the result of computing a profile for a column of an
- * alignment
+ * A profile for one column of an alignment
*
* @author gmcarstairs
*
*/
-public class Profile
+public class Profile implements ProfileI
{
/*
- * counts of keys (chars)
+ * an object holding counts of symbols in the profile
*/
private ResidueCount counts;
/*
- * the number of sequences in the profile
+ * the number of sequences (gapped or not) in the profile
*/
private int height;
this.modalResidue = modalRes;
}
- /**
- * Set the full profile of counts
- *
- * @param residueCounts
+ /* (non-Javadoc)
+ * @see jalview.datamodel.ProfileI#setCounts(jalview.datamodel.ResidueCount)
*/
+ @Override
public void setCounts(ResidueCount residueCounts)
{
this.counts = residueCounts;
}
- /**
- * Returns the percentage identity of the profile, i.e. the highest proportion
- * of conserved (equal) symbols. The percentage is as a fraction of all
- * sequences, or only ungapped sequences if flag ignoreGaps is set true.
- *
- * @param ignoreGaps
- * @return
+ /* (non-Javadoc)
+ * @see jalview.datamodel.ProfileI#getPercentageIdentity(boolean)
*/
+ @Override
public float getPercentageIdentity(boolean ignoreGaps)
{
if (height == 0)
return pid;
}
- /**
- * Returns the full symbol counts for this profile
- *
- * @return
+ /* (non-Javadoc)
+ * @see jalview.datamodel.ProfileI#getCounts()
*/
+ @Override
public ResidueCount getCounts()
{
return counts;
}
- /**
- * Returns the number of sequences in the profile
- *
- * @return
+ /* (non-Javadoc)
+ * @see jalview.datamodel.ProfileI#getHeight()
*/
+ @Override
public int getHeight()
{
return height;
}
- /**
- * Returns the number of sequences in the profile which had a gap character
- * (or were too short to be included in this column's profile)
- *
- * @return
+ /* (non-Javadoc)
+ * @see jalview.datamodel.ProfileI#getGapped()
*/
+ @Override
public int getGapped()
{
return gapped;
}
- /**
- * Returns the highest count for any symbol(s) in the profile
- *
- * @return
+ /* (non-Javadoc)
+ * @see jalview.datamodel.ProfileI#getMaxCount()
*/
+ @Override
public int getMaxCount()
{
return maxCount;
}
- /**
- * Returns the symbol (or concatenated symbols) which have the highest count
- * in the profile, or an empty string if there were no symbols counted
- *
- * @return
+ /* (non-Javadoc)
+ * @see jalview.datamodel.ProfileI#getModalResidue()
*/
+ @Override
public String getModalResidue()
{
return modalResidue;
}
- /**
- * Answers the number of non-gapped sequences in the profile
- *
- * @return
+ /* (non-Javadoc)
+ * @see jalview.datamodel.ProfileI#getNonGapped()
*/
+ @Override
public int getNonGapped()
{
return height - gapped;
--- /dev/null
+package jalview.datamodel;
+
+public interface ProfileI
+{
+
+ /**
+ * Set the full profile of counts
+ *
+ * @param residueCounts
+ */
+ public abstract void setCounts(ResidueCount residueCounts);
+
+ /**
+ * Returns the percentage identity of the profile, i.e. the highest proportion
+ * of conserved (equal) symbols. The percentage is as a fraction of all
+ * sequences, or only ungapped sequences if flag ignoreGaps is set true.
+ *
+ * @param ignoreGaps
+ * @return
+ */
+ public abstract float getPercentageIdentity(boolean ignoreGaps);
+
+ /**
+ * Returns the full symbol counts for this profile
+ *
+ * @return
+ */
+ public abstract ResidueCount getCounts();
+
+ /**
+ * Returns the number of sequences in the profile
+ *
+ * @return
+ */
+ public abstract int getHeight();
+
+ /**
+ * Returns the number of sequences in the profile which had a gap character
+ * (or were too short to be included in this column's profile)
+ *
+ * @return
+ */
+ public abstract int getGapped();
+
+ /**
+ * Returns the highest count for any symbol(s) in the profile
+ *
+ * @return
+ */
+ public abstract int getMaxCount();
+
+ /**
+ * Returns the symbol (or concatenated symbols) which have the highest count
+ * in the profile, or an empty string if there were no symbols counted
+ *
+ * @return
+ */
+ public abstract String getModalResidue();
+
+ /**
+ * Answers the number of non-gapped sequences in the profile
+ *
+ * @return
+ */
+ public abstract int getNonGapped();
+
+}
\ No newline at end of file
boolean upd = false;
try
{
- Profile[] cnsns = AAFrequency.calculate(sequences, startRes,
+ ProfileI[] cnsns = AAFrequency.calculate(sequences, startRes,
endRes + 1, showSequenceLogo);
if (consensus != null)
{
c.completeAnnotations(conservation, null, startRes, endRes + 1);
}
- public Profile[] consensusData = null;
+ public ProfileI[] consensusData = null;
- private void _updateConsensusRow(Profile[] cnsns, long nseq)
+ private void _updateConsensusRow(ProfileI[] cnsns, long nseq)
{
if (consensus == null)
{
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
import jalview.datamodel.ColumnSelection;
-import jalview.datamodel.Profile;
+import jalview.datamodel.ProfileI;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ResidueProperties;
import jalview.util.Platform;
private ColumnSelection columnSelection;
- private Profile[] hconsensus;
+ private ProfileI[] hconsensus;
private Hashtable[] complementConsensus;
package jalview.schemes;
import jalview.datamodel.AnnotatedCollectionI;
-import jalview.datamodel.Profile;
+import jalview.datamodel.ProfileI;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceI;
/**
* assign the given consensus profile for the colourscheme
*/
- public void setConsensus(Profile[] hconsensus);
+ public void setConsensus(ProfileI[] hconsensus);
/**
* assign the given conservation to the colourscheme
package jalview.schemes;
import jalview.analysis.Conservation;
-import jalview.datamodel.Profile;
+import jalview.datamodel.ProfileI;
/**
* Colourscheme that takes its colours from some other colourscheme
}
@Override
- public void setConsensus(Profile[] consensus)
+ public void setConsensus(ProfileI[] consensus)
{
if (colourScheme != null)
{
import jalview.analysis.Conservation;
import jalview.datamodel.AnnotatedCollectionI;
-import jalview.datamodel.Profile;
+import jalview.datamodel.ProfileI;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.SequenceI;
import jalview.util.ColorUtils;
/*
* Consensus data indexed by column
*/
- Profile[] consensus;
+ ProfileI[] consensus;
/*
* Conservation string as a char array
* DOCUMENT ME!
*/
@Override
- public void setConsensus(Profile[] consensus)
+ public void setConsensus(ProfileI[] consensus)
{
if (consensus == null)
{
import jalview.datamodel.CigarArray;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenSequences;
-import jalview.datamodel.Profile;
+import jalview.datamodel.ProfileI;
import jalview.datamodel.SearchResults;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceCollectionI;
/**
* results of alignment consensus analysis for visible portion of view
*/
- protected Profile[] hconsensus = null;
+ protected ProfileI[] hconsensus = null;
/**
* results of cDNA complement consensus visible portion of view
}
@Override
- public void setSequenceConsensusHash(Profile[] hconsensus)
+ public void setSequenceConsensusHash(ProfileI[] hconsensus)
{
this.hconsensus = hconsensus;
}
}
@Override
- public Profile[] getSequenceConsensusHash()
+ public ProfileI[] getSequenceConsensusHash()
{
return hconsensus;
}
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.Annotation;
-import jalview.datamodel.Profile;
+import jalview.datamodel.ProfileI;
import jalview.datamodel.SequenceI;
import jalview.schemes.ColourSchemeI;
*/
protected void computeConsensus(AlignmentI alignment)
{
- Profile[] hconsensus = new Profile[alignment.getWidth()];
+ ProfileI[] hconsensus = new ProfileI[alignment.getWidth()];
SequenceI[] aseqs = getSequences();
AAFrequency.calculate(aseqs, 0, alignment.getWidth(), hconsensus, true);
/**
* @param hconsensus
*/
- protected void setColourSchemeConsensus(Profile[] hconsensus)
+ protected void setColourSchemeConsensus(ProfileI[] hconsensus)
{
ColourSchemeI globalColourScheme = alignViewport
.getGlobalColourScheme();
public void updateResultAnnotation(boolean immediate)
{
AlignmentAnnotation consensus = getConsensusAnnotation();
- Profile[] hconsensus = (Profile[]) getViewportConsensus();
+ ProfileI[] hconsensus = (ProfileI[]) getViewportConsensus();
if (immediate || !calcMan.isWorking(this) && consensus != null
&& hconsensus != null)
{
* the computed consensus data
*/
protected void deriveConsensus(AlignmentAnnotation consensusAnnotation,
- Profile[] hconsensus)
+ ProfileI[] hconsensus)
{
long nseq = getSequences().length;
AAFrequency.completeConsensus(consensusAnnotation, hconsensus, 0,
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.Annotation;
-import jalview.datamodel.Profile;
+import jalview.datamodel.ProfileI;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
SequenceI seq3 = new Sequence("Seq3", "C---G");
SequenceI seq4 = new Sequence("Seq4", "CA--t");
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 };
- Profile[] result = new Profile[seq1.getLength()];
+ ProfileI[] result = new ProfileI[seq1.getLength()];
AAFrequency.calculate(seqs, 0, seq1.getLength(), result, false);
// col 0 is 100% C
- Profile col = result[0];
+ ProfileI col = result[0];
assertEquals(100f, col.getPercentageIdentity(false));
assertEquals(100f, col.getPercentageIdentity(true));
assertEquals(4, col.getMaxCount());
SequenceI seq3 = new Sequence("Seq3", "C--G");
SequenceI seq4 = new Sequence("Seq4", "CA-t");
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 };
- Profile[] result = new Profile[seq1.getLength()];
+ ProfileI[] result = new ProfileI[seq1.getLength()];
AAFrequency.calculate(seqs, 0, seq1.getLength(), result, true);
- Profile profile = result[0];
+ ProfileI profile = result[0];
assertEquals(4, profile.getCounts().getCount('C'));
assertEquals(4, profile.getHeight());
assertEquals(4, profile.getNonGapped());
SequenceI seq3 = new Sequence("Seq3", "C--G");
SequenceI seq4 = new Sequence("Seq4", "CA-t");
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 };
- Profile[] result = new Profile[seq1.getLength()];
+ ProfileI[] result = new ProfileI[seq1.getLength()];
// ensure class loaded and initialized
AAFrequency.calculate(seqs, 0, seq1.getLength(), result, true);
SequenceI seq3 = new Sequence("Seq3", "C---G");
SequenceI seq4 = new Sequence("Seq4", "CA--t");
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 };
- Profile[] profiles = new Profile[seq1.getLength()];
+ ProfileI[] profiles = new ProfileI[seq1.getLength()];
AAFrequency.calculate(seqs, 0, seq1.getLength(), profiles, true);
AlignmentAnnotation consensus = new AlignmentAnnotation("Consensus",
SequenceI seq3 = new Sequence("Seq3", "C---G");
SequenceI seq4 = new Sequence("Seq4", "CA--t");
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 };
- Profile[] profiles = new Profile[seq1.getLength()];
+ ProfileI[] profiles = new ProfileI[seq1.getLength()];
AAFrequency.calculate(seqs, 0, seq1.getLength(), profiles, true);
AlignmentAnnotation consensus = new AlignmentAnnotation("Consensus",
import static org.testng.AssertJUnit.assertTrue;
import jalview.datamodel.Profile;
+import jalview.datamodel.ProfileI;
import java.awt.Color;
* SR-T
* SR-T
*/
- Profile[] profiles = new Profile[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, "");