/
ElectronImpactPDBReactionTest.java
103 lines (81 loc) · 3.77 KB
/
ElectronImpactPDBReactionTest.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
package org.openscience.cdk.test.reaction.type;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.Molecule;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.interfaces.ISetOfMolecules;
import org.openscience.cdk.interfaces.ISetOfReactions;
import org.openscience.cdk.reaction.IReactionProcess;
import org.openscience.cdk.reaction.type.ElectronImpactPDBReaction;
import org.openscience.cdk.smiles.SmilesParser;
import org.openscience.cdk.test.CDKTestCase;
/**
* TestSuite that runs a test for the ElectronImpactPDBReactionTest.
*
* @cdk.module test-reaction
*/
public class ElectronImpactPDBReactionTest extends CDKTestCase {
public ElectronImpactPDBReactionTest() {}
public static Test suite() {
return new TestSuite(ElectronImpactPDBReactionTest.class);
}
/**
* A unit test for JUnit
*
*@return Description of the Return Value
*/
public void test1_5_Hexen_3_one() throws ClassNotFoundException, CDKException, java.lang.Exception {
/* ionize >C=C< , set the reactive center*/
Molecule reactant = (new SmilesParser()).parseSmiles("C=CCC(=O)CC");
IBond[] bonds = reactant.getBonds();
for(int i = 0 ; i < bonds.length ; i++){
IAtom[] atoms = bonds[i].getAtoms();
if(bonds[i].getOrder() == 2 &&
atoms[0].getSymbol().equals("C")&&
atoms[1].getSymbol().equals("C")){
bonds[i].setFlag(CDKConstants.REACTIVE_CENTER,true);
}
}
ISetOfMolecules setOfReactants = DefaultChemObjectBuilder.getInstance().newSetOfMolecules();
setOfReactants.addMolecule(reactant);
IReactionProcess type = new ElectronImpactPDBReaction();
Object[] params = {Boolean.TRUE};
type.setParameters(params);
ISetOfReactions setOfReactions = type.initiate(setOfReactants, null);
Assert.assertEquals(1, setOfReactions.getReactionCount());
IMolecule molecule = setOfReactions.getReaction(0).getProducts().getMolecule(0);
Assert.assertEquals(1, molecule.getAtomAt(1).getFormalCharge());
Assert.assertEquals(1, molecule.getSingleElectronSum(molecule.getAtomAt(0)));
molecule = setOfReactions.getReaction(0).getProducts().getMolecule(1);
Assert.assertEquals(1, molecule.getAtomAt(0).getFormalCharge());
Assert.assertEquals(1, molecule.getSingleElectronSum(molecule.getAtomAt(1)));
}
/**
* A unit test for JUnit
*
*@return Description of the Return Value
*/
public void test_Propene() throws ClassNotFoundException, CDKException, java.lang.Exception {
/* ionize all possible double bonds */
Molecule reactant = (new SmilesParser()).parseSmiles("C=CC");
ISetOfMolecules setOfReactants = DefaultChemObjectBuilder.getInstance().newSetOfMolecules();
setOfReactants.addMolecule(reactant);
IReactionProcess type = new ElectronImpactPDBReaction();
// Object[] params = {false};
// type.setParameters(params);
ISetOfReactions setOfReactions = type.initiate(setOfReactants, null);
Assert.assertEquals(1, setOfReactions.getReactionCount());
IMolecule molecule = setOfReactions.getReaction(0).getProducts().getMolecule(0);
Assert.assertEquals(1, molecule.getAtomAt(1).getFormalCharge());
Assert.assertEquals(1, molecule.getSingleElectronSum(molecule.getAtomAt(0)));
molecule = setOfReactions.getReaction(0).getProducts().getMolecule(1);
Assert.assertEquals(1, molecule.getAtomAt(0).getFormalCharge());
Assert.assertEquals(1, molecule.getSingleElectronSum(molecule.getAtomAt(1)));
}
}