summary refs log tree commit diff
diff options
context:
space:
mode:
authorDavid Elsing <david.elsing@posteo.net>2022-10-13 21:04:22 +0000
committerLiliana Marie Prikler <liliana.prikler@gmail.com>2022-10-15 12:05:15 +0200
commita3844f8a18c6ab28f000479a0ff0b372ceb3f33c (patch)
tree4995dd723aebab93d01b5a96e9f4cc30b53a4bc5
parentcfd62fdf86ec87b73a2f88e5e1c303095d94f0fe (diff)
downloadguix-a3844f8a18c6ab28f000479a0ff0b372ceb3f33c.tar.gz
gnu: Add avalon-toolkit.
* gnu/packages/chemistry.scm (avalon-toolkit): New variable.

Signed-off-by: Liliana Marie Prikler <liliana.prikler@gmail.com>
-rw-r--r--gnu/packages/chemistry.scm94
1 files changed, 94 insertions, 0 deletions
diff --git a/gnu/packages/chemistry.scm b/gnu/packages/chemistry.scm
index 1242417c57..c13890001f 100644
--- a/gnu/packages/chemistry.scm
+++ b/gnu/packages/chemistry.scm
@@ -905,3 +905,97 @@ emphasis on quality rather than speed.")
 Orbital Package} contains a program and library for performing extended Hückel
 calculations and analyzing the results.")
     (license license:bsd-2)))
+
+(define-public avalon-toolkit
+  (package
+    (name "avalon-toolkit")
+    (version "1.2.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append
+             "mirror://sourceforge/avalontoolkit/"
+             "AvalonToolkit_" (substring version 0 3) "/AvalonToolkit_"
+             version ".source.tar"))
+       (sha256
+        (base32
+         "0rnnyy6axs2da7aa4q6l30ldavbk49v6l22llj1adn74h1i67bpv"))
+       (modules '((guix build utils) (ice-9 ftw)))
+       (snippet
+        #~(begin
+            (delete-file-recursively "../SourceDistribution/java")))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      ;; There are no intended tests
+      #:tests? #f
+      #:phases
+      #~(let ((programs '("canonizer" "matchtest" "sketch" "smi2mol" "struchk")))
+          (modify-phases %standard-phases
+            (add-after 'unpack 'chdir
+              (lambda _ (chdir "common")))
+            (delete 'configure)
+            (add-before 'build 'dont-free-static-memory
+              (lambda _
+                (substitute* "reaccsio.c"
+                  (("MyFree\\(.*tempdir\\)" m)
+                   (string-append "/* freeing memory from getenv is bad */"
+                                  "// " m)))))
+            ;; The makefile has incorrect compiler flags and is missing some
+            ;; object files, so we build it ourselves.
+            (replace 'build
+              (lambda _
+                (for-each
+                 (lambda (part)
+                   (format #t "Compiling ~a.c ~~> ~a.o~%" part part)
+                   (invoke #$(cc-for-target) "-c" "-fPIC" "-O2"
+                           (string-append part ".c")
+                           "-o" (string-append part ".o")))
+                 (list "aacheck" "casutils" "denormal" "depictutil"
+                       "didepict" "fixcharges" "forio" "geometry"
+                       "graph" "hashcode" "layout" "local" "pattern"
+                       "perceive" "reaccsio" "rtutils" "set" "shortcut"
+                       "sketch" "ssmatch" "stereo" "symbol_lists"
+                       "symboltable" "utilities"))
+                (display "Building libavalontoolkit.so\n")
+                (apply invoke "gcc" "-fPIC" "-shared" "-lm"
+                       "-o" "libavalontoolkit.so" "canonizer.c" "smi2mol.c"
+                       "struchk.c" "patclean.c" (find-files "." "\\.o$"))
+                ;; patclean is not built here as there is an undeclared
+                ;; variable in main().
+                (for-each
+                 (lambda (program)
+                   (display (string-append "Building " program "\n"))
+                   (invoke "gcc" "-L." "-lavalontoolkit" "-lm" "-O2"
+                           (string-append "-Wl,-rpath=" #$output "/lib")
+                           "-DMAIN" (string-append program ".c") "-o" program))
+                 programs)))
+            (replace 'install
+              (lambda _
+                ;; Executables
+                (for-each
+                 (lambda (program)
+                   (install-file program (string-append #$output "/bin")))
+                 programs)
+                (for-each
+                 (lambda (name)
+                   (symlink (string-append #$output "/bin/smi2mol")
+                            (string-append #$output "/bin/" name)))
+                 '("mol2smi" "rdf2smi" "mol2tbl" "mol2sma" "smi2rdf"))
+                ;; Library
+                (install-file "libavalontoolkit.so"
+                              (string-append #$output "/lib"))
+                (for-each
+                 (lambda (file)
+                   (install-file file (string-append #$output
+                                                    "/include/avalontoolkit")))
+                 (find-files "." "\\.h$"))
+                (install-file "../license.txt"
+                              (string-append #$output "/share/doc/"
+                                             #$name "-" #$version "/"))))))))
+    (home-page "https://sourceforge.net/projects/avalontoolkit/")
+    (synopsis "Tools for SMILES and MOL files and for structure fingerprinting")
+    (description "This package contains a library and programs for
+canonicalization of SMILES and MOL files, molecular structure fingerprinting
+and rendering molecules.")
+    (license license:bsd-3)))