Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial working version of refgenie integration #1090

Merged
merged 21 commits into from
Jul 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added refgenie test
  • Loading branch information
KevinMenden committed May 25, 2021
commit 0a8e3b3da59136be7bf6bd1a54a95973499285c1
6 changes: 5 additions & 1 deletion nf_core/refgenie.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ def update_config(rgc):
if not nxf_home and "HOME" in os.environ:
nxf_home = os.path.join(os.environ.get("HOME"), ".nextflow")
if not os.path.exists(nxf_home):
log.info(f"Creating NXF_HOME directory at {nxf_home}")
os.makedirs(nxf_home, exist_ok=True)

# Get the path for storing the updated refgenie_genomes.config
Expand All @@ -124,7 +125,7 @@ def update_config(rgc):
refgenie_genomes_config_file = os.path.join(nxf_home, "nf-core/refgenie_genomes.config")
else:
log.info("Could not determine path to 'refgenie_genomes.config' file.")
return
return False

# Save the udated genome config
try:
Expand All @@ -133,7 +134,10 @@ def update_config(rgc):
log.info(f"Updated nf-core genomes config: {refgenie_genomes_config_file}")
except FileNotFoundError as e:
log.warn(f"Could not write to {refgenie_genomes_config_file}")
return False

# Add include statement to NXF_HOME/config
if nxf_home:
_update_nextflow_home_config(refgenie_genomes_config_file, nxf_home)

return True
2 changes: 1 addition & 1 deletion tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import nf_core.__main__

from click.testing import CliRunner
import mock
from unittest import mock
import unittest


Expand Down
2 changes: 1 addition & 1 deletion tests/test_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from nf_core.download import DownloadWorkflow

import hashlib
import mock
from unittest import mock
import os
import pytest
import shutil
Expand Down
2 changes: 1 addition & 1 deletion tests/test_launch.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import nf_core.launch

import json
import mock
from unittest import mock
import os
import shutil
import tempfile
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
import fnmatch
import json
import mock
from unittest import mock
import os
import pytest
import requests
Expand Down
2 changes: 1 addition & 1 deletion tests/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import nf_core.list

import json
import mock
from unittest import mock
import os
import pytest
import time
Expand Down
50 changes: 50 additions & 0 deletions tests/test_refgenie.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env python
""" Tests covering the refgenie integration code
"""

import nf_core.refgenie
import refgenconf
import json
import os
import pytest
import time
import unittest
import tempfile
from unittest import mock
import subprocess
from rich.console import Console


class TestRefgenie(unittest.TestCase):
"""Class for refgenie tests"""

def setUp(self):
"""
Prepare a refgenie config file
"""
self.tmp_dir = tempfile.mkdtemp()
self.NXF_HOME = os.path.join(self.tmp_dir, ".nextflow")
self.NXF_REFGENIE_PATH = os.path.join(self.NXF_HOME, "nf-core", "refgenie_genomes.config")
self.REFGENIE = os.path.join(self.tmp_dir, "genomes_config.yaml")

# create NXF_HOME and nf-core directories
os.makedirs(os.path.join(self.NXF_HOME, "nf-core"), exist_ok=True)

# Initialize a refgenie config
os.system(f"refgenie init -c {self.REFGENIE}")

# Populate the config with a genome
os.system(f"refgenie pull t7/fasta -c {self.REFGENIE}")

with open(self.REFGENIE, "a") as fh:
fh.write(f"nextflow_config: {os.path.join(self.NXF_REFGENIE_PATH)}")

def tearDown(self) -> None:
# Remove the tempdir again
os.system(f"rm -rf {self.tmp_dir}")

def test_update_refgenie_genomes_config(self):
"""Test that listing pipelines works"""
rgc = refgenconf.RefGenConf(self.REFGENIE)

assert nf_core.refgenie.update_config(rgc) == True
2 changes: 1 addition & 1 deletion tests/test_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import click
import json
import mock
from unittest import mock
import os
import pytest
import requests
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import nf_core.sync

import json
import mock
from unittest import mock
import os
import shutil
import tempfile
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import nf_core.list
import nf_core.utils

import mock
from unittest import mock
import os
import pytest
import requests
Expand Down