.. _script_formats:

Script File Formats
#####################

The |popy| script formats are shown in :numref:`table_popy_scripts`:-

.. _table_popy_scripts:

.. list-table:: Script Format
    :header-rows: 1
    
    * - Name
      - Purpose
      - Child Scripts
      
    * - :ref:`fit<fit_script>`
      - Fit a model to data
      - :ref:`grph<grph_script>`/:ref:`sim<sim_script>`/:ref:`msim<msim_script>`/:ref:`fitsum<fitsum_script>`

    * - :ref:`gen<gen_script>`
      - Generate data from a model
      - :ref:`grph<grph_script>`/:ref:`sim<sim_script>`/:ref:`gensum<gensum_script>`
      
    * - :ref:`sim<sim_script>`
      - Simulate |pkpd| curves
      - :ref:`grph<grph_script>`
      
    * - :ref:`tut<tut_script>`
      - Gen data and fit + compare
      - :ref:`grph<grph_script>`/:ref:`fit<fit_script>`/:ref:`comp<comp_script>`/:ref:`tutsum<tutsum_script>`

    * - :ref:`comp<comp_script>`
      - Compare gen and fit results
      - none
      
    * - :ref:`mfit<mfit_script>`
      - Fit a model to multiple data sets
      - none

    * - :ref:`mgen<mgen_script>`
      - Generate multiple data from a model
      - none
      
    * - :ref:`msim<sim_script>`
      - Simulate multiple |pkpd| curves
      - :ref:`vpc<vpc_script>`
      
    * - :ref:`mtut<mtut_script>`
      - Gen multiple data and fit + compare
      - :ref:`mgen<mgen_script>`/:ref:`mfit<mfit_script>`/:ref:`mcomp<mcomp_script>`

    * - :ref:`mcomp<mcomp_script>`
      - Compare mgen and mfit results
      - none
      
    * - :ref:`grph<grph_script>`
      - Plot graphs
      - none
      
    * - :ref:`vpc<vpc_script>`
      - Plot |vpcs|
      - none
      
    * - :ref:`fitsum<fitsum_script>`
      - |html| summary of :ref:`fit<fit_script>` results
      - none
      
    * - :ref:`gensum<gensum_script>`
      - |html| summary of :ref:`gen<gen_script>` results
      - none
      
    * - :ref:`tutsum<tutsum_script>`
      - |html| summary of :ref:`tut<tut_script>` results
      - none
      
    * - :ref:`n2pdat<n2pdat_script>`
      - converts |nonmem| to |popy| data
      - none
      
    * - :ref:`p2ndat<p2ndat_script>`
      - converts |popy| to |nonmem| data
      - none
      

A |popy| script file is a text file that defines how |popy| works with a |pkpd| model. Each configuration file typically has a '.pyml' file extension. The file suffix .pyml stands for |popy| :term:`YAML` format. 

To run a |popy| command on a particular script, :ref:`open_a_popy_command_prompt` in the directory containing the script file and type:-

.. code-block:: console

    $ popy_XXXX YYYY.pyml 
 
Where XXXX is one of the :ref:`popy_tools`, such as 'run', 'create', 'check' or 'format'. And YYYY.pyml is the file name of the script itself. For example:-

.. code-block:: console

    $ popy_run my_fit_file.pyml 
 
for running a script to fit |pkpd| parameters to a pre-existing data set, or:-

.. code-block:: console

    $ popy_create gen my_gen_file.pyml 
 
for creating a new script file that will generate synthetic |pkpd| data.

|popy| will first parse the script to check it is in the correct format. If so, |popy| will then process the script.

A |popy| script file can be one of multiple formats, as specified at the start of each script, in |method_options|. For example a :ref:`fit_script` starts with:-

.. code-block:: pyml

    METHOD_OPTIONS: {py_module: fit}

And a :ref:`gen_script` starts with:-

.. code-block:: pyml

    METHOD_OPTIONS: {py_module: gen}
      
      
..  toctree::
    :maxdepth: 1
    :hidden:
   
    fit_script
    gen_script
    sim_script
    tut_script
    comp_script  
   
    mfit_script
    mgen_script
    msim_script
    mtut_script
    mcomp_script
    
    grph_script
    vpc_script
    
    fitsum_script
    gensum_script
    tutsum_script

    n2pdat_script
    p2ndat_script
      
         
   