use of gov.sandia.n2a.db.MNode in project n2a by frothga.
the class ImportJob method ionChannel.
public void ionChannel(Node node) {
String id = getAttribute(node, "id");
String type = getAttribute(node, "type");
String species = getAttribute(node, "species");
String inherit;
if (type.isEmpty())
inherit = node.getNodeName();
else
inherit = type;
NameMap nameMap = partMap.importMap(inherit);
inherit = nameMap.internal;
// Expect to always create this part rather than fetch an existing child.
MNode part = models.childOrCreate(modelName, id);
part.set("$inherit", "\"" + inherit + "\"");
addDependency(part, inherit);
if (!species.isEmpty())
part.set("$metadata", "species", species);
addAttributes(node, part, nameMap, "id", "type", "species");
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child.getNodeType() != Node.ELEMENT_NODE)
continue;
String name = child.getNodeName();
if (name.startsWith("q10"))
q10(child, part);
else if (name.startsWith("gate"))
gate(child, part);
else
genericPart(child, part);
}
}
use of gov.sandia.n2a.db.MNode in project n2a by frothga.
the class ImportJob method transition.
public void transition(Node node, MNode container) {
String id = getAttribute(node, "id");
MNode part = container.set(id, "");
NameMap nameMap = partMap.importMap(node.getNodeName());
part.set("$inherit", "\"" + nameMap.internal + "\"");
addAttributes(node, part, nameMap, "id");
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child.getNodeType() == Node.ELEMENT_NODE)
rate(child, part, true, false);
}
}
use of gov.sandia.n2a.db.MNode in project n2a by frothga.
the class ImportJob method removeDependency.
public void removeDependency(MNode part, String inherit) {
dependents.remove(part);
MNode component = models.child(modelName, inherit);
if (component == null)
return;
int count = component.getInt("$count") - 1;
if (count > 0) {
component.set("$count", count);
} else {
component.clear("$count");
component.clear("$connected");
component.clear("$lemsUses");
// This is a proxy part created because a model is missing from the repo.
if (component.size() == 0)
models.clear(modelName, inherit);
}
}
use of gov.sandia.n2a.db.MNode in project n2a by frothga.
the class ImportJob method remap.
public void remap(MNode part, NameMap nameMap) {
MNode temp = new MVolatile();
temp.merge(part);
part.clear();
for (MNode v : temp) {
String key = nameMap.importName(v.key());
part.set(key, v);
}
}
use of gov.sandia.n2a.db.MNode in project n2a by frothga.
the class ImportJob method neuroml.
public void neuroml(Node node) {
File source = sources.getLast();
if (modelName.isEmpty()) {
modelName = getAttribute(node, "id");
if (// then get it from the filename
modelName.isEmpty()) {
modelName = source.getName();
int index = modelName.lastIndexOf('.');
if (index > 0)
modelName = modelName.substring(0, index);
}
modelName = NodePart.validIdentifierFrom(modelName);
// Preemptively scan for unique name, so our references to any sibling parts remain valid.
// IE: a name collision in the main part implies that sibling parts will also have name collisions.
modelName = AddDoc.uniqueName(modelName);
}
MNode model = models.childOrCreate(modelName);
String description = getAttribute(node, "description");
if (!description.isEmpty())
model.set("$metadata", "description", description);
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child.getNodeType() != Node.ELEMENT_NODE)
continue;
switch(child.getNodeName()) {
case // NeuroML include
"include":
// TODO: what if href actually references a web document?
File nextSource = new File(source.getParentFile(), getAttribute(child, "href"));
process(nextSource);
break;
case // LEMS include
"Include":
nextSource = new File(source.getParentFile(), getAttribute(child, "file"));
process(nextSource);
break;
// NeuroML ---------------------------------------------------
case "intracellularProperties":
case "extracellularProperties":
properties.put(getAttribute(child, "id"), child);
break;
case "morphology":
morphologies.put(getAttribute(child, "id"), child);
break;
case "ionChannel":
case "ionChannelHH":
case "ionChannelKS":
ionChannel(child);
break;
case "decayingPoolConcentrationModel":
case "fixedFactorConcentrationModel":
case // This tag appears in Cells.xml, but not in NeuroML_v2beta4.xsd
"fixedFactorConcentrationModelTraub":
concentrationModel(child);
break;
case "blockingPlasticSynapse":
blockingPlasticSynapse(child);
break;
case "biophysicalProperties":
biophysics.put(getAttribute(child, "id"), child);
break;
case "cell":
Cell cell = new Cell(child);
cells.put(cell.id, cell);
break;
case "fitzHughNagumoCell":
MNode FN = genericPart(child, model);
// Force time-scale to match the hard-coded value in LEMS definitions.
FN.set("TS", "1s");
break;
case "poissonFiringSynapse":
case "transientPoissonFiringSynapse":
case "spikeArray":
case "timedSynapticInput":
spikingSynapse(child);
break;
case "compoundInput":
compoundInput(child);
break;
case "network":
Network network = new Network(child);
networks.put(network.id, network);
break;
// LEMS ------------------------------------------------------
case "Target":
target(child);
break;
case "Dimension":
dimension(child);
break;
case "Unit":
unit(child);
break;
case "Constant":
// Create a bogus component to wrap the top level, so we can add a LEMS constant to it.
new ComponentType(model).genericVariable(child, "");
break;
case "ComponentType":
ComponentType component = new ComponentType(child);
components.put(component.part.key(), component);
break;
case "Simulation":
simulation(child);
break;
case "Component":
default:
// Any NeuroML part not specifically processed above will fall through to here.
genericPart(child, model);
break;
}
}
}
Aggregations