Search in sources :

Example 1 with TopDownNeutralLossFragmenter

use of de.ipbhalle.metfraglib.fragmenter.TopDownNeutralLossFragmenter in project MetFragRelaunched by ipb-halle.

the class MetfRag method generateAllFragments.

/**
 * @param molecule
 * @param maximumTreeDepth
 * @return
 */
public static IAtomContainer[] generateAllFragments(IAtomContainer molecule, int maximumTreeDepth) {
    Logger.getLogger("net.sf.jnati.deploy.artefact.ConfigManager").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.repository.ClasspathRepository").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.repository.LocalRepository").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.artefact.ManifestReader").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.NativeArtefactLocator").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.NativeLibraryLoader").setLevel(Level.ERROR);
    MetFragGlobalSettings settings = new MetFragGlobalSettings();
    MoleculeFunctions.prepareAtomContainer(molecule, true);
    ICandidate candidate = null;
    try {
        candidate = new TopDownPrecursorCandidate(MoleculeFunctions.getInChIInfoFromAtomContainer(molecule)[0], "1");
        candidate.initialisePrecursorCandidate();
    } catch (AtomTypeNotKnownFromInputListException e1) {
        e1.printStackTrace();
        return new IAtomContainer[0];
    } catch (Exception e1) {
        e1.printStackTrace();
        return new IAtomContainer[0];
    }
    settings.set(VariableNames.CANDIDATE_NAME, candidate);
    settings.set(VariableNames.MAXIMUM_TREE_DEPTH_NAME, (byte) 2);
    settings.set(VariableNames.MINIMUM_FRAGMENT_MASS_LIMIT_NAME, 0.0);
    settings.set(VariableNames.MAXIMUM_NUMBER_OF_TOPDOWN_FRAGMENT_ADDED_TO_QUEUE, (byte) maximumTreeDepth);
    TopDownNeutralLossFragmenter fragmenter = null;
    try {
        fragmenter = new TopDownNeutralLossFragmenter(settings);
    } catch (Exception e) {
        e.printStackTrace();
    }
    FragmentList fragmentList = fragmenter.generateFragments();
    IAtomContainer[] fragments = new IAtomContainer[fragmentList.getNumberElements()];
    for (int i = 0; i < fragmentList.getNumberElements(); i++) {
        fragments[i] = fragmentList.getElement(i).getStructureAsIAtomContainer(candidate.getPrecursorMolecule());
    }
    return fragments;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) MetFragGlobalSettings(de.ipbhalle.metfraglib.settings.MetFragGlobalSettings) TopDownNeutralLossFragmenter(de.ipbhalle.metfraglib.fragmenter.TopDownNeutralLossFragmenter) FragmentList(de.ipbhalle.metfraglib.list.FragmentList) TopDownPrecursorCandidate(de.ipbhalle.metfraglib.candidate.TopDownPrecursorCandidate) AtomTypeNotKnownFromInputListException(de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException) ICandidate(de.ipbhalle.metfraglib.interfaces.ICandidate) AtomTypeNotKnownFromInputListException(de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException) RelativeIntensityNotDefinedException(de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException)

Aggregations

TopDownPrecursorCandidate (de.ipbhalle.metfraglib.candidate.TopDownPrecursorCandidate)1 AtomTypeNotKnownFromInputListException (de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException)1 RelativeIntensityNotDefinedException (de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException)1 TopDownNeutralLossFragmenter (de.ipbhalle.metfraglib.fragmenter.TopDownNeutralLossFragmenter)1 ICandidate (de.ipbhalle.metfraglib.interfaces.ICandidate)1 FragmentList (de.ipbhalle.metfraglib.list.FragmentList)1 MetFragGlobalSettings (de.ipbhalle.metfraglib.settings.MetFragGlobalSettings)1 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)1