package ee.ut.ga.model;

/**
 * Keeps the motif scoring value for a motif starting in the specified row at specified position.
 * Comparable by weight.
 * @author Anton Stalnuhhin (a30858@math.ut.ee)
 */
public class Weight implements Comparable {
  private int dataRow; //row number in data
  private int dataRowPosition; //position in row, where motif starts
  private double weight; //weight of motif

  public Weight(int dataRow, int dataRowPosition, double weight) {
    this.dataRow = dataRow;
    this.dataRowPosition = dataRowPosition;
    this.weight = weight;
  }

  public int getDataRow() {
    return dataRow;
  }

  public void setDataRow(int gene) {
    this.dataRow = gene;
  }

  public int getDataRowPosition() {
    return dataRowPosition;
  }

  public void setDataRowPosition(int position) {
    this.dataRowPosition = position;
  }

  public double getWeight() {
    return weight;
  }

  public void setWeight(double weight) {
    this.weight = weight;
  }

  public String toString() {
    return "Gene #" + dataRow + " at position " + dataRowPosition + " with weight " + weight;
  }

  public int compareTo(Object o) {

    if (!(o instanceof Weight)) {
      throw new ClassCastException("Must be a Weight object!");
    }

    double diff = weight - ((Weight) o).getWeight();
    if (diff < 0)
      return 1;
    if (diff > 0)
      return -1;
    return 0;
  }

}