import jalview.datamodel.Annotation;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
+import jalview.ext.android.SparseIntArray;
import jalview.schemes.ResidueProperties;
import java.awt.Color;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import java.util.Vector;
/**
*/
public void calculate()
{
- int thresh, j, jSize = sequences.length;
- int[] values; // Replaces residueHash
- char c;
+ int jSize = sequences.length;
+ // int[] values; // Replaces residueHash
+ SparseIntArray values = new SparseIntArray();
- total = new Hashtable[maxLength];
+ total = new Map[maxLength];
for (int i = start; i <= end; i++)
{
- values = new int[255];
+ // values = new int[255];
+ values.clear();
- for (j = 0; j < jSize; j++)
+ for (int j = 0; j < jSize; j++)
{
if (sequences[j].getLength() > i)
{
- c = sequences[j].getCharAt(i);
+ char c = sequences[j].getCharAt(i);
if (canonicaliseAa)
{ // lookup the base aa code symbol
c = toUpperCase(c);
}
- values[c]++;
+ // values[c]++;
+ values.add(c, 1);
}
else
{
- values['-']++;
+ // values['-']++;
+ values.add('-', 1);
}
}
// What is the count threshold to count the residues in residueHash()
- thresh = (threshold * (jSize)) / 100;
+ int thresh = (threshold * jSize) / 100;
// loop over all the found residues
- Hashtable<String, Integer> resultHash = new Hashtable<String, Integer>();
- for (char v = '-'; v < 'Z'; v++)
+ // Hashtable<String, Integer> resultHash = new Hashtable<String,
+ // Integer>();
+ Map<String, Integer> resultHash = new TreeMap<String, Integer>();
+ // for (char v = '-'; v < 'Z'; v++)
+ for (int key = 0; key < values.size(); key++)
{
-
- if (values[v] > thresh)
+ char v = (char) values.keyAt(key);
+ // if (values[v] > thresh)
+ if (values.valueAt(key) > thresh)
{
String res = String.valueOf(v);
*/
public void verdict(boolean consflag, float percentageGaps)
{
- StringBuffer consString = new StringBuffer();
+ StringBuilder consString = new StringBuilder(end);
// NOTE THIS SHOULD CHECK IF THE CONSEQUENCE ALREADY
// EXISTS AND NOT OVERWRITE WITH '-', BUT THIS CASE
int[] gapcons = countConsNGaps(i);
int totGaps = gapcons[1];
float pgaps = ((float) totGaps * 100) / sequences.length;
- consSymbs[i - start] = new String();
+ StringBuilder positives = new StringBuilder(64);
+ StringBuilder negatives = new StringBuilder(32);
+ // consSymbs[i - start] = "";
if (percentageGaps > pgaps)
{
{
if (result == 1)
{
- consSymbs[i - start] = type + " " + consSymbs[i - start];
+ // consSymbs[i - start] = type + " " + consSymbs[i - start];
+ positives.append(positives.length() == 0 ? "" : " ");
+ positives.append(type);
count++;
}
}
{
if (result == 0)
{
- consSymbs[i - start] = consSymbs[i - start] + " !" + type;
+ /*
+ * add negatively conserved properties on the end
+ */
+ // consSymbs[i - start] = consSymbs[i - start] + " !" + type;
+ negatives.append(negatives.length() == 0 ? "" : " ");
+ negatives.append("!").append(type);
}
else
{
- consSymbs[i - start] = type + " " + consSymbs[i - start];
+ /*
+ * put positively conserved properties on the front
+ */
+ // consSymbs[i - start] = type + " " + consSymbs[i - start];
+ positives.append(positives.length() == 0 ? "" : " ");
+ positives.append(type);
}
count++;
}
}
}
+ if (negatives.length() > 0)
+ {
+ positives.append(" ").append(negatives);
+ }
+ consSymbs[i - start] = positives.toString();
if (count < 10)
{
{
tot = 0;
xx = new double[24];
- seqNum = (j < lengths[k]) ? seqNums.elementAt(k)[j + 1]
- : 23; // Sequence, or gap at the end
+ seqNum = (j < lengths[k]) ? seqNums.elementAt(k)[j + 1] : 23; // Sequence,
+ // or gap
+ // at the
+ // end
// This is a loop over r
for (i = 0; i < 23; i++)
Conservation cons = new Conservation(name, threshold, seqs, start, end);
cons.calculate();
cons.verdict(posOrNeg, consPercGaps);
-
+
if (calcQuality)
{
cons.findQuality();
}
-
+
return cons;
}
}
package jalview.api;
import jalview.analysis.Conservation;
+import jalview.analysis.Profile;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
ColumnSelection getColumnSelection();
- Hashtable[] getSequenceConsensusHash();
+ Profile[] getSequenceConsensusHash();
/**
* Get consensus data table for the cDNA complement of this alignment (if any)
*
* @param hconsensus
*/
- void setSequenceConsensusHash(Hashtable[] hconsensus);
+ void setSequenceConsensusHash(Profile[] hconsensus);
/**
* Set the cDNA complement consensus for the viewport
* @return String[]
*/
String[] getViewAsString(boolean selectedRegionOnly);
-
+
/**
* This method returns the visible alignment as text, as seen on the GUI, ie
* if columns are hidden they will not be returned in the result. Use this for
*
* @return String[]
*/
- String[] getViewAsString(boolean selectedRegionOnly, boolean isExportHiddenSeqs);
+ String[] getViewAsString(boolean selectedRegionOnly,
+ boolean isExportHiddenSeqs);
void setSelectionGroup(SequenceGroup sg);
*/
void setFollowHighlight(boolean b);
-
public void applyFeaturesStyle(FeatureSettingsModelI featureSettings);
/**
import jalview.analysis.AAFrequency;
import jalview.analysis.CodingUtils;
+import jalview.analysis.Profile;
import jalview.analysis.Rna;
import jalview.analysis.StructureFrequency;
import jalview.api.AlignViewportI;
private ColumnSelection columnSelection;
- private Hashtable[] hconsensus;
+ private Profile[] hconsensus;
private Hashtable[] complementConsensus;
annotationPanel = null;
}
- void drawStemAnnot(Graphics g, Annotation[] row_annotations,
- int lastSSX, int x, int y, int iconOffset, int startRes,
- int column, boolean validRes, boolean validEnd)
+ void drawStemAnnot(Graphics g, Annotation[] row_annotations, int lastSSX,
+ int x, int y, int iconOffset, int startRes, int column,
+ boolean validRes, boolean validEnd)
{
g.setColor(STEM_COLOUR);
int sCol = (lastSSX / charWidth) + startRes;
private Color sdNOTCANONICAL_COLOUR;
- void drawGlyphLine(Graphics g, Annotation[] row, int lastSSX,
- int x, int y, int iconOffset, int startRes, int column,
+ void drawGlyphLine(Graphics g, Annotation[] row, int lastSSX, int x,
+ int y, int iconOffset, int startRes, int column,
boolean validRes, boolean validEnd)
{
g.setColor(GLYPHLINE_COLOR);
}
- void drawHelixAnnot(Graphics g, Annotation[] row, int lastSSX,
- int x, int y, int iconOffset, int startRes, int column,
+ void drawHelixAnnot(Graphics g, Annotation[] row, int lastSSX, int x,
+ int y, int iconOffset, int startRes, int column,
boolean validRes, boolean validEnd)
{
g.setColor(HELIX_COLOUR);
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.analysis.Conservation;
+import jalview.analysis.Profile;
import jalview.api.AlignCalcManagerI;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
/**
* results of alignment consensus analysis for visible portion of view
*/
- protected Hashtable[] hconsensus = null;
+ protected Profile[] hconsensus = null;
/**
* results of cDNA complement consensus visible portion of view
}
@Override
- public void setSequenceConsensusHash(Hashtable[] hconsensus)
+ public void setSequenceConsensusHash(Profile[] hconsensus)
{
this.hconsensus = hconsensus;
}
}
@Override
- public Hashtable[] getSequenceConsensusHash()
+ public Profile[] getSequenceConsensusHash()
{
return hconsensus;
}
public boolean isHiddenRepSequence(SequenceI seq)
{
return (hiddenRepSequences != null && hiddenRepSequences
- .containsKey(seq));
+ .containsKey(seq));
}
/**
public void expandColSelection(SequenceGroup sg, boolean wholewidth)
{
int sgs, sge;
- if (sg != null
- && (sgs = sg.getStartRes()) >= 0
+ if (sg != null && (sgs = sg.getStartRes()) >= 0
&& sg.getStartRes() <= (sge = sg.getEndRes())
&& !this.hasSelectedColumns())
{