Main CLI Module#
Command-line interface for HBAT.
This module provides a command-line interface for running HBAT analysis without the GUI, suitable for batch processing and scripting.
- class hbat.cli.main.ProgressBar(width: int = 50)[source]#
Bases:
object
Simple CLI progress bar for analysis operations.
- __init__(width: int = 50)[source]#
Initialize progress bar.
- Parameters:
width (int) – Width of the progress bar in characters
- hbat.cli.main.create_parser() ArgumentParser [source]#
Create command-line argument parser.
Creates and configures an ArgumentParser with all CLI options for HBAT, including input/output options, analysis parameters, and preset management.
- Returns:
Configured argument parser
- Return type:
- hbat.cli.main.get_example_presets_directory() str [source]#
Get the example presets directory relative to the package.
Locates the example_presets directory that contains predefined analysis parameter configurations.
- Returns:
Path to the example presets directory
- Return type:
- hbat.cli.main.list_available_presets() None [source]#
List all available example presets.
Displays a formatted list of all available preset files with descriptions and icons to help users choose appropriate analysis parameters.
- Returns:
None
- Return type:
None
- hbat.cli.main.load_preset_file(preset_path: str) AnalysisParameters [source]#
Load parameters from a preset file.
Reads and parses a JSON preset file to create AnalysisParameters with predefined values for various analysis scenarios.
- Parameters:
preset_path (str) – Path to the preset file to load
- Returns:
Analysis parameters loaded from the preset
- Return type:
- Raises:
ValueError – If preset file format is invalid
FileNotFoundError – If preset file doesn’t exist
- hbat.cli.main.resolve_preset_path(preset_name: str) str [source]#
Resolve preset name to full path.
Takes a preset name or partial path and resolves it to a full path, searching in the example presets directory if needed.
- Parameters:
preset_name (str) – Name or path of the preset to resolve
- Returns:
Full path to the preset file
- Return type:
- Raises:
SystemExit – If preset file cannot be found
- hbat.cli.main.load_parameters_from_args(args: Namespace) AnalysisParameters [source]#
Create AnalysisParameters from command-line arguments.
Processes command-line arguments to create analysis parameters, with support for preset files and parameter overrides.
- Parameters:
args (argparse.Namespace) – Parsed command-line arguments
- Returns:
Analysis parameters configured from arguments
- Return type:
- hbat.cli.main.print_progress(message: str, verbose: bool = True) None [source]#
Print progress message if verbose mode enabled.
- hbat.cli.main.print_error(message: str) None [source]#
Print error message to stderr.
- Parameters:
message (str) – Error message to display
- Returns:
None
- Return type:
None
- hbat.cli.main.validate_input_file(filename: str) bool [source]#
Validate input PDB file.
Checks if the input file exists, is readable, and contains valid PDB-format content.
- hbat.cli.main.format_results_text(analyzer: NPMolecularInteractionAnalyzer, input_file: str, summary_only: bool = False) str [source]#
Format analysis results as text.
Creates a human-readable text report of analysis results, with options for summary or detailed output.
- hbat.cli.main.export_to_json(analyzer: NPMolecularInteractionAnalyzer, input_file: str, output_file: str) None [source]#
Export results to JSON format.
Exports complete analysis results to a structured JSON file with metadata, statistics, and detailed interaction data.
- hbat.cli.main.detect_output_format(filename: str) str [source]#
Detect output format from file extension.
- Parameters:
filename (str) – Output filename
- Returns:
Format type (‘text’, ‘csv’, ‘json’)
- Return type:
- Raises:
ValueError – If file extension is not supported
- hbat.cli.main.export_to_csv_files(analyzer: NPMolecularInteractionAnalyzer, base_filename: str) None [source]#
Export results to multiple CSV files.
Creates separate CSV files for each interaction type.
- Parameters:
analyzer (NPMolecularInteractionAnalyzer) – Analysis results to export
base_filename (str) – Base filename (extension will be removed)
- Returns:
None
- Return type:
None
- hbat.cli.main.export_to_json_files(analyzer: NPMolecularInteractionAnalyzer, base_filename: str, input_file: str) None [source]#
Export results to multiple JSON files.
Creates separate JSON files for each interaction type.
- Parameters:
analyzer (NPMolecularInteractionAnalyzer) – Analysis results to export
base_filename (str) – Base filename (extension will be removed)
input_file (str) – Path to the input file analyzed
- Returns:
None
- Return type:
None
- hbat.cli.main.export_to_csv(analyzer: NPMolecularInteractionAnalyzer, output_file: str) None [source]#
Export results to CSV format.
Exports analysis results to a CSV file with separate sections for different interaction types.
- Parameters:
analyzer (MolecularInteractionAnalyzer) – Analysis results to export
output_file (str) – Path to the CSV output file
- Returns:
None
- Return type:
None
- hbat.cli.main.run_analysis(args: Namespace) int [source]#
Run the analysis with given arguments.
Performs the complete analysis workflow including parameter loading, analysis execution, and result output based on command-line arguments.
- Parameters:
args (argparse.Namespace) – Parsed command-line arguments
- Returns:
Exit code (0 for success, non-zero for failure)
- Return type:
- hbat.cli.main.main() int [source]#
Main CLI entry point for HBAT molecular interaction analysis.
Parses command-line arguments and dispatches to appropriate functionality. Supports comprehensive analysis of molecular interactions including:
Hydrogen bonds (classical N-H···O, O-H···O)
Weak hydrogen bonds (C-H···O interactions)
Halogen bonds (C-X···A with default 150° angle cutoff)
π interactions with multiple subtypes: • Hydrogen-π: C-H···π, N-H···π, O-H···π, S-H···π • Halogen-π: C-Cl···π, C-Br···π, C-I···π
Cooperativity chains and interaction networks
Includes built-in parameter presets and PDB structure fixing capabilities.
- Returns:
Exit code (0 for success, non-zero for failure)
- Return type: