From c0f02ae9fd518d41c809c208df6002466f64b09e Mon Sep 17 00:00:00 2001 From: Blaise Li <blaise.li__git@nsup.org> Date: Tue, 6 Oct 2020 17:05:48 +0200 Subject: [PATCH] Avoid bytes and spurious white characters. --- smwrappers/explore_mapping_parameters/wrapper.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/smwrappers/explore_mapping_parameters/wrapper.py b/smwrappers/explore_mapping_parameters/wrapper.py index 177b65d..12bf14a 100644 --- a/smwrappers/explore_mapping_parameters/wrapper.py +++ b/smwrappers/explore_mapping_parameters/wrapper.py @@ -56,11 +56,10 @@ echo -e "${{rate}}\\t{snakemake.params.these_settings}" >> {snakemake.params.rat def split_on_tab(s): - # https://stackoverflow.com/a/15095537/1878788 - return s.split(b'\t') + return s.strip().split("\t") -with NamedTemporaryFile() as fastq, NamedTemporaryFile() as rates_record: +with NamedTemporaryFile() as fastq, NamedTemporaryFile(mode="w+t") as rates_record: snakemake.params.fastq = fastq.name # Take the first 10000 reads from the input # https://stackoverflow.com/a/46621920/1878788 @@ -75,7 +74,7 @@ with NamedTemporaryFile() as fastq, NamedTemporaryFile() as rates_record: for (rate, settings) in map(split_on_tab, rates_record)) with open(snakemake.output.mapping_params, "w") as fh: - fh.write(f"{best_settings}\t({best_rate}%%)\n") + fh.write(f"{best_settings}\t({best_rate}%)\n") if hasattr(snakemake.output, "methods"): shell(f"cp {snakemake.input.methods} {snakemake.output.methods}") -- GitLab