/** * {@inheritDoc} */ @Override public Hybridization getHybridization() { return atom.getHybridization(); }
private static boolean atomIsPotentiallyAromatic(IAtom atom) { if (atom.getHybridization() == Hybridization.SP2) return true; if (atom.getHybridization() == Hybridization.PLANAR3) return true; if (atom.getHybridization() == Hybridization.SP3 && getLonePairCount(atom) > 0) return true; return false; }
/** *{@inheritDoc} */ @Override public int encode(IAtom atom, IAtomContainer container) { IAtomType.Hybridization hybridization = atom.getHybridization(); return hybridization != null ? hybridization.ordinal() : 32451301; } },
/** * check whether the atom is Sp3 hybridization * * @param atom an atom * @return whether the atom is Sp3 */ private static boolean sp3(IAtom atom) { return IAtomType.Hybridization.SP3.equals(atom.getHybridization()); }
@Override public int compare(IAtom o1, IAtom o2) { if (o1.getSymbol().equalsIgnoreCase(o2.getSymbol())) { if (o1.getHybridization() != null && o2.getHybridization() != null) { return o1.getHybridization().compareTo(o2.getHybridization()); } return 0; } return 10 * o1.getSymbol().compareToIgnoreCase(o2.getSymbol()); } }
@Test public void testOrbitalHybridization() { IAtom atom = mock(IAtom.class); IAtomContainer container = mock(IAtomContainer.class); AtomEncoder encoder = BasicAtomEncoder.ORBITAL_HYBRIDIZATION; when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP2); assertThat(encoder.encode(atom, container), is(IAtomType.Hybridization.SP2.ordinal())); verify(atom, times(1)).getHybridization(); verifyNoMoreInteractions(atom, container); }
@Test public void testAccept_NoSubstituents() throws Exception { IAtom atom = mock(IAtom.class); IBond a = mock(IBond.class); List<IBond> bonds = Arrays.asList(a); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP2); when(a.getOrder()).thenReturn(IBond.Order.DOUBLE); assertFalse(GeometricDoubleBondEncoderFactory.accept(atom, bonds)); } }
@Test public void testHybridisation0F() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 0); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP1); assertFalse(expr.matches(atom)); }
@Test public void testHybridisationSp3d3T() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 6); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP3D3); assertTrue(expr.matches(atom)); }
@Test public void testHybridisationSp3d4F() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 7); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP1); assertFalse(expr.matches(atom)); }
@Test public void testHybridisationSp1Null() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 1); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(null); assertFalse(expr.matches(atom)); }
@Test public void testHybridisationSp3d4T() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 7); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP3D4); assertTrue(expr.matches(atom)); }
@Test public void testHybridisationSp1T() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 1); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP1); assertTrue(expr.matches(atom)); }
@Test public void testHybridisationSp1F() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 1); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP2); assertFalse(expr.matches(atom)); }
@Test public void testHybridisationSp2T() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 2); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP2); assertTrue(expr.matches(atom)); }
@Test public void testHybridisationSp2F() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 2); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP1); assertFalse(expr.matches(atom)); }
@Test public void testHybridisationSp3d2T() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 5); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP3D2); assertTrue(expr.matches(atom)); }
@Test public void testHybridisationSp3d5T() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 8); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP3D5); assertTrue(expr.matches(atom)); }
@Test public void testHybridisationSp3d5F() { Expr expr = new Expr(HYBRIDISATION_NUMBER, 8); IAtom atom = mock(IAtom.class); when(atom.getHybridization()).thenReturn(IAtomType.Hybridization.SP1); assertFalse(expr.matches(atom)); }
@Test public void testPyrrole() throws CDKException { IAtomContainer mol = sp.parseSmiles("c1c[nH]cc1"); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol); atasc.decideBondOrder(mol, true); Assert.assertEquals(mol.getAtom(1).getHybridization(), IAtomType.Hybridization.SP2); Assert.assertEquals(IBond.Order.DOUBLE, mol.getBond(0).getOrder()); Assert.assertEquals(IBond.Order.SINGLE, mol.getBond(1).getOrder()); Assert.assertEquals(IBond.Order.SINGLE, mol.getBond(2).getOrder()); Assert.assertEquals(IBond.Order.DOUBLE, mol.getBond(3).getOrder()); Assert.assertEquals(IBond.Order.SINGLE, mol.getBond(4).getOrder()); }