RefGenConf

0.13.1 · active · verified Thu Apr 16

RefGenConf provides a standardized configuration object for reference genome assemblies. It enables robust and centralized management of paths to reference genome assets, ensuring consistency for bioinformatics tools. The current version is 0.13.1, and the project maintains an active development and release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to initialize RefGenConf with a configuration file and retrieve paths to specific assets. It includes setup for a temporary config file for immediate execution. In practice, users typically rely on a `refgenie.yaml` file managed by the `refgenie` command-line tool.

import refgenconf
import os
import yaml

# --- Quickstart Setup: Create a dummy config file for demonstration ---
# In a real scenario, this would typically be '~/.refgenie/refgenie.yaml'
# initialized via 'refgenie init' command.
config_path = "temp_refgenie_config.yaml"
dummy_config_data = {
    "refgenie": {
        "genome_assembly": {
            "assets": {
                "fasta": {"path": "/path/to/fasta.fa", "description": "Genome fasta file"},
                "chrom_sizes": {"path": "/path/to/chrom.sizes", "description": "Chromosome sizes file"}
            }
        }
    }
}
with open(config_path, "w") as f:
    yaml.dump(dummy_config_data, f)
# ---------------------------------------------------------------------

# Initialize RefGenConf with the config file path
rgc = refgenconf.RefGenConf(config_path)

# Access a genome assembly's assets
genome = "genome_assembly"
asset_key = "fasta"

if rgc.has_genome(genome) and rgc.has_asset(genome, asset_key):
    asset_path = rgc.seek(genome, asset_key)
    print(f"Path to {asset_key} for {genome}: {asset_path}")
    # Example: Access metadata
    metadata = rgc.get_asset_data(genome, asset_key)
    print(f"Metadata for {asset_key}: {metadata}")
else:
    print(f"Genome '{genome}' or asset '{asset_key}' not found in config.")

# Clean up the dummy config file
os.remove(config_path)

view raw JSON →