File: CreateArrays1.cs

package info (click to toggle)
libsbml 5.17.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 156,336 kB
  • sloc: cpp: 1,012,766; xml: 314,374; cs: 58,129; ansic: 54,053; python: 27,299; java: 27,152; makefile: 9,721; perl: 9,039; sh: 8,777; ruby: 4,760; php: 202; csh: 3
file content (108 lines) | stat: -rw-r--r-- 3,382 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
using libsbmlcs;

class Program
{
  public static void Main(string[] args)
  {
    ArraysPkgNamespaces arraysNs = new ArraysPkgNamespaces();
    SBMLDocument doc = new SBMLDocument(arraysNs);
    doc.setPackageRequired("arrays", true);
    Model model = doc.createModel();

    // create compartment
    Compartment comp = model.createCompartment();
    comp.setMetaId("dd");
    comp.setId("s");
    comp.setConstant(true);

    // set dimensions
    ArraysSBasePlugin compPlugin = (ArraysSBasePlugin) comp.getPlugin("arrays");
    Dimension dim = compPlugin.createDimension();
    dim.setId("i");
    dim.setSize("n");

    // create species
    Species species = model.createSpecies();
    species.setId("A");
    species.setCompartment("s");
    species.setHasOnlySubstanceUnits(false);
    species.setBoundaryCondition(false);
    species.setConstant(false);

    ArraysSBasePlugin splugin = (ArraysSBasePlugin) species.getPlugin("arrays");
    dim = splugin.createDimension();
    dim.setId("i");
    dim.setSize("n");

    species = model.createSpecies();
    species.setId("B");
    species.setCompartment("s");
    species.setHasOnlySubstanceUnits(false);
    species.setBoundaryCondition(false);
    species.setConstant(false);

    splugin = (ArraysSBasePlugin) species.getPlugin("arrays");
    dim = splugin.createDimension();
    dim.setId("i");
    dim.setSize("n");

    species = model.createSpecies();
    species.setId("C");
    species.setCompartment("s");
    species.setHasOnlySubstanceUnits(false);
    species.setBoundaryCondition(false);
    species.setConstant(false);

    splugin = (ArraysSBasePlugin) species.getPlugin("arrays");
    dim = splugin.createDimension();
    dim.setId("i");
    dim.setSize("n");

    // create parameter
    Parameter param = model.createParameter();
    param.setId("n");
    param.setValue(100);
    param.setConstant(true);

    // create reaction
    Reaction reaction = model.createReaction();
    reaction.setId("reaction1");
    reaction.setReversible(false);
    reaction.setFast(false);

    ArraysSBasePlugin reactionPlugin = (ArraysSBasePlugin) reaction.getPlugin("arrays");
    dim = reactionPlugin.createDimension();
    dim.setId("i");
    dim.setSize("n");

    SpeciesReference speciesRef = reaction.createReactant();
    speciesRef.setSpecies("A");
    speciesRef.setConstant(false);
    ArraysSBasePlugin refPlugin = (ArraysSBasePlugin) speciesRef.getPlugin("arrays");
    Index index = refPlugin.createIndex();
    ASTNode ast = new ASTNode(libsbml.AST_LINEAR_ALGEBRA_SELECTOR);
    ASTNode ci = new ASTNode(libsbml.AST_NAME);
    ci.setName("A");
    ast.addChild(ci);
    ci = new ASTNode(libsbml.AST_NAME);
    ci.setName("i");
    ast.addChild(ci);
    index.setMath(ast);

    speciesRef = reaction.createProduct();
    speciesRef.setSpecies("C");
    speciesRef.setConstant(false);
    refPlugin = (ArraysSBasePlugin) speciesRef.getPlugin("arrays");
    index = refPlugin.createIndex();
    ast = new ASTNode(libsbml.AST_LINEAR_ALGEBRA_SELECTOR);
    ci = new ASTNode(libsbml.AST_NAME);
    ci.setName("C");
    ast.addChild(ci);
    ci = new ASTNode(libsbml.AST_NAME);
    ci.setName("i");
    ast.addChild(ci);
    index.setMath(ast);

    libsbml.writeSBMLToFile(doc, "arrays1.xml");
  }
}