summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/bwa/package.py
blob: ad003282995649155d147971e7b028761e103a03 (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
# Copyright 2013-2024 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)

import platform

from spack.package import *


class Bwa(Package):
    """Burrow-Wheeler Aligner for pairwise alignment between DNA sequences."""

    homepage = "https://github.com/lh3/bwa"
    url = "https://github.com/lh3/bwa/releases/download/v0.7.15/bwa-0.7.15.tar.bz2"

    license("GPL-3.0-only")

    version("0.7.17", sha256="de1b4d4e745c0b7fc3e107b5155a51ac063011d33a5d82696331ecf4bed8d0fd")
    version("0.7.15", sha256="2f56afefa49acc9bf45f12edb58e412565086cc20be098b8bf15ec07de8c0515")
    version("0.7.13", sha256="559b3c63266e5d5351f7665268263dbb9592f3c1c4569e7a4a75a15f17f0aedc")
    version(
        "0.7.12",
        sha256="285f55b7fa1f9e873eda9a9b06752378a799ecdecbc886bbd9ba238045bf62e0",
        url="https://github.com/lh3/bwa/archive/0.7.12.tar.gz",
    )

    depends_on("zlib-api")
    depends_on("sse2neon", when="target=aarch64:")

    patch(
        "bwa_for_aarch64.patch",
        sha256="b77213b16cf8760f01e32f9a0b2cd8988cf7bac48a11267100f703cbd55c4bfd",
        when="target=aarch64:",
    )

    def install(self, spec, prefix):
        zlib_inc_path = spec["zlib-api"].prefix.include
        if platform.machine() == "aarch64":
            sse2neon_inc_path = spec["sse2neon"].prefix.include
            filter_file(
                r"^INCLUDES=",
                "INCLUDES=-I%s -I%s" % (zlib_inc_path, sse2neon_inc_path),
                "Makefile",
            )
        else:
            filter_file(r"^INCLUDES=", "INCLUDES=-I%s" % zlib_inc_path, "Makefile")
        filter_file(r"^LIBS=", "LIBS=-L%s " % spec["zlib-api"].prefix.lib, "Makefile")
        # use spack C compiler
        filter_file("^CC=.*", "CC={0}".format(spack_cc), "Makefile")
        # fix gcc 10+ errors
        if self.spec.satisfies("%gcc@10:"):
            filter_file(
                "const uint8_t rle_auxtab[8]",
                "extern const uint8_t rle_auxtab[8]",
                "rle.h",
                string=True,
            )
        make()

        mkdirp(prefix.bin)
        install("bwa", join_path(prefix.bin, "bwa"))
        set_executable(join_path(prefix.bin, "bwa"))
        mkdirp(prefix.doc)
        install("README.md", prefix.doc)
        install("NEWS.md", prefix.doc)
        mkdirp(prefix.man.man1)
        install("bwa.1", prefix.man.man1)