[med-svn] r16855 - trunk/packages/python-biopython/trunk/debian/patches
Andreas Tille
tille at moszumanska.debian.org
Tue Apr 29 09:05:48 UTC 2014
Author: tille
Date: 2014-04-29 09:05:48 +0000 (Tue, 29 Apr 2014)
New Revision: 16855
Added:
trunk/packages/python-biopython/trunk/debian/patches/biopython-from-pil-import-image.patch
trunk/packages/python-biopython/trunk/debian/patches/use_upstream_patch_for_bwa_test.patch
Modified:
trunk/packages/python-biopython/trunk/debian/patches/series
Log:
Add some patches enhancing the test suite
Added: trunk/packages/python-biopython/trunk/debian/patches/biopython-from-pil-import-image.patch
===================================================================
--- trunk/packages/python-biopython/trunk/debian/patches/biopython-from-pil-import-image.patch (rev 0)
+++ trunk/packages/python-biopython/trunk/debian/patches/biopython-from-pil-import-image.patch 2014-04-29 09:05:48 UTC (rev 16855)
@@ -0,0 +1,31 @@
+Author: Jakub Wilk <jwilk at debian.org>
+Last-Update: Mon, 28 Apr 2014 15:39:59 +0200
+Description: Avoid python-imaging compatibility package
+ python-imaging's description more or less says what you have to change:
+ “PIL used to provide a PIL.pth file which allowed you to `import
+ Image` but this is deprecated. Use `from PIL import Image` now, or
+ install this compatibility package to temporarily get the old behavior
+ back
+
+--- a/Tests/test_GenomeDiagram.py
++++ b/Tests/test_GenomeDiagram.py
+@@ -27,7 +27,7 @@ except ImportError:
+ "Install reportlab if you want to use Bio.Graphics.")
+
+ try:
+- import Image
++ from PIL import Image
+ from reportlab.graphics import renderPM
+ except ImportError:
+ #This is an optional part of ReportLab, so may not be installed.
+--- a/Tests/test_GraphicsBitmaps.py
++++ b/Tests/test_GraphicsBitmaps.py
+@@ -35,7 +35,7 @@ except:
+ "bitmaps with Bio.Graphics.")
+ try:
+ # Skip the test if PIL is not installed
+- import Image as i
++ from PIL import Image as i
+ del i
+ except:
+ raise MissingPythonDependencyError(
Modified: trunk/packages/python-biopython/trunk/debian/patches/series
===================================================================
--- trunk/packages/python-biopython/trunk/debian/patches/series 2014-04-29 06:42:27 UTC (rev 16854)
+++ trunk/packages/python-biopython/trunk/debian/patches/series 2014-04-29 09:05:48 UTC (rev 16855)
@@ -1,2 +1,4 @@
fix_test_emboss.patch
add_missing_test_Fasttree_tool.patch
+use_upstream_patch_for_bwa_test.patch
+biopython-from-pil-import-image.patch
Added: trunk/packages/python-biopython/trunk/debian/patches/use_upstream_patch_for_bwa_test.patch
===================================================================
--- trunk/packages/python-biopython/trunk/debian/patches/use_upstream_patch_for_bwa_test.patch (rev 0)
+++ trunk/packages/python-biopython/trunk/debian/patches/use_upstream_patch_for_bwa_test.patch 2014-04-29 09:05:48 UTC (rev 16855)
@@ -0,0 +1,191 @@
+Author: Saket Choudhary <saketkc at gmail.com>
+Last-Update: Tue, 29 Apr 2014 01:37:43 +0530
+Description: Skip bwa aln tests if it is an unrecognized command
+Comment: Taken over from upstream commit d884ee6e12a798b974b3a3996e22b5292ab79be6
+Forwarded-Upstream: yes
+
+--- a/Tests/test_BWA_tool.py
++++ b/Tests/test_BWA_tool.py
+@@ -9,12 +9,12 @@ from Bio import MissingExternalDependenc
+ import sys
+ import os
+ import unittest
+-from Bio import SeqIO
+-from Bio import AlignIO
+-from Bio.Sequencing.Applications import BwaIndexCommandline, BwaAlignCommandline
+-from Bio.Sequencing.Applications import BwaSamseCommandline, BwaSampeCommandline
+-from Bio.Sequencing.Applications import BwaBwaswCommandline
+-from Bio.Application import ApplicationError
++#TODO from Bio.Sequencing.Applications import BwaBwaswCommandline
++from Bio.Sequencing.Applications import BwaIndexCommandline
++from Bio.Sequencing.Applications import BwaAlignCommandline
++from Bio.Sequencing.Applications import BwaSamseCommandline
++from Bio.Sequencing.Applications import BwaSampeCommandline
++
+
+ #################################################################
+
+@@ -29,11 +29,8 @@ if sys.platform == "win32":
+ prog_files = os.environ["PROGRAMFILES"]
+ except KeyError:
+ prog_files = r"C:\Program Files"
+- #A default path of C:\Program Files\bwa.exe was chosen
+- #but this path can be edited depending on where bwa is located
+-
+- likely_dirs = ["bwa", "BWA", "Bwa", "bwa-0.6.2"]
+- likely_exes = ["bwa.exe", "BWA.exe", "Bwa.exe"]
++ likely_dirs = ["bwa", "bwa-0.6.2", ""]
++ likely_exes = ["bwa"]
+ for folder in likely_dirs:
+ if os.path.isdir(os.path.join(prog_files, folder)):
+ for filename in likely_exes:
+@@ -50,52 +47,96 @@ else:
+ #really the bwa tool's output
+ bwa_found = False
+ if "not found" not in output and "bwa" in output \
+- and "alignment via Burrows-Wheeler transformation" in output:
++ and "alignment via Burrows-Wheeler transformation" in output:
+ bwa_exe = "bwa"
+
+ if not bwa_exe:
+- raise MissingExternalDependencyError(\
+- "Install bwa and correctly set the file path to the program if you want to use it from Biopython")
++ raise MissingExternalDependencyError("Install bwa and correctly set"
++ " the file path to the program if"
++ " you want to use it from Biopython")
+
+
+ class BwaTestCase(unittest.TestCase):
+ """Class for implementing BWA test cases"""
+ def setUp(self):
+- self.reference_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), "BWA", "human_g1k_v37_truncated.fasta")
+- self.infile1 = os.path.join(os.path.dirname(os.path.abspath(__file__)), "BWA", "HNSCC1_1_truncated.fastq")
+- self.infile2 = os.path.join(os.path.dirname(os.path.abspath(__file__)), "BWA", "HNSCC1_2_truncated.fastq")
+- self.saifile1 = os.path.join(os.path.dirname(os.path.abspath(__file__)), "BWA", "1.sai")
+- self.saifile2 = os.path.join(os.path.dirname(os.path.abspath(__file__)), "BWA", "2.sai")
+- self.samfile1 = os.path.join(os.path.dirname(os.path.abspath(__file__)), "BWA", "1.sam")
+- self.samfile2 = os.path.join(os.path.dirname(os.path.abspath(__file__)), "BWA", "2.sam")
+- self.samfile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "BWA", "out.sam")
++ self.reference_file = "BWA/human_g1k_v37_truncated.fasta"
++ self.reference_extensions = ['amb', 'ann', 'bwt', 'pac', 'sa']
++ self.infile1 = "BWA/HNSCC1_1_truncated.fastq"
++ self.infile2 = "BWA/HNSCC1_2_truncated.fastq"
++ self.saifile1 = "BWA/1.sai"
++ self.saifile2 = "BWA/2.sai"
++ self.samfile1 = "BWA/1.sam"
++ self.samfile2 = "BWA/2.sam"
++ self.samfile = "BWA/out.sam"
++ self.files_to_clean = [self.saifile1, self.saifile2,
++ self.samfile1, self.samfile2,
++ self.samfile]
++
++ def tearDown(self):
++ for filename in self.files_to_clean:
++ if os.path.isfile(filename):
++ os.remove(filename)
++ for extension in self.reference_extensions:
++ index_file = self.reference_file + "." + extension
++ if os.path.exists(index_file):
++ os.remove(index_file)
+
+ def test_index(self):
+ """Test for creating index files for the reference genome fasta file"""
+- cmdline = BwaIndexCommandline()
++ cmdline = BwaIndexCommandline(bwa_exe)
+ cmdline.set_parameter("infile", self.reference_file)
+ cmdline.set_parameter("algorithm", "bwtsw")
+ stdout, stderr = cmdline()
+- output = stdout.startswith("[bwt_gen]")
++ for extension in self.reference_extensions:
++ index_file = self.reference_file + "." + extension
++ self.assertTrue(os.path.exists(index_file),
++ "Index File %s not found"
++ % (index_file))
+ self.assertTrue(stdout.startswith("[bwt_gen]"),
+- "FASTA indexing failed:\n%s\nStdout:%s" \
++ "FASTA indexing failed:\n%s\nStdout:%s"
+ % (cmdline, stdout))
+
+ def do_aln(self, in_file, out_file):
+ """Test for generating sai files given the reference and read file"""
+- cmdline = BwaAlignCommandline()
++ cmdline = BwaAlignCommandline(bwa_exe)
+ cmdline.set_parameter("reference", self.reference_file)
+ cmdline.read_file = in_file
+ self.assertTrue(os.path.isfile(in_file))
+ stdout, stderr = cmdline(stdout=out_file)
+
+ self.assertTrue("fail to locate the index" not in stderr,
+- "Error aligning sequence to reference:\n%s\nStderr:%s" \
++ "Error aligning sequence to reference:\n%s\nStderr:%s"
+ % (cmdline, stderr))
+
++ def skip_aln_tests(self):
++ """As reported on http://lists.open-bio.org/pipermail/biopython-dev/2014-April/011342.html
++ 'bwa aln' is failing for bwa[0.7.6a-r433]
++ Tests using 'aln' should be skipped in that case"""
++
++ aln_output = getoutput("bwa aln")
++ if "unrecognized" in aln_output:
++ return True
++ return False
++
++ def create_fasta_index(self):
++ """Creates index for fasta file
++ BWA requires an indexed fasta for each alignment operation.
++ This should be called to create an index before any alignment
++ operation.
++
++ """
++ cmdline = BwaIndexCommandline(bwa_exe)
++ cmdline.set_parameter("infile", self.reference_file)
++ cmdline.set_parameter("algorithm", "bwtsw")
++ stdout, stderr = cmdline()
++
+ def test_samse(self):
+ """Test for single end sequencing """
+- cmdline = BwaSamseCommandline()
++ if self.skip_aln_tests():
++ return
++ self.create_fasta_index()
++ self.do_aln(self.infile1, self.saifile1)
++ cmdline = BwaSamseCommandline(bwa_exe)
+ cmdline.set_parameter("reference", self.reference_file)
+ cmdline.set_parameter("read_file", self.infile1)
+ cmdline.set_parameter("sai_file", self.saifile1)
+@@ -104,16 +145,20 @@ class BwaTestCase(unittest.TestCase):
+ with open(self.samfile1, "r") as handle:
+ headline = handle.readline()
+ self.assertTrue(headline.startswith("@SQ"),
+- "Error generating sam files:\n%s\nOutput starts:%s" \
++ "Error generating sam files:\n%s\nOutput starts:%s"
+ % (cmdline, headline))
+
+ def test_sampe(self):
+ """Test for generating samfile by paired end sequencing"""
++ if self.skip_aln_tests():
++ return
++ self.create_fasta_index()
++
+ ##Generate sai files from paired end data
+ self.do_aln(self.infile1, self.saifile1)
+ self.do_aln(self.infile2, self.saifile2)
+
+- cmdline = BwaSampeCommandline()
++ cmdline = BwaSampeCommandline(bwa_exe)
+ cmdline.set_parameter("reference", self.reference_file)
+ cmdline.set_parameter("sai_file1", self.saifile1)
+ cmdline.set_parameter("sai_file2", self.saifile2)
+@@ -124,10 +169,11 @@ class BwaTestCase(unittest.TestCase):
+ with open(self.samfile, "r") as handle:
+ headline = handle.readline()
+ self.assertTrue(headline.startswith("@SQ"),
+- "Error generating sam files:\n%s\nOutput starts:%s" \
++ "Error generating sam files:\n%s\nOutput starts:%s"
+ % (cmdline, headline))
+
+
+ if __name__ == "__main__":
+ runner = unittest.TextTestRunner(verbosity=2)
+ unittest.main(testRunner=runner)
++
More information about the debian-med-commit
mailing list