metrumresearchgroup / mrgsolve

Simulate from ODE-based population PK/PD and QSP models in R
https://mrgsolve.org
GNU General Public License v2.0
130 stars 36 forks source link

Syntax for comments #447

Closed sbihorel closed 5 years ago

sbihorel commented 5 years ago

Hi

Is there a specific syntax that allow the insertion of random comments in a model file (especially before the very first $XXX code block)?

Thanks

kylebaron commented 5 years ago

Hi @sbihorel


[ PROB ] 

Everything in here is a "comment" ... any text you want ... it will do nothing.

sqrt("foo")  ... no problem!

To comment out a line (anywhere):


[ MAIN ] // like $PK
// PK parameters
double CL = THETA21; // Clearance

You can use shift-(control|command)-C in Rstudio to comment out a block.

Does this help?

sbihorel commented 5 years ago

Thanks @kylebmetrum

Yes, I think it does... although I feel I have to ask a follow-up question though (please, bear with me, I am just starting to read the user manual): I thought that the .cpp files used the $MAIN notation (not [ MAIN ] notation). Does "//" indicates a comment also in the .cpp files?

kylebaron commented 5 years ago

@sbihorel Happy to answer any question.

Please don't hesitate to follow up if one of the points isn't clear.

sbihorel commented 5 years ago

That's crystal clear !

Thanks

sbihorel commented 5 years ago

Hi

I get compilation errors when I use // in [ PARAM ] @annotated block. I don't get the error if the block is not annotated.

kylebaron commented 5 years ago

Please post an example that isn’t working along with the error message you’re getting. Thanks.

kylebaron commented 5 years ago

All of this should be valid


library(mrgsolve)

code <- '

[ PARAM ] @annotated // test
// test
CL : 1  : clearance  //test
VC : 20 : volume // test
// test

'

mod <- mcode("foo", code)
#> Building foo ... done.

param(mod)
#> 
#>  Model parameters (N=2):
#>  name value . name value
#>  CL   1     | VC   20

Created on 2019-02-03 by the reprex package (v0.2.1)

sbihorel commented 5 years ago

Hi

> require(mrgsolve)
Loading required package: mrgsolve
> code <- '[ PARAM ] @annotated // comment
+   // comment
+   TVCL  : 3    : Elimination Clearance (-) // comment
+   TVVC  : 10   : Central Volume (-)
+   TVQ   : 0.5  : Distribution Clearance (-)
+   TVVP  : 75   : Peripheral Volume (-)
+   TVKA  : 0.5  : First-order Absortion Rate (1/h)
+   TVBASE: 50   : Baseline Response (-)
+   TVKOUT: 0.01 : Elimination Rate of Response (-)
+   TVIMAX: 0.5  : Maximum Inhibition (-)
+   TVIC50: 10   : Half-inhibitory Concentration (-)'
> mod <- mcode('foo', code)
Error: improper annotation format 
  Context: not given
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Linux Mint 18.3

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] mrgsolve_0.9.0

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.0                crayon_1.3.4             
 [3] dplyr_0.7.8               assertthat_0.2.0         
 [5] R6_2.2.2                  magrittr_1.5             
 [7] pillar_1.3.0              rlang_0.3.1              
 [9] RcppArmadillo_0.8.400.0.0 bindrcpp_0.2.2           
[11] tools_3.4.4               glue_1.2.0               
[13] purrr_0.2.4               compiler_3.4.4           
[15] pkgconfig_2.0.1           bindr_0.1.1              
[17] tidyselect_0.2.4          tibble_1.4.2 
kylebaron commented 5 years ago

Thanks; looks like it's the leading space that is causing the issue there. I'll address open another issue for this.

> code <- '[ PARAM ] @annotated // comment
+ // comment
+ TVCL  : 3    : Elimination Clearance (-) 
+ TVVC  : 10   : Central Volume (-)
+ TVQ   : 0.5  : Distribution Clearance (-)
+ TVVP  : 75   : Peripheral Volume (-)
+ TVKA  : 0.5  : First-order Absortion Rate (1/h)
+ TVBASE: 50   : Baseline Response (-)
+ TVKOUT: 0.01 : Elimination Rate of Response (-)
+ TVIMAX: 0.5  : Maximum Inhibition (-)
+ TVIC50: 10   : Half-inhibitory Concentration (-)
+ '
> 
> mcode("foo", code)
Building foo ... done.

------------ mrgsolve model object (unix) ------------
  project: /private/var/fol.../T/RtmpTIW9xt
  source:        foo.cpp
  shared object: foo-so-8f76a6ccec4 

  time:          start: 0 end: 24 delta: 1
                 add: <none>
                 tscale: 1

  compartments:  <none>
  parameters:    TVCL TVVC TVQ TVVP TVKA TVBASE TVKOUT
                 TVIMAX TVIC50 [9]
  omega:         0x0 
  sigma:         0x0 

  solver:        atol: 1e-08 rtol: 1e-08
                 maxsteps: 5000 hmin: 0 hmax: 0