Search in sources :

Example 1 with MarkushAtomDictionaryObject

use of ambit2.sln.dictionary.MarkushAtomDictionaryObject in project ambit-mirror by ideaconsult.

the class Expander method expandDictionaryAtom.

public List<IAtom> expandDictionaryAtom(SLNAtom at) {
    // Handle a dictionary object
    if (at.dictObj instanceof AtomDictionaryObject) {
        AtomDictionaryObject aDO = (AtomDictionaryObject) at.dictObj;
        SLNAtom newAt = aDO.atom.clone();
        expContainer.addAtom(newAt);
        List<IAtom> list = new ArrayList<IAtom>();
        list.add(newAt);
        return list;
    } else if (at.dictObj instanceof MacroAtomDictionaryObject) {
        return expandMacroAtomDictionaryObject((MacroAtomDictionaryObject) at.dictObj);
    } else if (at.dictObj instanceof MarkushAtomDictionaryObject) {
        // Get the proper macro/atom component from the Markush atom
        // according to the markushPos[...] value
        // maObj is either AtomDictionaryObject or MacroAtomDictionaryObject
        ISLNDictionaryObject maObj = getProperDictionaryObject(at);
        if (maObj instanceof AtomDictionaryObject) {
            AtomDictionaryObject aDO = (AtomDictionaryObject) maObj;
            SLNAtom newAt = aDO.atom.clone();
            expContainer.addAtom(newAt);
            List<IAtom> list = new ArrayList<IAtom>();
            list.add(newAt);
            return list;
        } else {
            return expandMacroAtomDictionaryObject((MacroAtomDictionaryObject) maObj);
        }
    }
    return null;
}
Also used : ArrayList(java.util.ArrayList) SLNAtom(ambit2.sln.SLNAtom) IAtom(org.openscience.cdk.interfaces.IAtom)

Example 2 with MarkushAtomDictionaryObject

use of ambit2.sln.dictionary.MarkushAtomDictionaryObject in project ambit-mirror by ideaconsult.

the class SLNParser method parseMarkushDictionaryObject.

public ISLNDictionaryObject parseMarkushDictionaryObject(String dictObjectString) {
    markushHelper.analyzeMarkushString();
    if (!markushHelper.getErrors().isEmpty()) {
        newError(markushHelper.getErrorMessages(), 0, dictObjectString);
        return null;
    }
    List<ISLNDictionaryObject> macroAtoms = new ArrayList<ISLNDictionaryObject>();
    List<String> components = markushHelper.getComponentList();
    for (int i = 0; i < components.size(); i++) {
        // System.out.println("  " + components.get(i));
        ISLNDictionaryObject dictObj = parseMacroAtomDictionaryObject(components.get(i), false);
        if (dictObj != null)
            macroAtoms.add(dictObj);
    }
    MarkushAtomDictionaryObject markushAtom = new MarkushAtomDictionaryObject(markushHelper.getMarkushAtomName(), dictObjectString, macroAtoms);
    return markushAtom;
}
Also used : MarkushAtomDictionaryObject(ambit2.sln.dictionary.MarkushAtomDictionaryObject) ISLNDictionaryObject(ambit2.sln.dictionary.ISLNDictionaryObject) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 SLNAtom (ambit2.sln.SLNAtom)1 ISLNDictionaryObject (ambit2.sln.dictionary.ISLNDictionaryObject)1 MarkushAtomDictionaryObject (ambit2.sln.dictionary.MarkushAtomDictionaryObject)1 IAtom (org.openscience.cdk.interfaces.IAtom)1