예제 #1
0
  /** A unit test for JUnit */
  @Test
  public void testAlanin() throws Exception {
    HydrogenPlacer hydrogenPlacer = new HydrogenPlacer();
    IAtomContainer mol1 = new AtomContainer();
    SmilesGenerator sg = new SmilesGenerator();
    mol1.addAtom(new Atom("N", new Point2d(1, 0)));
    // 1
    mol1.addAtom(new Atom("C", new Point2d(1, 2)));
    // 2
    mol1.addAtom(new Atom("F", new Point2d(1, 2)));
    // 3
    mol1.addAtom(new Atom("C", new Point2d(0, 0)));
    // 4
    mol1.addAtom(new Atom("C", new Point2d(1, 4)));
    // 5
    mol1.addAtom(new Atom("O", new Point2d(1, 5)));
    // 6
    mol1.addAtom(new Atom("O", new Point2d(1, 6)));
    // 7
    mol1.addBond(0, 1, IBond.Order.SINGLE);
    // 1
    mol1.addBond(1, 2, IBond.Order.SINGLE, IBond.Stereo.UP);
    // 2
    mol1.addBond(1, 3, IBond.Order.SINGLE, IBond.Stereo.DOWN);
    // 3
    mol1.addBond(1, 4, IBond.Order.SINGLE);
    // 4
    mol1.addBond(4, 5, IBond.Order.SINGLE);
    // 5
    mol1.addBond(4, 6, IBond.Order.DOUBLE);
    // 6
    addExplicitHydrogens(mol1);
    hydrogenPlacer.placeHydrogens2D(mol1, 1.0);
    IsotopeFactory ifac = IsotopeFactory.getInstance(mol1.getBuilder());
    ifac.configureAtoms(mol1);

    String smiles1 = null;
    if (standAlone) {
      display(mol1);
    }
    smiles1 = sg.createSMILES(mol1, true, new boolean[mol1.getBondCount()]);
    if (standAlone) {
      System.err.println("SMILES 1: " + smiles1);
    }
    Assert.assertNotNull(smiles1);
    Assert.assertEquals("[H]OC(=O)[C@](F)(N([H])[H])C([H])([H])[H]", smiles1);
    mol1.getBond(1).setStereo(IBond.Stereo.DOWN);
    mol1.getBond(2).setStereo(IBond.Stereo.UP);
    smiles1 = sg.createSMILES(mol1, true, new boolean[mol1.getBondCount()]);
    if (standAlone) {
      System.err.println("SMILES 1: " + smiles1);
    }
    Assert.assertNotNull(smiles1);
    Assert.assertEquals("[H]OC(=O)[C@](F)(C([H])([H])[H])N([H])[H]", smiles1);
  }
예제 #2
0
  /** A unit test for JUnit */
  @Test
  public void testDoubleBondConfiguration() throws Exception {
    HydrogenPlacer hydrogenPlacer = new HydrogenPlacer();
    IAtomContainer mol1 = new AtomContainer();
    SmilesGenerator sg = new SmilesGenerator();
    mol1.addAtom(new Atom("S", new Point2d(0, 0)));
    // 1
    mol1.addAtom(new Atom("C", new Point2d(1, 1)));
    // 2
    mol1.addAtom(new Atom("F", new Point2d(2, 0)));
    // 3
    mol1.addAtom(new Atom("C", new Point2d(1, 2)));
    // 4
    mol1.addAtom(new Atom("F", new Point2d(2, 3)));
    // 5
    mol1.addAtom(new Atom("S", new Point2d(0, 3)));
    // 1

    mol1.addBond(0, 1, IBond.Order.SINGLE);
    // 1
    mol1.addBond(1, 2, IBond.Order.SINGLE);
    // 2
    mol1.addBond(1, 3, IBond.Order.DOUBLE);
    // 3
    mol1.addBond(3, 4, IBond.Order.SINGLE);
    // 4
    mol1.addBond(3, 5, IBond.Order.SINGLE);
    // 4
    try {
      IsotopeFactory ifac = IsotopeFactory.getInstance(mol1.getBuilder());
      ifac.configureAtoms(mol1);
    } catch (IOException ex) {
    }
    String smiles1 = null;
    if (standAlone) {
      display(mol1);
    }
    boolean[] bool = new boolean[mol1.getBondCount()];
    bool[2] = true;
    try {
      smiles1 = sg.createSMILES(mol1, true, bool);
    } catch (Exception exc) {
      System.out.println(exc);
      if (!standAlone) {
        Assert.fail();
      }
    }
    if (standAlone) {
      System.err.println("SMILES 1: " + smiles1);
    }
    Assert.assertNotNull(smiles1);
    Assert.assertEquals("F/C(=C/(F)S)S", smiles1);
    mol1.getAtom(4).setPoint2d(new Point2d(0, 3));
    mol1.getAtom(5).setPoint2d(new Point2d(2, 3));
    try {
      smiles1 = sg.createSMILES(mol1, true, bool);
    } catch (Exception exc) {
      System.out.println(exc);
      if (!standAlone) {
        Assert.fail();
      }
    }
    if (standAlone) {
      System.err.println("SMILES 1: " + smiles1);
    }
    Assert.assertNotNull(smiles1);
    Assert.assertEquals("F/C(=C\\(F)S)S", smiles1);
    try {
      addExplicitHydrogens(mol1);
      hydrogenPlacer.placeHydrogens2D(mol1, 1.0);
    } catch (IOException ex) {
    } catch (ClassNotFoundException ex) {
    }
    bool = new boolean[mol1.getBondCount()];
    bool[2] = true;
    try {
      smiles1 = sg.createSMILES(mol1, true, bool);
    } catch (Exception exc) {
      System.out.println(exc);
      if (!standAlone) {
        Assert.fail();
      }
    }
    Assert.assertEquals("[H]S/C(F)=C/(F)S[H]", smiles1);
    mol1.getAtom(5).setPoint2d(new Point2d(0, 3));
    mol1.getAtom(4).setPoint2d(new Point2d(2, 3));
    try {
      smiles1 = sg.createSMILES(mol1, true, bool);
    } catch (Exception exc) {
      System.out.println(exc);
      if (!standAlone) {
        Assert.fail();
      }
    }
    Assert.assertEquals("[H]S/C(F)=C\\(F)S[H]", smiles1);
  }
예제 #3
0
 /** A unit test for JUnit */
 @Test
 public void testCisTransDecalin() throws Exception {
   HydrogenPlacer hydrogenPlacer = new HydrogenPlacer();
   IAtomContainer mol1 = new AtomContainer();
   SmilesGenerator sg = new SmilesGenerator();
   mol1.addAtom(new Atom("H", new Point2d(1, 0)));
   // 1
   mol1.addAtom(new Atom("C", new Point2d(1, 2)));
   // 2
   mol1.addAtom(new Atom("C", new Point2d(1, 2)));
   // 3
   mol1.addAtom(new Atom("C", new Point2d(0, 0)));
   // 4
   mol1.addAtom(new Atom("C", new Point2d(1, 4)));
   // 5
   mol1.addAtom(new Atom("C", new Point2d(1, 5)));
   // 6
   mol1.addAtom(new Atom("C", new Point2d(1, 6)));
   // 7
   mol1.addAtom(new Atom("H", new Point2d(1, 0)));
   // 1
   mol1.addAtom(new Atom("C", new Point2d(1, 2)));
   // 2
   mol1.addAtom(new Atom("C", new Point2d(1, 2)));
   // 3
   mol1.addAtom(new Atom("C", new Point2d(1, 2)));
   // 2
   mol1.addAtom(new Atom("C", new Point2d(1, 2)));
   // 3
   mol1.addBond(0, 1, IBond.Order.SINGLE, IBond.Stereo.DOWN);
   // 1
   mol1.addBond(1, 2, IBond.Order.SINGLE);
   // 2
   mol1.addBond(2, 3, IBond.Order.SINGLE);
   // 3
   mol1.addBond(3, 4, IBond.Order.SINGLE);
   // 4
   mol1.addBond(4, 5, IBond.Order.SINGLE);
   // 5
   mol1.addBond(5, 6, IBond.Order.SINGLE);
   // 6
   mol1.addBond(6, 7, IBond.Order.SINGLE, IBond.Stereo.DOWN);
   // 3
   mol1.addBond(6, 8, IBond.Order.SINGLE);
   // 4
   mol1.addBond(8, 9, IBond.Order.SINGLE);
   // 5
   mol1.addBond(9, 10, IBond.Order.SINGLE);
   // 6
   mol1.addBond(10, 11, IBond.Order.SINGLE);
   // 6
   mol1.addBond(11, 1, IBond.Order.SINGLE);
   // 6
   mol1.addBond(1, 6, IBond.Order.SINGLE);
   // 6
   try {
     addExplicitHydrogens(mol1);
     hydrogenPlacer.placeHydrogens2D(mol1, 1.0);
     IsotopeFactory ifac = IsotopeFactory.getInstance(mol1.getBuilder());
     ifac.configureAtoms(mol1);
   } catch (IOException ex) {
   } catch (ClassNotFoundException ex) {
   }
   String smiles1 = null;
   if (standAlone) {
     display(mol1);
   }
   try {
     smiles1 = sg.createSMILES(mol1, true, new boolean[mol1.getBondCount()]);
   } catch (Exception exc) {
     System.out.println(exc);
     if (!standAlone) {
       Assert.fail();
     }
   }
   if (standAlone) {
     System.err.println("SMILES 1: " + smiles1);
   }
   Assert.assertNotNull(smiles1);
   Assert.assertEquals(
       "[H]C1([H])(C([H])([H])C([H])([H])C\\2([H])(C([H])([H])C([H])([H])C([H])([H])C([H])([H])C\\2([H])(C1([H])([H]))))",
       smiles1);
   mol1.getBond(6).setStereo(IBond.Stereo.UP);
   String smiles3 = null;
   try {
     smiles3 = sg.createSMILES(mol1, true, new boolean[mol1.getBondCount()]);
   } catch (Exception exc) {
     System.out.println(exc);
     if (!standAlone) {
       Assert.fail();
     }
   }
   Assert.assertNotSame(smiles3, smiles1);
 }
예제 #4
0
 /** A unit test for JUnit */
 @Test
 public void testCisResorcinol() throws Exception {
   HydrogenPlacer hydrogenPlacer = new HydrogenPlacer();
   IAtomContainer mol1 = new AtomContainer();
   SmilesGenerator sg = new SmilesGenerator();
   mol1.addAtom(new Atom("O", new Point2d(3, 1)));
   // 1
   mol1.addAtom(new Atom("H", new Point2d(2, 0)));
   // 2
   mol1.addAtom(new Atom("C", new Point2d(2, 1)));
   // 3
   mol1.addAtom(new Atom("C", new Point2d(1, 1)));
   // 4
   mol1.addAtom(new Atom("C", new Point2d(1, 4)));
   // 5
   mol1.addAtom(new Atom("C", new Point2d(1, 5)));
   // 6
   mol1.addAtom(new Atom("C", new Point2d(1, 2)));
   // 7
   mol1.addAtom(new Atom("C", new Point2d(2, 2)));
   // 1
   mol1.addAtom(new Atom("O", new Point2d(3, 2)));
   // 2
   mol1.addAtom(new Atom("H", new Point2d(2, 3)));
   // 3
   mol1.addBond(0, 2, IBond.Order.SINGLE, IBond.Stereo.DOWN);
   // 1
   mol1.addBond(1, 2, IBond.Order.SINGLE, IBond.Stereo.UP);
   // 2
   mol1.addBond(2, 3, IBond.Order.SINGLE);
   // 3
   mol1.addBond(3, 4, IBond.Order.SINGLE);
   // 4
   mol1.addBond(4, 5, IBond.Order.SINGLE);
   // 5
   mol1.addBond(5, 6, IBond.Order.SINGLE);
   // 6
   mol1.addBond(6, 7, IBond.Order.SINGLE);
   // 3
   mol1.addBond(7, 8, IBond.Order.SINGLE, IBond.Stereo.UP);
   // 4
   mol1.addBond(7, 9, IBond.Order.SINGLE, IBond.Stereo.DOWN);
   // 5
   mol1.addBond(7, 2, IBond.Order.SINGLE);
   // 6
   try {
     addExplicitHydrogens(mol1);
     hydrogenPlacer.placeHydrogens2D(mol1, 1.0);
     IsotopeFactory ifac = IsotopeFactory.getInstance(mol1.getBuilder());
     ifac.configureAtoms(mol1);
   } catch (IOException ex) {
   } catch (ClassNotFoundException ex) {
   }
   String smiles1 = null;
   if (standAlone) {
     display(mol1);
   }
   try {
     smiles1 = sg.createSMILES(mol1, true, new boolean[mol1.getBondCount()]);
   } catch (Exception exc) {
     System.out.println(exc);
     if (!standAlone) {
       Assert.fail();
     }
   }
   if (standAlone) {
     System.err.println("SMILES 1: " + smiles1);
   }
   Assert.assertNotNull(smiles1);
   Assert.assertEquals(
       "[H]O[C@]1(C([H])([H])C([H])([H])C([H])([H])C([H])([H])[C@]1(O[H])([H]))([H])", smiles1);
   mol1 = AtomContainerManipulator.removeHydrogens(mol1);
   try {
     smiles1 = sg.createSMILES(mol1);
   } catch (Exception exc) {
     System.out.println(exc);
     if (!standAlone) {
       Assert.fail();
     }
   }
   if (standAlone) {
     System.err.println("SMILES 1: " + smiles1);
   }
   Assert.assertNotNull(smiles1);
   Assert.assertEquals("OC1CCCCC1(O)", smiles1);
 }