From: =?utf-8?q?=C3=89tienne_Mollier?= <emollier@debian.org>
Date: Sat, 14 Sep 2024 09:48:28 +0200
Subject: expect muscle3 as executable instead of muscle.
Bug-Debian: https://bugs.debian.org/1009118
Forwarded: not-needed
Last-Update: 2022-11-24

When installed concurrently, muscle3 may be a preferable default over plain
muscle because the latter would probably be muscle 5, which is not compatible
with the biopython wrapper.

Forwarding is not needed since wrappers are deprecated and due to be removed
in an upcoming biopython version.
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- python-biopython.orig/Bio/Align/Applications/_Muscle.py
+++ python-biopython/Bio/Align/Applications/_Muscle.py
@@ -11,6 +11,14 @@
 from Bio.Application import AbstractCommandline
 from subprocess import getoutput
 
+# Prefer defaulting to muscle3, as can be installed alongside muscle version 5.
+default_muscle = "muscle3"
+output = getoutput(default_muscle + " --version")
+if "not found" in output or "not recognized" in output:
+    # The below should ascertain plain muscle is muscle 3 indeed.
+    output = getoutput("muscle --version")
+    if "MUSCLE" in output and "Edgar" in output:
+        default_muscle = "muscle"
 
 class MuscleCommandline(AbstractCommandline):
     r"""Command line wrapper for the multiple alignment program MUSCLE.
@@ -44,7 +52,7 @@
 
     """
 
-    def __init__(self, cmd="muscle", **kwargs):
+    def __init__(self, cmd=default_muscle, **kwargs):
         """Initialize the class."""
         CLUSTERING_ALGORITHMS = ["upgma", "upgmb", "neighborjoining"]
         DISTANCE_MEASURES_ITER1 = [
--- python-biopython.orig/Tests/test_Muscle_tool.py
+++ python-biopython/Tests/test_Muscle_tool.py
@@ -57,12 +57,18 @@
 else:
     from subprocess import getoutput
 
-    output = getoutput("muscle -version")
+    output = getoutput("muscle3 -version")
     # Since "not found" may be in another language, try and be sure this is
     # really the MUSCLE tool's output
     if "not found" not in output and "not recognized" not in output:
         if "MUSCLE" in output and "Edgar" in output:
-            muscle_exe = "muscle"
+            muscle_exe = "muscle3"
+    else:
+        # Maybe the unversionned version will still be muscle 3.
+        output = getoutput("muscle -version")
+        if "not found" not in output and "not recognized" not in output:
+            if "MUSCLE" in output and "Edgar" in output:
+                muscle_exe = "muscle"
 
 if not muscle_exe:
     raise MissingExternalDependencyError(
@@ -189,7 +195,7 @@
         cmdline.set_parameter("stable")
         #Set some others options just to test them
         cmdline.set_parameter("maxiters", 2)
-        self.assertEqual(str(cmdline).rstrip(), "muscle -in Fasta/f002 -maxiters 2 -stable")
+        self.assertEqual(str(cmdline).rstrip(), "muscle3 -in Fasta/f002 -maxiters 2 -stable")
         result, out_handle, err_handle = generic_run(cmdline)
         #NOTE: generic_run has been removed from Biopython
         print(err_handle.read())
