コード例 #1
0
  /** @cdk.bug 2142400 */
  @Test
  public void testHydrogenCount2() throws Exception {
    String cmlString =
        "<molecule><atomArray>"
            + "<atom id='a1' elementType='C' hydrogenCount='4'/>"
            + "<atom id='a2' elementType='H'/>"
            + "<atom id='a3' elementType='H'/>"
            + "<atom id='a4' elementType='H'/>"
            + "<atom id='a5' elementType='H'/>"
            + "</atomArray>"
            + "<bondArray>"
            + "<bond id='b1' atomRefs2='a1 a2' order='S'/>"
            + "<bond id='b2' atomRefs2='a1 a3' order='S'/>"
            + "<bond id='b3' atomRefs2='a1 a4' order='S'/>"
            + "<bond id='b4' atomRefs2='a1 a5' order='S'/>"
            + "</bondArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(5, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertNotNull(atom);
    Assert.assertEquals("C", atom.getSymbol());
    Assert.assertNotNull(atom.getImplicitHydrogenCount());
    Assert.assertEquals(0, atom.getImplicitHydrogenCount().intValue());
  }
  /**
   * Get the resonance structures from an IMolecule.
   *
   * @param molecule The IMolecule to analyze
   * @return The different resonance structures
   */
  @TestMethod("testGetStructures_IMolecule")
  public IMoleculeSet getStructures(IMolecule molecule) {
    int countStructure = 0;
    IMoleculeSet setOfMol = molecule.getBuilder().newMoleculeSet();
    setOfMol.addMolecule(molecule);

    for (int i = 0; i < setOfMol.getMoleculeCount(); i++) {
      IMolecule mol = setOfMol.getMolecule(i);
      for (IReactionProcess aReactionsList : reactionsList) {
        IReactionProcess reaction = aReactionsList;
        IMoleculeSet setOfReactants = molecule.getBuilder().newMoleculeSet();
        setOfReactants.addMolecule(mol);
        try {
          IReactionSet setOfReactions = reaction.initiate(setOfReactants, null);
          if (setOfReactions.getReactionCount() != 0)
            for (int k = 0; k < setOfReactions.getReactionCount(); k++)
              for (int j = 0;
                  j < setOfReactions.getReaction(k).getProducts().getAtomContainerCount();
                  j++) {
                IMolecule product = setOfReactions.getReaction(k).getProducts().getMolecule(j);
                if (!existAC(setOfMol, product)) {
                  setOfMol.addMolecule(product);
                  countStructure++;
                  if (countStructure > maxStructures) return setOfMol;
                }
              }
        } catch (CDKException e) {
          e.printStackTrace();
        }
      }
    }
    return setOfMol;
  }
コード例 #3
0
  /**
   * Modules for cleaning a molecule
   *
   * @param molecule
   * @return cleaned AtomContainer
   */
  @TestMethod("testCheckAndCleanMolecule")
  public static IAtomContainer checkAndCleanMolecule(IAtomContainer molecule) {
    boolean isMarkush = false;
    for (IAtom atom : molecule.atoms()) {
      if (atom.getSymbol().equals("R")) {
        isMarkush = true;
        break;
      }
    }

    if (isMarkush) {
      System.err.println("Skipping Markush structure for sanity check");
    }

    // Check for salts and such
    if (!ConnectivityChecker.isConnected(molecule)) {
      // lets see if we have just two parts if so, we assume its a salt and just work
      // on the larger part. Ideally we should have a check to ensure that the smaller
      //  part is a metal/halogen etc.
      IMoleculeSet fragments = ConnectivityChecker.partitionIntoMolecules(molecule);
      if (fragments.getMoleculeCount() > 2) {
        System.err.println("More than 2 components. Skipped");
      } else {
        IMolecule frag1 = fragments.getMolecule(0);
        IMolecule frag2 = fragments.getMolecule(1);
        if (frag1.getAtomCount() > frag2.getAtomCount()) {
          molecule = frag1;
        } else {
          molecule = frag2;
        }
      }
    }
    configure(molecule);
    return molecule;
  }
コード例 #4
0
ファイル: DbCASSearchAction.java プロジェクト: egonw/ambit
  public IIteratingChemObjectReader getSearchReader(
      Connection connection, Object query, int page, int pagesize) throws AmbitException {
    String cas = "50-00-0";
    Object c = null;
    if (query instanceof IMolecule) {
      c = ((IMolecule) query).getProperty(CDKConstants.CASRN);
      if (c != null) cas = c.toString();
    }
    if (c == null) {
      IMolecule m = ((AmbitDatabaseToolsData) userData).getMolecule();
      if (m != null) {
        c = m.getProperty(CDKConstants.CASRN);
        if (c != null) cas = c.toString();
      }
    }
    cas =
        getSearchCriteria(
            "Search database by CAS Registry Number", "Enter CAS Registry Number\n", cas);
    // If a string was returned, say so.
    if ((cas != null) && (cas.length() > 0)) {
      try {
        cas = IdentifiersProcessor.hyphenateCAS(cas);
      } catch (Exception x) {
        logger.error(x);
      }
      if (CASNumber.isValid(cas.trim())) {

        return new DbStructureReader(connection, sql + '"' + cas.trim() + "\" limit 0,1");
      } else JOptionPane.showMessageDialog(mainFrame, "Invalid CAS Registry Number!\n" + cas);
    }
    return null;
  }
コード例 #5
0
  @Test
  public void testReading() throws Exception {
    String filename = "data/asn/pubchem/cid1145.xml";
    logger.info("Testing: " + filename);
    InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
    PCCompoundXMLReader reader = new PCCompoundXMLReader(ins);
    IMolecule molecule = (IMolecule) reader.read(new Molecule());
    Assert.assertNotNull(molecule);

    // check atom stuff
    Assert.assertEquals(14, molecule.getAtomCount());
    Assert.assertEquals("O", molecule.getAtom(0).getSymbol());
    Assert.assertEquals(Integer.valueOf(-1), molecule.getAtom(0).getFormalCharge());
    Assert.assertEquals("N", molecule.getAtom(1).getSymbol());
    Assert.assertEquals(Integer.valueOf(1), molecule.getAtom(1).getFormalCharge());

    // check bond stuff
    Assert.assertEquals(13, molecule.getBondCount());
    Assert.assertNotNull(molecule.getBond(3));

    // coordinates
    Assert.assertNull(molecule.getAtom(0).getPoint3d());
    Point2d point = molecule.getAtom(0).getPoint2d();
    Assert.assertNotNull(point);
    Assert.assertEquals(3.7320508956909, point.x, 0.00000001);
    Assert.assertEquals(0.5, point.y, 0.00000001);
  }
コード例 #6
0
  /**
   * A unit test suite for JUnit for Ethene. Reaction: O=C-C-H => O(H)-C=C. Manually putting for
   * active center.
   *
   * @cdk.inchi InChI=1/C2H4/c1-2/h1-2H2
   * @return The test suite
   */
  @Test
  public void testManuallyCentreActive() throws Exception {
    IReactionProcess type = new AdductionProtonPBReaction();
    IMolecule molecule = getEthene();

    IMoleculeSet setOfReactants = DefaultChemObjectBuilder.getInstance().newMoleculeSet();
    setOfReactants.addMolecule(molecule);

    /*manually putting the active center*/
    molecule.getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(0).setFlag(CDKConstants.REACTIVE_CENTER, true);

    /* initiate */
    List<IParameterReact> paramList = new ArrayList<IParameterReact>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.TRUE);
    paramList.add(param);
    type.setParameterList(paramList);
    IReactionSet setOfReactions = type.initiate(setOfReactants, null);

    Assert.assertEquals(2, setOfReactions.getReactionCount());
    Assert.assertEquals(1, setOfReactions.getReaction(0).getProductCount());

    IMolecule product = setOfReactions.getReaction(0).getProducts().getMolecule(0);

    IMolecule molecule2 = getExpected();

    IQueryAtomContainer queryAtom =
        QueryAtomContainerCreator.createSymbolAndChargeQueryContainer(product);
    Assert.assertTrue(UniversalIsomorphismTester.isIsomorph(molecule2, queryAtom));
  }
コード例 #7
0
  /**
   * A unit test suite for JUnit.
   *
   * @cdk.inchi InChI=1/C2H4/c1-2/h1-2H2
   * @return The test suite
   */
  @Test
  public void testCDKConstants_REACTIVE_CENTER() throws Exception {
    IReactionProcess type = new AdductionProtonPBReaction();
    IMoleculeSet setOfReactants = builder.newMoleculeSet();
    IMolecule molecule = getEthene();

    /*manually putting the active center*/
    molecule.getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER, true);
    molecule.getBond(0).setFlag(CDKConstants.REACTIVE_CENTER, true);

    setOfReactants.addMolecule(molecule);
    List<IParameterReact> paramList = new ArrayList<IParameterReact>();
    IParameterReact param = new SetReactionCenter();
    param.setParameter(Boolean.TRUE);
    paramList.add(param);
    type.setParameterList(paramList);

    /* initiate */
    IReactionSet setOfReactions = type.initiate(setOfReactants, null);

    IMolecule reactant = setOfReactions.getReaction(0).getReactants().getMolecule(0);
    Assert.assertTrue(molecule.getAtom(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getAtom(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(molecule.getAtom(1).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getAtom(1).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(molecule.getBond(0).getFlag(CDKConstants.REACTIVE_CENTER));
    Assert.assertTrue(reactant.getBond(0).getFlag(CDKConstants.REACTIVE_CENTER));
  }
コード例 #8
0
  /** Converts a Molecule Element from a CDK Molecule object */
  public MoleculeType convert(IMolecule molecule) throws MSMLConversionException {
    try {
      MoleculeType molMoleculeElement = ObjectFactorySingelton.getFactory().createMoleculeType();
      setMetaData(molMoleculeElement, molecule);
      // molMoleculeElement.setMoleculeClass(MoleculeClassType.HETERO);//?
      // Add Atom block:
      Iterable<IAtom> atomBlock = molecule.atoms();
      AtomArrayType atomArrayElement = convertAtoms(atomBlock, molMoleculeElement.getId());

      // Save hashes of atoms to map the atom back to the atom ID
      ArrayList<String> hashes = generateHashCodes(atomBlock);
      molMoleculeElement.setAtomArray(atomArrayElement);

      // Add bond block
      Iterable<IBond> bondBlock = molecule.bonds();
      BondArrayType bondArrayElement = convertBonds(bondBlock, molMoleculeElement.getId(), hashes);
      molMoleculeElement.setBondArray(bondArrayElement);

      // Add properties block
      for (Entry<Object, Object> prop : molecule.getProperties().entrySet()) {
        if (_excludedProperties.contains(prop.getKey())) continue;
        CustomProperty cmlProp = ObjectFactorySingelton.getFactory().createCustomProperty();
        cmlProp.setKey((String) prop.getKey());
        cmlProp.setValue((String) prop.getValue());
        molMoleculeElement.getCustomProperty().add(cmlProp);
      }

      return molMoleculeElement;
    } catch (Exception e) {
      String msg = "Conversion of MDL molecule structure failed! " + e.getMessage();
      LOGGER.error(msg, e);
      throw new MSMLConversionException(msg, e);
    }
  }
コード例 #9
0
 @Test
 public void testViaFlags() throws Exception {
   IMolecule molecule = MoleculeFactory.makeBenzene();
   for (Iterator atoms = molecule.atoms().iterator(); atoms.hasNext(); ) {
     ((IAtom) atoms.next()).setFlag(CDKConstants.ISAROMATIC, true);
   }
   Assert.assertEquals(6, ((IntegerResult) descriptor.calculate(molecule).getValue()).intValue());
 }
コード例 #10
0
  /**
   * Initiate process. It is needed to call the addExplicitHydrogensToSatisfyValency from the class
   * tools.HydrogenAdder.
   *
   * @param reactants reactants of the reaction
   * @param agents agents of the reaction (Must be in this case null)
   * @exception CDKException Description of the Exception
   */
  @TestMethod("testInitiate_IMoleculeSet_IMoleculeSet")
  public IReactionSet initiate(IMoleculeSet reactants, IMoleculeSet agents) throws CDKException {

    logger.debug("initiate reaction: HeterolyticCleavagePBReaction");

    if (reactants.getMoleculeCount() != 1) {
      throw new CDKException("HeterolyticCleavagePBReaction only expects one reactant");
    }
    if (agents != null) {
      throw new CDKException("HeterolyticCleavagePBReaction don't expects agents");
    }

    IReactionSet setOfReactions =
        DefaultChemObjectBuilder.getInstance().newInstance(IReactionSet.class);
    IMolecule reactant = reactants.getMolecule(0);

    /* if the parameter hasActiveCenter is not fixed yet, set the active centers*/
    IParameterReact ipr = super.getParameterClass(SetReactionCenter.class);
    if (ipr != null && !ipr.isSetParameter()) setActiveCenters(reactant);

    Iterator<IBond> bondis = reactant.bonds().iterator();
    while (bondis.hasNext()) {
      IBond bondi = bondis.next();
      IAtom atom1 = bondi.getAtom(0);
      IAtom atom2 = bondi.getAtom(1);
      if (bondi.getFlag(CDKConstants.REACTIVE_CENTER)
          && bondi.getOrder() != IBond.Order.SINGLE
          && atom1.getFlag(CDKConstants.REACTIVE_CENTER)
          && atom2.getFlag(CDKConstants.REACTIVE_CENTER)
          && (atom1.getFormalCharge() == CDKConstants.UNSET ? 0 : atom1.getFormalCharge()) == 0
          && (atom2.getFormalCharge() == CDKConstants.UNSET ? 0 : atom2.getFormalCharge()) == 0
          && reactant.getConnectedSingleElectronsCount(atom1) == 0
          && reactant.getConnectedSingleElectronsCount(atom2) == 0) {

        /**/
        for (int j = 0; j < 2; j++) {

          ArrayList<IAtom> atomList = new ArrayList<IAtom>();
          if (j == 0) {
            atomList.add(atom1);
            atomList.add(atom2);
          } else {
            atomList.add(atom2);
            atomList.add(atom1);
          }
          ArrayList<IBond> bondList = new ArrayList<IBond>();
          bondList.add(bondi);

          IMoleculeSet moleculeSet = reactant.getBuilder().newInstance(IMoleculeSet.class);
          moleculeSet.addMolecule(reactant);
          IReaction reaction = mechanism.initiate(moleculeSet, atomList, bondList);
          if (reaction == null) continue;
          else setOfReactions.addReaction(reaction);
        }
      }
    }
    return setOfReactions;
  }
コード例 #11
0
  @Test
  public void testMoleculeId() throws Exception {
    String cmlString = "<molecule id='m1'><atomArray><atom id='a1'/></atomArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals("m1", mol.getID());
  }
コード例 #12
0
 @Test
 public void testNNMolecule_int_int_int_int() {
   IMolecule m = new NNMolecule(5, 5, 1, 1);
   Assert.assertNotNull(m);
   Assert.assertEquals(0, m.getAtomCount());
   Assert.assertEquals(0, m.getBondCount());
   Assert.assertEquals(0, m.getLonePairCount());
   Assert.assertEquals(0, m.getSingleElectronCount());
 }
コード例 #13
0
  @Test
  public void testName() throws Exception {
    String cmlString =
        "<molecule id='m1'><name>acetic acid</name><atomArray atomID='a1 a2 a3'/></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals("acetic acid", mol.getProperty(CDKConstants.TITLE));
  }
コード例 #14
0
  @Test
  public void testInChI() throws Exception {
    String cmlString =
        "<molecule id='m1'><identifier convention='iupac:inchi' value='InChI=1/CH2O2/c2-1-3/h1H,(H,2,3)'/><atomArray atomID='a1 a2 a3'/></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals("InChI=1/CH2O2/c2-1-3/h1H,(H,2,3)", mol.getProperty(CDKConstants.INCHI));
  }
コード例 #15
0
  @Test
  public void testAtomElementType3() throws Exception {
    String cmlString = "<molecule id='m1'><atomArray atomID='a1' elementType='C'/></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(1, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertEquals("C", atom.getSymbol());
  }
コード例 #16
0
  @Test
  public void testAtomId3() throws Exception {
    String cmlString = "<molecule id='m1'><atomArray atomID='a1 a2 a3'/></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(3, mol.getAtomCount());
    IAtom atom = mol.getAtom(1);
    Assert.assertEquals("a2", atom.getID());
  }
コード例 #17
0
  @Test
  public void testVdWRadiusDescriptor()
      throws ClassNotFoundException, CDKException, java.lang.Exception {
    double[] testResult = {1.7};
    IAtomicDescriptor descriptor = new VdWRadiusDescriptor();
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IMolecule mol = sp.parseSmiles("NCCN(C)(C)");
    double retval =
        ((DoubleResult) descriptor.calculate(mol.getAtom(1), mol).getValue()).doubleValue();

    Assert.assertEquals(testResult[0], retval, 0.01);
  }
コード例 #18
0
  @Test
  public void testBondStereo() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'><bondStereo dictRef='cml:H'/></bond></bondArray></molecule>";
    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(2, mol.getAtomCount());
    Assert.assertEquals(1, mol.getBondCount());
    IBond bond = mol.getBond(0);
    Assert.assertEquals(IBond.Stereo.DOWN, bond.getStereo());
  }
コード例 #19
0
  @Test
  public void testIsotopicMass() throws Exception {
    String cmlString =
        "<molecule><atomArray><atom id='a1' elementType=\"C\"><scalar dataType=\"xsd:float\" dictRef=\"cdk:isotopicMass\">12.0</scalar></atom></atomArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(1, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertEquals("C", atom.getSymbol());
    Assert.assertEquals(12.0, atom.getExactMass().doubleValue(), 0.01);
  }
コード例 #20
0
  @Test
  public void testMassNumber() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray><atom id='a1' elementType='C' isotopeNumber='12'/></atomArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(1, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertEquals("C", atom.getSymbol());
    Assert.assertEquals(12, atom.getMassNumber().intValue());
  }
コード例 #21
0
  @Test
  public void testAtomicNumber() throws Exception {
    String cmlString =
        "<molecule><atomArray><atom id='a1' elementType=\"C\"><scalar dataType=\"xsd:integer\" dictRef=\"cdk:atomicNumber\">6</scalar></atom></atomArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(1, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertEquals("C", atom.getSymbol());
    Assert.assertEquals(6, atom.getAtomicNumber().intValue());
  }
コード例 #22
0
  @Test
  public void testBondId() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray><atom id='a1'/><atom id='a2'/></atomArray><bondArray><bond id='b1' atomRefs2='a1 a2'/></bondArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(2, mol.getAtomCount());
    Assert.assertEquals(1, mol.getBondCount());
    org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);
    Assert.assertEquals("b1", bond.getID());
  }
コード例 #23
0
  @Test
  public void testBondAromatic2() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray atomID='a1 a2'/><bondArray><bond atomRefs='a1 a2' order='2'><bondType dictRef='cdk:aromaticBond'/></bond></bondArray></molecule>";
    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(2, mol.getAtomCount());
    Assert.assertEquals(1, mol.getBondCount());
    org.openscience.cdk.interfaces.IBond bond = mol.getBond(0);
    Assert.assertEquals(CDKConstants.BONDORDER_DOUBLE, bond.getOrder());
    Assert.assertTrue(bond.getFlag(CDKConstants.ISAROMATIC));
  }
コード例 #24
0
  /** @cdk.bug 2142400 */
  @Test
  public void testHydrogenCount1() throws Exception {
    String cmlString =
        "<molecule><atomArray><atom id='a1' elementType='C' hydrogenCount='4'/></atomArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(1, mol.getAtomCount());
    IAtom atom = mol.getAtom(0);
    Assert.assertNotNull(atom);
    Assert.assertNotNull(atom.getImplicitHydrogenCount());
    Assert.assertEquals(4, atom.getImplicitHydrogenCount().intValue());
  }
コード例 #25
0
  @Test
  public void testFractional3D() throws Exception {
    String cmlString =
        "<molecule id='m1'><atomArray atomID='a1 a2' xFract='0.0 0.1' yFract='1.2 1.3' zFract='2.1 2.5'/></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Assert.assertEquals(2, mol.getAtomCount());
    Assert.assertNull(mol.getAtom(0).getPoint3d());
    Assert.assertNull(mol.getAtom(1).getPoint3d());
    Assert.assertNotNull(mol.getAtom(0).getFractionalPoint3d());
    Assert.assertNotNull(mol.getAtom(1).getFractionalPoint3d());
  }
コード例 #26
0
 @Test
 public void testModelBuilder3D_CccccC() throws Exception {
   ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
   String smile = "CccccC";
   SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
   IMolecule mol = sp.parseSmiles(smile);
   addExplicitHydrogens(mol);
   mol = mb3d.generate3DCoordinates(mol, false);
   for (int i = 0; i < mol.getAtomCount(); i++) {
     Assert.assertNotNull(mol.getAtom(i).getPoint3d());
   }
   checkAverageBondLength(mol);
   // logger.debug("Layout molecule with SMILE: "+smile);
 }
コード例 #27
0
 @Test
 public void testModelBuilder3D_reserpine() throws Exception {
   ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
   String filename = "data/mdl/reserpine.mol";
   InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
   MDLV2000Reader reader = new MDLV2000Reader(ins);
   ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
   List containersList = ChemFileManipulator.getAllAtomContainers(chemFile);
   IMolecule ac = new NNMolecule((IAtomContainer) containersList.get(0));
   ac = mb3d.generate3DCoordinates(ac, false);
   for (int i = 0; i < ac.getAtomCount(); i++) {
     Assert.assertNotNull(ac.getAtom(i).getPoint3d());
   }
   checkAverageBondLength(ac);
 }
コード例 #28
0
  @Test
  public void testModelBuilder3D_C1CCCCCCC1CC() throws Exception {
    Assume.assumeTrue(runSlowTests());

    ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
    String smile = "C1CCCCCCC1CC";
    SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
    IMolecule mol = sp.parseSmiles(smile);
    addExplicitHydrogens(mol);
    mol = mb3d.generate3DCoordinates(mol, false);
    for (int i = 0; i < mol.getAtomCount(); i++) {
      Assert.assertNotNull(mol.getAtom(i).getPoint3d());
    }
    checkAverageBondLength(mol);
  }
コード例 #29
0
  /** @cdk.bug 1315823 */
  @Test
  public void testModelBuilder3D_232() throws Exception {
    Assume.assumeTrue(runSlowTests());

    ModelBuilder3D mb3d = ModelBuilder3D.getInstance();
    String filename = "data/mdl/allmol232.mol";
    InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
    MDLV2000Reader reader = new MDLV2000Reader(ins);
    ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
    List containersList = ChemFileManipulator.getAllAtomContainers(chemFile);
    IMolecule ac = new NNMolecule((IAtomContainer) containersList.get(0));
    addExplicitHydrogens(ac);
    ac = mb3d.generate3DCoordinates(ac, false);
    Assert.assertNotNull(ac.getAtom(0).getPoint3d());
    checkAverageBondLength(ac);
  }
コード例 #30
0
  @Test
  public void testDictRef() throws Exception {
    String cmlString =
        "<molecule id=\"alanine\" dictRef=\"pdb:aminoAcid\"><name>alanine</name><name dictRef=\"pdb:residueName\">Ala</name><name dictRef=\"pdb:oneLetterCode\">A</name><scalar dictRef=\"pdb:id\">3</scalar><atomArray><atom id=\"a1\" elementType=\"C\" x2=\"265.0\" y2=\"989.0\"/><atom id=\"a2\" elementType=\"N\" x2=\"234.0\" y2=\"972.0\" dictRef=\"pdb:nTerminus\"/><atom id=\"a3\" elementType=\"C\" x2=\"265.0\" y2=\"1025.0\"/><atom id=\"a4\" elementType=\"C\" x2=\"296.0\" y2=\"971.0\" dictRef=\"pdb:cTerminus\"/><atom id=\"a5\" elementType=\"O\" x2=\"296.0\" y2=\"935.0\"/><atom id=\"a6\" elementType=\"O\" x2=\"327.0\" y2=\"988.0\"/></atomArray><bondArray><bond id=\"b1\" atomRefs2=\"a2 a1\" order=\"S\"/><bond id=\"b2\" atomRefs2=\"a1 a3\" order=\"S\"/><bond id=\"b3\" atomRefs2=\"a1 a4\" order=\"S\"/><bond id=\"b4\" atomRefs2=\"a4 a5\" order=\"D\"/><bond id=\"b5\" atomRefs2=\"a4 a6\" order=\"S\"/></bondArray></molecule>";

    IChemFile chemFile = parseCMLString(cmlString);
    IMolecule mol = checkForSingleMoleculeFile(chemFile);

    Iterator<Object> props = mol.getProperties().keySet().iterator();
    boolean foundDictRefs = false;
    while (props.hasNext()) {
      Object next = props.next();
      if (next instanceof DictRef) foundDictRefs = true;
    }
    Assert.assertTrue(foundDictRefs);
  }