ComputeVM: picard.py

File picard.py, 3.6 KB (added by george, 9 years ago)
Line 
1##
2# Copyright 2009-2015 Ghent University
3#
4# This file is part of EasyBuild,
5# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
6# with support of Ghent University (http://ugent.be/hpc),
7# the Flemish Supercomputer Centre (VSC) (https://vscentrum.be/nl/en),
8# the Hercules foundation (http://www.herculesstichting.be/in_English)
9# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
10#
11# http://github.com/hpcugent/easybuild
12#
13# EasyBuild is free software: you can redistribute it and/or modify
14# it under the terms of the GNU General Public License as published by
15# the Free Software Foundation v2.
16#
17# EasyBuild is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with EasyBuild.  If not, see <http://www.gnu.org/licenses/>.
24##
25"""
26Support for building and installing picard, implemented as an easyblock.
27
28@author: Stijn De Weirdt (Ghent University)
29@author: Dries Verdegem (Ghent University)
30@author: Kenneth Hoste (Ghent University)
31@author: Pieter De Baets (Ghent University)
32@author: Jens Timmerman (Ghent University)
33"""
34
35import os
36import re
37import shutil
38
39from distutils.version import LooseVersion
40from easybuild.framework.easyblock import EasyBlock
41
42
43class EB_picard(EasyBlock):
44    """Support for building and installing picard."""
45
46    def configure_step(self):
47        """No configure step for picard"""
48        pass
49
50    def build_step(self):
51        """No build step for picard"""
52        pass
53
54    def install_step(self):
55        """Install picard by copying required files"""
56        # recent version may contain more than just the picard-tools subdirectory
57        picard_tools_dir = 'picard-tools-%s' % self.version
58        if not re.search("%s/?$" % picard_tools_dir, self.cfg['start_dir']):
59            self.cfg['start_dir'] = os.path.join(self.cfg['start_dir'], picard_tools_dir)
60            if not os.path.exists(self.cfg['start_dir']):
61                self.log.error("Path %s to copy files from doesn't exist." % self.cfg['start_dir'])
62
63        for jar in os.listdir(self.cfg['start_dir']):
64            src = os.path.join(self.cfg['start_dir'], jar)
65            dst = os.path.join(self.installdir, jar)
66            try:
67                shutil.copy2(src, dst)
68                self.log.info("Successfully copied %s to %s" % (src, dst))
69            except OSError, err:
70                self.log.error("Failed to copy %s to %s (%s)" % (src, dst, err))
71
72    def sanity_check_step(self):
73        """Custom sanity check for picard"""
74        if LooseVersion(self.version) < LooseVersion('1.120'):
75            jar_files = ['picard']
76            if LooseVersion(self.version) < LooseVersion('1.115'):
77                jar_files.append('sam')
78            custom_paths = {
79                'files': ["%s-%s.jar" % (x, self.version) for x in jar_files],
80                'dirs': [],
81            }
82        else:
83            jar_files = ['picard', 'picard-lib', "htsjdk-%s" % (self.version)]
84            custom_paths = {
85                'files': ["%s.jar" % (x) for x in jar_files],
86                'dirs': [],
87            }
88        super(EB_picard, self).sanity_check_step(custom_paths=custom_paths)
89
90    def make_module_extra(self):
91        """Add module entries specific to picard"""
92        txt = super(EB_picard, self).make_module_extra()
93        txt += self.module_generator.prepend_paths('PATH', '')
94        return txt