From ecbce1369df5eb314d407f5470f8e1bde121d44d Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Thu, 27 May 2021 13:29:15 +0200 Subject: [PATCH 1/3] fix pysam.view call otherwise samtools output is the return value of `pysam.view` and the output stays empty. see also https://github.com/pysam-developers/pysam/issues/677 --- lib/galaxy/tool_util/verify/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/tool_util/verify/__init__.py b/lib/galaxy/tool_util/verify/__init__.py index b3b1abda323..e59be9540db 100644 --- a/lib/galaxy/tool_util/verify/__init__.py +++ b/lib/galaxy/tool_util/verify/__init__.py @@ -184,12 +184,12 @@ def _bam_to_sam(local_name, temp_name): temp_local = tempfile.NamedTemporaryFile(suffix='.sam', prefix='local_bam_converted_to_sam_') with tempfile.NamedTemporaryFile(suffix='.sam', prefix='history_bam_converted_to_sam_', delete=False) as temp: try: - pysam.view('-h', '-o%s' % temp_local.name, local_name) + pysam.view('-h', '-o', temp_local.name, local_name, catch_stdout=False) except Exception as e: msg = "Converting local (test-data) BAM to SAM failed: %s" % unicodify(e) raise Exception(msg) try: - pysam.view('-h', '-o%s' % temp.name, temp_name) + pysam.view('-h', '-o', temp.name, temp_name, catch_stdout=False) except Exception as e: msg = "Converting history BAM to SAM failed: %s" % unicodify(e) raise Exception(msg) From 1cf34d74d063094343328d18adb8e4328e06a69e Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Thu, 27 May 2021 14:58:26 +0200 Subject: [PATCH 2/3] psyam should not add a `@PG` headerline i.e. leave the sam content of the bam file untouched --- lib/galaxy/tool_util/verify/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/tool_util/verify/__init__.py b/lib/galaxy/tool_util/verify/__init__.py index e59be9540db..5414d31ac75 100644 --- a/lib/galaxy/tool_util/verify/__init__.py +++ b/lib/galaxy/tool_util/verify/__init__.py @@ -184,12 +184,12 @@ def _bam_to_sam(local_name, temp_name): temp_local = tempfile.NamedTemporaryFile(suffix='.sam', prefix='local_bam_converted_to_sam_') with tempfile.NamedTemporaryFile(suffix='.sam', prefix='history_bam_converted_to_sam_', delete=False) as temp: try: - pysam.view('-h', '-o', temp_local.name, local_name, catch_stdout=False) + pysam.view('-h', '--no-PG', '-o', temp_local.name, local_name, catch_stdout=False) except Exception as e: msg = "Converting local (test-data) BAM to SAM failed: %s" % unicodify(e) raise Exception(msg) try: - pysam.view('-h', '-o', temp.name, temp_name, catch_stdout=False) + pysam.view('-h', '--no-PG', '-o', temp.name, temp_name, catch_stdout=False) except Exception as e: msg = "Converting history BAM to SAM failed: %s" % unicodify(e) raise Exception(msg) From 01eba8ee7a509ca52d8d9846a9e8d44609851d86 Mon Sep 17 00:00:00 2001 From: Matthias Bernt Date: Thu, 27 May 2021 15:10:05 +0200 Subject: [PATCH 3/3] add ftype for sam_to_bam test to also convert this to sam in tests --- test/functional/tools/sam_to_bam.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/functional/tools/sam_to_bam.xml b/test/functional/tools/sam_to_bam.xml index b01152a7670..3420ed73ec9 100644 --- a/test/functional/tools/sam_to_bam.xml +++ b/test/functional/tools/sam_to_bam.xml @@ -11,7 +11,7 @@ cat '$input1' > '$out_file1' - +