2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
23 import org.testng.Assert;
24 import org.testng.annotations.BeforeClass;
25 import org.testng.annotations.Test;
27 import jalview.gui.JvOptionPane;
29 public class ContactMatrixTest
31 @BeforeClass(alwaysRun = true)
32 public void setUpJvOptionPane()
34 JvOptionPane.setInteractiveMode(false);
35 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
39 * standard asserts for ContactMatrixI
41 public static void testContactMatrixI(ContactMatrixI cm,
44 // assume contact matrix is square for text
45 ContactListI clist = cm.getContactList(1);
47 int width = clist.getContactHeight();
48 Double minValue, maxValue;
49 minValue = clist.getContactAt(0);
52 for (int p = 0; p < width; p++)
54 ContactListI pList = cm.getContactList(p);
55 for (int q = p; q < width; q++)
59 // compute minMax for pList
60 minMax(minValue, maxValue, pList);
63 ContactListI qList = cm.getContactList(q);
66 Assert.assertEquals(qList.getContactAt(p), pList.getContactAt(q),
67 "Contact matrix not symmetric");
71 Assert.assertNotEquals(qList.getContactAt(p),
72 pList.getContactAt(q),
73 "Contact matrix expected to be not symmetric");
79 private static void minMax(Double minValue, Double maxValue,
82 int width = pList.getContactHeight();
83 for (int rowcol = 0; rowcol < width; rowcol++)
85 double v = pList.getContactAt(rowcol);
97 @Test(groups = { "Functional" })
98 public void testminMaxCalc()
100 ContactListI clist = new ContactListImpl(new ContactListProviderI()
102 double[] val = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7 };
105 public int getPosition()
111 public int getContactHeight()
117 public double getContactAt(int column)
119 if (column < 0 || column >= val.length)
127 // TODO - write test !
131 * test construction and accessors for asymmetric contact matrix
133 @Test(groups = { "Functional" })
134 public void testAsymmetricContactMatrix()
136 // TODO - write test !
141 * test construction and accessors for symmetric contact matrix
143 @Test(groups = { "Functional" })
144 public void testSymmetricContactMatrix()
146 // TODO - write test !