Package org.openscience.cdk.exception

Examples of org.openscience.cdk.exception.CDKException


        JChemPaint.replaceReferencesWithClones(chemModel);

        // check the model is not completely empty
        if (ChemModelManipulator.getBondCount(chemModel) == 0 &&
            ChemModelManipulator.getAtomCount(chemModel) == 0) {
            throw new CDKException(
                    "Structure does not have bonds or atoms. Cannot depict structure.");
        }
        JChemPaint.removeDuplicateMolecules(chemModel);
        JChemPaint.checkCoordinates(chemModel);
        JChemPaint.removeEmptyMolecules(chemModel);

        if (avoidOverlap) {
          try {
            ControllerHub.avoidOverlap(chemModel);
          } catch (Exception e) {
                JOptionPane.showMessageDialog(panel, GT.get("Structure could not be generated"));
                throw new CDKException(
                        "Cannot depict structure");
                }
          }
       
        //We update implicit Hs in any case
View Full Code Here


                error = "Error while reading file: " + exception.getMessage();
                exception.printStackTrace();
            }
        }
        if (error != null) {
            throw new CDKException(error);
        }
        if (chemModel == null && chemFile != null) {
            chemModel = (ChemModel) chemFile.getChemSequence(0).getChemModel(0);
        }
        if (cor.accepts(ChemModel.class) && chemModel==null) {
            // try to read a ChemModel
            try {

                chemModel = (ChemModel) cor.read((IChemObject) new ChemModel());
                if (chemModel == null) {
                    error = "The object chemModel was empty unexpectedly!";
                }
            } catch (Exception exception) {
                error = "Error while reading file: " + exception.getMessage();
                exception.printStackTrace();
            }
        }

        // Smiles reading
        if (cor.accepts(IAtomContainerSet.class) && chemModel==null) {
            // try to read a Molecule set
            try {
                IAtomContainerSet som = (AtomContainerSet) cor.read(new AtomContainerSet());
                chemModel = new ChemModel();
                chemModel.setMoleculeSet(som);
                if (chemModel == null) {
                    error = "The object chemModel was empty unexpectedly!";
                }
            } catch (Exception exception) {
                error = "Error while reading file: " + exception.getMessage();
                exception.printStackTrace();
            }
        }

        // MDLV3000 reading
        if (cor.accepts(IAtomContainer.class) && chemModel==null) {
            // try to read a Molecule
                IAtomContainer mol = (AtomContainer) cor.read(new AtomContainer());
                if(mol!=null )
                    try{
                        IAtomContainerSet newSet = new AtomContainerSet();
                        newSet.addAtomContainer(mol);
                        chemModel = new ChemModel();
                        chemModel.setMoleculeSet(newSet);
                        if (chemModel == null) {
                            error = "The object chemModel was empty unexpectedly!";
                        }
                    } catch (Exception exception) {
                        error = "Error while reading file: " + exception.getMessage();
                        exception.printStackTrace();
                    }
        }

        // RGroupQuery reading
        if (cor.accepts(RGroupQuery.class) && chemModel==null) {
          IRGroupQuery rgroupQuery = (RGroupQuery) cor.read(new RGroupQuery(DefaultChemObjectBuilder.getInstance()));
          if(rgroupQuery!=null )
            try{
              chemModel = new ChemModel();
              RGroupHandler rgHandler =  new RGroupHandler(rgroupQuery, panel);
              panel.get2DHub().setRGroupHandler(rgHandler);
              chemModel.setMoleculeSet(rgHandler.getMoleculeSet(chemModel));
              rgHandler.layoutRgroup();
             
            } catch (Exception exception) {
              error = "Error while reading file: " + exception.getMessage();
              exception.printStackTrace();
            }
        }
       
        if (error != null) {
            throw new CDKException(error);
        }

        if (chemModel == null && chemFile != null) {
            chemModel = (ChemModel) chemFile.getChemSequence(0).getChemModel(0);
        }
View Full Code Here

                sdg.setMolecule(molecule);
                sdg.generateCoordinates();
                molecule = sdg.getMolecule();
            } catch (Exception exc) {
                JOptionPane.showMessageDialog(chemPaintPanel, GT.get("Structure could not be generated"));
                throw new CDKException(
                        "Cannot depict structure");
            }
        }

        if(moleculeSet.getAtomContainer(0).getAtomCount()==0)
View Full Code Here

                                              + " Shall we lay out the structure?");
                int answer = JOptionPane.showConfirmDialog(null, error,
                        "No 2D coordinates", JOptionPane.YES_NO_OPTION);

                if (answer == JOptionPane.NO_OPTION) {
                    throw new CDKException(GT
                            .get("Cannot display without 2D coordinates"));
                } else {
                    // CreateCoordinatesForFileDialog frame =
                    // new CreateCoordinatesForFileDialog(chemModel);
                    // frame.pack();
View Full Code Here

        InChIGeneratorFactory igf = InChIGeneratorFactory.getInstance();
        InChIToStructure its = igf.getInChIToStructure(inchi.getInChI(),
                                                       DefaultChemObjectBuilder.getInstance());

        if (its.getReturnStatus() != INCHI_RET.OKAY && its.getReturnStatus() != INCHI_RET.WARNING)
            throw new CDKException("Could not parse InChI - " + its.getMessage());

        return its.getAtomContainer();
    }
View Full Code Here

    @Override public InChI generate(IAtomContainer container) throws CDKException {
        InChIGeneratorFactory igf = InChIGeneratorFactory.getInstance();
        InChIGenerator its = igf.getInChIGenerator(container);

        if (its.getReturnStatus() != INCHI_RET.OKAY && its.getReturnStatus() != INCHI_RET.WARNING)
            throw new CDKException("Could not generate InChI - " + its.getMessage());

        InChI inchi = new InChI();
        inchi.setInChI(its.getInchi());
        inchi.setKey(its.getInchiKey());
        inchi.setAuxInfo(its.getAuxInfo());
View Full Code Here

                cor = new SMILESReader(getReader(url));
            }

        }
        if (cor == null) {
            throw new CDKException(GT.get("Could not determine file format"));
        }

        // Take care of files called .mol, but having several, sdf-style entries
        if (cor instanceof MDLV2000Reader) {
            try {
View Full Code Here

            }
            in.close();
        } catch (Exception e) {

            e.printStackTrace();
            throw new CDKException(e.getMessage());
        }
        return chemModel;
    }
View Full Code Here

   * @throws CDKException
   */
  public IAtomContainerSet getMoleculeSet (IChemModel chemModel) throws CDKException {

    if (rGroupQuery==null || rGroupQuery.getRootStructure() == null || rGroupQuery.getRootStructure().getAtomCount()==0)
      throw new CDKException( "The R-group is empty");

    IAtomContainerSet moleculeSet = chemModel.getBuilder().newInstance(IAtomContainerSet.class);
    moleculeSet.addAtomContainer(rGroupQuery.getRootStructure());
    chemModel.setMoleculeSet(moleculeSet);
    for (int rgrpNum : sortRGroupNumbers()) {
View Full Code Here

   * @throws CDKException
   */
  public void layoutRgroup() throws CDKException {

    if (rGroupQuery==null || rGroupQuery.getRootStructure() == null || rGroupQuery.getRootStructure().getAtomCount()==0)
      throw new CDKException( "The R-group is empty");

    /*
     * This is how we want to layout:
     *
     *    {Root structure}
View Full Code Here

TOP

Related Classes of org.openscience.cdk.exception.CDKException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.