- c = sequences[j].getCharAt(i);
-
- if (canonicaliseAa)
- { // lookup the base aa code symbol
- c = (char) ResidueProperties.aaIndex[sequences[j].getCharAt(i)];
- if (c > 20)
- {
- c = '-';
- }
- else
- {
- // recover canonical aa symbol
- c = ResidueProperties.aa[c].charAt(0);
- }
- }
- else
- {
- // original behaviour - operate on ascii symbols directly
- // No need to check if its a '-'
- if (c == '.' || c == ' ')
- {
- c = '-';
- }
-
- c = toUpperCase(c);
- }
- values[c]++;
+ recordConservation(resultHash, String.valueOf(c));
+ }
+ }
+ if (values.getGapCount() > thresh)
+ {
+ recordConservation(resultHash, "-");
+ }
+
+ if (total.length > 0)
+ {
+ total[column - start] = resultHash;
+ }
+ }
+ }
+
+ /**
+ * Updates the conservation results for an observed residue
+ *
+ * @param resultMap
+ * a map of {property, conservation} where conservation value is +1
+ * (all residues have the property), 0 (no residue has the property)
+ * or -1 (some do, some don't)
+ * @param res
+ */
+ protected static void recordConservation(Map<String, Integer> resultMap,
+ String res)
+ {
+ res = res.toUpperCase();
+ for (Entry<String, Map<String, Integer>> property : ResidueProperties.propHash
+ .entrySet())
+ {
+ String propertyName = property.getKey();
+ Integer residuePropertyValue = property.getValue().get(res);
+
+ if (!resultMap.containsKey(propertyName))
+ {
+ /*
+ * first time we've seen this residue - note whether it has this property
+ */
+ if (residuePropertyValue != null)
+ {
+ resultMap.put(propertyName, residuePropertyValue);