import java.util.*;
import java.lang.String;


/**
 * DNA holds a string of nucleotides and allows
 * @param   nucleos The nucleotide string
 *                  anything that isn't ACG or T is ignored
 *                  by all functions in the class.
 */
public class DNA {
  private String nucleotides = "";
  public DNA(String nucleos) {
    this.nucleotides = nucleos;
  }

  /**
   * nucleotideCounts returns a Map of how many there are of each
   * nucleotide in the string.
   * @return    The Map from nucleotide -> count
   */
  public Map<Character, Integer> nucleotideCounts() {
    Map<Character, Integer> ret = new HashMap<Character, Integer>();
    ret.put('A', this.count('A'));
    ret.put('C', this.count('C'));
    ret.put('G', this.count('G'));
    ret.put('T', this.count('T'));
    return ret;
  }

  /**
   * Counts how many instances of a specific nucleotide exist
   * in the string.
   * @param which The nucleotide that we're counting
   * @return      How many of that nucleotide there were.
   */
  public int count(char which) {
    if(which != 'A' && which != 'C' && which != 'G' && which != 'T') {
      throw new IllegalArgumentException();
    }
    char[] nucChar = this.nucleotides.toCharArray();
    int ret = 0;
    for(int i = 0; i < nucChar.length; i++) {
      if(nucChar[i] == which) {
        ret++;
      }
    }
    return ret;
  }
}
