Skip to content

Commit 0f02bb7

Browse files
authored
Merge pull request #43 from broadinstitute/dp-ksummary
docker build fix and filter_taxids_to_focal_hits fix
2 parents bb675f3 + 30bc8bd commit 0f02bb7

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ENV VIRAL_CLASSIFY_PATH=$INSTALL_PATH/viral-classify \
77

88
COPY requirements-conda.txt requirements-conda-env2.txt $VIRAL_CLASSIFY_PATH/
99
# install most dependencies to the main environment
10-
RUN $VIRAL_NGS_PATH/docker/install-conda-dependencies.sh $VIRAL_CLASSIFY_PATH/requirements-conda.txt
10+
RUN $VIRAL_NGS_PATH/docker/install-conda-dependencies.sh $VIRAL_CLASSIFY_PATH/requirements-conda.txt $VIRAL_NGS_PATH/requirements-conda.txt
1111

1212
# install packages with dependency incompatibilities to the second environment
1313
RUN CONDA_PREFIX="$MINICONDA_PATH/envs/env2"; \

metagenomics.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -728,18 +728,16 @@ def filter_taxids_to_focal_hits(taxids_tsv, focal_report_tsv, taxdb_dir, min_rea
728728
with util.file.open_or_gzopen(focal_report_tsv, "rt") as inf:
729729
for row in csv.DictReader(inf, delimiter='\t'):
730730
if int(row['reads_excl_children']) >= min_read_count:
731-
hits.add(row['taxon_id'])
731+
hits.add(int(row['taxon_id']))
732732

733733
# filter taxids_tsv -> output_tsv
734734
with util.file.open_or_gzopen(taxids_tsv, "rt") as inf:
735735
with util.file.open_or_gzopen(output_tsv, "wt") as outf:
736736
for line in inf:
737-
taxid = line.rstrip('\r\n').split('\t')[0]
737+
taxid = int(line.rstrip('\r\n').split('\t')[0])
738738
ancestors = taxdb.get_ordered_ancestors(taxid)
739-
for node in [taxid] + ancestors:
740-
if taxid in hits:
741-
outf.write(line)
742-
break
739+
if any(node in hits for node in [taxid] + ancestors):
740+
outf.write(line)
743741

744742
__commands__.append(('filter_taxids_to_focal_hits', parser_filter_taxids_to_focal_hits))
745743

requirements-conda.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
blast=2.9.0
1+
blast>=2.9.0
22
bmtagger>=3.101
3-
diamond>=2.1.6
4-
kmc>=3.1.1rc1
5-
kraken2>=2.1.2
3+
diamond>=2.1.9
4+
kmc>=3.2.1
5+
kraken2>=2.1.3
66
krona>=2.8.1
7-
last>=876
7+
last>=1541

test/unit/test_taxon_filter.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55

66
import unittest
7+
import glob
78
import os, os.path
89
import tempfile
910
import shutil
@@ -364,13 +365,11 @@ def setUp(self):
364365

365366
# tar one db, but not the other
366367
tar_db_tgz = util.file.mkstempfname('-humanChr9Subset.blastn.db.tar.gz')
367-
cmd = ['tar', '-C', self.tempDir, '-cvzf', tar_db_tgz]
368-
for ext in ('nhr', 'nin', 'nsq'):
369-
cmd.append('humanChr9Subset.'+ext)
368+
cmd = ['tar', '-C', self.tempDir, '-cvzf', tar_db_tgz] + list(os.path.basename(f) for f in glob.glob(os.path.join(self.tempDir, "humanChr9Subset.n*")))
370369
subprocess.check_call(cmd)
371370
self.blastdbs_multi[1] = tar_db_tgz
372-
for ext in ('nhr', 'nin', 'nsq'):
373-
os.unlink(os.path.join(self.tempDir, 'humanChr9Subset.'+ext))
371+
for idx in glob.glob(os.path.join(self.tempDir, "humanChr9Subset.n*")):
372+
os.unlink(idx)
374373

375374
def test_deplete_blastn_bam(self):
376375
tempDir = tempfile.mkdtemp()

0 commit comments

Comments
 (0)