Пример #1
0
  /**
   * Test reading from a XML config file with content like:
   *
   * <pre>
   *   <atomType id="C">
   *    <!-- for example in CC-->
   *    <atom elementType="C" formalCharge="0">
   *      <scalar dataType="xsd:double" dictRef="cdk:maxBondOrder">1.0</scalar>
   *      <scalar dataType="xsd:double" dictRef="cdk:bondOrderSum">4.0</scalar>
   *      <scalar dataType="xsd:integer" dictRef="cdk:formalNeighbourCount">4</scalar>
   *      <scalar dataType="xsd:integer" dictRef="cdk:valency">4</scalar>
   *    </atom>
   *    <scalar dataType="xsd:string" dictRef="cdk:hybridization">sp3</scalar>
   *    <scalar dataType="xsd:string" dictRef="cdk:DA">-</scalar>
   *    <scalar dataType="xsd:string" dictRef="cdk:sphericalMatcher">[CSP]-[0-4][-]?+;[A-Za-z\+\-&amp;&amp;[^=%]]{0,6}[(].*+</scalar>
   *  </atomType>
   * </pre>
   *
   * @throws Exception if the atom typ info cannot be loaded
   */
  @Test
  public void testGetAtomTypeFromMM2() throws Exception {
    AtomTypeFactory factory;
    factory =
        AtomTypeFactory.getInstance(
            "org/openscience/cdk/config/data/mm2_atomtypes.xml", new ChemObject().getBuilder());

    IAtomType atomType = factory.getAtomType("C");
    Assert.assertNotNull(atomType);
    Assert.assertEquals("C", atomType.getSymbol());
    Assert.assertEquals("C", atomType.getAtomTypeName());
    Assert.assertEquals(
        "[CSP]-[0-4][-]?+;[A-Za-z\\+\\-&&[^=%]]{0,6}[(].*+",
        atomType.getProperty(CDKConstants.SPHERICAL_MATCHER));
    Assert.assertEquals(Hybridization.SP3, atomType.getHybridization());

    atomType = factory.getAtomType("Sthi");
    Assert.assertNotNull(atomType);
    Assert.assertEquals("S", atomType.getSymbol());
    Assert.assertEquals("Sthi", atomType.getAtomTypeName());
    Assert.assertEquals(
        "S-[2];[H]{0,3}+=C.*+", atomType.getProperty(CDKConstants.SPHERICAL_MATCHER));
    Assert.assertEquals(Hybridization.SP2, atomType.getHybridization());
    Assert.assertTrue(atomType.getFlag(CDKConstants.IS_HYDROGENBOND_ACCEPTOR));
    Assert.assertEquals(5, atomType.getProperty(CDKConstants.PART_OF_RING_OF_SIZE));
  }
Пример #2
0
  @Test
  public void testGetAtomTypeFromOWL() throws Exception {
    AtomTypeFactory factory =
        AtomTypeFactory.getInstance(
            "org/openscience/cdk/dict/data/cdk-atom-types.owl", new ChemObject().getBuilder());
    IAtomType atomType = factory.getAtomType("C.sp3");
    Assert.assertNotNull(atomType);
    Assert.assertEquals("C", atomType.getSymbol());
    Assert.assertEquals("C.sp3", atomType.getAtomTypeName());
    Assert.assertEquals(IAtomType.Hybridization.SP3, atomType.getHybridization());
    Assert.assertEquals(0, atomType.getFormalCharge().intValue());
    Assert.assertEquals(4, atomType.getFormalNeighbourCount().intValue());
    Assert.assertNotNull(atomType.getProperty(CDKConstants.LONE_PAIR_COUNT));
    Assert.assertTrue(atomType.getProperty(CDKConstants.LONE_PAIR_COUNT) instanceof Integer);
    Assert.assertEquals(
        0, ((Integer) atomType.getProperty(CDKConstants.LONE_PAIR_COUNT)).intValue());
    Assert.assertNotNull(atomType.getProperty(CDKConstants.PI_BOND_COUNT));
    Assert.assertTrue(atomType.getProperty(CDKConstants.PI_BOND_COUNT) instanceof Integer);
    Assert.assertEquals(0, ((Integer) atomType.getProperty(CDKConstants.PI_BOND_COUNT)).intValue());

    atomType = factory.getAtomType("N.sp2.radical");
    Assert.assertNotNull(atomType);
    Assert.assertEquals("N", atomType.getSymbol());
    Assert.assertEquals("N.sp2.radical", atomType.getAtomTypeName());
    Assert.assertEquals(IAtomType.Hybridization.SP2, atomType.getHybridization());
    Assert.assertEquals(0, atomType.getFormalCharge().intValue());
    Assert.assertEquals(1, atomType.getFormalNeighbourCount().intValue());
    Assert.assertNotNull(atomType.getProperty(CDKConstants.LONE_PAIR_COUNT));
    Assert.assertTrue(atomType.getProperty(CDKConstants.LONE_PAIR_COUNT) instanceof Integer);
    Assert.assertEquals(
        1, ((Integer) atomType.getProperty(CDKConstants.LONE_PAIR_COUNT)).intValue());
    Assert.assertNotNull(atomType.getProperty(CDKConstants.PI_BOND_COUNT));
    Assert.assertTrue(atomType.getProperty(CDKConstants.PI_BOND_COUNT) instanceof Integer);
    Assert.assertEquals(1, ((Integer) atomType.getProperty(CDKConstants.PI_BOND_COUNT)).intValue());

    atomType = factory.getAtomType("N.planar3");
    Assert.assertNotNull(atomType);
    Assert.assertEquals("N", atomType.getSymbol());
    Assert.assertEquals("N.planar3", atomType.getAtomTypeName());
    Assert.assertEquals(IAtomType.Hybridization.PLANAR3, atomType.getHybridization());
    Assert.assertEquals(0, atomType.getFormalCharge().intValue());
    Assert.assertEquals(3, atomType.getFormalNeighbourCount().intValue());
    Assert.assertNotNull(atomType.getProperty(CDKConstants.LONE_PAIR_COUNT));
    Assert.assertTrue(atomType.getProperty(CDKConstants.LONE_PAIR_COUNT) instanceof Integer);
    Assert.assertEquals(
        1, ((Integer) atomType.getProperty(CDKConstants.LONE_PAIR_COUNT)).intValue());
    Assert.assertNotNull(atomType.getProperty(CDKConstants.PI_BOND_COUNT));
    Assert.assertTrue(atomType.getProperty(CDKConstants.PI_BOND_COUNT) instanceof Integer);
    Assert.assertEquals(0, ((Integer) atomType.getProperty(CDKConstants.PI_BOND_COUNT)).intValue());
  }
Пример #3
0
 @Test
 public void testGetAtomType_String() throws Exception {
   IAtomType atomType = atf.getAtomType("C4");
   Assert.assertNotNull(atomType);
   Assert.assertEquals("C", atomType.getSymbol());
   Assert.assertEquals("C4", atomType.getAtomTypeName());
   Assert.assertEquals(4.0, atomType.getBondOrderSum(), 0.001);
   Assert.assertEquals(IBond.Order.TRIPLE, atomType.getMaxBondOrder());
 }
Пример #4
0
  @Test
  public void testGetAtomTypeFromJmol() throws Exception {
    AtomTypeFactory factory =
        AtomTypeFactory.getInstance(
            "org/openscience/cdk/config/data/jmol_atomtypes.txt", new ChemObject().getBuilder());
    IAtomType atomType = factory.getAtomType("H");

    Assert.assertNotNull(atomType);
    Assert.assertEquals("H", atomType.getSymbol());
    Assert.assertEquals("H", atomType.getAtomTypeName());
  }