Mercurial > repos > artbio > repenrich2
diff RepEnrich2.py @ 9:2b61c6407efb draft default tip
planemo upload for repository https://github.com/ARTbio/tools-artbio/tree/main/tools/repenrich2 commit 961a14cd73dd8e40b2f30d5e4df136b98cd8f07a
author | artbio |
---|---|
date | Thu, 25 Apr 2024 16:22:34 +0000 |
parents | 567549a49eb2 |
children |
line wrap: on
line diff
--- a/RepEnrich2.py Thu Apr 25 09:06:48 2024 +0000 +++ b/RepEnrich2.py Thu Apr 25 16:22:34 2024 +0000 @@ -109,9 +109,13 @@ ''' write to files to save memory ''' - metagenome, fastqfile = args - b_opt = "-k 1 -p 1 --quiet --no-hd --no-unal" - command = shlex.split(f"bowtie2 {b_opt} -x {metagenome} {fastqfile}") + metagenome = args + b_opt = "-k 1 -p 2 --quiet --no-hd --no-unal" + if paired_end is True: + command = shlex.split(f"bowtie2 {b_opt} -x {metagenome}" + f" -1 {fastqfile_1} -2 {fastqfile_1}") + else: + command = shlex.split(f"bowtie2 {b_opt} -x {metagenome} {fastqfile_1}") bowtie_align = subprocess.run(command, check=True, capture_output=True, text=True).stdout bowtie_align = bowtie_align.rstrip('\r\n').split('\n') @@ -123,17 +127,14 @@ # multimapper parsing -args_list = [(metagenome, fastqfile_1) for metagenome in repeat_list] -if paired_end: - args_list.extend([(metagenome, fastqfile_2) for - metagenome in repeat_list]) +args_list = [metagenome for metagenome in repeat_list] with ProcessPoolExecutor(max_workers=cpus) as executor: results = executor.map(run_bowtie, args_list) # Aggregate results (avoiding race conditions) metagenome_reads = defaultdict(list) # metagenome: list of multimap reads -# Now we read .reads file to populate metagnomes_reads +# Now we read .reads files to populate metagnomes_reads for metagenome in repeat_list: with open(f"{metagenome}.reads") as readfile: for read in readfile: