gnu: Use 'modify-phases' syntax.
[jackhill/guix/guix.git] / gnu / packages / machine-learning.scm
index 73c7874..291146b 100644 (file)
   #:use-module (guix svn-download)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system ocaml)
   #:use-module (guix build-system r)
   #:use-module (gnu packages)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cran)
   #:use-module (gnu packages dejagnu)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages image)
   #:use-module (gnu packages maths)
+  #:use-module (gnu packages ocaml)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -187,9 +190,9 @@ classification.")
                                  "@unittest.skip(\"Disabled by Guix\")\n"
                                  line)))
                #t))
-           (add-before 'configure 'autogen
+           (add-after 'disable-broken-tests 'autogen
              (lambda _
-               (zero? (system* "bash" "./autogen.sh")))))))
+               (zero? (system* "bash" "autogen.sh")))))))
       (inputs
        `(("python" ,python-2) ; only Python 2 is supported
          ("libxml2" ,libxml2)))
@@ -205,7 +208,7 @@ classification.")
       (description
        "The General Hidden Markov Model library (GHMM) is a C library with
 additional Python bindings implementing a wide range of types of @dfn{Hidden
-Markov Models} (HMM) and algorithms: discrete, continous emissions, basic
+Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic
 training, HMM clustering, HMM mixtures.")
       (license license:lgpl2.0+))))
 
@@ -239,6 +242,42 @@ networks) based on simulation of (stochastic) flow in graphs.")
     ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html
     (license license:gpl3)))
 
+(define-public ocaml-mcl
+  (package
+    (name "ocaml-mcl")
+    (version "12-068oasis4")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "https://github.com/fhcrc/mcl/archive/"
+             version ".tar.gz"))
+       (file-name (string-append name "-" version ".tar.gz"))
+       (sha256
+        (base32
+         "1l5jbhwjpsj38x8b9698hfpkv75h8hn3kj0gihjhn8ym2cwwv110"))))
+    (build-system ocaml-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-before 'configure 'patch-paths
+           (lambda _
+             (substitute* "configure"
+               (("SHELL = /bin/sh") (string-append "SHELL = "(which "sh"))))
+             (substitute* "setup.ml"
+               (("LDFLAGS=-fPIC")
+                (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh"))))
+             #t)))))
+    (home-page "https://github.com/fhcrc/mcl")
+    (synopsis "OCaml wrappers around MCL")
+    (description
+     "This package provides OCaml bindings for the MCL graph clustering
+algorithm.")
+    (license license:gpl3)))
+
+(define-public ocaml4.01-mcl
+  (package-with-ocaml4.01 ocaml-mcl))
+
 (define-public randomjungle
   (package
     (name "randomjungle")
@@ -337,54 +376,50 @@ sample proximities between pairs of cases.")
     (arguments
      '(#:tests? #f ;no check target
        #:phases
-       (alist-cons-after
-        'unpack 'delete-broken-symlinks
-        (lambda _
-          (for-each delete-file '("applications/arts/data"
-                                  "applications/asp/data"
-                                  "applications/easysvm/data"
-                                  "applications/msplicer/data"
-                                  "applications/ocr/data"
-                                  "examples/documented/data"
-                                  "examples/documented/matlab_static"
-                                  "examples/documented/octave_static"
-                                  "examples/undocumented/data"
-                                  "examples/undocumented/matlab_static"
-                                  "examples/undocumented/octave_static"
-                                  "tests/integration/data"
-                                  "tests/integration/matlab_static"
-                                  "tests/integration/octave_static"
-                                  "tests/integration/python_modular/tests"))
-          #t)
-        (alist-cons-after
-         'unpack 'change-R-target-path
-         (lambda* (#:key outputs #:allow-other-keys)
-           (substitute* '("src/interfaces/r_modular/CMakeLists.txt"
-                          "src/interfaces/r_static/CMakeLists.txt"
-                          "examples/undocumented/r_modular/CMakeLists.txt")
-             (("\\$\\{R_COMPONENT_LIB_PATH\\}")
-              (string-append (assoc-ref outputs "out")
-                             "/lib/R/library/")))
-           #t)
-         (alist-cons-after
-          'unpack 'fix-octave-modules
-          (lambda* (#:key outputs #:allow-other-keys)
-            (substitute* '("src/interfaces/octave_modular/CMakeLists.txt"
-                           "src/interfaces/octave_static/CMakeLists.txt")
-              (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}")
-               "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave"))
+       (modify-phases %standard-phases
+         (add-after 'unpack 'delete-broken-symlinks
+           (lambda _
+             (for-each delete-file '("applications/arts/data"
+                                     "applications/asp/data"
+                                     "applications/easysvm/data"
+                                     "applications/msplicer/data"
+                                     "applications/ocr/data"
+                                     "examples/documented/data"
+                                     "examples/documented/matlab_static"
+                                     "examples/documented/octave_static"
+                                     "examples/undocumented/data"
+                                     "examples/undocumented/matlab_static"
+                                     "examples/undocumented/octave_static"
+                                     "tests/integration/data"
+                                     "tests/integration/matlab_static"
+                                     "tests/integration/octave_static"
+                                     "tests/integration/python_modular/tests"))
+             #t))
+         (add-after 'unpack 'change-R-target-path
+           (lambda* (#:key outputs #:allow-other-keys)
+             (substitute* '("src/interfaces/r_modular/CMakeLists.txt"
+                            "src/interfaces/r_static/CMakeLists.txt"
+                            "examples/undocumented/r_modular/CMakeLists.txt")
+               (("\\$\\{R_COMPONENT_LIB_PATH\\}")
+                (string-append (assoc-ref outputs "out")
+                               "/lib/R/library/")))
+             #t))
+         (add-after 'unpack 'fix-octave-modules
+           (lambda* (#:key outputs #:allow-other-keys)
+             (substitute* '("src/interfaces/octave_modular/CMakeLists.txt"
+                            "src/interfaces/octave_static/CMakeLists.txt")
+               (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}")
+                "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave"))
 
-            ;; change target directory
-            (substitute* "src/interfaces/octave_modular/CMakeLists.txt"
-              (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}")
-               (string-append (assoc-ref outputs "out")
-                              "/share/octave/packages")))
-            #t)
-          (alist-cons-before
-           'build 'set-HOME
+             ;; change target directory
+             (substitute* "src/interfaces/octave_modular/CMakeLists.txt"
+               (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}")
+                (string-append (assoc-ref outputs "out")
+                               "/share/octave/packages")))
+             #t))
+         (add-before 'build 'set-HOME
            ;; $HOME needs to be set at some point during the build phase
-           (lambda _ (setenv "HOME" "/tmp") #t)
-           %standard-phases))))
+           (lambda _ (setenv "HOME" "/tmp") #t)))
        #:configure-flags
        (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
              "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT
@@ -402,7 +437,7 @@ sample proximities between pairs of cases.")
     (inputs
      `(("python" ,python)
        ("numpy" ,python-numpy)
-       ("r" ,r)
+       ("r-minimal" ,r-minimal)
        ("octave" ,octave)
        ("swig" ,swig)
        ("hdf5" ,hdf5)