1 package jalview.datamodel;
3 import jalview.gui.JvOptionPane;
5 import org.testng.Assert;
6 import org.testng.annotations.BeforeClass;
7 import org.testng.annotations.Test;
9 public class ContactMatrixTest
11 @BeforeClass(alwaysRun = true)
12 public void setUpJvOptionPane()
14 JvOptionPane.setInteractiveMode(false);
15 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
19 * standard asserts for ContactMatrixI
21 public static void testContactMatrixI(ContactMatrixI cm, boolean symmetric)
23 // assume contact matrix is square for text
24 ContactListI clist = cm.getContactList(1);
26 int width = clist.getContactHeight();
27 Double minValue, maxValue;
28 minValue = clist.getContactAt(0);
31 for (int p = 0; p < width; p++)
33 ContactListI pList = cm.getContactList(p);
34 for (int q = p; q < width; q++)
38 // compute minMax for pList
39 minMax(minValue, maxValue, pList);
42 ContactListI qList = cm.getContactList(q);
45 Assert.assertEquals(qList.getContactAt(p), pList.getContactAt(q),
46 "Contact matrix not symmetric");
50 Assert.assertNotEquals(qList.getContactAt(p),
51 pList.getContactAt(q),
52 "Contact matrix expected to be not symmetric");
58 private static void minMax(Double minValue, Double maxValue,
61 int width = pList.getContactHeight();
62 for (int rowcol = 0; rowcol < width; rowcol++)
64 double v = pList.getContactAt(rowcol);
76 @Test(groups = { "Functional" })
77 public void testminMaxCalc()
79 ContactListI clist = new ContactListImpl(new ContactListProviderI()
81 double[] val = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7 };
84 public int getContactHeight()
90 public double getContactAt(int column)
92 if (column < 0 || column >= val.length)
103 * test construction and accessors for asymmetric contact matrix
105 @Test(groups = { "Functional" })
106 public void testAsymmetricContactMatrix()
112 * test construction and accessors for symmetric contact matrix
114 @Test(groups = { "Functional" })
115 public void testSymmetricContactMatrix()