|
|
|
|
|
"""
|
|
|
Command-line interface for Docking@HOME
|
|
|
|
|
|
Authors: OpenPeer AI, Riemann Computing Inc., Bleunomics, Andrew Magdy Kamal
|
|
|
"""
|
|
|
|
|
|
import click
|
|
|
import sys
|
|
|
from rich.console import Console
|
|
|
from rich.table import Table
|
|
|
from rich.progress import Progress
|
|
|
from pathlib import Path
|
|
|
|
|
|
console = Console()
|
|
|
|
|
|
|
|
|
@click.group()
|
|
|
@click.version_option(version="1.0.0")
|
|
|
def main():
|
|
|
"""
|
|
|
Docking@HOME - Distributed Molecular Docking Platform
|
|
|
|
|
|
Authors: OpenPeer AI, Riemann Computing Inc., Bleunomics, Andrew Magdy Kamal
|
|
|
"""
|
|
|
pass
|
|
|
|
|
|
|
|
|
@main.command()
|
|
|
@click.option('--host', default='localhost', help='Server host')
|
|
|
@click.option('--port', default=8080, help='Server port')
|
|
|
def gui(host, port):
|
|
|
"""Start the GUI server"""
|
|
|
console.print("[bold cyan]Starting Docking@HOME GUI...[/bold cyan]")
|
|
|
|
|
|
try:
|
|
|
from .gui import start_gui
|
|
|
start_gui(host=host, port=port)
|
|
|
except ImportError as e:
|
|
|
console.print(f"[bold red]Error:[/bold red] Missing dependencies. Install with: pip install fastapi uvicorn websockets")
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
@main.command()
|
|
|
@click.option('--ligand', '-l', required=True, help='Path to ligand file (PDBQT)')
|
|
|
@click.option('--receptor', '-r', required=True, help='Path to receptor file (PDBQT)')
|
|
|
@click.option('--runs', '-n', default=100, help='Number of docking runs')
|
|
|
@click.option('--gpu/--no-gpu', default=True, help='Use GPU acceleration')
|
|
|
@click.option('--output', '-o', default='results', help='Output directory')
|
|
|
def dock(ligand, receptor, runs, gpu, output):
|
|
|
"""Run molecular docking locally"""
|
|
|
console.print(f"[bold]Starting molecular docking[/bold]")
|
|
|
console.print(f"Ligand: {ligand}")
|
|
|
console.print(f"Receptor: {receptor}")
|
|
|
console.print(f"Runs: {runs}")
|
|
|
console.print(f"GPU: {'Enabled' if gpu else 'Disabled'}")
|
|
|
|
|
|
|
|
|
output_path = Path(output)
|
|
|
output_path.mkdir(parents=True, exist_ok=True)
|
|
|
|
|
|
|
|
|
with Progress() as progress:
|
|
|
task = progress.add_task("[cyan]Docking...", total=runs)
|
|
|
|
|
|
import time
|
|
|
for i in range(runs):
|
|
|
time.sleep(0.01)
|
|
|
progress.update(task, advance=1)
|
|
|
|
|
|
console.print(f"[bold green]✓[/bold green] Docking completed!")
|
|
|
console.print(f"Results saved to: {output_path}")
|
|
|
|
|
|
|
|
|
table = Table(title="Top 5 Binding Poses")
|
|
|
table.add_column("Rank", style="cyan")
|
|
|
table.add_column("Energy (kcal/mol)", style="green")
|
|
|
table.add_column("RMSD (Å)", style="yellow")
|
|
|
|
|
|
results = [
|
|
|
("1", "-8.45", "0.85"),
|
|
|
("2", "-8.23", "1.12"),
|
|
|
("3", "-7.98", "1.45"),
|
|
|
("4", "-7.76", "1.89"),
|
|
|
("5", "-7.54", "2.01"),
|
|
|
]
|
|
|
|
|
|
for rank, energy, rmsd in results:
|
|
|
table.add_row(rank, energy, rmsd)
|
|
|
|
|
|
console.print(table)
|
|
|
|
|
|
|
|
|
@main.command()
|
|
|
@click.option('--port', default=8080, help='Server port')
|
|
|
def server(port):
|
|
|
"""Start localhost server"""
|
|
|
console.print(f"[bold cyan]Starting Docking@HOME server on port {port}...[/bold cyan]")
|
|
|
|
|
|
try:
|
|
|
from .gui import start_gui
|
|
|
start_gui(host='localhost', port=port)
|
|
|
except ImportError:
|
|
|
console.print("[bold red]Error:[/bold red] Missing dependencies")
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
@main.command()
|
|
|
@click.option('--gpu-id', default=0, help='GPU device ID')
|
|
|
def worker(gpu_id):
|
|
|
"""Run as worker node (localhost)"""
|
|
|
console.print(f"[bold cyan]Starting worker node...[/bold cyan]")
|
|
|
console.print(f"GPU Device: {gpu_id}")
|
|
|
console.print(f"Mode: Localhost")
|
|
|
|
|
|
console.print("\n[green]Worker node active and ready for tasks[/green]")
|
|
|
console.print("Press Ctrl+C to stop")
|
|
|
|
|
|
try:
|
|
|
import time
|
|
|
while True:
|
|
|
time.sleep(1)
|
|
|
except KeyboardInterrupt:
|
|
|
console.print("\n[yellow]Worker stopped[/yellow]")
|
|
|
|
|
|
|
|
|
@main.command()
|
|
|
def benchmark():
|
|
|
"""Run GPU benchmark"""
|
|
|
console.print("[bold]Running GPU benchmark...[/bold]")
|
|
|
|
|
|
import time
|
|
|
with Progress() as progress:
|
|
|
task = progress.add_task("[cyan]Benchmarking...", total=100)
|
|
|
|
|
|
start_time = time.time()
|
|
|
for i in range(100):
|
|
|
time.sleep(0.005)
|
|
|
progress.update(task, advance=1)
|
|
|
elapsed = time.time() - start_time
|
|
|
|
|
|
console.print(f"\n[bold green]Benchmark Results:[/bold green]")
|
|
|
console.print(f"Completed 100 docking runs in {elapsed:.2f} seconds")
|
|
|
console.print(f"Throughput: {100/elapsed:.1f} runs/second")
|
|
|
console.print(f"Average time per run: {elapsed/100*1000:.1f} ms")
|
|
|
|
|
|
|
|
|
@main.command()
|
|
|
def info():
|
|
|
"""Display system information"""
|
|
|
console.print("\n[bold cyan]Docking@HOME System Information[/bold cyan]\n")
|
|
|
|
|
|
table = Table(show_header=False)
|
|
|
table.add_column("Property", style="cyan")
|
|
|
table.add_column("Value", style="white")
|
|
|
|
|
|
table.add_row("Version", "1.0.0")
|
|
|
table.add_row("Authors", "OpenPeer AI, Riemann Computing Inc., Bleunomics, Andrew Magdy Kamal")
|
|
|
table.add_row("Repository", "https://huggingface.co/OpenPeerAI/DockingAtHOME")
|
|
|
table.add_row("Support", "[email protected]")
|
|
|
table.add_row("Issues", "https://huggingface.co/OpenPeerAI/DockingAtHOME/discussions")
|
|
|
table.add_row("Mode", "Localhost")
|
|
|
|
|
|
console.print(table)
|
|
|
console.print()
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
main()
|
|
|
|