JAL-2349 bean for getting max/min/avg for contact range
authorJim Procter <jprocter@issues.jalview.org>
Wed, 18 Jan 2017 17:11:23 +0000 (17:11 +0000)
committerJim Procter <jprocter@issues.jalview.org>
Wed, 18 Jan 2017 17:11:23 +0000 (17:11 +0000)
src/jalview/datamodel/ContactRange.java [new file with mode: 0644]
test/jalview/datamodel/ContactRangeTest.java [new file with mode: 0644]

diff --git a/src/jalview/datamodel/ContactRange.java b/src/jalview/datamodel/ContactRange.java
new file mode 100644 (file)
index 0000000..0fb71cf
--- /dev/null
@@ -0,0 +1,144 @@
+package jalview.datamodel;
+
+
+/**
+ * bean for max/min positions for a given range
+ * 
+ * @author jprocter
+ *
+ */
+public class ContactRange
+{
+  int minPos;
+
+  double min;
+
+  int maxPos;
+
+  double max;
+
+  int from_column, to_column;
+
+  /**
+   * update the bean with given values
+   * 
+   * @param from_column
+   * @param to_column
+   * @param minPos
+   * @param min
+   * @param maxPos
+   * @param max
+   */
+  public void update(int from_column, int to_column, int minPos,
+          double min, int maxPos, double max)
+  {
+    this.from_column = from_column;
+    this.to_column = to_column;
+    this.minPos = minPos;
+    this.min = min;
+    this.maxPos = maxPos;
+    this.max = max;
+  }
+
+  /**
+   * @return the minPos
+   */
+  public int getMinPos()
+  {
+    return minPos;
+  }
+
+  /**
+   * @param minPos
+   *          the minPos to set
+   */
+  public void setMinPos(int minPos)
+  {
+    this.minPos = minPos;
+  }
+
+  /**
+   * @return the min
+   */
+  public double getMin()
+  {
+    return min;
+  }
+
+  /**
+   * @param min
+   *          the min to set
+   */
+  public void setMin(double min)
+  {
+    this.min = min;
+  }
+
+  /**
+   * @return the maxPos
+   */
+  public int getMaxPos()
+  {
+    return maxPos;
+  }
+
+  /**
+   * @param maxPos
+   *          the maxPos to set
+   */
+  public void setMaxPos(int maxPos)
+  {
+    this.maxPos = maxPos;
+  }
+
+  /**
+   * @return the max
+   */
+  public double getMax()
+  {
+    return max;
+  }
+
+  /**
+   * @param max
+   *          the max to set
+   */
+  public void setMax(double max)
+  {
+    this.max = max;
+  }
+
+  /**
+   * @return the from_column
+   */
+  public int getFrom_column()
+  {
+    return from_column;
+  }
+
+  /**
+   * @param from_column
+   *          the from_column to set
+   */
+  public void setFrom_column(int from_column)
+  {
+    this.from_column = from_column;
+  }
+
+  /**
+   * @return the to_column
+   */
+  public int getTo_column()
+  {
+    return to_column;
+  }
+
+  /**
+   * @param to_column
+   *          the to_column to set
+   */
+  public void setTo_column(int to_column)
+  {
+    this.to_column = to_column;
+  }
+}
diff --git a/test/jalview/datamodel/ContactRangeTest.java b/test/jalview/datamodel/ContactRangeTest.java
new file mode 100644 (file)
index 0000000..a0242a7
--- /dev/null
@@ -0,0 +1,32 @@
+package jalview.datamodel;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class ContactRangeTest {
+
+  @Test
+  public void testContactRangeBean()
+  {
+    ContactRange cr = new ContactRange();
+    cr.update(5, 15, 6, 0.2, 12, 1.5);
+    Assert.assertEquals(5, cr.getFrom_column());
+    Assert.assertEquals(15, cr.getTo_column());
+    Assert.assertEquals(6, cr.getMinPos());
+    Assert.assertEquals(0.2, cr.getMin());
+    Assert.assertEquals(12, cr.getMaxPos());
+    Assert.assertEquals(1.5, cr.getMax());
+    cr.setFrom_column(6);
+    Assert.assertEquals(6, cr.getFrom_column());
+    cr.setTo_column(16);
+    Assert.assertEquals(16, cr.getTo_column());
+    cr.setMinPos(7);
+    Assert.assertEquals(7, cr.getMinPos());
+    cr.setMin(0.4);
+    Assert.assertEquals(0.4, cr.getMin());
+    cr.setMaxPos(13);
+    Assert.assertEquals(13, cr.getMaxPos());
+    cr.setMax(2.5);
+    Assert.assertEquals(2.5, cr.getMax());
+  }
+}