Search in sources :

Example 1 with IMolecularFormula

use of de.ipbhalle.metfraglib.interfaces.IMolecularFormula in project MetFragRelaunched by ipb-halle.

the class PreProcessingCandidateElementInclusionExclusiveFilter method passesFilter.

public boolean passesFilter(ICandidate candidate) {
    if (this.includedElements == null)
        return true;
    IMolecularFormula molecularFormula = null;
    try {
        molecularFormula = candidate.getMolecularFormula();
    } catch (AtomTypeNotKnownFromInputListException e) {
        e.printStackTrace();
    }
    if (molecularFormula.getNumberElements() > this.includedElements.length)
        return false;
    String[] elementsArray = molecularFormula.getElementsAsStringArray();
    boolean[] atomsIsContained = new boolean[this.includedElements.length];
    for (int i = 0; i < elementsArray.length; i++) {
        boolean isContained = false;
        for (int j = 0; j < this.includedElements.length; j++) {
            if (this.includedElements[j].equals(elementsArray[i])) {
                isContained = true;
                atomsIsContained[i] = true;
                break;
            }
        }
        if (!isContained)
            return false;
    }
    for (Boolean contained : atomsIsContained) if (!contained)
        return false;
    return true;
}
Also used : IMolecularFormula(de.ipbhalle.metfraglib.interfaces.IMolecularFormula) AtomTypeNotKnownFromInputListException(de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException)

Example 2 with IMolecularFormula

use of de.ipbhalle.metfraglib.interfaces.IMolecularFormula in project MetFragRelaunched by ipb-halle.

the class PreProcessingCandidateMaximalElementFilter method passesFilter.

public boolean passesFilter(ICandidate candidate) {
    if (this.maximalFormulaElements == null)
        return true;
    IMolecularFormula molecularFormula = null;
    try {
        molecularFormula = candidate.getMolecularFormula();
    } catch (AtomTypeNotKnownFromInputListException e) {
        e.printStackTrace();
    }
    byte[] atomIndeces = this.maximalFormulaElements.getAtomsAsIndeces();
    short[] numberAtoms = this.maximalFormulaElements.getNumberOfAtoms();
    for (int i = 0; i < atomIndeces.length; i++) {
        if (molecularFormula.getNumberElementsFromByte(atomIndeces[i]) > numberAtoms[i])
            return false;
    }
    return true;
}
Also used : IMolecularFormula(de.ipbhalle.metfraglib.interfaces.IMolecularFormula) AtomTypeNotKnownFromInputListException(de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException)

Example 3 with IMolecularFormula

use of de.ipbhalle.metfraglib.interfaces.IMolecularFormula in project MetFragRelaunched by ipb-halle.

the class PreProcessingCandidateMinimalElementFilter method passesFilter.

public boolean passesFilter(ICandidate candidate) throws AtomTypeNotKnownFromInputListException {
    if (this.minimumFormulaElements == null)
        return true;
    IMolecularFormula molecularFormula = candidate.getMolecularFormula();
    byte[] atomIndeces = this.minimumFormulaElements.getAtomsAsIndeces();
    short[] numberAtoms = this.minimumFormulaElements.getNumberOfAtoms();
    for (int i = 0; i < atomIndeces.length; i++) {
        if (molecularFormula.getNumberElementsFromByte(atomIndeces[i]) < numberAtoms[i])
            return false;
    }
    return true;
}
Also used : IMolecularFormula(de.ipbhalle.metfraglib.interfaces.IMolecularFormula)

Aggregations

IMolecularFormula (de.ipbhalle.metfraglib.interfaces.IMolecularFormula)3 AtomTypeNotKnownFromInputListException (de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException)2