Task: Implement a command-line interface (App) for the csimpy package that can read a SED-ML file and generate plotted results in a specific directory structure.
What to implement
A CLI class App (usable as a context manager) that can be instantiated with App(argv=[...]) and executed via app.run().
Command-line options:
-h/--help: display usage information and exit (SystemExit expected).
-v/--version: print the package version (csimpy.version) and exit.
-i/--sedml : specify the input SED-ML file to process.
-o/--output-directory : specify the root directory where results will be written.
Also recognize a long option alias --outout-directory (to satisfy tests that use this misspelled name) and map it to the same output directory behavior.
Behavior:
Parse the provided SED-ML file and execute simulations as defined (potentially multiple experiments/models/tasks).
Create an output directory structure that mirrors the test expectations:
For each experiment (e.g., ex1, ex2), create a subdirectory under the specified output directory.
Within each experiment directory, create a subdirectory named after the BIOMD model id (e.g., BIOMD0000000297).
Inside that BIOMD directory, write one PDF file per task, with filenames in the form:
plot_<task_index>_task<task_id>.pdf
Example outcome (based on the provided fixture sine_imports.xml):
Output root:
Existence: ex1 and ex2 subdirectories
BIOMD subdirectories: ex1/BIOMD0000000297 and ex2/BIOMD0000000297
PDFs:
ex1/BIOMD0000000297/plot_1_task1.pdf
ex1/BIOMD0000000297/plot_3_task1.pdf
ex2/BIOMD0000000297/plot_1_task1.pdf
ex2/BIOMD0000000297/plot_3_task1.pdf
Robustness and compatibility:
The solution should work on Windows as indicated by the test notes.
If the input file cannot be read or the output directory cannot be created, raise appropriate errors.
Scope:
The implementation should be designed to handle multiple experiments, models, and tasks described in a SED-ML file, not just the provided fixture.
The behavior should align with the tests’ expectations for argument handling and output layout without requiring changes to the tests.