-
Notifications
You must be signed in to change notification settings - Fork 0
/
copasi_api.h
1277 lines (1084 loc) · 38.4 KB
/
copasi_api.h
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*! \mainpage Simplifed API for the COPASI Library
*
* \section intro_sec Introduction
*
* The developers of COPASI provide COPASI as a reusable library as well as
* the well known COPASI user interface. The library however has a fairly
* complex API and can take some time getting used. We have therefore layered
* on top of the COPASI library a new C based API that we feel is much simpler
* to use. For example, to run a simple SBML model and generate time series data
* we would call:
*
\code
copasi_model m;
c_matrix output;
m = cReadSBMLFile ("mymodel.xml");
output = cSimulationDeterministic (m, 0, 10, 100);
\endcode
More complex example:
\code
#include <stdlib.h>
#include <stdio.h>
#include "copasi_api.h"
int main(int nargs, char** argv)
{
c_matrix efm, output, params;
copasi_model m1, m2;
if (nargs < 2)
{
m1 = model1();
}
else
{
printf("loading model file %s\n", argv[1]);
m1 = cReadSBMLFile(argv[1]);
}
cWriteAntimonyFile(m1, "model.txt");
printf("Antimony file written to model.txt\nSimulating...\n");
output = cSimulateDeterministic(m1, 0, 100, 1000); //model, start, end, num. points
printf("output.tab has %i rows and %i columns\n",output.rows, output.cols);
c_printMatrixToFile("output.tab", output);
c_deleteMatrix(output);
cRemoveModel(m1);
copasi_end();
return 0;
}
\endcode
* \section install_sec Installation
*
* Installation documentation is provided in the main google code page.
\defgroup loadsave Read and Write models
\brief Read and write models to files or strings. Support for SBML and Antimony formats.
\defgroup create Define models
\brief Create models and set model components using code
\defgroup state Current state of system
\brief Compute derivatives, fluxed, and other values of the system at the current state
\defgroup reaction Reaction group
\brief Get information about reaction rates
\defgroup rateOfChange Rates of change group
\brief Get information about rates of change
\defgroup boundary Boundary species group
\brief Get information about reaction rates
\defgroup floating Floating species group
\brief Get information about reaction rates
\defgroup parameters Parameter group
\brief set and get global and local parameters
\defgroup compartment Compartment group
\brief set and get information on compartments
\defgroup simulation Time-course simulation
\brief Deterministic, stochastic, and hybrid simulation algorithms
\defgroup mca Metabolic Control Analysis
\brief Calculate control coefficients and sensitivities
\defgroup matrix Stoichiometry analysis
\brief Linear algebra based methods for analyzing a reaction network
\defgroup optim Parameter optimization
\brief Optimization of parameters to match given data
*/
#ifndef COPASI_SIMPLE_C_API
#define COPASI_SIMPLE_C_API
/**
* @file copasi_api.h
* @brief Simple C API for the Copasi C++ library
This is a C API for the COPASI C++ library. Rate equations in COPASI require the "complete name",
e.g. instead of X, the rate must specify <model.compartment.X>. In this C API, those complete names
are stored in a hash table. The API replaces the simple strings, i.e. "C", with the complete names by
using the hash-table. This is mainly for speed; otherwise, every cSetReactionRate would be searching
through the entire model for each of its variables. The hash-table idea is used for functions such
as cSetValue, which can set the value of a parameter or that of a molecular species. Again, it uses the
hash table to identify what a variable is.
The C API hides the C++ classes by casting some of the main classes into void pointers inside
C structs.
std::map is used for performing the hashing (it is not a real hash-table, but close enough).
boost::regex is used for string substitutions.
*/
#include "cstructs.h"
#define COPASIAPIEXPORT CAPIEXPORT
/*!\brief This struct is used to contain a pointer to an instance of a COPASI object*/
typedef struct
{
void * CopasiModelPtr;
void * CopasiDataModelPtr;
void * qHash;
char * errorMessage;
char * warningMessage;
} copasi_model;
/*!\brief This struct is used to contain a pointer to an instance of a COPASI reaction object*/
typedef struct
{
void * CopasiReactionPtr;
void * CopasiModelPtr;
void * qHash;
} copasi_reaction;
/*!\brief This struct is used to contain a pointer to an instance of a COPASI compartment object*/
typedef struct
{
void * CopasiCompartmentPtr;
void * CopasiModelPtr;
void * qHash;
} copasi_compartment;
BEGIN_C_DECLS
COPASIAPIEXPORT void copasi_init();
// -----------------------------------------------------------------------
/**
* @name Memory management
*/
/** \{*/
/*!
\brief destroy copasi -- MUST BE CALLED at the end of program
\ingroup memory
*/
COPASIAPIEXPORT void copasi_end();
/*!
\brief remove a model
\ingroup memory
*/
COPASIAPIEXPORT void cRemoveModel(copasi_model);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Read and write models
*/
/** \{ */
/*!
\brief Set the expected version and level of SBML files and strings; default is 2.4
\param int level
\param in version
\ingroup loadsave
*/
COPASIAPIEXPORT void cSetSBMLLevelAndVersion(int level, int version);
/*!
\brief Create a model from an Antimony, see antimony.sf.net for details of Antimony syntax
\param char* file name
\return copasi_model Copasi model of the Antimony file
\ingroup loadsave
*/
COPASIAPIEXPORT copasi_model cReadAntimonyFile(const char * filename);
/*!
\brief Create a model from an Antimony string
\param char* Antimony string
\return copasi_model Copasi model of the Antimony string
\ingroup loadsave
*/
COPASIAPIEXPORT copasi_model cReadAntimonyString(const char * sbml);
/*!
\brief Create a model from an SBML file
\param char* file name
\return copasi_model Copasi model of the SBML file
\ingroup loadsave
*/
COPASIAPIEXPORT copasi_model cReadSBMLFile(const char * filename);
/*!
\brief Create a model from an SBML string
\param char* SBML string
\return copasi_model Copasi model of the SBML string
\ingroup loadsave
*/
COPASIAPIEXPORT copasi_model cReadSBMLString(const char * sbml);
/*!
\brief Save a model as an SBML file
\param copasi_model copasi model
\param char* file name
\ingroup loadsave
*/
COPASIAPIEXPORT void cWriteSBMLFile(copasi_model model, const char * filename);
/*!
\brief Save a model as an Antimony file, see antimony.sf.net for details of Antimony syntax
\param copasi_model copasi model
\param char* file name
\ingroup loadsave
*/
COPASIAPIEXPORT void cWriteAntimonyFile(copasi_model model, const char * filename);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Create model group
*/
/** \{ */
/*!
\brief Create a model
\param char* model name
\return copasi_model a new copasi model
\ingroup create
*/
COPASIAPIEXPORT copasi_model cCreateModel(const char * name);
/*!
\brief This function MUST be called after creating a model or modifying a model (except parameter changes)
This function was called internally inside every analysis function, but that was inefficient, so it must be
called manually.
Note that when models are generated from a file or string (e.g. sbml), they do not need to be compiled again.
\param copasi_model model
\ingroup create
*/
COPASIAPIEXPORT void cCompileModel(copasi_model model);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Compartment group
*/
/** \{ */
/*!
\brief Create compartment
\param char* compartment name
\param double volume
\return copasi_compartment a new compartment
\ingroup create
*/
COPASIAPIEXPORT copasi_compartment cCreateCompartment(copasi_model model, const char* name, double volume);
/*!
\brief Set a volume of compartment
\param copasi_model model
\param char * compartment name
\param double volume
\ingroup create
*/
COPASIAPIEXPORT void cSetVolume(copasi_model, const char * compartment, double volume);
/*!
\brief Get the vector of compartment names and volumes
\param copasi_model model
\return c_matrix column vector with compartment names as row names
\ingroup compartment
*/
COPASIAPIEXPORT c_matrix cGetCompartments (copasi_model);
/*!
\brief Set all compartment volumes using a vector of compartment values with row names.
Row names MUST be provided. Order is not important because the row names are used to assign the values, not the index
\param copasi_model model
\param double row vector with row names corresponding to the compartment names.
\ingroup compartment
*/
COPASIAPIEXPORT void cSetCompartmentVolumes (copasi_model, c_matrix v);
/*!
\brief Get number of compartments. This is same as cGetCompartments(model).cols
\param copasi_model model
\return int
\ingroup compartment
*/
COPASIAPIEXPORT int cGetNumberOfCompartments (copasi_model);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Assignments (forcing functions)
*/
/** \{ */
/*!
\brief Set the assignment rule for a species (automatically assumes boundary species)
\param copasi_model model
\param char * species name
\param char* formula, use 0 to remove assignment rule
\return int 0=failed 1=success
\code
result = cSetAssignmentRule (m, "S1", "sin (time*k1)");
\endcode
\ingroup create
*/
COPASIAPIEXPORT int cSetAssignmentRule(copasi_model model, const char * species, const char * formula);
/*!
\brief Create a new variable that is defined by a formula
\param copasi_model model
\param char* name of new variable
\param char* formula
\return int 0=failed 1=success
\ingroup create
*/
COPASIAPIEXPORT int cCreateVariable(copasi_model model, const char * name, const char * formula);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Events
*/
/** \{ */
/*!
\brief Add a trigger and a response, where the response is defined by a target variable and an assignment formula
\param copasi_model model
\param char * event name
\param char * trigger formula
\param char * response: name of variable or species
\param char* response: assignment formula
\return int 0=failed 1=success
Example Usage. The following code will create an event where the parameter k1 is halved when time > 10.
\code
result = cCreateEvent (m, "myEvent", "time > 10", "k1", "k1/2");
\endcode
\ingroup create
*/
COPASIAPIEXPORT int cCreateEvent(copasi_model model, const char * name, const char * trigger, const char * variable, const char * formula);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Reaction group
*/
/** \{ */
/*!
\brief Create a new reaction with a given name
\param copasi_model model
\param char* reaction name
\return copasi_reaction a new reaction
\code
r = cCreateReaction (m, "J1")
\endcode
\ingroup create
*/
COPASIAPIEXPORT copasi_reaction cCreateReaction(copasi_model model, const char* name);
/*!
\brief Add a reactant to a reaction
\param copasi_reaction reaction
\param char * reactant
\param double stoichiometry
\code
cCreateReaction (m, "S1", 1);
\endcode
\ingroup create
*/
COPASIAPIEXPORT void cAddReactant(copasi_reaction reaction, const char * species, double stoichiometry);
/*!
\brief Add a product to a reaction
\param copasi_reaction reaction
\param char * product
\param double stoichiometry
Create a reaction J1: 2 A -> B + C
\code
r = cCreateReaction (m, "J1");
cAddReactant (r, "A", 2);
cAddProduct (r, "B", 1);
cAddProduct (r, "C", 1);
\endcode
\ingroup create
*/
COPASIAPIEXPORT void cAddProduct(copasi_reaction reaction, const char * species, double stoichiometry);
/*!
\brief Set reaction rate equation
\param copasi_reaction reaction
\param char* custom formula
\return int success=1 failure=0
\code
int result;
result = cSetReactionRate (r, "k1*S1");
\endcode
\ingroup create
*/
COPASIAPIEXPORT int cSetReactionRate(copasi_reaction reaction, const char * formula);
/*!
\brief Compute current flux through the given reactions
\param copasi_model model
\param string reaction name, e.g. "J1"
\return double rate. If reaction by this name does not exist that NaN will be returned
The names of the fluxes are included in the matrix column labels
\ingroup state
*/
COPASIAPIEXPORT double cGetReactionRate(copasi_model, const char * name);
/*!
\brief Returns the rates of change given an array of new species concentrations and/or parameter values
\param copasi_model model
\param c_matrix vector of floating concentrations. must have row names
\return c_matrix vector of reaction rates with row names
\ingroup reaction
*/
COPASIAPIEXPORT c_matrix cGetReactionRatesEx(copasi_model, c_matrix values);
/*!
\brief Compute current flux through the given reactions
\param copasi_model model
\param string reaction name, e.g. "J1"
\return double rate. If reaction by this name does not exist that NaN will be returned
The names of the fluxes are included in the matrix column labels
\ingroup state
*/
COPASIAPIEXPORT double cGetFlux(copasi_model, const char * name);
/*!
\brief Compute current flux through the given reactions in terms of particles
\param copasi_model model
\param string reaction name, e.g. "J1"
\return double rate. If reaction by this name does not exist that NaN will be returned
\ingroup state
*/
COPASIAPIEXPORT double cGetParticleFlux(copasi_model, const char * name);
/*!
\brief Get the list of reaction names and their current fluxes
\param copasi_model model
\return c_matrix row vector with column names corresponding to reaction names
\sa c_matrix
\ingroup reaction
*/
COPASIAPIEXPORT c_matrix cGetReactionRates(copasi_model);
/*!
\brief Get number of reactions. This is same as cGetAllFluxes(model).rows
\param copasi_model model
\return int
\ingroup compartment
*/
COPASIAPIEXPORT int cGetNumberOfReactions (copasi_model);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Species group
*/
/** \{ */
/*!
\brief Get number of species (all) in the model
\param copasi_model model
\param int
\ingroup create
*/
COPASIAPIEXPORT int cGetNumberOfSpecies(copasi_model);
/*!
\brief Get number of floating species in the model
\param copasi_model model
\param int
\ingroup create
*/
COPASIAPIEXPORT int cGetNumberOfFloatingSpecies(copasi_model);
/*!
\brief Get number of boundary species in the model
\param copasi_model model
\param int
\ingroup create
*/
COPASIAPIEXPORT int cGetNumberOfBoundarySpecies(copasi_model);
/*!
\brief Add a species to the model. Species must belong inside a compartment.
\param copasi_compartment compartment where the species belongs
\param char* species name
\param double initial value (concentration or count, depending on the model)
\ingroup create
*/
COPASIAPIEXPORT void cCreateSpecies(copasi_compartment compartment, const char* name, double initialValue);
/*!
\brief Set a species as boundary or floating (will remove any assignment rules)
\param copasi_model model
\param char * name
\param int boundary = 1, floating = 0 (default)
\ingroup create
*/
COPASIAPIEXPORT void cSetSpeciesType(copasi_model model, const char * species, int isBoundary);
/*!
\brief Set a species current concentration
\param copasi_model model
\param char * species name
\param double concentration
\ingroup create
*/
COPASIAPIEXPORT void cSetSpeciesConcentration(copasi_model, const char * species, double conc);
/*!
\brief Set a species initial concentration
\param copasi_model model
\param char * species name
\param double concentration
\ingroup create
*/
COPASIAPIEXPORT void cSetInitialConcentration(copasi_model, const char * species, double conc);
/*!
\brief Set a species amounts
\param copasi_model model
\param char * species name
\param double amount
\ingroup create
*/
COPASIAPIEXPORT void cSetSpeciesAmount(copasi_model, const char * species, double amount);
/*!
\brief Set multiple boundary or floating species concentration. Order is not important because the names are used to set value.
\param copasi_model model
\param c_matric row vector of boundary or floating species concentrations. rows must be named
\ingroup boundary
*/
COPASIAPIEXPORT void cSetSpeciesConcentrations (copasi_model model, c_matrix d);
/*!
\brief Get the initial floating species concentrations
\param copasi_model model
\return c_matrix row vector of initial floating species concentrations
\ingroup floating
*/
COPASIAPIEXPORT c_matrix cGetFloatingSpeciesIntitialConcentrations (copasi_model model);
/*!
\brief Set the initial floating species concentrations. Order does not matter because row names are used to assign values.
\param copasi_model model
\param c_matrix row vector of initial floating species concentrations
\ingroup floating
*/
COPASIAPIEXPORT void cSetFloatingSpeciesIntitialConcentrations (copasi_model model, c_matrix sp);
/*!
\brief Get species names and concentrations
\param copasi_model model
\param int index ith boundary species
\return c_matrix column vector where row names are the species names and first column has the concentrations
\ingroup state
*/
COPASIAPIEXPORT c_matrix cGetAllSpecies(copasi_model model);
/*!
\brief Get the current concentrations of all floating species
\param copasi_model model
\return c_matrix matrix of with 1 row and n columns, where n = number of species
The names of the species are included in the matrix column labels
\ingroup state
*/
COPASIAPIEXPORT c_matrix cGetFloatingSpeciesConcentrations(copasi_model);
/*!
\brief Get the current concentrations of all boundary species
\param copasi_model model
\return c_matrix matrix of with 1 row and n columns, where n = number of species
The names of the species are included in the matrix column labels
\ingroup state
*/
COPASIAPIEXPORT c_matrix cGetBoundarySpecies(copasi_model);
/*!
\brief Get the current amounts of all species. The amounts are calculated from the concentrations and compartment volume
\param copasi_model model
\return c_matrix matrix of with 1 row and n columns, where n = number of species
The names of the species are included in the matrix column labels
\ingroup state
*/
COPASIAPIEXPORT c_matrix cGetAmounts(copasi_model);
/*!
\brief Get the current concentration of a species
\param copasi_model model
\param string species name
\return double concentration. -1 indicates that a species by this name was not found
\ingroup state
*/
COPASIAPIEXPORT double cGetConcentration(copasi_model, const char * name);
/*!
\brief Get the current amount of a species. The amounts are calculated from the concentrations and compartment volume
\param copasi_model model
\param string species name
\return double amount. -1 indicates that a species by this name was not found
\ingroup state
*/
COPASIAPIEXPORT double cGetAmount(copasi_model, const char * name);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Parameter group
*/
/** \{ */
/*!
\brief Set the concentration of a species, volume of a compartment, or value of a parameter
The function will figure out which using the name (fast lookup using hashtables).
If the name does not exist in the model, a new global parameter will be created.
\param copasi_model model
\param char * name
\param double value
\return 0 if new variable was created. 1 if existing variable was found
\ingroup create
*/
COPASIAPIEXPORT int cSetValue(copasi_model, const char * name, double value);
/*!
\brief Get the concentration of a species, volume of a compartment, or value of a parameter
The function will figure out which using the name (fast lookup using hashtables).
\param copasi_model model
\param char * name
\return double value of species, parameters, or compartment
\ingroup create
*/
COPASIAPIEXPORT double cGetValue(copasi_model, const char * names);
/*!
\brief Set the value of an existing global parameter or create a new global parameter
\param copasi_model model
\param char* parameter name
\param double value
\return int 0=new value created 1=found existing value
\ingroup create
*/
COPASIAPIEXPORT int cSetGlobalParameter(copasi_model model, const char * name, double value);
/*!
\brief Get the number of of global parameter names
\param copasi_model model
\return int
\ingroup parameter
*/
COPASIAPIEXPORT int cGetNumberOfGlobalParameters (copasi_model);
/*!
\brief Get the list of global parameter names and values
\param copasi_model model
\return c_matrix column vector with parameter names are the row names
\ingroup parameter
*/
COPASIAPIEXPORT c_matrix cGetGlobalParameters (copasi_model);
/*!
\brief Set the vector of global parameters
\param copasi_model model
\paramn c_matrix column vector containing the values for the global parameters.
\ingroup parameter
*/
COPASIAPIEXPORT void cSetGlobalParameterValues(copasi_model, c_matrix gp);
/*!
\brief Set values for species, parameters, or compartments
\param copasi_model model
\param c_matrix column vector with names and values of species or parameters or compartments
\ingroup floating
*/
COPASIAPIEXPORT void cSetValues(copasi_model model, c_matrix );
// -----------------------------------------------------------------------
/** \} */
/**
* @name Time course simulation
*/
/** \{ */
/*!
\brief Compute the current rates of change for all species
\param copasi_model model
\return c_matrix matrix of with 1 row and n columns, where n = number of species
\ingroup rateOfChange
*/
COPASIAPIEXPORT c_matrix cGetRatesOfChange(copasi_model);
/*!
\brief Compute the current rates of change for one species
\param copasi_model model
\param string name of species
\return c_matrix matrix of with 1 row and n columns, where n = number of species
\ingroup rateOfChange
*/
COPASIAPIEXPORT double cGetRateOfChange(copasi_model, const char * species);
/*!
\brief Compute the rates of change for all species after updating species concentrations
\param copasi_model model
\param c_matrix new species concentrations
\return c_matrix matrix of with 1 row and n columns, where n = number of species
\ingroup rateOfChange
*/
COPASIAPIEXPORT c_matrix cGetRatesOfChangeEx(copasi_model, c_matrix);
/*!
\brief Simulate using LSODA numerical integrator
\param copasi_model model
\param double start time
\param double end time
\param int number of steps in the output
\return c_matrix matrix of concentration or particles
\code
result = cSimulateDeterministic (m, 0.0, 10.0, 100);
\endcode
\ingroup simulation
*/
COPASIAPIEXPORT c_matrix cSimulateDeterministic(copasi_model model, double startTime, double endTime, int numSteps);
/*!
\brief Simulate the differential equation model over one time step
\param copasi_model model
\param double time step
\return double new time, i.e (current time + timeStep)
\ingroup simulation
*/
COPASIAPIEXPORT double cOneStep(copasi_model model, double timeStep);
/*!
\brief Simulate using exact stochastic algorithm
\param copasi_model model
\param double start time
\param double end time
\param int number of steps in the output
\return c_matrix matrix of concentration or particles
\ingroup simulation
*/
COPASIAPIEXPORT c_matrix cSimulateStochastic(copasi_model model, double startTime, double endTime, int numSteps);
/*!
\brief Simulate using Hybrid algorithm/deterministic algorithm
\param copasi_model model
\param double start time
\param double end time
\param int number of steps in the output
\return c_matrix matrix of concentration or particles
\ingroup simulation
*/
COPASIAPIEXPORT c_matrix cSimulateHybrid(copasi_model model, double startTime, double endTime, int numSteps);
/*!
\brief Simulate using Tau Leap stochastic algorithm
\param copasi_model model
\param double start time
\param double end time
\param int number of steps in the output
\return c_matrix matrix of concentration or particles
\ingroup simulation
*/
COPASIAPIEXPORT c_matrix cSimulateTauLeap(copasi_model model, double startTime, double endTime, int numSteps);
/*!
\brief set current state to initial state
\ingroup simulation
*/
COPASIAPIEXPORT void cResetState(copasi_model);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Create filters for time-course data
*/
/** \{ */
/*!
\brief Compute all the reaction rates, or flux, for each row of a time course data
\param copasi_model model
\param c_matrix original results with species as column names
\return c_matrix
\ingroup simulation
*/
COPASIAPIEXPORT c_matrix cGetReactionRatesFromTimeCourse(copasi_model model, c_matrix results);
/*!
\brief Compute derivatives for each species from the time course data
\param copasi_model model
\param c_matrix original results with species as column names
\return c_matrix
\ingroup simulation
*/
COPASIAPIEXPORT c_matrix cGetDerivativesFromTimeCourse(copasi_model model, c_matrix results);
/*!
\brief Get all the control coefficients for each row of a time course data
\param copasi_model model
\param c_matrix original results with species as column names
\return c_matrix
\ingroup simulation
*/
COPASIAPIEXPORT c_matrix cGetCCFromTimeCourse(copasi_model model, c_matrix results);
/*!
\brief Get all the elasticities for each row of a time course data
\param copasi_model model
\param c_matrix original results with species as column names
\return c_matrix
\ingroup simulation
*/
COPASIAPIEXPORT c_matrix cGetElasticitiesFromTimeCourse(copasi_model model, c_matrix results);
/*!
\brief Filter the results of a time-course simulation based on the list of names provided. -- NOT IMPLEMENTED
The list of names can consist of species names, reaction names, control coefficients, or derivatives.
Use species or reaction names to add a species of reaction
Use species' for derivatives, e.g. A' for derivative of A
Use cc_(x)_y for the control coefficient of x on y
Use elasticities_(x)_y for the scaled elasticity of x wrt y
\param copasi_model model
\param c_matrix original results with species as column names
\param c_strings array of names to return
\return c_matrix
\ingroup simulation
*/
COPASIAPIEXPORT c_matrix cFilterTimeCourseResults(copasi_model model, c_matrix results, c_strings names);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Steady state analysis
*/
/** \{ */
/*!
\brief Bring the system to steady state by solving for the zeros of the ODE's.
Performs an initial simulation before solving.
\param copasi_model model
\return c_matrix matrix with 1 row and n columns, where n = number of species
\ingroup steadystate
*/
COPASIAPIEXPORT c_matrix cGetSteadyState(copasi_model model);
/*!
\brief Bring the system to steady state by doing repeated simulations.
Use this is cGetSteadyState
\param copasi_model model
\param int max iterations (each iteration doubles the time duration)
\return c_matrix matrix with 1 row and n columns, where n = number of species
\ingroup steadystate
*/
COPASIAPIEXPORT c_matrix cGetSteadyStateUsingSimulation(copasi_model model, int iter);
/*!
\brief Set the epsilon value (small positive number) that is used in a few functions, e.g.
cGetJacobian, to perform small perturbations
\param double new epsilon value, default is 1E-3
\return double updated epsilon value (should be same as argument if >0)
\ingroup steadystate
*/
COPASIAPIEXPORT double cSetEpsilon(double eps);
/*!
\brief Get the full Jacobian at the current state
\param copasi_model model
\return c_matrix matrix with n rows and n columns, where n = number of species
\ingroup steadystate
*/
COPASIAPIEXPORT c_matrix cGetJacobian(copasi_model model);
/*!
\brief Get the eigenvalues of the Jacobian at the current state
\param copasi_model model
\return c_matrix matrix with 1 row and n columns, each containing an eigenvalue
\ingroup steadystate
*/
COPASIAPIEXPORT c_matrix cGetEigenvalues(copasi_model model);
// -----------------------------------------------------------------------
/** \} */
/**
* @name Metabolic control analysis (MCA)
*/
/** \{ */
/*!
\brief Compute the unscaled flux control coefficients
\param copasi_model model
\return c_matrix rows consist of the fluxes that are perturbed, and columns consist
of the fluxes that are affected
\ingroup mca
*/
COPASIAPIEXPORT c_matrix cGetUnscaledFluxControlCoeffs(copasi_model model);
/*!
\brief Compute the scaled flux control coefficients
\param copasi_model model
\return c_matrix rows consist of the fluxes that are perturbed, and columns consist
of the fluxes that are affected
\ingroup mca
*/
COPASIAPIEXPORT c_matrix cGetScaledFluxControlCoeffs(copasi_model model);
/*!
\brief Compute the unscaled concentration control coefficients
\param copasi_model model
\return c_matrix rows consist of the fluxes that are perturbed, and columns consist
of the concentrations that are affected
\ingroup mca
*/
COPASIAPIEXPORT c_matrix cGetUnscaledConcentrationControlCoeffs(copasi_model model);
/*!
\brief Compute the scaled concentration control coefficients
\param copasi_model model
\return c_matrix rows consist of the fluxes that are perturbed, and columns consist
of the concentrations that are affected
\ingroup mca
*/
COPASIAPIEXPORT c_matrix cGetScaledConcentrationConcentrationCoeffs(copasi_model model);
/*!
\brief Compute the unscaled elasticities
\param copasi_model model
\return c_matrix rows consist of the species that are perturbed, and columns consist
of the reactions that are affected
\ingroup mca
*/
COPASIAPIEXPORT c_matrix cGetUnscaledElasticities(copasi_model model);
/*!
\brief Compute the scaled elasticities
\param copasi_model model
\return c_matrix rows consist of the species that are perturbed, and columns consist
of the reactions that are affected
\ingroup mca
*/
COPASIAPIEXPORT c_matrix cGetScaledElasticities(copasi_model model);