Skip to content

Commit

Permalink
Merge github.com:broadinstitute/viral-ngs into sy-pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
yesimon committed May 4, 2016
2 parents cdaa862 + 62d028f commit 5fa0345
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions pipes/config.yaml
Expand Up @@ -37,6 +37,9 @@ kraken_db: "/idi/sabeti-scratch/yesimon/db/kraken_full_20150910"
# Path of DIAMOND database file for metagenomics identification
diamond_db: "/idi/sabeti-scratch/yesimon/db/diamond_db/nr"

# Directory of the krona database for generating html reports.
krona_db: "/idi/sabeti-scratch/yesimon/db/krona"

# These are variables that must be set
env_vars:
# The directory path to the location of the GATK jar file.
Expand Down
2 changes: 1 addition & 1 deletion pipes/rules/metagenomics.rules
Expand Up @@ -36,7 +36,7 @@ rule krona_import_taxonomy:
output: join(config["data_dir"], config["subdirs"]["metagenomics"], "{sample}.kraken.krona.html")
shell:
"""
{config[bin_dir]}/metagenomics.py krona {input} {output} --noRank
{config[bin_dir]}/metagenomics.py krona {input} {config[krona_db]} {output} --noRank
"""


Expand Down
22 changes: 15 additions & 7 deletions test/integration/test_kraken.py
Expand Up @@ -87,10 +87,14 @@ class CommonTests(object):
@unittest.skipIf(sys.version_info < (3,2), "Python version is too old for snakemake.")
def test_pipes(self):
runner = SnakemakeRunner()
runner.set_override_config({
override_config = {
'kraken_db': self.db,
'diamond_db': None,
})
}
krona_db = getattr(self, 'krona_db', None)
if krona_db:
override_config['krona_db'] = self.krona_db
runner.set_override_config(override_config)
runner.setup()
runner.link_samples([self.bam], destination='source')
runner.create_sample_files(sample_files=['samples_metagenomics'])
Expand All @@ -101,10 +105,10 @@ def test_pipes(self):
krona_out = join(runner.workdir, runner.data_dir, runner.config['subdirs']['metagenomics'],
'.'.join([os.path.splitext(os.path.basename(self.bam))[0], 'kraken.krona.html']))

# runner.run(['all_metagenomics'])
runner.run([kraken_out])
runner.run(['all_metagenomics'])
# runner.run([kraken_out])
self.assertGreater(os.path.getsize(kraken_out), 0)
# self.assertGreater(os.path.getsize(krona_out), 0)
self.assertGreater(os.path.getsize(krona_out), 0)

def test_kraken(self):
bin = join(util.file.get_project_path(), 'metagenomics.py')
Expand All @@ -119,10 +123,12 @@ def test_kraken(self):
self.assertGreater(os.path.getsize(out_reads), 0)


class TestKrakenTiny(TestKrakenBase, CommonTests):
class TestKrakenTiny(TestKrakenBase, TestKronaBase, CommonTests):

@classmethod
def setUpClass(cls):
TestKronaBase.setUpClass()
cls.krona_db = cls.build_krona_db()
super().setUpClass()
cls.data_dir = join(util.file.get_test_input_path(), 'TestToolKraken')
cls.db_dir = os.path.join(cls.data_dir, 'db')
Expand All @@ -147,10 +153,12 @@ def test_kraken_tool(self):
self.assertGreater(os.path.getsize(out_report), 0)
self.assertGreater(os.path.getsize(out_filtered), 0)

class TestKrakenVirusMix(TestKrakenBase, CommonTests):
class TestKrakenVirusMix(TestKrakenBase, TestKronaBase, CommonTests):

@classmethod
def setUpClass(cls):
TestKronaBase.setUpClass()
cls.krona_db = cls.build_krona_db()
super().setUpClass()
cls.data_dir = join(util.file.get_test_input_path(), 'TestKrakenViralMix')
cls.db_dir = os.path.join(cls.data_dir, 'db')
Expand Down
2 changes: 1 addition & 1 deletion util/misc.py
Expand Up @@ -216,7 +216,7 @@ def run_and_print(args, stdout=None, stderr=None,
print(e.output.decode('utf-8'))
try:
print(e.stderr.decode('utf-8'))
except TypeError:
except AttributeError:
pass
sys.stdout.flush()
raise(e)
Expand Down

0 comments on commit 5fa0345

Please sign in to comment.