Package org.openscience.cdk

Examples of org.openscience.cdk.MoleculeSet


        }
        return resultSet;
    }

    public static IMoleculeSet filterMoleculeByStringProperty(IMoleculeSet molSet, String propertyName, String filterString) {
        IMoleculeSet resultSet = new MoleculeSet();
        for (IAtomContainer eachMol : molSet.molecules()) {
            for (int i = 0; i < filterString.length(); i++) {
                if (((String) eachMol.getProperty(propertyName)).toLowerCase().contains(filterString.toLowerCase())) {
                    resultSet.addMolecule((IMolecule) eachMol);
                }
            }
        }
        return resultSet;
    }
View Full Code Here


        }
        return resultSet;
    }

    public static IMoleculeSet filterMoleculeByDoubleProperty(IMoleculeSet molSet, String propertyName, Double filterThreshold) {
        IMoleculeSet resultSet = new MoleculeSet();
        for (IAtomContainer eachMol : molSet.molecules()) {
            Boolean isRemaining = false;
            for (String eachString : ((String) eachMol.getProperty(propertyName)).split("\n")) {
                if (Double.parseDouble(eachString) >= filterThreshold) {
                    isRemaining = true;
                }
            }
            if (isRemaining) {
                resultSet.addMolecule((IMolecule) eachMol);
            }
        }
        return resultSet;
    }
View Full Code Here

        }
        return resultSet;
    }

    public static IMoleculeSet filterMoleculeByIntegerProperty(IMoleculeSet molSet, String propertyName, Double filterThreshold) {
        return new MoleculeSet();
    }
View Full Code Here

*/
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

            theFrame.setLogTextArea().append(theMolecule.getProperty(MolecularPropertyCalculator.MOLECULAR_FORMULA_PROPERTY_NAME).toString());
        }
    }

    private static IMoleculeSet __readFolderWithTag(File theDir, String tagPropertyName, String theTag) {
        IMoleculeSet theResultMoleculeSet = new MoleculeSet();
        File[] theFileArray = theDir.listFiles();

        for (File theFile : theFileArray) {
            theResultMoleculeSet.add(SDFReader.openMoleculeFile(theFile));
        }

        for (int mi = 0, mEnd = theResultMoleculeSet.getMoleculeCount(); mi < mEnd; mi++) {
            theResultMoleculeSet.getMolecule(mi).setProperty(tagPropertyName, theTag);
        }

        return theResultMoleculeSet;
    }
View Full Code Here

TOP

Related Classes of org.openscience.cdk.MoleculeSet

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.