Refgenie

0.13.0 · active · verified Fri Apr 17

Refgenie creates a standardized folder structure for reference genome files and indexes, facilitating their sharing and usage across different bioinformatics tools and analyses. The current version is 0.13.0, with new releases typically occurring a few times per year, focusing on bug fixes, feature enhancements, and occasional schema updates.

Common errors

Warnings

Install

Imports

Quickstart

Initialize a RefgenieClient, list available genomes, and demonstrate how to interact with assets. This example includes a setup for a dummy config file to make it runnable even if Refgenie hasn't been initialized via the CLI, though actual asset retrieval requires prior `refgenie pull` or `refgenie build` commands.

import refgenie
import os

# Initialize RefgenieClient. It will look for ~/.refgenie/refgenie.yaml by default.
# For a temporary or custom config, provide the path.
# If no config is found at the default path, an empty client is initialized.
# For this example, we'll try to use a default or an empty one.

# Create a dummy refgenie.yaml for demonstration if it doesn't exist
config_path = os.path.expanduser("~/.refgenie/refgenie.yaml")
if not os.path.exists(os.path.dirname(config_path)):
    os.makedirs(os.path.dirname(config_path))
if not os.path.exists(config_path):
    with open(config_path, 'w') as f:
        f.write("refgenie:\n  genome_config_version: 0.2\n  genomes: {}\n")

rg = refgenie.RefgenieClient(config_file=config_path)

print(f"Refgenie client initialized. Config file: {rg.config_file}")

# List available genomes (will be empty if no assets are pulled)
genomes = rg.list_genomes()
print(f"Available genomes: {list(genomes.keys())}")

# Example: trying to get an asset (will likely fail if not pulled/built)
# To make this runnable without pre-pulled assets, we'll skip direct asset retrieval
# Try to get a non-existent asset to show expected behavior without erroring
try:
    # This assumes 'human_genome' is a valid genome and 'fasta' is an asset for it
    # For a real scenario, you would run `refgenie pull human_genome/fasta` first
    # or build your own assets.
    # asset_path = rg.get_asset("human_genome/fasta")
    # print(f"Path to human_genome fasta: {asset_path}")
    print("To get an asset, first ensure it's pulled or built locally.")
    print("Example: 'refgenie pull hg38/fasta' from command line.")
except Exception as e:
    print(f"Could not retrieve asset (expected if not pulled): {e}")

# Clean up dummy config for demonstration
# os.remove(config_path)
# os.rmdir(os.path.dirname(config_path)) # Only if directory is empty

view raw JSON →