@Test public void testIntegerArrayResult() { IntegerArrayResult result = new IntegerArrayResult(); Assert.assertNotNull(result); Assert.assertEquals(0, result.length()); }
@Test public void IntegerArrayResult_int() { IntegerArrayResult result = new IntegerArrayResult(5); Assert.assertNotNull(result); Assert.assertEquals(5, result.length()); }
@Test public void testAdd_int() { IntegerArrayResult result = new IntegerArrayResult(); Assert.assertNotNull(result); result.add(5); result.add(5); result.add(5); result.add(5); result.add(5); Assert.assertEquals(5, result.length()); }
@Test public void testAACount() throws Exception { IBioPolymer protein = ProteinBuilderTool.createProtein("ARNDCFQEGHIPLKMSTYVW", SilentChemObjectBuilder.getInstance()); IDescriptorResult result = descriptor.calculate(protein).getValue(); Assert.assertTrue(result instanceof IntegerArrayResult); IntegerArrayResult iaResult = (IntegerArrayResult) result; for (int i = 0; i < iaResult.length(); i++) { Assert.assertTrue(iaResult.get(i) >= 1); // all AAs are found at least once } Assert.assertEquals(20, iaResult.get(8)); // glycine is in all of them, so 20 times }
@Test public void test1() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("CCO"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); Aromaticity.cdkLegacy().apply(mol); DescriptorValue value = descriptor.calculate(mol); IntegerArrayResult result = (IntegerArrayResult) value.getValue(); Assert.assertEquals(79, result.length()); Assert.assertEquals(1, result.get(getIndex("khs.sOH"))); }
@Test public void test3() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("C#CC(C)(C)C(C)(C)C#C"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); Aromaticity.cdkLegacy().apply(mol); DescriptorValue value = descriptor.calculate(mol); IntegerArrayResult result = (IntegerArrayResult) value.getValue(); Assert.assertEquals(79, result.length()); Assert.assertEquals(2, result.get(getIndex("khs.tsC"))); Assert.assertEquals(2, result.get(getIndex("khs.ssssC"))); } }
/** * Checks that the results of the first and the second descriptor results * are identical. * * @param v1 first {@link IDescriptorResult} * @param v2 second {@link IDescriptorResult} * @param errorMessage error message to report when the results are not the same */ private void assertEqualOutput(IDescriptorResult v1, IDescriptorResult v2, String errorMessage) { if (v1 instanceof IntegerResult) { Assert.assertEquals(errorMessage, ((IntegerResult) v1).intValue(), ((IntegerResult) v2).intValue()); } else if (v1 instanceof DoubleResult) { Assert.assertEquals(errorMessage, ((DoubleResult) v1).doubleValue(), ((DoubleResult) v2).doubleValue(), 0.00001); } else if (v1 instanceof BooleanResult) { Assert.assertEquals(errorMessage, ((BooleanResult) v1).booleanValue(), ((BooleanResult) v2).booleanValue()); } else if (v1 instanceof DoubleArrayResult) { DoubleArrayResult da1 = (DoubleArrayResult) v1; DoubleArrayResult da2 = (DoubleArrayResult) v2; for (int i = 0; i < da1.length(); i++) { Assert.assertEquals(errorMessage, da1.get(i), da2.get(i), 0.00001); } } else if (v1 instanceof IntegerArrayResult) { IntegerArrayResult da1 = (IntegerArrayResult) v1; IntegerArrayResult da2 = (IntegerArrayResult) v2; for (int i = 0; i < da1.length(); i++) { Assert.assertEquals(errorMessage, da1.get(i), da2.get(i)); } } }
@Test public void test2() throws Exception { SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("c1c(CN)cc(CCNC)cc1C(CO)CC(=O)CCOCCCO"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); Aromaticity.cdkLegacy().apply(mol); DescriptorValue value = descriptor.calculate(mol); IntegerArrayResult result = (IntegerArrayResult) value.getValue(); Assert.assertEquals(79, result.length()); Assert.assertEquals(2, result.get(getIndex("khs.sOH"))); Assert.assertEquals(1, result.get(getIndex("khs.dO"))); Assert.assertEquals(1, result.get(getIndex("khs.ssO"))); Assert.assertEquals(1, result.get(getIndex("khs.sNH2"))); Assert.assertEquals(1, result.get(getIndex("khs.ssNH"))); }