Skip to content

Commit

Permalink
BUG: fix how contig and mag files are collected in _classify_kraken2 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
colinvwood authored Oct 9, 2023
1 parent 70afdfa commit 0b0c3af
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions q2_moshpit/kraken2/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#
# The full license is in the file LICENSE, distributed with this software.
# ----------------------------------------------------------------------------
import glob
import os
import subprocess
from copy import deepcopy
Expand All @@ -16,6 +15,7 @@
SingleLanePerSamplePairedEndFastqDirFmt,
SingleLanePerSampleSingleEndFastqDirFmt
)
from q2_types.feature_data import DNAFASTAFormat

from q2_moshpit._utils import run_command, _process_common_input_params
from q2_moshpit.kraken2.utils import _process_kraken2_arg
Expand Down Expand Up @@ -75,14 +75,20 @@ def get_paths_for_contigs(contig_id, fp):
return contig_id.rstrip('_contigs'), [fp]

try:
if manifest is not None: # we got reads - use the manifest
if manifest is not None:
# we got reads - use the manifest
iterate_over = manifest.iterrows()
path_function = get_paths_for_reads
else:
iterate_over = (
(os.path.basename(fp).split(".")[0], fp)
for fp in sorted(glob.glob(os.path.join(seqs.path, "*.fasta")))
# we got contigs or MAGs
def view_to_paths(arg):
relpath, _ = arg
return relpath.stem, str(seqs.path / relpath)

iterate_over = map(
view_to_paths, seqs.sequences.iter_views(DNAFASTAFormat)
)

if type(seqs) is MAGSequencesDirFmt:
path_function = get_paths_for_mags
elif type(seqs) is ContigSequencesDirFmt:
Expand Down

0 comments on commit 0b0c3af

Please sign in to comment.