# Creating Example Scripts

PoPy contains built in example scripts that can be generated on the command line. The general method is:-

    $ popy_create [script_type] [script_name]

These built in scripts are designed to get you started with using a particular type of script file. Once generated you can edit the default text for your own PK/PD modelling requirements.

See popy_create documentation, or the Creating an example Fit Script and Creating an example Tut Script examples below.

## Creating an example Fit Script

First, Open a PoPy Command Prompt. Then do:-

    $ popy_create fit my_fit_script.pyml

where

- popy_create is one of the Command Line Tools
- the fit option requests a fit script to be created and
- the ‘my_fit_script.pyml’ file is the name of the Fit Script written to disk.

You can generate a more verbose example script with comments using:-

    $ popy_create -acsl fit my_fit_script.pyml

See popy_create for the meaning of the ‘-acsl’ command line switch options. Or type ‘popy_create -h’.

You will notice that popy_create also creates a file called my_fit_script.pyml.create.main.log. This is a record of the messages output by the popy_create tool. In this case the log file is very short. These log files, created by all of the Command Line Tools, act as part of the audit trail for your experiments. You can open the ‘my_fit_script.pyml’ in your system editor as follows:-

    $ popy_edit my_fit_script.pyml

You can try running the fit_script:-

    $ popy_run my_fit_script.pyml

However, you will likely see a message, similar to the following:-

    CAST_ERROR= ERROR in value_record: ROOT->FILE_PATHS->input_data_file
    ERROR when casting input file element
    input file path = C:\Users\david\my_popy_egs\examples\fit_example4\input.csv
    NOT present on file system.

Essentially this is telling you that this entry in ‘builtin_fit_example.pyml’:-

    FILE_PATHS: {input_data_file: input.csv}

Is causing a problem because ‘input.csv’ does not exist. The popy_create tool outputs a script file only, so the ‘input.csv’ entry is just a place holder. You need to set the ‘input_data_file’ field to point at an existing data file to run the Fit Script.

Note one way of creating a data file is to create and then run a Gen Script or Tut Script, as described below.

The ‘my_fit_script.pyml’ is just meant to provide an easy template for you to use for your own analyses. The ‘tut_script’ example below is more complete, as a Tut Script works with just a single .pyml file.

## Creating an example Tut Script

As always the first step is to Open a PoPy Command Prompt. Then do:-

    $ popy_create tut my_tut_script.pyml

You can generate a more verbose example script with comments using:-

    $ popy_create -acsl tut my_tut_script.pyml

See popy_create for the command line switch options. Or type ‘popy_create -h’.

You can use this mechanism to create an example file for any of the Script File Formats in PoPy.

You can open the ‘my_tut_script.pyml’ in your system editor as follows:-

    $ popy_edit my_tut_script.pyml

You should now have a run-able Tut Script. Run as follows:-

    $ popy_run my_tut_script.pyml

You can use this mechanism to create an example file for any of the Script File Formats in PoPy.