1818@author: Kenneth Hoste (Ghent University)
1919@author: George Tsouloupas <[email protected] > 2020"""
21-
2221import os
23- import shutil
2422from distutils .version import LooseVersion
2523
2624from easybuild .easyblocks .generic .configuremake import ConfigureMake
27- from easybuild .tools .build_log import EasyBuildError
25+ from easybuild .tools .filetools import copy_file , mkdir
2826
2927
3028class EB_BWA (ConfigureMake ):
@@ -35,45 +33,55 @@ class EB_BWA(ConfigureMake):
3533 def __init__ (self , * args , ** kwargs ):
3634 """Add extra config options specific to BWA."""
3735 super (EB_BWA , self ).__init__ (* args , ** kwargs )
38- self .files = []
3936
40- def configure_step (self ):
41- """
42- Empty function as bwa comes with _no_ configure script
43- """
44- self .files = ["bwa" , "qualfa2fq.pl" , "xa2multi.pl" ]
45- if LooseVersion (self .version ) < LooseVersion ("0.7.0" ):
37+ self .files = ['bwa' , 'qualfa2fq.pl' , 'xa2multi.pl' ]
38+ if LooseVersion (self .version ) < LooseVersion ('0.7.0' ):
4639 # solid2fastq was dropped in recent versions because the same functionality
4740 # is covered by other tools already
4841 # cfr. http://osdir.com/ml/general/2010-10/msg26205.html
49- self .files .append ("solid2fastq.pl" )
42+ self .files .append ('solid2fastq.pl' )
43+
44+ def configure_step (self ):
45+ """
46+ Empty function as BWA comes with _no_ configure script
47+ """
48+ pass
49+
50+ def build_step (self ):
51+ """Custom build procedure: pass down compiler command and options as arguments to 'make'."""
52+
53+ for env_var in ('CC' , 'CFLAGS' ):
54+ if env_var + '=' not in self .cfg ['buildopts' ]:
55+ self .cfg .update ('buildopts' , env_var + '="$' + env_var + '"' )
56+
57+ super (EB_BWA , self ).build_step ()
5058
5159 def install_step (self ):
5260 """
5361 Install by copying files to install dir
5462 """
5563 srcdir = self .cfg ['start_dir' ]
5664 destdir = os .path .join (self .installdir , 'bin' )
57- mandir = os .path .join (self .installdir , 'man' )
58- manman1dir = os .path .join (self .installdir , 'man/man1' )
65+ mkdir (destdir )
66+ for filename in self .files :
67+ srcfile = os .path .join (srcdir , filename )
68+ copy_file (srcfile , destdir )
69+
5970 manfile = os .path .join (srcdir , 'bwa.1' )
60- srcfile = None
61- try :
62- os .makedirs (destdir )
63- os .makedirs (mandir )
64- os .makedirs (manman1dir )
65- for filename in self .files :
66- srcfile = os .path .join (srcdir , filename )
67- shutil .copy2 (srcfile , destdir )
68- shutil .copy2 (manfile , manman1dir )
69- except OSError as err :
70- raise EasyBuildError ("Copying %s to installation dir %s failed: %s" , srcfile , destdir , err )
71+ manman1dir = os .path .join (self .installdir , 'man' , 'man1' )
72+ mkdir (manman1dir , parents = True )
73+ copy_file (manfile , manman1dir )
7174
7275 def sanity_check_step (self ):
7376 """Custom sanity check for BWA."""
77+
7478 custom_paths = {
75- 'files' : [" bin/%s" % x for x in self .files ],
79+ 'files' : [os . path . join ( ' bin' , x ) for x in self .files ],
7680 'dirs' : []
7781 }
7882
79- super (EB_BWA , self ).sanity_check_step (custom_paths = custom_paths )
83+ # 'bwa' command doesn't have a --help option, but it does print help-like information to stderr
84+ # when run without arguments (and exits with exit code 1)
85+ custom_commands = ["bwa 2>&1 | grep 'index sequences in the FASTA format'" ]
86+
87+ super (EB_BWA , self ).sanity_check_step (custom_paths = custom_paths , custom_commands = custom_commands )
0 commit comments