summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/hal/package.py
blob: b598c127f3b0219b5733395ec9d136e0542e0ff0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)


from spack import *


class Hal(MakefilePackage):
    """HAL is a structure to efficiently store and index multiple
    genome alignments and ancestral reconstructions.

    HAL is a graph-based representation which provides several advantages
    over matrix/block-based formats such as MAF, such as
    improved scalability and the ability to perform queries with
    respect to an arbitrary reference or subtree."""

    homepage = "https://github.com/ComparativeGenomicsToolkit/hal"
    url      = "https://github.com/ComparativeGenomicsToolkit/hal/archive/release-V2.1.tar.gz"

    version('2.1', '540255be1af55abf390359fe034b82d7e61bdf6c3277df3cc01259cd450994e5')

    maintainers = ['ilbiondo']

    # HAL expects to be compiled alongside sonlib so we need both the
    # source version and python library version

    depends_on('hdf5+cxx~mpi')
    depends_on('sonlib',    type='build')
    depends_on('python',    type='run')
    depends_on('py-sonlib', type='run')

    # As we install sonlib seperately the include.mk needs
    # editing to comment out an include

    def patch(self):
        includemk = FileFilter('include.mk')
        includemk.filter(r'^include  \$\{sonLibRootDir\}/include\.mk',
                         '# include  ${sonLibRootDir}/include.mk')

    def setup_build_environment(self, env):
        env.set('sonLibRootDir', self.spec['sonlib'].prefix)

    def install(self, spec, prefix):

        # First the easy bit

        install_tree('bin', prefix.bin)
        install_tree('lib', prefix.lib)

        # Copy the rest of the "toolkit" as to a directory named hal
        # in order that the python libraries can be found and used

        haldirs = ['alignmentDepth',
                   'analysis',
                   'api',
                   'assemblyHub',
                   'benchmarks',
                   'blockViz',
                   'doc',
                   'extra',
                   'extract',
                   'fasta',
                   'liftover',
                   'lod',
                   'maf',
                   'modify',
                   'mutations',
                   'objs',
                   'phyloP',
                   'randgen',
                   'stats',
                   'synteny',
                   'testdata',
                   'validate']

        for folder in haldirs:

            install_tree(folder, join_path(self.prefix, 'hal', folder))

        install('__init__.py', join_path(self.prefix, 'hal'))

        # Now in order to make things useful we copy some python tools to bin

        halpyfiles = ['analysis/halContiguousRegions.py',
                      'assemblyHub/hal2assemblyHub.py',
                      'liftover/halLiftoverStatus.py',
                      'lod/halLodBenchmark.py',
                      'lod/halLodInterpolate.py',
                      'maf/hal2mafMP.py',
                      'phyloP/halPhyloPMP.py']

        for pyfile in halpyfiles:

            install(pyfile, self.prefix.bin)

    # The hal directory is a python library so we set the path
    # to be the installation root

    def setup_run_environment(self, env):
        env.prepend_path('PYTHONPATH', self.prefix)