This week, I implemented the main classes for the arrays package. I think during this process, I was able to understand the class hierarchy much better. The arrays package is pretty simple:

SBase is extended to have 0 or 1 list of dimensions, where the list contains 0 or more dimension objects and dimension inherits from SBase. Dimension is used to indicate an element is arrayed. The id and name are optional fields. The size of an dimension is an referenced to an Sid object. Currently, the size has to be scalar and constant. The array dimension is used to indicate which dimension you are referring to. Currently, the array dimension is limited to have at most three dimensions.

Similarly, SBase is extended to have 0 or 1 list of indices, where the list contains 0 or more index objects and index inherits from SBase. Index is used to reference an element. You specify which attribute (e.g. variable) you are referencing. Array dimension is the same for dimension. The math is used to determine the index value for the referenced element.

This is easier to understand through an example:

n = 5;

int[] y = new int[n];

for(int i = 0; i < n; i++)

y[i] = i;

To encode this using the arrays package in SBML, n would be a constant parameter, y would have a dimension of size n and arrayDimension would be 0 (1-D array). In the loop, we have an assignment rule where we index the ith element of y and set it to i.

In order to do this in JSBML, I created a plugin for the arrays package, which is used as a place holder for new attributes. In this case, the the attributes are list of dimensions and indices. I created a dimension object with the required fields shown on the UML diagram. Dimension extends AbstractNamedSBase because it can have id and name and implements UniqueNamedSBase to enforce that the identifier associated with the dimension object is unique. Index extends AbstractMathContainer which is a base class for everything that contains math. For both the dimension and index classes, I created getter/setter methods for each field and implemented the abstract methods.

The next step is to throughly test everything.

## No comments:

## Post a Comment