git://source.jalview.org
/
jalview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8dc4fa1
)
JAL-98 bug fix, string optimisation, sorted AA properties
author
gmungoc
<g.m.carstairs@dundee.ac.uk>
Mon, 26 Sep 2016 10:35:33 +0000
(11:35 +0100)
committer
gmungoc
<g.m.carstairs@dundee.ac.uk>
Mon, 26 Sep 2016 10:35:33 +0000
(11:35 +0100)
src/jalview/analysis/Conservation.java
patch
|
blob
|
history
diff --git
a/src/jalview/analysis/Conservation.java
b/src/jalview/analysis/Conservation.java
index
26a7b9f
..
0467900
100755
(executable)
--- a/
src/jalview/analysis/Conservation.java
+++ b/
src/jalview/analysis/Conservation.java
@@
-28,9
+28,9
@@
import jalview.ext.android.SparseIntArray;
import jalview.schemes.ResidueProperties;
import java.awt.Color;
import jalview.schemes.ResidueProperties;
import java.awt.Color;
-import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import java.util.Vector;
/**
import java.util.Vector;
/**
@@
-189,22
+189,22
@@
public class Conservation
*/
public void calculate()
{
*/
public void calculate()
{
- int thresh, j, jSize = sequences.length;
+ int jSize = sequences.length;
// int[] values; // Replaces residueHash
SparseIntArray values = new SparseIntArray();
// int[] values; // Replaces residueHash
SparseIntArray values = new SparseIntArray();
- char c;
- total = new Hashtable[maxLength];
+ total = new Map[maxLength];
for (int i = start; i <= end; i++)
{
// values = new int[255];
for (int i = start; i <= end; i++)
{
// values = new int[255];
+ values.clear();
- for (j = 0; j < jSize; j++)
+ for (int j = 0; j < jSize; j++)
{
if (sequences[j].getLength() > i)
{
{
if (sequences[j].getLength() > i)
{
- c = sequences[j].getCharAt(i);
+ char c = sequences[j].getCharAt(i);
if (canonicaliseAa)
{ // lookup the base aa code symbol
if (canonicaliseAa)
{ // lookup the base aa code symbol
@@
-231,25
+231,28
@@
public class Conservation
c = toUpperCase(c);
}
// values[c]++;
c = toUpperCase(c);
}
// values[c]++;
- values.put(c, values.get(c) + 1);
+ values.add(c, 1);
}
else
{
// values['-']++;
}
else
{
// values['-']++;
- values.put('-', values.get('-') + 1);
+ values.add('-', 1);
}
}
// What is the count threshold to count the residues in residueHash()
}
}
// 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
// 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++)
{
{
-
+ char v = (char) values.keyAt(key);
// if (values[v] > thresh)
// if (values[v] > thresh)
- if (values.get(v) > thresh)
+ if (values.valueAt(key) > thresh)
{
String res = String.valueOf(v);
{
String res = String.valueOf(v);
@@
-364,7
+367,7
@@
public class Conservation
*/
public void verdict(boolean consflag, float percentageGaps)
{
*/
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
// NOTE THIS SHOULD CHECK IF THE CONSEQUENCE ALREADY
// EXISTS AND NOT OVERWRITE WITH '-', BUT THIS CASE
@@
-379,7
+382,9
@@
public class Conservation
int[] gapcons = countConsNGaps(i);
int totGaps = gapcons[1];
float pgaps = ((float) totGaps * 100) / sequences.length;
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 (percentageGaps > pgaps)
{
@@
-394,7
+399,9
@@
public class Conservation
{
if (result == 1)
{
{
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++;
}
}
count++;
}
}
@@
-404,16
+411,31
@@
public class Conservation
{
if (result == 0)
{
{
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
{
}
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++;
}
}
}
}
count++;
}
}
}
+ if (negatives.length() > 0)
+ {
+ positives.append(" ").append(negatives);
+ }
+ consSymbs[i - start] = positives.toString();
if (count < 10)
{
if (count < 10)
{