Search in sources :

Example 51 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class ImportJob method addDependency.

public void addDependency(MNode part, String inherit) {
    dependents.add(part);
    MNode component = models.child(modelName, inherit);
    if (component == null) {
        component = models.childOrCreate(modelName, inherit);
        component.set("$count", "1");
        // TODO: map name to neuroml parts
        if (AppData.models.child(inherit) != null) {
            // Setting our inherit line supports analysis in genericPart().
            component.set("$inherit", inherit);
        // IDs will be filled during postprocessing.
        }
    } else {
        int count = component.getInt("$count");
        component.set("$count", count + 1);
    }
}
Also used : MNode(gov.sandia.n2a.db.MNode)

Example 52 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class ImportJob method q10.

public void q10(Node node, MNode container) {
    String id = "Q10Parameters";
    int suffix = 2;
    // This seems pointless, but the NeuroML XSD says the number of elements is unbounded.
    while (container.child(id) != null) id = "Q10Parameters" + suffix++;
    MNode part = container.set(id, "");
    // This isn't the correct name for use with ion channel, but it will still work.
    NameMap nameMap = partMap.importMap("baseQ10Settings");
    String inherit = nameMap.internal;
    part.set("$inherit", "\"" + inherit + "\"");
    addDependency(part, inherit);
    NamedNodeMap attributes = node.getAttributes();
    int count = attributes.getLength();
    for (int i = 0; i < count; i++) {
        Node a = attributes.item(i);
        String name = a.getNodeName();
        // probably switches between fixed and exponential, but there is no example/guidance on its use
        if (name.equals("type"))
            continue;
        String value = biophysicalUnits(a.getNodeValue());
        if (name.equals("fixedQ10"))
            value = "*" + value;
        name = nameMap.importName(name);
        part.set(name, value);
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) MNode(gov.sandia.n2a.db.MNode) NameMap(gov.sandia.n2a.backend.neuroml.PartMap.NameMap) MNode(gov.sandia.n2a.db.MNode)

Example 53 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class ImportJob method addAttributes.

public void addAttributes(Node node, MNode part, NameMap nameMap, String... forbidden) {
    NamedNodeMap attributes = node.getAttributes();
    int count = attributes.getLength();
    List<String> forbiddenList = Arrays.asList(forbidden);
    for (int i = 0; i < count; i++) {
        Node a = attributes.item(i);
        String name = a.getNodeName();
        String value = a.getNodeValue();
        if (forbiddenList.contains(name))
            continue;
        if (name.equals("neuroLexId")) {
            part.set("$metadata", "neuroLexID", value);
            continue;
        }
        name = nameMap.importName(name);
        String defaultUnit = nameMap.defaultUnit(name);
        // biophysicalUnits() will only modify text if there is a numeric value
        part.set(name, biophysicalUnits(value, defaultUnit));
    }
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) Node(org.w3c.dom.Node) MNode(gov.sandia.n2a.db.MNode)

Example 54 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class ImportJob method output.

public void output(Node node, MNode part) {
    // String path     = getAttribute (node, "path");  // TODO: what is the relationship between path and fileName here?
    String fileName = getAttribute(node, "fileName");
    for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
        if (child.getNodeType() != Node.ELEMENT_NODE)
            continue;
        String quantity = getAttribute(child, "quantity");
        String select = getAttribute(child, "select");
        String event = getAttribute(child, "eventPort");
        if (quantity.isEmpty() && !select.isEmpty())
            quantity = select + "/ignored";
        Path variablePath = new Path(quantity);
        variablePath.resolve(part);
        MNode container = variablePath.container();
        if (container == null)
            continue;
        String variable = variablePath.target();
        String dummy = "x0";
        int index = 1;
        while (container.child(dummy) != null) dummy = "x" + index++;
        String condition = variablePath.condition();
        if (!event.isEmpty()) {
            if (!condition.isEmpty())
                condition += "&&";
            condition += "event(" + event + ")";
            variable = "1";
        }
        if (!condition.isEmpty())
            condition = "@" + condition;
        if (fileName.isEmpty())
            container.set(dummy, "output(" + variable + ")" + condition);
        else
            container.set(dummy, "output(\"" + fileName + "\"," + variable + ")" + condition);
    }
}
Also used : Node(org.w3c.dom.Node) MNode(gov.sandia.n2a.db.MNode) MNode(gov.sandia.n2a.db.MNode)

Example 55 with MNode

use of gov.sandia.n2a.db.MNode in project n2a by frothga.

the class ImportJob method compoundInput.

public void compoundInput(Node node) {
    MNode part = genericPart(node, models.child(modelName));
    String inherit = part.get("$inherit").replace("\"", "");
    part.clear("$inherit");
    if (!inherit.isEmpty())
        removeDependency(part, inherit);
    part.set("$metadata", "backend.lems.part", "compoundInput");
    for (MNode c : part) {
        // not a sub-part
        if (c.child("$inherit") == null)
            continue;
        // force sub-part to get its connection binding from us
        c.set("B", "$kill");
    }
}
Also used : MNode(gov.sandia.n2a.db.MNode)

Aggregations

MNode (gov.sandia.n2a.db.MNode)63 Node (org.w3c.dom.Node)11 NameMap (gov.sandia.n2a.backend.neuroml.PartMap.NameMap)9 MVolatile (gov.sandia.n2a.db.MVolatile)5 MPart (gov.sandia.n2a.eqset.MPart)5 ArrayList (java.util.ArrayList)5 PanelModel (gov.sandia.n2a.ui.eq.PanelModel)4 MPersistent (gov.sandia.n2a.db.MPersistent)3 EquationSet (gov.sandia.n2a.eqset.EquationSet)3 Variable (gov.sandia.n2a.eqset.Variable)3 AccessVariable (gov.sandia.n2a.language.AccessVariable)3 PanelReference (gov.sandia.n2a.ui.ref.PanelReference)3 Element (org.w3c.dom.Element)3 NamedNodeMap (org.w3c.dom.NamedNodeMap)3 MDoc (gov.sandia.n2a.db.MDoc)2 ParseException (gov.sandia.n2a.language.ParseException)2 AddDoc (gov.sandia.n2a.ui.eq.undo.AddDoc)2 IOException (java.io.IOException)2 TreeMap (java.util.TreeMap)2 IncommensurableException (javax.measure.IncommensurableException)2