-
Notifications
You must be signed in to change notification settings - Fork 154
/
VFlibTurboHandlerTest.java
222 lines (192 loc) · 8.54 KB
/
VFlibTurboHandlerTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
/* Copyright (C) 2009-2010 Syed Asad Rahman <asad@ebi.ac.uk>
*
* Contact: cdk-devel@lists.sourceforge.net
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation; either version 2.1
* of the License, or (at your option) any later version.
* All we ask is that proper credit is given for our work, which includes
* - but is not limited to - adding the above copyright notice to the beginning
* of your source code files, and to any copyright notice that you may distribute
* with programs based on this work.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package org.openscience.cdk.smsd.algorithm.vflib;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openscience.cdk.AtomContainer;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.exception.InvalidSmilesException;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.io.IChemObjectReader.Mode;
import org.openscience.cdk.io.MDLV2000Reader;
import org.openscience.cdk.smiles.SmilesParser;
import org.openscience.cdk.smsd.interfaces.AbstractSubGraphTest;
import org.openscience.cdk.smsd.tools.MolHandler;
/**
* @author Syed Asad Rahman <asad@ebi.ac.uk>
*
* @cdk.module test-smsd
* @cdk.require java1.6+
*/
public class VFlibTurboHandlerTest extends AbstractSubGraphTest {
public VFlibTurboHandlerTest() {}
@BeforeClass
public static void setUpClass() throws Exception {}
@AfterClass
public static void tearDownClass() throws Exception {}
@Before
@Override
public void setUp() {}
@After
@Override
public void tearDown() {}
/**
* Test of isSubgraph method, of class VFlibSubStructureHandler.
* @throws InvalidSmilesException
*/
@Test
@Override
public void testIsSubgraph() throws InvalidSmilesException {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
IAtomContainer queryac = sp.parseSmiles("Nc1ccccc1");
VFlibSubStructureHandler smsd1 = new VFlibSubStructureHandler();
MolHandler mol1 = new MolHandler(queryac, true, true);
MolHandler mol2 = new MolHandler(target, true, true);
smsd1.set(mol1, mol2);
assertTrue(smsd1.isSubgraph(true));
}
/**
* Test of set method, of class VFlibSubStructureHandler.
* @throws Exception
*/
@Test
public void testSet_IAtomContainer_IAtomContainer() throws Exception {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
IAtomContainer queryac = sp.parseSmiles("Nc1ccccc1");
VFlibSubStructureHandler smsd1 = new VFlibSubStructureHandler();
MolHandler mol1 = new MolHandler(queryac, true, true);
MolHandler mol2 = new MolHandler(target, true, true);
smsd1.set(mol1, mol2);
assertTrue(smsd1.isSubgraph(true));
}
/**
* Test of set method, of class VFlibSubStructureHandler.
* @throws CDKException
*/
@Test
public void testSet_String_String() throws CDKException {
String molfile = "data/mdl/decalin.mol";
String queryfile = "data/mdl/decalin.mol";
IAtomContainer query = new AtomContainer();
IAtomContainer target = new AtomContainer();
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(molfile);
MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.STRICT);
reader.read(query);
ins = this.getClass().getClassLoader().getResourceAsStream(queryfile);
reader = new MDLV2000Reader(ins, Mode.STRICT);
reader.read(target);
VFlibSubStructureHandler smsd1 = new VFlibSubStructureHandler();
MolHandler mol1 = new MolHandler(query, true, true);
MolHandler mol2 = new MolHandler(target, true, true);
smsd1.set(mol1, mol2);
assertTrue(smsd1.isSubgraph(true));
}
/**
* Test of set method, of class VFlibSubStructureHandler.
* @throws InvalidSmilesException
*/
@Test
public void testSet_MolHandler_MolHandler() throws InvalidSmilesException {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer target1 = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
IAtomContainer queryac = sp.parseSmiles("Nc1ccccc1");
MolHandler source = new MolHandler(queryac, true, true);
MolHandler target = new MolHandler(target1, true, true);
VFlibSubStructureHandler instance = new VFlibSubStructureHandler();
instance.set(source, target);
assertTrue(instance.isSubgraph(true));
}
/**
* Test of getAllAtomMapping method, of class VFlibSubStructureHandler.
* @throws InvalidSmilesException
*/
@Test
public void testGetAllAtomMapping() throws InvalidSmilesException {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
IAtomContainer queryac = sp.parseSmiles("Nc1ccccc1");
VFlibSubStructureHandler smsd1 = new VFlibSubStructureHandler();
MolHandler mol1 = new MolHandler(queryac, true, true);
MolHandler mol2 = new MolHandler(target, true, true);
smsd1.set(mol1, mol2);
smsd1.isSubgraph(true);
assertEquals(4, smsd1.getAllAtomMapping().size());
}
/**
* Test of getAllMapping method, of class VFlibSubStructureHandler.
* @throws InvalidSmilesException
*/
@Test
public void testGetAllMapping() throws InvalidSmilesException {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
IAtomContainer queryac = sp.parseSmiles("Nc1ccccc1");
VFlibSubStructureHandler smsd1 = new VFlibSubStructureHandler();
MolHandler mol1 = new MolHandler(queryac, true, true);
MolHandler mol2 = new MolHandler(target, true, true);
smsd1.set(mol1, mol2);
smsd1.isSubgraph(true);
assertEquals(4, smsd1.getAllMapping().size());
}
/**
* Test of getFirstAtomMapping method, of class VFlibSubStructureHandler.
* @throws InvalidSmilesException
*/
@Test
public void testGetFirstAtomMapping() throws InvalidSmilesException {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
IAtomContainer queryac = sp.parseSmiles("Nc1ccccc1");
VFlibSubStructureHandler smsd1 = new VFlibSubStructureHandler();
MolHandler mol1 = new MolHandler(queryac, true, true);
MolHandler mol2 = new MolHandler(target, true, true);
smsd1.set(mol1, mol2);
smsd1.isSubgraph(true);
assertEquals(7, smsd1.getFirstAtomMapping().size());
}
/**
* Test of getFirstMapping method, of class VFlibSubStructureHandler.
* @throws InvalidSmilesException
*/
@Test
public void testGetFirstMapping() throws InvalidSmilesException {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer target = sp.parseSmiles("C\\C=C/Nc1cccc(c1)N(O)\\C=C\\C\\C=C\\C=C/C");
IAtomContainer queryac = sp.parseSmiles("Nc1ccccc1");
VFlibSubStructureHandler smsd1 = new VFlibSubStructureHandler();
MolHandler mol1 = new MolHandler(queryac, true, true);
MolHandler mol2 = new MolHandler(target, true, true);
smsd1.set(mol1, mol2);
smsd1.isSubgraph(true);
assertEquals(7, smsd1.getFirstMapping().size());
}
}