$darkmode
DENOPTIM
FragmentIsomorphismInspectorTest.java
Go to the documentation of this file.
1package denoptim.graph;
2
3/*
4 * DENOPTIM
5 * Copyright (C) 2019 Vishwesh Venkatraman <vishwesh.venkatraman@ntnu.no>
6 * and Marco Foscato <marco.foscato@uib.no>
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published
10 * by the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22import static org.junit.jupiter.api.Assertions.assertFalse;
23import static org.junit.jupiter.api.Assertions.assertTrue;
24
25import javax.vecmath.Point3d;
26
27import org.junit.jupiter.api.Test;
28import org.openscience.cdk.Atom;
29import org.openscience.cdk.silent.Bond;
30
31import denoptim.exception.DENOPTIMException;
32
40{
41
42//------------------------------------------------------------------------------
43
45 {
46 Fragment v = new Fragment();
47 for (int i=0; i<size; i++)
48 {
49 Atom a = new Atom("C", new Point3d());
50 v.addAtom(a);
51 for (int j=0; j<i; j++)
52 {
53 v.addBond(new Bond(a,v.getAtom(j)));
54 }
55 v.addAPOnAtom(a, APClass.make("apc:1"), new Point3d());
56 }
57 return v;
58 }
59
60//------------------------------------------------------------------------------
61
62 @Test
63 public void testTimeout() throws Exception
64 {
67
69 new FragmentIsomorphismInspector(a,b, 10000); // 10 secs
70 inspector.reportTimeoutIncidents = false;
71 assertTrue(inspector.isomorphismExists());
72
73 inspector = new FragmentIsomorphismInspector(a,b, 10); // 0.01 secs
74 inspector.reportTimeoutIncidents = false;
75 assertFalse(inspector.isomorphismExists());
76 }
77
78//------------------------------------------------------------------------------
79
80}
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
Definition: APClass.java:136
Class representing a continuously connected portion of chemical object holding attachment points.
Definition: Fragment.java:61
AttachmentPoint addAPOnAtom(IAtom srcAtm, APClass apc, Point3d vector)
Add an attachment point to the specifies atom.
Definition: Fragment.java:424
void addBond(IBond bond)
Definition: Fragment.java:871
void addAtom(IAtom atom)
Definition: Fragment.java:836
IAtom getAtom(int number)
Definition: Fragment.java:843
boolean isomorphismExists()
Checks if an isomorphism exists between the two fragments.