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);
}
}
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);
}
}
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));
}
}
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);
}
}
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");
}
}
Aggregations