Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor CLI to handle help command and following clig.dev guidelines #64

Merged
merged 1 commit into from
Nov 29, 2024

Conversation

sikatikenmogne
Copy link
Collaborator

@sikatikenmogne sikatikenmogne commented Nov 29, 2024

Description

This pull request includes several changes to the aphylogeo project, focusing on improving the command-line interface, updating function documentation, and modifying output handling. The most important changes include updating the Makefile command, modifying the main.py file to enhance the CLI, and updating utility functions for better output file handling.

Command-line interface improvements:

  • aphylogeo/main.py: Enhanced the typer.Typer app initialization to include help text and a callback function for displaying the title card.
  • aphylogeo/main.py: Added a new run command to replace the previous main callback, providing a more intuitive way to run the pipelines and process trees.
  • Makefile: Updated the aPhylogeo command to include the run argument for better clarity.

Function documentation updates:

  • aphylogeo/main.py: Updated the docstrings for climate_pipeline and genetic_pipeline functions to improve clarity and consistency.

Output handling modifications:

  • aphylogeo/utils.py: Modified the writeOutputFile function to accept an output_file parameter, allowing for dynamic output file paths.
  • aphylogeo/utils.py: Updated the filterResults function to return data in a list format and removed the file creation step, making the function more flexible. [1] [2]- Updated Typer app initialization to invoke_without_command=False to enforce command requirement.
  • Improved command-line interface consistency and usability.

Documentation proposal

Command-Line Interface (CLI) for aPhyloGeo

The aPhyloGeo tool now includes a command-line interface (CLI) built with Typer, allowing users to run pipelines and process genetic and climatic trees directly from the terminal. This feature enhances usability and facilitates integration into automated workflows.

Usage

To see the available commands and options, you can run:

python aphylogeo/main.py --help

Main Command Structure

python aphylogeo/main.py [OPTIONS] COMMAND [ARGS]...

Description

A tool for processing climatic and genetic data to generate phylogenetic trees.

Global Options

Option Description
--install-completion Install completion for the current shell.
--show-completion Show completion for the current shell, to copy it or customize the installation.
--help Show help message and exit.

Commands

1. Climate Pipeline

This command runs the climatic pipeline that processes climatic trees.

python aphylogeo/main.py climate-pipeline [OPTIONS]

Options:

Option Type Description
--file-name TEXT The name of the file containing the climatic data. [default: ./datasets/example/geo.csv]
--output TEXT The name of the file to save the climatic trees. [default: ./datasets/example/climaticTrees.nwk]
--help Show help message and exit.

Example Usage:

python aphylogeo/main.py climate-pipeline --file-name './datasets/example/geo.csv' --output './datasets/example/climaticTrees.nwk'

2. Genetic Pipeline

This command runs the genetic pipeline that processes genetic trees.

python aphylogeo/main.py genetic-pipeline [OPTIONS]

Options:

Option Type Description
--reference-gene-filepath TEXT The path to the reference gene file. [default: ./datasets/example/sequences.fasta]
--output TEXT The name of the file to save the genetic trees. [default: ./datasets/example/geneticTrees.json]
--help Show help message and exit.

Example Usage:

python aphylogeo/main.py genetic-pipeline --reference-gene-filepath './datasets/example/sequences.fasta' --output './datasets/example/geneticTrees.json'

3. Run Command

The run command executes both pipelines, processes the trees, and performs phylogeographic analyses.

python aphylogeo/main.py run [OPTIONS]

Options:

Option Type Description
--climatic-tree TEXT The name of the file containing the climatic trees. [default: None]
--genetic-tree TEXT The name of the file containing the genetic trees. [default: None]
--output TEXT The name of the file to save output results. [default: ./results/output.json]
--help Show help message and exit.

Example Usage:

To run phylogenetic analysis with pre-generated climatic and genetic trees:

python aphylogeo/main.py run --climatic-tree './datasets/example/climaticTrees.nwk' --genetic-tree './datasets/example/geneticTrees.json' --output './result.csv'

Screenshot:

image

To run phylogenetic analysis with only pre-generated genetic trees:

python aphylogeo/main.py run --genetic-tree './datasets/example/geneticTrees.json' --output './result.csv'

image

Complete Example Workflow

To run both pipelines in sequence, you can execute:

  1. Generate Climatic Trees:
python aphylogeo/main.py run climate-pipeline --file-name './datasets/example/geo.csv' --output './datasets/example/climaticTrees.nwk'
  1. Generate Genetic Trees:
python aphylogeo/main.py genetic-pipeline --reference-gene-filepath './datasets/example/sequences.fasta' --output './datasets/example/geneticTrees.json'
  1. Process Both Trees:
python aphylogeo/main.py run --climatic-tree './datasets/example/climaticTrees.nwk' --genetic-tree './datasets/example/geneticTrees.json' --output './result.csv'

- Updated `Typer` app initialization to `invoke_without_command=False` to enforce command requirement.
- Improved command-line interface consistency and usability.
@TahiriNadia TahiriNadia merged commit 9357479 into main Nov 29, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants