CLI Commands

This section provides detailed documentation for the command-line interface (CLI) commands available in OmniGenBench. The CLI allows users to run benchmarks, train models, and manage resources directly from the terminal, making it easy to perform common tasks without writing Python scripts.

Overview:

  • OmniGenBench’s CLI is designed for codeless operation, enabling users to quickly execute benchmarking, training, and resource management workflows.

  • The CLI covers base commands, main entry points, benchmarking commands, and specialized commands for RNA and other tasks.

  • Each command is documented with its available options, arguments, and usage examples.

Key CLI Components:

  • Base Commands: Core commands for general operations and configuration.

  • Main CLI: The main entry point for OmniGenBench’s command-line interface.

  • Bench Commands: Commands for running automated benchmarks on genomic models and datasets.

  • RNA Commands: Specialized commands for RNA-related tasks and workflows.

Auto-Pipeline CLI Example:

omnigenbench bench --model model_name --dataset dataset_name
omnigenbench train --model model_name --dataset dataset_name

Refer to the API documentation below for details on each CLI command, including available options and usage instructions.

Base Commands

class omnigenbench.cli.commands.base.BaseCommand[source]

Bases: ABC

This class provides a common interface for all command-line interface commands in the OmniGenome framework. It defines the structure that all command classes must follow, including registration and common argument handling. Subclasses must implement the register_command method to define their specific command-line interface and arguments.

Example

>>> class MyCommand(BaseCommand):
...     @classmethod
...     def register_command(cls, subparsers):
...         parser = subparsers.add_parser("mycommand", help="My command")
...         parser.add_argument("--input", required=True)
...         parser.set_defaults(func=cls.execute)
...
...     @staticmethod
...     def execute(args):
...         print(f"Executing with input: {args.input}")
classmethod add_common_arguments(parser)[source]

This method adds standard arguments that are common across all OmniGenome CLI commands, such as logging level and output directory.

Parameters:

parser – The ArgumentParser for the specific command

Example

>>> parser = argparse.ArgumentParser()
>>> BaseCommand.add_common_arguments(parser)
abstractmethod classmethod register_command(subparsers)[source]

This abstract method must be implemented by all subclasses to define their specific command-line interface, including arguments, help text, and default functions.

Parameters:

subparsers – The subparsers object from the main ArgumentParser

Example

>>> parser = argparse.ArgumentParser()
>>> subparsers = parser.add_subparsers()
>>> MyCommand.register_command(subparsers)

Main CLI

omnigenbench.cli.omnigenome_cli.main()[source]

The main entry point for the OmniGenome command-line interface. This function sets up the command-line argument parser and handles the execution of different subcommands. Currently supports RNA design functionality with genetic algorithm optimization.

Example

>>> # Design RNA sequences from command line
>>> python -m omnigenbench.cli.omnigenome_cli rna_design --structure "(((...)))"
>>> # Design with custom parameters
>>> python -m omnigenbench.cli.omnigenome_cli rna_design
...     --structure "(((...)))"
...     --model "yangheng/OmniGenome-186M"
...     --mutation-ratio 0.3
...     --num-population 200
...     --num-generation 150
...     --output-file "results.json"

Bench Commands

class omnigenbench.cli.commands.bench.bench_cli.BenchCommand[source]

Bases: BaseCommand

This class provides a CLI interface for the AutoBench functionality, allowing users to easily run comprehensive evaluations of genomic models across multiple benchmarks. It supports various benchmarks, models, and training configurations.

Variables:
  • benchmarks (list) – List of available benchmarks (RGB, PGB, GUE, GB, BEACON)

  • trainers (list) – List of available trainers (native, accelerate, hf_trainer)

Example

>>> # Run basic benchmark
>>> python -m omnigenbench.cli autobench --model "model_name" --benchmark "RGB"
>>> # Run with custom settings
>>> python -m omnigenbench.cli autobench
...     --model "model_name"
...     --benchmark "RGB"
...     --trainer "accelerate"
...     --bs_scale 2
...     --overwrite True
static execute(args: Namespace)[source]

Execute the autobench command with the provided arguments. It handles model and tokenizer loading, benchmark execution, and result logging.

Parameters:

args (argparse.Namespace) – Parsed command-line arguments containing benchmark configuration and model settings

Example

>>> args = parser.parse_args(['autobench', '--model', 'model_name'])
>>> BenchCommand.execute(args)
classmethod register_command(subparsers)[source]

This method sets up the command-line interface for the autobench functionality, including all necessary arguments and their descriptions.

Parameters:

subparsers – The subparsers object from argparse to add the command to

Example

>>> parser = argparse.ArgumentParser()
>>> subparsers = parser.add_subparsers()
>>> BenchCommand.register_command(subparsers)
omnigenbench.cli.commands.bench.bench_cli.register_command(subparsers)[source]

This function is a convenience wrapper for registering the BenchCommand with the argument parser.

Parameters:

subparsers – The subparsers object from argparse to add the command to

Example

>>> parser = argparse.ArgumentParser()
>>> subparsers = parser.add_subparsers()
>>> register_command(subparsers)

RNA Commands

class omnigenbench.cli.commands.rna.rna_design.RNADesignCommand[source]

Bases: BaseCommand

This class provides a CLI interface for designing RNA sequences that fold into specific secondary structures. It uses genetic algorithms with customizable parameters to optimize sequence design for target structures.

The design process involves:

  1. Loading a pre-trained RNA design model

  2. Running genetic algorithm optimization

  3. Generating sequences that match the target structure

  4. Saving results to file (optional)

Variables:
  • model_path (str) – Path to the pre-trained RNA design model

  • structure (str) – Target RNA secondary structure in dot-bracket notation

  • mutation_ratio (float) – Genetic algorithm mutation rate

  • num_population (int) – Population size for genetic algorithm

  • num_generation (int) – Number of generations for evolution

Example

>>> # Basic RNA design
>>> python -m omnigenbench.cli design --structure "(((...)))"
>>> # Design with custom parameters
>>> python -m omnigenbench.cli design
...     --structure "(((...)))"
...     --model-path "yangheng/OmniGenome-186M"
...     --mutation-ratio 0.3
...     --num-population 200
...     --num-generation 150
...     --output "results.json"
static execute(args: Namespace)[source]

This method runs the RNA sequence design process using genetic algorithms. It validates parameters, loads the model, runs the design optimization, and outputs or saves the results.

Parameters:

args (argparse.Namespace) – Parsed command-line arguments containing design parameters and model settings

Raises:

ValueError – If mutation_ratio is not between 0.0 and 1.0

Example

>>> args = parser.parse_args(['design', '--structure', '(((...)))'])
>>> RNADesignCommand.execute(args)
classmethod register_command(subparsers)[source]

This method sets up the command-line interface for RNA sequence design, including all necessary arguments and their descriptions.

Parameters:

subparsers – The subparsers object from argparse to add the command to

Example

>>> parser = argparse.ArgumentParser()
>>> subparsers = parser.add_subparsers()
>>> RNADesignCommand.register_command(subparsers)
omnigenbench.cli.commands.rna.rna_design.register_command(subparsers)[source]

This function is a convenience wrapper for registering the RNADesignCommand with the argument parser.

Parameters:

subparsers – The subparsers object from argparse to add the command to

Example

>>> parser = argparse.ArgumentParser()
>>> subparsers = parser.add_subparsers()
>>> register_command(subparsers)