[med-svn] [metabit] 02/02: Safely detect metaphlan script

Andreas Tille tille at debian.org
Tue Jul 26 12:17:43 UTC 2016


This is an automated email from the git hooks/post-receive script.

tille pushed a commit to branch master
in repository metabit.

commit c79db0f019ce096fc03d3a22d5d376c140a16dff
Author: Andreas Tille <tille at debian.org>
Date:   Tue Jul 26 14:17:09 2016 +0200

    Safely detect metaphlan script
---
 debian/patches/safely_detect_metaphlan.patch | 48 ++++++++++++++++++++++++++++
 debian/patches/series                        |  1 +
 2 files changed, 49 insertions(+)

diff --git a/debian/patches/safely_detect_metaphlan.patch b/debian/patches/safely_detect_metaphlan.patch
new file mode 100644
index 0000000..5859cd3
--- /dev/null
+++ b/debian/patches/safely_detect_metaphlan.patch
@@ -0,0 +1,48 @@
+Author: Andreas Tille <tille at debian.org>
+Last-Updates: Mon, 25 Jul 2016 14:09:29 +0200
+Description: Since MetaPhLan contains a script metaphlan2_strainer.py it is
+ undetermined which one comes first in list of glob.  This patch safely detects
+ the right metaphlan2 script
+
+--- a/parts.py
++++ b/parts.py
+@@ -404,11 +404,16 @@ def analyzing(makefile, config, metaphla
+ def _build_bowtie2_nodes(config, input_files_1, input_files_2, output_file,
+                          log_file, dependencies, options):
+ 
+-    metaphlan_script = glob(os.path.join(config.metaphlan_path, "metaphlan*.py"))[0]
+-    if metaphlan_script.endswith("metaphlan.py"):
+-        prefix = os.path.join(config.metaphlan_path, "bowtie2db", "mpa")
+-    elif metaphlan_script.endswith("metaphlan2.py"):
+-        prefix = os.path.join(config.metaphlan_path, "db_v20", "mpa_v20_m200")
++    prefix = ''
++    for metaphlan_script in glob(os.path.join(config.metaphlan_path, "metaphlan*.py")):
++        if metaphlan_script.endswith("metaphlan2.py"):
++            prefix = os.path.join(config.metaphlan_path, "db_v20", "mpa_v20_m200")
++            break
++        if metaphlan_script.endswith("metaphlan.py"):
++            prefix = os.path.join(config.metaphlan_path, "bowtie2db", "mpa")
++            break
++    if prefix == '':
++	raise "MetaPhLan not found at %s." % config.metaphlan_path
+     reference = prefix
+     
+     params = Bowtie2Node.customize(input_files_1,
+@@ -435,7 +440,16 @@ def _build_metaphlan_node(config, params
+         raise RuntimeError("No input given to metaphlan, you made a mistake somewhere.\n"
+                            "have you excluded all the libraries of sample %s ?" %Samplename)
+     else:
+-        metaphlan_script = glob(os.path.join(config.metaphlan_path, "metaphlan*.py"))[0]
++        metaphlan_script = ''
++        for m_script in glob(os.path.join(config.metaphlan_path, "metaphlan*.py")):
++            if m_script.endswith("metaphlan2.py"):
++                metaphlan_script = m_script
++                break
++            if m_script.endswith("metaphlan.py"):
++                metaphlan_script = m_script
++                break
++        if metaphlan_script == '':
++            raise "MetaPhLan not found at %s." % config.metaphlan_path
+         node = MetaphlanNode.customize(metaphlan_script,
+                                        threads=config.metaphlan_max_threads,
+                                        **params)
diff --git a/debian/patches/series b/debian/patches/series
index 1e62050..2c3639f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1 +1,2 @@
 use_debian_packaged_yaml.patch
+safely_detect_metaphlan.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/metabit.git



More information about the debian-med-commit mailing list