summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/openrasmol/package.py
blob: 7c6b7ac76e2404649e576e2f1cf09472129071a1 (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
# Copyright 2013-2023 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.package import *


class Openrasmol(MakefilePackage):
    """RasMol is a molecular graphics program intended for the
    visualisation of proteins, nucleic acids and small molecules."""

    homepage = "http://www.openrasmol.org/"
    url = "https://sourceforge.net/projects/openrasmol/files/RasMol/RasMol_2.7.5/RasMol-2.7.5.2.tar.gz"

    license("GPL-2.0-only")

    version("2.7.5.2", sha256="b975e6e69d5c6b161a81f04840945d2f220ac626245c61bcc6c56181b73a5718")

    depends_on("imake", type="build")
    depends_on("libxext", type="link")
    depends_on("libxi", type="link")

    depends_on("cbflib@0.9.2", type="link")
    depends_on("cqrlib@1.1.2", type="link")
    depends_on("cvector@1.0.3", type="link")
    depends_on("neartree@3.1", type="link")
    depends_on("xforms@1.0.91", type="link")

    patch("rasmol_noqa.patch")
    patch("rasmol_help.patch")

    def edit(self, spec, prefix):
        with working_dir("src"):
            # Imakefile
            bash = which("bash")
            bash("./rasmol_build_options.sh")
            # host.def
            with open("host.def", "w") as f:
                f.write("#ifdef AfterVendorCF\n")
                f.write("#define CcCmd {0}\n".format(spack_cc))
                f.write("#endif\n")

    def setup_build_environment(self, env):
        env.set("XFORMSLIB_DIR", self.spec["xforms"].prefix)
        env.set("CBFLIB_DIR", self.spec["cbflib"].prefix)
        env.set("CQRLIB_DIR", self.spec["cqrlib"].prefix)
        env.set("CVECTOR_DIR", self.spec["cvector"].prefix)
        env.set("NEARTREE_DIR", self.spec["neartree"].prefix)

    def build(self, spec, prefix):
        with working_dir("src"):
            bash = which("bash")
            bash("./build_all.sh")

    def install(self, spec, prefix):
        install_tree("./data", prefix.sample)
        install_tree("./doc", prefix.doc)
        with working_dir("src"):
            bash = which("bash")
            bash("./rasmol_install.sh", "--prefix={0}".format(prefix))

    def test_rasmol(self):
        """run rasmol on sample"""
        opts = [
            "-insecure",
            "-script",
            join_path(self.test_suite.current_test_data_dir, "test.rsc"),
            join_path(self.prefix.sample, "1crn.pdb"),
        ]
        rasmol = which(self.prefix.bin.rasmol)
        rasmol(*opts)