JAL-1741 nucleotide-aware colour schemes applied to structures
[jalview.git] / src / jalview / schemes / ResidueProperties.java
index 0f34824..662a77e 100755 (executable)
  */
 package jalview.schemes;
 
-import jalview.analysis.scoremodels.FeatureScoreModel;
-import jalview.analysis.scoremodels.PIDScoreModel;
-import jalview.api.analysis.ScoreModelI;
-
 import java.awt.Color;
 import java.util.ArrayList;
 import java.util.Enumeration;
@@ -33,6 +29,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.Vector;
 
+import jalview.analysis.scoremodels.FeatureScoreModel;
+import jalview.analysis.scoremodels.PIDScoreModel;
+import jalview.api.analysis.ScoreModelI;
+
 public class ResidueProperties
 {
   public static Hashtable<String, ScoreModelI> scoreMatrices = new Hashtable();
@@ -1787,4 +1787,52 @@ public class ResidueProperties
   }
   // to here
 
+  /**
+   * Returns a list of residue characters for the specified inputs
+   * 
+   * @param nucleotide
+   * @param includeAmbiguous
+   * @return
+   */
+  public static List<String> getResidues(boolean nucleotide,
+          boolean includeAmbiguous)
+  {
+    List<String> result = new ArrayList<String>();
+    if (nucleotide)
+    {
+      for (String nuc : nucleotideName.keySet())
+      {
+        int val = nucleotideIndex[nuc.charAt(0)];
+        if ((!includeAmbiguous && val > 4) || (val >= maxNucleotideIndex))
+        {
+          continue;
+        }
+        nuc = nuc.toUpperCase();
+        if (!result.contains(nuc))
+        {
+          result.add(nuc);
+        }
+      }
+    } else {
+      /*
+       * Peptide
+       */
+      for (String res : aa3Hash.keySet())
+      {
+        int index = aa3Hash.get(res).intValue();
+        if ((!includeAmbiguous && index >= 20) || index >= maxProteinIndex)
+        {
+          continue;
+        }
+        res = res.toUpperCase();
+        if (!result.contains(res))
+        {
+          result.add(res);
+        }
+      }
+    }
+
+    return result;
+  }
+
 }