AtomHybridizationVSEPRDescriptor extends AbstractAtomicDescriptor implements IAtomicDescriptor { @Override public DescriptorValue calculate(IAtom atom, IAtomContainer container) { IAtomType atomType; try { atomType = CDKAtomTypeMatcher.getInstance(atom.getBuilder()).findMatchingAtomType(container, atom); } catch (CDKException e) { return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult( (int) Double.NaN), getDescriptorNames(), new CDKException("Atom type was null")); } if (atomType == null) { return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult( (int) Double.NaN), getDescriptorNames(), new CDKException("Atom type was null")); } if (atomType.getHybridization() == null) { return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult( (int) Double.NaN), getDescriptorNames(), new CDKException("Hybridization was null")); } int hybridizationCDK = atomType.getHybridization().ordinal(); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult( hybridizationCDK), getDescriptorNames()); } AtomHybridizationVSEPRDescriptor(); @Override DescriptorSpecification getSpecification(); @Override void setParameters(Object[] params); @Override Object[] getParameters(); @Override String[] getDescriptorNames(); @Override DescriptorValue calculate(IAtom atom, IAtomContainer container); @Override String[] getParameterNames(); @Override Object getParameterType(String name);  }
@Test public void testAtomHybridizationVSEPRDescriptorTest_1() throws ClassNotFoundException, CDKException, java.lang.Exception { AtomHybridizationVSEPRDescriptor descriptor = new AtomHybridizationVSEPRDescriptor(); IAtomContainer molecule = new AtomContainer(); Atom O1 = new Atom("O"); Atom c2 = new Atom("C"); c2.setImplicitHydrogenCount(1); Atom c3 = new Atom("C"); c3.setImplicitHydrogenCount(3); molecule.addAtom(O1); molecule.addAtom(c2); molecule.addAtom(c3); Bond b1 = new Bond(c2, O1, IBond.Order.DOUBLE); Bond b2 = new Bond(c2, c3, IBond.Order.SINGLE); molecule.addBond(b1); molecule.addBond(b2); assertAtomTypesPerceived(molecule); Assert.assertEquals(IAtomType.Hybridization.SP2.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(0), molecule).getValue()).intValue()); Assert.assertEquals(IAtomType.Hybridization.SP2.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(1), molecule).getValue()).intValue()); Assert.assertEquals(IAtomType.Hybridization.SP3.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(2), molecule).getValue()).intValue()); }
@Test public void testAtomHybridizationVSEPRDescriptorTest_2() throws ClassNotFoundException, CDKException, java.lang.Exception { AtomHybridizationVSEPRDescriptor descriptor = new AtomHybridizationVSEPRDescriptor(); IAtomContainer molecule = new AtomContainer(); Atom O1 = new Atom("O"); O1.setFormalCharge(1); Atom c2 = new Atom("C"); Atom c3 = new Atom("C"); c3.setImplicitHydrogenCount(3); molecule.addAtom(O1); molecule.addAtom(c2); molecule.addAtom(c3); Bond b1 = new Bond(c2, O1, IBond.Order.TRIPLE); Bond b2 = new Bond(c2, c3, IBond.Order.SINGLE); molecule.addBond(b1); molecule.addBond(b2); assertAtomTypesPerceived(molecule); Assert.assertEquals(IAtomType.Hybridization.SP1.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(0), molecule).getValue()).intValue()); Assert.assertEquals(IAtomType.Hybridization.SP1.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(1), molecule).getValue()).intValue()); Assert.assertEquals(IAtomType.Hybridization.SP3.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(2), molecule).getValue()).intValue()); }
@Test public void testAtomHybridizationVSEPRDescriptorTest_3() throws ClassNotFoundException, CDKException, java.lang.Exception { AtomHybridizationVSEPRDescriptor descriptor = new AtomHybridizationVSEPRDescriptor(); IAtomContainer molecule = new AtomContainer(); Atom c1 = new Atom("C"); c1.setFormalCharge(1); c1.setImplicitHydrogenCount(2); Atom c2 = new Atom("C"); c2.setImplicitHydrogenCount(2); Atom c3 = new Atom("C"); c3.setImplicitHydrogenCount(3); molecule.addAtom(c1); molecule.addAtom(c2); molecule.addAtom(c3); Bond b1 = new Bond(c1, c2, IBond.Order.SINGLE); Bond b2 = new Bond(c2, c3, IBond.Order.SINGLE); molecule.addBond(b1); molecule.addBond(b2); assertAtomTypesPerceived(molecule); Assert.assertEquals(IAtomType.Hybridization.PLANAR3.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(0), molecule).getValue()).intValue()); Assert.assertEquals(IAtomType.Hybridization.SP3.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(1), molecule).getValue()).intValue()); Assert.assertEquals(IAtomType.Hybridization.SP3.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(2), molecule).getValue()).intValue()); }
@Test public void testAtomHybridizationVSEPRDescriptorTest_4() throws ClassNotFoundException, CDKException, java.lang.Exception { AtomHybridizationVSEPRDescriptor descriptor = new AtomHybridizationVSEPRDescriptor(); IAtomContainer molecule = new AtomContainer(); Atom S1 = new Atom("S"); Atom O2 = new Atom("O"); Atom O3 = new Atom("O"); Atom O4 = new Atom("O"); molecule.addAtom(S1); molecule.addAtom(O2); molecule.addAtom(O3); molecule.addAtom(O4); Bond b1 = new Bond(S1, O2, IBond.Order.DOUBLE); Bond b2 = new Bond(S1, O3, IBond.Order.DOUBLE); Bond b3 = new Bond(S1, O4, IBond.Order.DOUBLE); molecule.addBond(b1); molecule.addBond(b2); molecule.addBond(b3); assertAtomTypesPerceived(molecule); Assert.assertEquals(IAtomType.Hybridization.SP2.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(0), molecule).getValue()).intValue()); }
@Test public void testAtomHybridizationVSEPRDescriptorTest_5() throws ClassNotFoundException, CDKException, java.lang.Exception { AtomHybridizationVSEPRDescriptor descriptor = new AtomHybridizationVSEPRDescriptor(); IAtomContainer molecule = new AtomContainer(); Atom Xe1 = new Atom("Xe"); Atom F2 = new Atom("F"); Atom F3 = new Atom("F"); Atom F4 = new Atom("F"); Atom F5 = new Atom("F"); molecule.addAtom(Xe1); molecule.addAtom(F2); molecule.addAtom(F3); molecule.addAtom(F4); molecule.addAtom(F5); Bond b1 = new Bond(Xe1, F2, IBond.Order.SINGLE); Bond b2 = new Bond(Xe1, F3, IBond.Order.SINGLE); Bond b3 = new Bond(Xe1, F4, IBond.Order.SINGLE); Bond b4 = new Bond(Xe1, F5, IBond.Order.SINGLE); molecule.addBond(b1); molecule.addBond(b2); molecule.addBond(b3); molecule.addBond(b4); assertAtomTypesPerceived(molecule); Assert.assertEquals(IAtomType.Hybridization.SP3D2.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(0), molecule).getValue()).intValue()); }
@Test public void testAtomHybridizationVSEPRDescriptorTest_6() throws ClassNotFoundException, CDKException, java.lang.Exception { AtomHybridizationVSEPRDescriptor descriptor = new AtomHybridizationVSEPRDescriptor(); IAtomContainer molecule = new AtomContainer(); Atom I1 = new Atom("I"); I1.setFormalCharge(-1); Atom F2 = new Atom("F"); Atom F3 = new Atom("F"); molecule.addAtom(I1); molecule.addAtom(F2); molecule.addAtom(F3); Bond b1 = new Bond(I1, F2, IBond.Order.SINGLE); Bond b2 = new Bond(I1, F3, IBond.Order.SINGLE); molecule.addBond(b1); molecule.addBond(b2); assertAtomTypesPerceived(molecule); Assert.assertEquals(IAtomType.Hybridization.SP3D1.ordinal(), ((IntegerResult) descriptor.calculate(molecule.getAtom(0), molecule).getValue()).intValue()); }
@Test public void testAtomHybridizationVSEPRDescriptorTest_7() throws ClassNotFoundException, CDKException, java.lang.Exception { int[] testResult = {IAtomType.Hybridization.SP3.ordinal(), IAtomType.Hybridization.SP2.ordinal(), IAtomType.Hybridization.SP2.ordinal()}; AtomHybridizationVSEPRDescriptor descriptor = new AtomHybridizationVSEPRDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("F-C=C"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); assertAtomTypesPerceived(mol); addExplicitHydrogens(mol); LonePairElectronChecker lpcheck = new LonePairElectronChecker(); lpcheck.saturate(mol); assertAtomTypesPerceived(mol); for (int i = 0; i < 3; i++) { Assert.assertEquals(testResult[i], ((IntegerResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).intValue()); } }
@Test public void testAtomHybridizationVSEPRDescriptorTest_8() throws ClassNotFoundException, CDKException, java.lang.Exception { int[] testResult = {IAtomType.Hybridization.SP2.ordinal(), IAtomType.Hybridization.SP2.ordinal(), IAtomType.Hybridization.SP3.ordinal()}; AtomHybridizationVSEPRDescriptor descriptor = new AtomHybridizationVSEPRDescriptor(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer mol = sp.parseSmiles("[F+]=C-[C-]"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); assertAtomTypesPerceived(mol); addImplicitHydrogens(mol); LonePairElectronChecker lpcheck = new LonePairElectronChecker(); lpcheck.saturate(mol); assertAtomTypesPerceived(mol); for (int i = 0; i < 3; i++) { Assert.assertEquals(testResult[i], ((IntegerResult) descriptor.calculate(mol.getAtom(i), mol).getValue()).intValue()); } }