summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/astral/package.py
blob: 4a06d3658a0eca2b745d4b119a9ddba9af3a2dfb (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
# 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 os.path

from spack.package import *


class Astral(Package):
    """ASTRAL is a tool for estimating an unrooted species tree given a set of
    unrooted gene trees."""

    homepage = "https://github.com/smirarab/ASTRAL"
    url = "https://github.com/smirarab/ASTRAL/archive/v4.10.7.tar.gz"

    license("Apache-2.0")

    version("5.7.1", sha256="8aa6fd4324efca325d3dde432517090fac314bea95f407b1dd59977181fec77e")
    version(
        "5.6.1",
        sha256="b49a67c9fe19c0c92a89dc2f1a3928840e698a53054a595c61546ca98448a076",
        url="https://github.com/smirarab/ASTRAL/archive/untagged-697f19dbce69929ece09.tar.gz",
    )
    version("4.10.7", sha256="314b49e0129ec06a7c78a1b60d590259ede6a5e75253407031e108d8048fcc79")

    depends_on("java", type=("build", "run"))
    depends_on("zip", type="build")

    def install(self, spec, prefix):
        make = Executable("./make.sh")
        make()
        mkdirp(prefix.bin)
        install_tree("lib", prefix.tools.lib)
        jar_file = f"astral.{self.version}.jar"
        install(jar_file, prefix.tools)

        script_sh = join_path(os.path.dirname(__file__), "astral.sh")
        script = prefix.bin.astral
        install(script_sh, script)
        set_executable(script)

        java = self.spec["java"].prefix.bin.java
        kwargs = {"ignore_absent": False, "backup": False, "string": False}
        filter_file("^java", java, script, **kwargs)
        filter_file("astral.jar", join_path(prefix.tools, jar_file), script, **kwargs)

    def setup_run_environment(self, env):
        env.set("ASTRAL_HOME", self.prefix.tools)