How to use the genomepy.install_genome function in genomepy

To help you get started, we’ve selected a few genomepy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vanheeringen-lab / genomepy / tests / test_5_install_options.py View on Github external
bgzip = False if bgzip == "unzipped" else True

    genomepy.install_genome(
        genome, provider, genome_dir=tmp, localname=localname, bgzip=bgzip, force=force
    )

    # force test
    ext = ".fa.gz" if bgzip else ".fa"
    name = genomepy.utils.get_localname(genome, localname)
    path = os.path.join(tmp, name, name + ext)

    t0 = os.path.getmtime(path)
    # OSX rounds down getmtime to the second
    if system() != "Linux":
        sleep(1)
    genomepy.install_genome(
        genome, provider, genome_dir=tmp, localname=localname, bgzip=bgzip, force=force
    )

    t1 = os.path.getmtime(path)
    assert t0 != t1 if force else t0 == t1

    shutil.rmtree(tmp)
github vanheeringen-lab / genomepy / tests / test_genomepy.py View on Github external
def test_bad_url():
    """Test URL.

    Try to download a non-genome url link.
    """
    with pytest.raises(ValueError):
        genomepy.install_genome("www.google.com", "url")
github vanheeringen-lab / genomepy / tests / test_03_download_genomes.py View on Github external
def test_ucsc_genome(genome="sacCer3", provider="UCSC"):
    """Test UCSC.

    Download S. cerevisiae genome from UCSC and retrieve a specific sequence."""
    tmp = mkdtemp()
    genomepy.install_genome(genome, provider, genome_dir=tmp)
    g = genomepy.Genome(genome, genome_dir=tmp)
    seq = g["chrIV"][1337000:1337020]
    assert str(seq) == "TTTGGTTGTTCCTCTTCCTT"
github vanheeringen-lab / genomepy / tests / test_02_links.py View on Github external
def test_bad_url():
    """Test URL.

    Try to download a non-genome url link.
    """
    with pytest.raises(ValueError):
        genomepy.install_genome("www.google.com", "url")
github vanheeringen-lab / genomepy / tests / test_genomepy.py View on Github external
def test_nonexisting_url():
    """Test URL.

    Try to download a non-genome url link.
    """
    with pytest.raises(ValueError):
        genomepy.install_genome("this is not an url", "url")
github vanheeringen-lab / genomepy / tests / test_03_download_genomes.py View on Github external
def test_zipped_genomes(zipped_genomes):
    """Download a gzipped and a tar.gzipped genome"""
    genome = "ASM14646v1" if zipped_genomes == ".gz" else "sacCer3"
    provider = "NCBI" if zipped_genomes == ".gz" else "UCSC"
    tmp = mkdtemp()
    genomepy.install_genome(genome, provider, genome_dir=tmp)
    shutil.rmtree(tmp)
github vanheeringen-lab / genomepy / tests / test_genomepy.py View on Github external
def test_install_options(bgzip_force, genome="sacCer3"):
    """Test force and bgzip"""
    tmp = mkdtemp()
    bgzip = False
    if bgzip_force[0] == "bgzipped":
        bgzip = True
    force = False
    if bgzip_force[1] == "overwrite":
        force = True

    genomepy.install_genome(genome, "UCSC", genome_dir=tmp, bgzip=bgzip, force=force)

    ext = ".fa.gz" if bgzip else ".fa"
    path = os.path.join(tmp, genome, genome + ext)
    t0 = os.path.getmtime(path)
    genomepy.install_genome(genome, "UCSC", genome_dir=tmp, bgzip=bgzip, force=force)
    t1 = os.path.getmtime(path)
    if force:
        assert t0 != t1
    else:
        assert t0 == t1

    shutil.rmtree(tmp)
github vanheeringen-lab / genomepy / tests / test_06_human_genomes.py View on Github external
def test_ensembl_human():
    """Test Ensembl.

    Download human genome from Ensembl and retrieve a
    specific sequence.
    """
    tmp = mkdtemp()
    genomepy.install_genome("GRCh38.p13", "Ensembl", genome_dir=tmp)
    g = genomepy.Genome("GRCh38.p13", genome_dir=tmp)
    seq = g["6"][166168664:166168679]
    assert str(seq) == "CCTCCTCGCTCTCTT"
    shutil.rmtree(tmp)
github vanheeringen-lab / genomepy / genomepy / cli.py View on Github external
provider,
    genomes_dir,
    localname,
    mask,
    regex,
    invert_match,
    bgzip,
    annotation,
    only_annotation,
    skip_sanitizing,
    threads,
    force,
    **kwargs,
):
    """Install genome NAME from provider PROVIDER in directory GENOME_DIR."""
    genomepy.install_genome(
        name,
        provider,
        genomes_dir=genomes_dir,
        localname=localname,
        mask=mask,
        regex=regex,
        invert_match=invert_match,
        bgzip=bgzip,
        annotation=annotation,
        only_annotation=only_annotation,
        skip_sanitizing=skip_sanitizing,
        threads=threads,
        force=force,
        **kwargs,
    )