/** * Generate a valid SBML identifier using UUID. * * @param model * @return */ public static String nextId(Model model) { String idOne; do { idOne = UUID.randomUUID().toString().replace("-", "_"); if (Character.isDigit(idOne.charAt(0))) { // Add an underscore at the beginning of the new id only if // necessary. idOne = '_' + idOne; } } while (model.findNamedSBase(idOne) != null); return idOne; }
@Override public ASTNodeValue compile(String name) { NamedSBase sbase = model.findNamedSBase(name); if (sbase != null) { if (sbase instanceof Variable) { Variable var = (Variable) sbase; return new ASTNodeValue(var.getConstant(), this); } return new ASTNodeValue(false, this); } if (isSetConstantIds) { if (constantIds.contains(name)) { return new ASTNodeValue(true, this); } } return new ASTNodeValue(false, this); }
/** * Gets the {@link Transition} that has the given id. * * @param id * @return the {@link Transition} that has the given id or null if * no {@link Transition} are found that match {@code id}. */ public Transition getTransition(String id) { if (isSetListOfTransitions()) { Model m = getModel(); if (m != null) { return (Transition) m.findNamedSBase(id); } return listOfTransitions.firstHit(new NameFilter(id)); } return null; }
/** * Gets the actual SBase instance referred by the {@code idRef} or {@code metaIdRef}, returns null * if nothing is found. * * @return the actual SBase instance referred by the {@code idRef} or {@code metaIdRef}, returns null * if nothing is found. */ public SBase getSBaseInstance() { SBase instance = null; if (isSetIdRef()) { Model model = getModel(); if (model != null) { instance = model.findNamedSBase(idRef); } } else if (isSetMetaIdRef()) { SBMLDocument doc = getSBMLDocument(); if (doc != null) { instance = doc.findSBase(metaIdRef); } } return instance; }
SBase sbase = model.findNamedSBase(name); if (sbase != null) { if (useId) {
SBase variable = model.findNamedSBase(assignment.getVariable()); if (variable == null) { return false;
SBase refSBase = model.findNamedSBase(refValue);
/** * Checks if adding an {@link Index} object to a parent * {@link SBase} object for referencing another {@link SBase} object does not * cause out-of-bounds issues. * * @param model * @param parent * @param refAttribute * @param math * @param arrayDim * @return */ public static boolean evaluateIndexBounds(Model model, SBase parent, String refAttribute, ASTNode math, int arrayDim) { String refId = parent.writeXMLAttributes().get(refAttribute); SBase reference = model.findNamedSBase(refId); ArraysSBasePlugin arraysSBasePlugin = (ArraysSBasePlugin) parent.getExtension(ArraysConstants.shortLabel); ArraysSBasePlugin parentArraysSBasePlugin = (ArraysSBasePlugin) parent.getParentSBMLObject().getExtension(ArraysConstants.shortLabel); ArraysSBasePlugin refSbasePlugin = (ArraysSBasePlugin) reference.getExtension(ArraysConstants.shortLabel); Dimension dimByArrayDim = refSbasePlugin.getDimensionByArrayDimension(arrayDim); if (dimByArrayDim == null) { return false; } Map<String, Double> dimensionSizes = getDimensionSizes(model, arraysSBasePlugin); if (parentArraysSBasePlugin != null) { dimensionSizes.putAll(getDimensionSizes(model,parentArraysSBasePlugin)); } Map<String, Double> refSBaseSizes = getDimensionSizes(model, refSbasePlugin); double size = refSBaseSizes.get(dimByArrayDim.getId()); return evaluateBounds(dimensionSizes, math, size); }
/** * @param node * @param value */ private void updateASTNodeName(ASTNode node, String value) { if (node.isVector()) { for (int i = 0; i < node.getChildCount(); ++i) { ASTNode child = node.getChild(i); updateASTNodeName(child, value); } } else if (node.isName()) { String appendName = node.getName(); while(model.findNamedSBase(value + appendName) != null) { appendName = "_" + appendName; } node.setName(value + appendName); } else { node.setName("unknown"); } }
SBase sbase = model.findNamedSBase(obj.toString());
if (node.isString()) { String id = node.toString(); SBase sbase = model.findNamedSBase(id); ArraysSBasePlugin arraysSBasePlugin = (ArraysSBasePlugin) sbase.getExtension(ArraysConstants.shortLabel); for (Dimension dim : arraysSBasePlugin.getListOfDimensions()) {
String refValue = parent.writeXMLAttributes().get(index.getReferencedAttribute()); SBase refSBase = model.findNamedSBase(refValue);
SBase sbase = model.findNamedSBase(id); if (sbase == null) { return;
SBase sbase = model.findNamedSBase(obj.toString());