Package org.openscience.cdk.interfaces

Examples of org.openscience.cdk.interfaces.IMoleculeSet


*/
public abstract class SDFReader implements Serializable{
    private static final long serialVersionUID = -2191073842377518778L;
   
    public static IMoleculeSet openMoleculeFile(File theSdFile) {
        IMoleculeSet theMoleculeSet = new MoleculeSet();
       
        try {
            IteratingMDLReader reader = new IteratingMDLReader(
                    new FileInputStream(theSdFile),
                    DefaultChemObjectBuilder.getInstance());
            while (reader.hasNext()) {
                theMoleculeSet.addMolecule((IMolecule) reader.next());
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
       
View Full Code Here


* @author grinn
*/
public class MoleculeSetFilter {

    public static IMoleculeSet getMoleculesByStringMatch(IMoleculeSet theInputMoleculeSet, String thePropertyName, String theMatchString) {
        IMoleculeSet theResultMoleculeSet = new MoleculeSet();
        for (IAtomContainer theMolecule : theInputMoleculeSet.molecules()) {
            try {
                if ( theMolecule.getProperty(thePropertyName).toString().toLowerCase().contains(theMatchString.toLowerCase())) {
                    theResultMoleculeSet.addMolecule((Molecule) theMolecule);
                }
            } catch (NullPointerException e) {
                //System.err.println("there's no field named " + propertyName);
            }
        }
View Full Code Here

        return theResultMoleculeSet;
    }

    public static IMoleculeSet getMoleculesByAllStringMatch(IMoleculeSet inputMoleculeSet, String propertyName, ArrayList<String> matchString) {
        boolean hasAllStrings;
        IMoleculeSet result = new MoleculeSet();
        for (IAtomContainer theMolecule : inputMoleculeSet.molecules()) {
            hasAllStrings = true;
            for (String theString : matchString) {
                if (!(((String) theMolecule.getProperty(propertyName)).toLowerCase().contains(theString.toLowerCase()))) {
                    hasAllStrings = false;
                }
            }
            if (hasAllStrings) {
                result.addMolecule((Molecule) theMolecule);
            }
        }
        return result;
    }
View Full Code Here

        return result;
    }

    public static IMoleculeSet getMoleculesByORStringMatch(IMoleculeSet inputMoleculeSet, String propertyName, ArrayList<String> matchString) {
        boolean hasAnyOfStrings;
        IMoleculeSet result = new MoleculeSet();
        for (IAtomContainer theMolecule : inputMoleculeSet.molecules()) {
            hasAnyOfStrings = false;
            for (String theString : matchString) {
                if (((String) theMolecule.getProperty(propertyName)).toLowerCase().contains(theString.toLowerCase())) {
                    hasAnyOfStrings = true;
                }
            }
            if (hasAnyOfStrings) {
                result.addMolecule((Molecule) theMolecule);
            }
        }
        return result;
    }
View Full Code Here

        }
        return result;
    }

    public static IMoleculeSet getMoleculesByORStringMatch(IMoleculeSet inputMoleculeSet, ArrayList<String> propertyNameList, ArrayList<String> matchString) {
        IMoleculeSet result = new MoleculeSet();
        for (String thePropName : propertyNameList) {
            MoleculeSetFilter.getMoleculesByORStringMatch(inputMoleculeSet, thePropName, matchString);
        }
        return result;
    }
View Full Code Here

    public static void matchBetweenMassAndMoleculeInDB(MainFrame theFrame) /*throws IOException, CDKException*/ {
        final String SPECIES_PROPERTY_NAME = "SciName";
        final String DB_PROPERTY_NAME = "DBSource";

        IMoleculeSet theInputMoleculeSet = new MoleculeSet();

        File theSDFile = new File("E:\\FG\\DB\\ppinput2resultDir\\dasima.sdf");//Input

        String theFGDBDir = "E:\\FG\\DB";
        File theKEGGMoleculeFolder = new File(theFGDBDir + "\\KEGG");
        File theKTKPMoleculeFolder = new File(theFGDBDir + "\\KTKP");
        File theHERBMoleculeFolder = new File(theFGDBDir + "\\HERB");
        File theGinsengMoleculeFolder = new File(theFGDBDir + "\\ginseng");
        File theLamMoleculeFolder = new File("E:\\FG\\REAXYS\\2");
        File theScutellariaMoleculeFolder = new File("E:\\FG\\REAXYS\\8");
        File theOphiopogonMoleculeFolder = new File("E:\\FG\\REAXYS\\11");
        File thePoriaMoleculeFolder = new File("E:\\FG\\REAXYS\\15");

        theInputMoleculeSet.add(MassMatcher.__readFolderWithTag(theHERBMoleculeFolder, DB_PROPERTY_NAME, "HERB"));
        theInputMoleculeSet.add(MassMatcher.__readFolderWithTag(theGinsengMoleculeFolder, DB_PROPERTY_NAME, "ginseng"));
        theInputMoleculeSet.add(MassMatcher.__readFolderWithTag(theKTKPMoleculeFolder, DB_PROPERTY_NAME, "KTKP"));
        theInputMoleculeSet.add(MassMatcher.__readFolderWithTag(theKEGGMoleculeFolder, DB_PROPERTY_NAME, "KEGG"));
        theInputMoleculeSet.add(MassMatcher.__readFolderWithTag(theGinsengMoleculeFolder, "SciName", "Panax ginseng"));
        theInputMoleculeSet.add(MassMatcher.__readFolderWithTag(theLamMoleculeFolder, "SciName", "Laminaria japonica"));
        theInputMoleculeSet.add(MassMatcher.__readFolderWithTag(theScutellariaMoleculeFolder, "SciName", "Scutellaria baicalensis"));
        theInputMoleculeSet.add(MassMatcher.__readFolderWithTag(thePoriaMoleculeFolder, "SciName", "Poria cocos"));
        theInputMoleculeSet.add(MassMatcher.__readFolderWithTag(theOphiopogonMoleculeFolder, "SciName", "Ophiopogon japonicus"));

        theFrame.setLogTextArea().append(Integer.toString(theInputMoleculeSet.getAtomContainerCount()));
        //inputMolSet = SDFReader.openMoleculeFile(theSDFile);
        theFrame.setLogTextArea().append("read molecule done");
        try {
            MolecularPropertyCalculator thePropertyCalculator = new MolecularPropertyCalculator(theInputMoleculeSet);

            theFrame.setLogTextArea().append(Integer.toString(theInputMoleculeSet.getAtomContainerCount()));
            thePropertyCalculator.calculateExactMass();
            theFrame.setLogTextArea().append(Integer.toString(theInputMoleculeSet.getAtomContainerCount()));
            theInputMoleculeSet = MoleculeSetFilter.getMoleculesByStringMatch(thePropertyCalculator.getMoleculeSet(), SPECIES_PROPERTY_NAME, "Panax ginseng");
            theFrame.setLogTextArea().append(Integer.toString(theInputMoleculeSet.getAtomContainerCount()));
        } catch (CDKException e) {
            JOptionPane.showMessageDialog(null, "CDKException in MolecularPropertyCaluculator!!", "Error", JOptionPane.ERROR_MESSAGE);
        }
        for (IAtomContainer theMolecule : theInputMoleculeSet.molecules()) {
            theFrame.setLogTextArea().append(theMolecule.getProperty(MolecularPropertyCalculator.MOLECULAR_FORMULA_PROPERTY_NAME).toString());
        }
    }
View Full Code Here

            this.__setCarbonSpectrumKeyList().add(this.CARBON_SPECTRUM_KEY + ki);
        }
    }

    private void __sortUsualMolecule(File theMoleculeFile, boolean theExistedTempFile) {
        IMoleculeSet theMoleculeSet = SDFReader.openMoleculeFile(theMoleculeFile);
        StringBuilder theTempMoleculeFilePath = new StringBuilder();
        int theNumberOfMolecule = 0;

        this.setMoleculeSet(new MoleculeSet());

        for (int mi = 0, mEnd = theMoleculeSet.getMoleculeCount(); mi < mEnd; mi++) {
            if (this.__isUsualMolecule(theMoleculeSet.getMolecule(mi))) {
                this.setMoleculeSet().addMolecule(theMoleculeSet.getMolecule(mi));
            }
        }

        if (!theExistedTempFile) {
            this.__makeNewDir(this.TEMP_MOLECULE_DIR);
View Full Code Here

            theFileWriter.flush();
            theFileWriter.write(theResultString);
            theFileWriter.close();

            IMoleculeSet theMoleculeSet = SDFReader.openMoleculeFile(new File(theResultFilePath.toString()));
            SDFWriter.writeSDFile(theMoleculeSet, new File(theResultFilePath.toString()));
        }

        theFileReader.close();
    }
View Full Code Here

    public void deleteTempDirectory() {
        Module.deleteDirectory(new File(this.TOTAL_TEMP_DIR));
    }

    public void writeChemicalShiftAndMpeoeAndCdeapBySDFormat(String theResultFilePath, String theFunctionalGroup) {
        IMoleculeSet theMoleculeSet = new MoleculeSet();

        for (int li = 0, lEnd = this.getHydrogenPeakListByMolecules().size(); li < lEnd; li++) {
            theMoleculeSet.add(this.__getChemicalShiftAndMpeoeAndCdeapBySDFormat(this.getHydrogenPeakListByMolecules().get(li), li, theFunctionalGroup));
        }

        SDFWriter.writeSDFile(theMoleculeSet, new File(theResultFilePath));
    }
View Full Code Here

        SDFWriter.writeSDFile(theMoleculeSet, new File(theResultFilePath));
    }

    private IMoleculeSet __getChemicalShiftAndMpeoeAndCdeapBySDFormat(List<Nmr1dUnitList> thePeak2dList, int theMoleculeIndex, String theFunctionalGroup) {
        IMoleculeSet theMoleculeSet = new MoleculeSet();

        for (Nmr1dUnitList thePeakList : thePeak2dList) {
            theMoleculeSet.add(this.__getChemicalShiftAndMpeoeAndCdeapBySDFormat(thePeakList, theMoleculeIndex, theFunctionalGroup));
        }

        return theMoleculeSet;
    }
View Full Code Here

TOP

Related Classes of org.openscience.cdk.interfaces.IMoleculeSet

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.