Package org.openscience.cdk.io

Examples of org.openscience.cdk.io.MDLV2000Reader


                            if(restname.indexOf("/")==restname.length()-1){
                                entriesMol.put(restname.substring(0,restname.length()-1), new ArrayList<IAtomContainer>());
                            }else if(restname.indexOf("/")>-1 && withsubdirs){
                                if(entry.getName().indexOf(".mol")>-1){
                                    InputStream ins = dummy.getClass().getClassLoader().getResourceAsStream(entry.getName());
                                    MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.RELAXED);
                                    IAtomContainer cdkmol = (IAtomContainer)reader.read(DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class));
                                    entriesMol.get(restname.substring(0,restname.indexOf("/"))).add(cdkmol);
                                    entriesMolName.put(cdkmol,entry.getName().substring(0,entry.getName().length()-4));
                                }else{
                                    Icon icon = new ImageIcon(new URL(url.toString()+entry.getName()));
                                    entriesIcon.put(entry.getName().substring(0,entry.getName().length()-4),icon);
                                }
                            }
                        }
                    }
                }
            }catch(IOException ex){
                //This is a version we fall back to if no jar available. This should be in Eclipse only.
                File file = new File(new File(dummy.getClass().getProtectionDomain().getCodeSource().getLocation().toURI()).getAbsolutePath()+File.separator+TEMPLATES_PACKAGE.replace('/', File.separatorChar));
                for (int i=0;i<file.listFiles().length ; i++) {
                    if(file.listFiles()[i].isDirectory()){
                        File dir = file.listFiles()[i];
                        if(!dir.getName().startsWith(".")) {
                            entriesMol.put(dir.getName(), new ArrayList<IAtomContainer>());
                            if(withsubdirs){
                                for(int k=0;k<dir.list().length;k++){
                                    if(dir.listFiles()[k].getName().indexOf(".mol")>-1){
                                        MDLV2000Reader reader = new MDLV2000Reader(new FileInputStream(dir.listFiles()[k]), Mode.RELAXED);
                                        IAtomContainer cdkmol = (IAtomContainer)reader.read(DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class));
                                        entriesMol.get(dir.getName()).add(cdkmol);
                                        entriesMolName.put(cdkmol,dir.listFiles()[k].getName().substring(0,dir.listFiles()[k].getName().length()-4));
                                    }else{
   
                                        Icon icon = new ImageIcon(dir.listFiles()[k].getAbsolutePath());
View Full Code Here


            else if (format instanceof CMLFormat ) {
              cor = new CMLReader(urlString);
              cor.setReader(url.openStream());
            }
            else if (format instanceof MDLV2000Format ) {
                  cor = new MDLV2000Reader(getReader(url));
              cor.setReader(input);
            }
            // SMILES format is never guessed :(
            //else if (format instanceof SMILESFormat ) {
            //  cor = new SMILESReader(getReader(url));
            //  cor.setReader(input);
            //}
            //InChI format is never guessed :(
            //else if (format instanceof INChIPlainTextFormat ) {
            //  cor = new INChIPlainTextReader(getReader(url));
            //   cor.setReader(input);
            //}
          }
        } catch (Exception exc) {
            exc.printStackTrace();
        }

       
        if (cor == null) {
            // try to determine from user's guess
          type = ext;
            if (type.equals(JCPFileFilter.cml)|| type.equals(JCPFileFilter.xml)) {
                cor = new CMLReader(urlString);

            } else if (type.equals(JCPFileFilter.sdf)) {
                cor = new MDLV2000Reader(getReader(url));
            } else if (type.equals(JCPFileFilter.mol)) {
                cor = new MDLV2000Reader(getReader(url));
            } else if (type.equals(JCPFileFilter.inchi)) {
                try {
                    cor = new INChIReader(new URL(urlString).openStream());
                } catch (Exception e) {
                  e.printStackTrace();
View Full Code Here

        JPanelFixture jcppanel=applet.panel("appletframe");
        JChemPaintPanel panel = (JChemPaintPanel)jcppanel.target;
        panel.get2DHub().getController2DModel().setAutoUpdateImplicitHydrogens(true);
        String filename = "data/basic.mol";
        InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
        MDLV2000Reader reader = new MDLV2000Reader(ins);
        IChemModel basic;
        try {
            basic = (IChemModel) reader.read(DefaultChemObjectBuilder.getInstance().newInstance(IChemModel.class));
            AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(basic.getMoleculeSet().getAtomContainer(0));
            CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(basic.getMoleculeSet().getAtomContainer(0)
                    .getBuilder());
            hAdder.addImplicitHydrogens(basic.getMoleculeSet().getAtomContainer(0));
            //valencies are set when doing atom typing, which we don't want in jcp
View Full Code Here

            newmol.append(mol.substring(s, e));
            newmol.append(System.getProperty("line.separator"));
            s = e + 2;
        }
        newmol.append(mol.substring(s));
        MDLV2000Reader reader = new MDLV2000Reader(new StringReader(newmol
                .toString()));
        IAtomContainer cdkmol = (IAtomContainer) reader.read(DefaultChemObjectBuilder
                .getInstance().newInstance(IAtomContainer.class));
        JChemPaint.generateModel(theJcpp, cdkmol, false,false);
        theJcpp.get2DHub().updateView();
        // the newly opened file should nicely fit the screen
        theJcpp.getRenderPanel().setFitToScreen(true);
View Full Code Here

      if (mol.contains("$RGP")) {
        cor= new RGroupQueryReader(new StringReader(mol));
        chemModel=JChemPaint.getChemModelFromReader(cor, theJcpp);
      }
      else {
        cor= new MDLV2000Reader(new StringReader(mol), Mode.RELAXED);
        chemModel=JChemPaint.getChemModelFromReader(cor, theJcpp);
        JChemPaint.cleanUpChemModel(chemModel,true, theJcpp);
      }

      theJcpp.setChemModel(chemModel);
View Full Code Here

          JTextComponentFixture text = dialog.textBox();
          text.setText(file.toString());
          JButtonFixture okbutton = new JButtonFixture(dialog.robot, dialog.robot.finder().find(new ButtonTextComponentMatcher("Open")));
          okbutton.click();
              ins = this.getClass().getClassLoader().getResourceAsStream(filename);
              MDLV2000Reader reader = new MDLV2000Reader(ins, Mode.STRICT);
              ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile());
              Assert.assertNotNull(chemFile);
              List<IAtomContainer> containersList = ChemFileManipulator.getAllAtomContainers(chemFile);
              JPanelFixture jcppanel=applet.panel("appletframe");
              JChemPaintPanel panel = (JChemPaintPanel)jcppanel.target;
              Assert.assertEquals(1, containersList.size());
View Full Code Here

            if(file.listFiles()[i].isDirectory()){
                File dir = file.listFiles()[i];
                for(int k=0;k<dir.list().length;k++){
                    if(dir.listFiles()[k].getName().indexOf(".mol")>-1){
                        System.err.println(dir.listFiles()[k].getAbsolutePath());
                        MDLV2000Reader reader = new MDLV2000Reader(new FileInputStream(dir.listFiles()[k]), Mode.RELAXED);
                        IAtomContainer cdkmol = (IAtomContainer)reader.read(DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class));
                        String inputstr = getMolSvg(cdkmol, 100, 100);
                        ImageTranscoder imageTranscoder = new JPEGTranscoder();
                        imageTranscoder.addTranscodingHint(JPEGTranscoder.KEY_QUALITY, new Float(.8));
                        TranscoderInput input = new TranscoderInput(new StringReader(inputstr));
                        FileOutputStream ostream = new FileOutputStream(new File(dir.listFiles()[k].getAbsolutePath().substring(0,dir.listFiles()[k].getAbsolutePath().length()-4)+".png"));
View Full Code Here

                throw new CDKException (errMsg);
            }

            //From Molfile to Atom container -----------------------------------
            InputStream ins = new FileInputStream(tmpMolFile);
            MDLV2000Reader reader = new MDLV2000Reader(ins);
            ChemFile chemFile = (ChemFile)reader.read((ChemObject)new ChemFile());
            atc= ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
            atc.setProperty(CDKConstants.TITLE, null);

            // Generate coordinates for the atom container
            StructureDiagramGenerator sdg =
View Full Code Here

TOP

Related Classes of org.openscience.cdk.io.MDLV2000Reader

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.