MATLAB Answers

Better understanding of variants sought (also project files)

4 views (last 30 days)
Jim Bosley
Jim Bosley on 4 Sep 2018
Edited: Jim Bosley on 5 Sep 2018
If I create a model using the dashboard, including variants(suppose 2, 'var1', and 'var2'), and save the model, the variants are saved with the model. If I close the model, then open it with
then the model is not listed in the workspace. But I can use the dashboard to see the model (including variants). I can load the model object into the workspace to allow manipulation using scripting:
sbr = sbioroot;
m1 = sbr.models(1)
Because I left the semicolon off, I see something like:
SimBiology Model - MyModel
Model Components:
Compartments: 7
Events: 0
Parameters: 181
Reactions: 83
Rules: 42
Species: 40
Note that there are no variants listed! But if I use
vars = sbioselect('Type','Variant');
I get
SimBiology Variant Array
Index: Name: Active:
1 var1 false
2 var2 false
So the variants are there, but are not listed with the model. The variants aren't listed using sbiowhos, either. Why aren't the variants listed? Is there a command (besides using sbioselect for each type of object) that lists all components of a model?
My understanding of the difference between sbioloadproject('modelname') and simbiology('modelname') is confused. As I understood it, the Simbiology() command opens a model, including variants and all other properties. It has to, because it opens the full model in the dashboard. But my understanding is that the sbioloadproject() command does NOT load variants, tasks, datasets, and graphical location information (that is, the stuff that tells the dashboard how to arrange species and reactions on the diagram view). Is there someplace tells me how to find ALL of the components of a model object? It might help to know all of what goes into a sbproj file, and (assuming that simbiology() loads all model elements) what are the elements that sbioloadoproject does NOT load. Clearly I was wrong, and variants are loaded.
And I would think that typing 'm1' (where m1 is a model object in the workspace) should list everything associated with that object including variants and datasets and (in the case of loading with Simbiology()) the set of object locations.


Sign in to comment.

Answers (1)

Arthur Goldsipe
Arthur Goldsipe on 4 Sep 2018
Hi Jim,
Variants (and doses) are handled differently than the objects you see listed in the display for a model. As you discovered, one way to get access to them is via sbioselect. The primary way that we intended users to get access to them is via the methods getvariant and getdose. And you'll find a list of all methods and properties for a model on this reference page.


Jim Bosley
Jim Bosley on 5 Sep 2018
Yes, thanks. From your other answer I checked out getvariants. I have a working solution for the issue at hand.
Philosphically, though, I did note that
AllVariants = m1.Variant;
returns variants in M1. So there is a Variant array object associated with the model object. I'm probably asking something obvious, but is there a way to list ALL properties of the model object? I ask, because 1) this is how I learn, and 2) its often convenient to access model properties and this helps remind one of the name, and 3) having this method fits my philosophy*. I've tried, for example,
and get
No class SimBiology.Model.
As always, your answer is helpful, and I'm back on track on my project.
*Sorry if this is pedantic, but the philosophy is that for every object type a complete and useful environment has easy and documented ways to
  1. Create an object instance
  2. List all similar object instances
  3. Delete any of the object instances
  4. List all of the properties and property values in the object, with the option of listing even those properties that aren't used.
  5. List possible choices for each property (could be 'floating point', 'integer', T/F, or a list of possible values)
  6. Provide ways to change each property
Arthur Goldsipe
Arthur Goldsipe on 5 Sep 2018
As you've discovered, there is currently an undocumented Variants property on SimBiology models. If you look at the public, visible properties in the documentation or programmatically, you will not find this property listed. (I'll describe how to programmatically list public, visible properties in a minute.) Therefore, I generally recommend using the getvariant method rather than the Variants property, since undocumented behavior could change at any time.
There are several ways to programmatically get a list of all public, visible properties. The function properties does not currently work due to an incompatibility that we hope to address in the near future. Until then, fieldnames is a more general function that works on MATLAB objects, Java objects, and structs. Finally, you can also use the set and get methods to find out information about the properties on a SimBiology object. get(obj) will return a struct that contains all the public, visible properties that you can get. set(obj) will return a struct that contains all the public, visible properties that you can directly set. Oh, and you can also rely on tab-completion to get property names, so obj.<TAB> should bring up a list of all methods and properties.
Regarding your list of things that a useful environment must provide: We strive for all of these things to be described clearly in our documentation. Not all of that information can be accessed programmatically today, but there are lots of MATLAB features to make it more and more available. The SimBiology team will hopefully take advantage of those features soon, so that it is easier for you to figure out interactively how to use SimBiology.
Jim Bosley
Jim Bosley on 5 Sep 2018
The fieldnames() function is something that I was looking for - VERY useful. And this satisfies a lot of the need wrt to my "list".
I think it's awfully hard for experts/creators of software to write documentation. First, mostly we hate doing it (at least I do). Second, when one has created something, we have implicit knowledge of what objects are and what they do, and sometimes this implicit stuff is hard to write out and isn't included in the docs.
fieldnames() will be used extensively. While I'll pat myself on the back finding modelname.Variant, I'll also try to stick to the prescribed "getvariant" command.
Suffice to say that I'm enjoying using SimBiology and feel that I'm productive at this point and learning to be more so. This level of satisfaction and progress would NOT be happening without help from you and your colleague's. So, thanks again.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!