/** * @return */ public Model getModel() { SBMLDocument doc = getSBMLDocument(); return doc != null ? doc.getModel() : null; }
/** * Returns the {@link SBase} with the given metaid in this * {@link SBMLDocument} or null * if no such {@link SBase} is found. * * <p>This method make use of {@link HashMap} so it is more efficient * to search for metaid than anywhere else down in the SBML hierarchy.</p> * * @param metaid * - the metaid of {@link SBase} to find * @return the {@link SBase} with the given metaid or null * @see #findSBase(String) */ @Override public SBase getElementByMetaId(String metaid) { return findSBase(metaid); }
@Override public SBMLDocument convert(SBMLDocument doc) throws SBMLException { SBMLDocument resultdoc = doc; Model m = doc.getModel(); if (m == null || m.getFunctionDefinitionCount() == 0) { // In this case, we cannot do anything about the FunctionDefinition or there is nothing to do return doc; } try { resultdoc = doc.clone(); resultdoc.filter(new Filter() { @Override public boolean accepts(Object o) { if (o instanceof MathContainer) { // call an utility that will replace the FDs expandFunctionDefinition((MathContainer) o); } return false; } }); } catch (Exception e) { // something went wrong during cloning. It can happen with malformed FunctionDefinition math // just returning the original unmodified document } return resultdoc; }
/** * * @return */ public Model getModel() { return doc.isSetModel() ? doc.getModel() : doc.createModel(); }
/** * Creates a new instance of Model from id and the level and version of this * SBMLDocument. * * @param id * @return the new {@link Model} instance. */ public Model createModel(String id) { setModel(new Model(id, getLevel(), getVersion())); return getModel(); }
if (document.isPackageEnabled(CompConstants.shortLabel)) { CompSBMLDocumentPlugin compSBMLDocumentPlugin = (CompSBMLDocumentPlugin) document.getExtension(CompConstants.shortLabel); if (document.isSetModel() && document.getModel().getExtension(CompConstants.shortLabel) != null) { CompModelPlugin compModelPlugin = (CompModelPlugin) document.getModel().getExtension(CompConstants.shortLabel); handlePorts(compModelPlugin, compModelPlugin.getListOfPorts()); replaceElementsInModelDefinition(compModelPlugin, null); this.flattenedModel.unsetPlugin(CompConstants.shortLabel); document.setModel(this.flattenedModel); document.unsetExtension(CompConstants.shortLabel); document.disablePackage(CompConstants.shortLabel);
if (sb.isSetModel()) { setModel(sb.getModel().clone()); } else { model = null;
LoggingValidationContext ctx = new LoggingValidationContext(getLevel(), getVersion()); if (isSetModel() && getModel().getFunctionDefinitionCount() > 0) { ExpandFunctionDefinitionConverter converter = new ExpandFunctionDefinitionConverter(); docToValidate = converter.convert(this);
if (sbmlDocument.isSetModel()) { Model model = sbmlDocument.getModel(); sbmlDocument.filter(new Filter() {
@Override public TreeNode getChildAt(int index) { if (index < 0) { throw new IndexOutOfBoundsException(MessageFormat.format( resourceBundle.getString("IndexSurpassesBoundsException"), index, 0)); } int count = super.getChildCount(), pos = 0; if (index < count) { return super.getChildAt(index); } else { index -= count; } if (isSetModel()) { if (pos == index) { return getModel(); } } throw new IndexOutOfBoundsException(MessageFormat.format( resourceBundle.getString("IndexExceedsBoundsException"), index, Math.min(pos, 0))); }
/** * This method flattens out arrays objects of a given {@link SBMLDocument}. * * @param document - the document you want to convert. * @return new Document that is not associated with the arrays package. */ public static SBMLDocument convert(SBMLDocument document) { try { SBMLDocument flattenedDoc = document.clone(); Model model = flattenedDoc.getModel(); Map<String, ASTNode> idToVector = new HashMap<String, ASTNode>(); getVectors(flattenedDoc.getModel(), idToVector); convert(flattenedDoc, model, new ArraysCompiler(), idToVector, new ArrayList<Integer>()); convertMath(flattenedDoc, model, idToVector); return flattenedDoc; } catch(SBMLException exception) { logger.error(exception.getMessage()); return null; } }
/** * Validates the given {@link SBMLDocument} * * @param document - a document that needs to be validated * @return a list of {@link SBMLError}s */ public static List<SBMLError> validate(SBMLDocument document) { List<SBMLError> listOfErrors = new ArrayList<SBMLError>(); Enumeration<TreeNode> children = document.children(); while(children.hasMoreElements()) { TreeNode child = children.nextElement(); validate(document.getModel(), child, listOfErrors); } return listOfErrors; }
System.out.println("Number of namespaces: " + testDocument.getDeclaredNamespaces().size()); for (String prefix : testDocument.getDeclaredNamespaces().keySet()) { System.out.println("PREFIX = "+prefix); String uri = testDocument.getDeclaredNamespaces().get(prefix); System.out.println("URI = "+uri); System.out.println("Model NoRDFAnnotation String = \n@" + testDocument.getModel().getAnnotation().getNonRDFannotation() + "@"); System.out.println("Model Annotation String = \n@" + testDocument.getModel().getAnnotationString() + "@"); for (Species species : testDocument.getModel().getListOfSpecies()) { species.getAnnotationString();
model.setLevel(sbmlDocument.getLevel()); model.setVersion(sbmlDocument.getVersion()); model.initDefaults(); sbmlDocument.setModel(model);
Map<String, String> declaredNamespaces = doc.getDeclaredNamespaces(); List<String> packageNamespaces = new ArrayList<String>(); String namespace = declaredNamespaces.get(xmlns); if (doc.isPackageEnabled(namespace)) { packageNamespaces.add(namespace);
@Override public boolean isPackageEnabled(String packageURIOrName) { SBMLDocument doc = getSBMLDocument(); if (doc != null) { return doc.isPackageEnabled(packageURIOrName); } return false; }
@Override public int getChildCount() { return super.getChildCount() + (isSetModel() ? 1 : 0); }
/** * Creates a new Model inside this {@link SBMLDocument}, and returns a * pointer to it. * In SBML Level 2, the use of an identifier on a {@link Model} object is * optional. This method takes an optional argument, sid, for setting the * identifier. If not supplied, the identifier attribute on the Model * instance is not set. * * @return the new {@link Model} instance. */ public Model createModel() { Model oldValue = getModel(); setModel(new Model(getLevel(), getVersion())); firePropertyChange(TreeNodeChangeEvent.model, oldValue, getModel()); return getModel(); }
/** * Returns {@code true} if the given SBML Level 3 package is enabled within * the containing {@link SBMLDocument}. * * @param packageURIOrName * the name or URI of the package extension. * @return {@code true} if the given SBML Level 3 package is enabled within * the containing {@link SBMLDocument}, {@code false} otherwise. */ public boolean isPackageEnabled(String packageURIOrName) { SBMLDocument doc = getParentSBMLObject().getSBMLDocument(); // TODO - need to prevent NullPointerException if (doc != null) { return doc.isPackageEnabled(packageURIOrName); } return false; }
/** * Appends "_<number>" to a given String. <number> is being set to * the next free number, so that this sID is unique in this * {@link SBMLDocument}. Should only be called from {@link #nameToSId(String)}. * * @return */ private static String incrementSIdSuffix(String prefix, SBMLDocument doc) { int i = 1; String aktString = prefix + "_" + i; Model model = doc.getModel(); while (model.containsUniqueNamedSBase(aktString)) { aktString = prefix + "_" + (++i); } return aktString; }