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

from spack.package import *


class Dock(Package):
    """DOCK is a molecular docking program used in drug discovery.

    This program, given a protein binding site and a small molecule, tries
    to predict the correct binding mode of the small molecule in the binding
    site, and the associated binding energy."""

    homepage = "http://dock.compbio.ucsf.edu/DOCK_6/index.htm"
    url = "file://{0}/dock.6.9_source.tar.gz".format(os.getcwd())
    maintainers("snehring")
    manual_download = True

    version("6.9", sha256="c2caef9b4bb47bb0cb437f6dc21f4c605fd3d0d9cc817fa13748c050dc87a5a8")

    variant("mpi", default=True, description="Enable mpi")

    depends_on("bison", type="build")
    depends_on("flex", type="build")
    depends_on("mpi", when="+mpi")

    def setup_build_environment(self, env):
        if "+mpi" in self.spec:
            env.set("MPICH_HOME", self.spec["mpi"].prefix)

    def install(self, spec, prefix):
        compiler_targets = {"gcc": "gnu", "intel": "intel", "pgi": "pgi", "sgi": "sgi"}

        if self.compiler.name not in compiler_targets:
            template = "Unsupported compiler {0}! Supported compilers: {1}"
            err = template.format(self.compiler.name, ", ".join(list(compiler_targets.keys())))

            raise InstallError(err)

        if self.compiler.name == "pgi" and "+mpi" in spec:
            raise InstallError("Parallel output is not supported with pgi.")

        with working_dir("install"):
            sh_args = ["./configure", compiler_targets[self.compiler.name]]
            config_source = compiler_targets[self.compiler.name]

            if "+mpi" in spec:
                sh_args.append("parallel")
                config_source = config_source + ".parallel"

            if self.spec.satisfies("@6.9%gcc@10:"):
                # Versions of gcc before 10 treat mismatched arguments as a warning
                # 10+ makes it an error. This makes it a warning again
                filter_file(
                    r"(-fno-second-underscore)", r"\1 -fallow-argument-mismatch", config_source
                )

            which("sh")(*sh_args)
            which("make")("YACC=bison -o y.tab.c")

        mkdirp(prefix.bin)
        install_tree("bin", prefix.bin)