gnu: Add mmtf-cpp.
[jackhill/guix/guix.git] / gnu / packages / chemistry.scm
CommitLineData
73114e30
KH
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2018 Konrad Hinsen <konrad.hinsen@fastmail.net>
ead60993 3;;; Copyright © 2018, 2021 Kei Kebreau <kkebreau@posteo.net>
4ae16f9c 4;;; Copyright © 2018 Efraim Flashner <efraim@flashner.co.il>
631249dd 5;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
357328d2 6;;; Copyright © 2020 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
1c560401 7;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
73114e30
KH
8;;;
9;;; This file is part of GNU Guix.
10;;;
11;;; GNU Guix is free software; you can redistribute it and/or modify it
12;;; under the terms of the GNU General Public License as published by
13;;; the Free Software Foundation; either version 3 of the License, or (at
14;;; your option) any later version.
15;;;
16;;; GNU Guix is distributed in the hope that it will be useful, but
17;;; WITHOUT ANY WARRANTY; without even the implied warranty of
18;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;;; GNU General Public License for more details.
20;;;
21;;; You should have received a copy of the GNU General Public License
22;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
23
24(define-module (gnu packages chemistry)
25 #:use-module (guix packages)
4ae16f9c 26 #:use-module (guix utils)
73114e30
KH
27 #:use-module ((guix licenses) #:prefix license:)
28 #:use-module (guix download)
631249dd 29 #:use-module (guix git-download)
0c468cb5 30 #:use-module (gnu packages)
348edd91 31 #:use-module (gnu packages algebra)
ead60993 32 #:use-module (gnu packages autotools)
7d01ee66 33 #:use-module (gnu packages boost)
06ed1dba 34 #:use-module (gnu packages check)
a49eb85c 35 #:use-module (gnu packages compression)
7d01ee66
KK
36 #:use-module (gnu packages documentation)
37 #:use-module (gnu packages gl)
06ed1dba 38 #:use-module (gnu packages graphviz)
f250a868
KH
39 #:use-module (gnu packages gv)
40 #:use-module (gnu packages maths)
06ed1dba
VL
41 #:use-module (gnu packages mpi)
42 #:use-module (gnu packages perl)
348edd91 43 #:use-module (gnu packages pkg-config)
73114e30 44 #:use-module (gnu packages python)
44d10b1f 45 #:use-module (gnu packages python-xyz)
7d01ee66 46 #:use-module (gnu packages qt)
06ed1dba 47 #:use-module (gnu packages sphinx)
348edd91
KK
48 #:use-module (gnu packages xml)
49 #:use-module (guix build-system cmake)
a49eb85c 50 #:use-module (guix build-system gnu)
73114e30
KH
51 #:use-module (guix build-system python))
52
7d01ee66
KK
53(define-public avogadro
54 (package
55 (name "avogadro")
56 (version "1.2.0")
631249dd
TGR
57 (source
58 (origin
59 (method git-fetch)
60 (uri (git-reference
b0e7b699 61 (url "https://github.com/cryos/avogadro")
631249dd
TGR
62 (commit version)))
63 (sha256
64 (base32 "0258py3lkba85qhs5ynancinyym61vlp0zaq9yrfs3hhnhpzv9n2"))
65 (file-name (git-file-name name version))
66 (patches
67 (search-patches "avogadro-eigen3-update.patch"
68 "avogadro-python-eigen-lib.patch"
69 "avogadro-boost148.patch"))))
7d01ee66
KK
70 (build-system cmake-build-system)
71 (arguments
4ae16f9c 72 `(#:tests? #f
7d01ee66
KK
73 #:configure-flags
74 (list "-DENABLE_GLSL=ON"
75 (string-append "-DPYTHON_LIBRARIES="
76 (assoc-ref %build-inputs "python")
77 "/lib")
78 (string-append "-DPYTHON_INCLUDE_DIRS="
79 (assoc-ref %build-inputs "python")
4ae16f9c
EF
80 "/include/python"
81 ,(version-major+minor
82 (package-version python))))
7d01ee66
KK
83 #:phases
84 (modify-phases %standard-phases
85 (add-after 'unpack 'patch-python-lib-path
86 (lambda* (#:key outputs #:allow-other-keys)
87 ;; This is necessary to install the Python module in the correct
88 ;; directory.
89 (substitute* "libavogadro/src/python/CMakeLists.txt"
90 (("^EXECUTE_PROCESS.*$") "")
91 (("^.*from sys import stdout.*$") "")
92 (("^.*OUTPUT_VARIABLE.*")
93 (string-append "set(PYTHON_LIB_PATH \""
94 (assoc-ref outputs "out")
4ae16f9c
EF
95 "/lib/python"
96 ,(version-major+minor
97 (package-version python))
98 "/site-packages\")")))
7d01ee66
KK
99 #t))
100 (add-after 'install 'wrap-program
101 (lambda* (#:key inputs outputs #:allow-other-keys)
102 ;; Make sure 'avogadro' runs with the correct PYTHONPATH.
103 (let* ((out (assoc-ref outputs "out")))
104 (setenv "PYTHONPATH"
105 (string-append
106 (assoc-ref outputs "out")
4ae16f9c
EF
107 "/lib/python"
108 ,(version-major+minor
109 (package-version python))
110 "/site-packages:"
7d01ee66
KK
111 (getenv "PYTHONPATH")))
112 (wrap-program (string-append out "/bin/avogadro")
113 `("PYTHONPATH" ":" prefix (,(getenv "PYTHONPATH")))))
114 #t)))))
115 (native-inputs
116 `(("doxygen" ,doxygen)
117 ("pkg-config" ,pkg-config)))
118 (inputs
119 `(("boost" ,boost)
120 ("eigen" ,eigen)
121 ("glew" ,glew)
122 ("openbabel" ,openbabel)
123 ("python" ,python-2)
124 ("python-numpy" ,python2-numpy)
125 ("python-pyqt" ,python2-pyqt-4)
126 ("python-sip" ,python2-sip)
127 ("qt" ,qt-4)
128 ("zlib" ,zlib)))
129 (home-page "https://avogadro.cc")
130 (synopsis "Advanced molecule editor")
131 (description
132 "Avogadro is an advanced molecule editor and visualizer designed for use
133in computational chemistry, molecular modeling, bioinformatics, materials
134science, and related areas. It offers flexible high quality rendering and a
135powerful plugin architecture.")
136 (license license:gpl2+)))
137
73114e30
KH
138(define-public domainfinder
139 (package
140 (name "domainfinder")
141 (version "2.0.5")
142 (source
143 (origin
144 (method url-fetch)
145 (uri (string-append "https://bitbucket.org/khinsen/"
146 "domainfinder/downloads/DomainFinder-"
147 version ".tar.gz"))
148 (sha256
149 (base32
150 "1z26lsyf7xwnzwjvimmbla7ckipx6p734w7y0jk2a2fzci8fkdcr"))))
151 (build-system python-build-system)
152 (inputs
153 `(("python-mmtk" ,python2-mmtk)))
154 (arguments
155 `(#:python ,python-2
156 ;; No test suite
157 #:tests? #f))
7f489c56 158 (home-page "http://dirac.cnrs-orleans.fr/DomainFinder.html")
73114e30
KH
159 (synopsis "Analysis of dynamical domains in proteins")
160 (description "DomainFinder is an interactive program for the determination
161and characterization of dynamical domains in proteins. It can infer dynamical
162domains by comparing two protein structures, or from normal mode analysis on a
163single structure. The software is currently not actively maintained and works
164only with Python 2 and NumPy < 1.9.")
165 (license license:cecill-c)))
f250a868 166
a49eb85c
KK
167(define-public inchi
168 (package
169 (name "inchi")
170 (version "1.05")
171 (source (origin
172 (method url-fetch)
173 (uri (string-append "http://www.inchi-trust.org/download/"
174 (string-join (string-split version #\.) "")
175 "/INCHI-1-SRC.zip"))
176 (sha256
177 (base32
178 "081pcjx1z5jm23fs1pl2r3bccia0ww8wfkzcjpb7byhn7b513hsa"))
179 (file-name (string-append name "-" version ".zip"))))
180 (build-system gnu-build-system)
181 (arguments
182 '(#:tests? #f ; no check target
183 #:phases
184 (modify-phases %standard-phases
185 (delete 'configure) ; no configure script
186 (add-before 'build 'chdir-to-build-directory
187 (lambda _ (chdir "INCHI_EXE/inchi-1/gcc") #t))
188 (add-after 'build 'build-library
189 (lambda _
190 (chdir "../../../INCHI_API/libinchi/gcc")
191 (invoke "make")))
192 (replace 'install
193 (lambda* (#:key inputs outputs #:allow-other-keys)
194 (let* ((out (assoc-ref outputs "out"))
195 (bin (string-append out "/bin"))
196 (doc (string-append out "/share/doc/inchi"))
197 (include-dir (string-append out "/include/inchi"))
198 (lib (string-append out "/lib/inchi"))
199 (inchi-doc (assoc-ref inputs "inchi-doc"))
200 (unzip (string-append (assoc-ref inputs "unzip")
201 "/bin/unzip")))
202 (chdir "../../..")
203 ;; Install binary.
204 (with-directory-excursion "INCHI_EXE/bin/Linux"
205 (rename-file "inchi-1" "inchi")
206 (install-file "inchi" bin))
207 ;; Install libraries.
208 (with-directory-excursion "INCHI_API/bin/Linux"
209 (for-each (lambda (file)
210 (install-file file lib))
211 (find-files "." "libinchi\\.so\\.1\\.*")))
212 ;; Install header files.
213 (with-directory-excursion "INCHI_BASE/src"
214 (for-each (lambda (file)
215 (install-file file include-dir))
216 (find-files "." "\\.h$")))
217 ;; Install documentation.
218 (mkdir-p doc)
219 (invoke unzip "-j" "-d" doc inchi-doc)
220 #t))))))
221 (native-inputs
222 `(("unzip" ,unzip)
223 ("inchi-doc"
224 ,(origin
225 (method url-fetch)
226 (uri (string-append "http://www.inchi-trust.org/download/"
227 (string-join (string-split version #\.) "")
228 "/INCHI-1-DOC.zip"))
229 (sha256
230 (base32
231 "1id1qb2y4lwsiw91qr2yqpn6kxbwjwhjk0hb2rwk4fxhdqib6da6"))
232 (file-name (string-append name "-" version ".zip"))))))
233 (home-page "https://www.inchi-trust.org")
234 (synopsis "Utility for manipulating machine-readable chemical structures")
235 (description
236 "The @dfn{InChI} (IUPAC International Chemical Identifier) algorithm turns
237chemical structures into machine-readable strings of information. InChIs are
238unique to the compound they describe and can encode absolute stereochemistry
239making chemicals and chemistry machine-readable and discoverable. A simple
240analogy is that InChI is the bar-code for chemistry and chemical structures.")
241 (license (license:non-copyleft
242 "file://LICENCE"
243 "See LICENCE in the distribution."))))
244
daa4728e
KK
245(define-public mmtf-cpp
246 (package
247 (name "mmtf-cpp")
248 (version "1.0.0")
249 (source
250 (origin
251 (method git-fetch)
252 (uri (git-reference
253 (url "https://github.com/rcsb/mmtf-cpp")
254 (commit (string-append "v" version))))
255 (file-name (git-file-name name version))
256 (sha256
257 (base32
258 "17ylramda69plf5w0v5hxbl4ggkdi5s15z55cv0pljl12yvyva8l"))))
259 (build-system cmake-build-system)
260 ;; Tests require the soon-to-be-deprecated version 1 of the catch-framework.
261 (arguments
262 '(#:tests? #f))
263 (home-page "https://mmtf.rcsb.org/")
264 (synopsis "C++ API for the Macromolecular Transmission Format")
265 (description "This package is a library for the
266@acronym{MMTF,macromolecular transmission format}, a binary encoding of
267biological structures.")
268 (license license:expat)))
269
f250a868
KH
270(define with-numpy-1.8
271 (package-input-rewriting `((,python2-numpy . ,python2-numpy-1.8))))
272
273(define-public nmoldyn
274 (package
275 (name "nmoldyn")
276 (version "3.0.11")
277 (source
278 (origin
e2293cbb
KH
279 (method git-fetch)
280 (uri (git-reference
281 (url "https://github.com/khinsen/nMOLDYN3")
282 (commit (string-append "v" version))))
283 (file-name (git-file-name name version))
f250a868
KH
284 (sha256
285 (base32
e2293cbb 286 "016h4bqg419p6s7bcx55q5iik91gqmk26hbnfgj2j6zl0j36w51r"))))
f250a868
KH
287 (build-system python-build-system)
288 (inputs
289 `(("python-matplotlib" ,(with-numpy-1.8 python2-matplotlib))
c695fb76
TGR
290 ("python-scientific" ,python2-scientific)
291 ("netcdf" ,netcdf)
f250a868
KH
292 ("gv" ,gv)))
293 (propagated-inputs
294 `(("python-mmtk" ,python2-mmtk)))
295 (arguments
296 `(#:python ,python-2
297 #:tests? #f ; No test suite
298 #:phases
299 (modify-phases %standard-phases
300 (add-before 'build 'create-linux2-directory
301 (lambda _
302 (mkdir-p "nMOLDYN/linux2")))
303 (add-before 'build 'change-PDF-viewer
304 (lambda* (#:key inputs #:allow-other-keys)
305 (substitute* "nMOLDYN/Preferences.py"
306 ;; Set the paths for external executables, substituting
307 ;; gv for acroread.
308 ;; There is also vmd_path, but VMD is not free software
309 ;; and Guix contains currently no free molecular viewer that
310 ;; could be substituted.
311 (("PREFERENCES\\['acroread_path'\\] = ''")
30d0f7fa 312 (format #f "PREFERENCES['acroread_path'] = '~a'"
f250a868
KH
313 (which "gv")))
314 (("PREFERENCES\\['ncdump_path'\\] = ''")
30d0f7fa 315 (format #f "PREFERENCES['ncdump_path'] = '~a'"
f250a868
KH
316 (which "ncdump")))
317 (("PREFERENCES\\['ncgen_path'\\] = ''")
30d0f7fa 318 (format #f "PREFERENCES['ncgen_path'] = '~a'"
f250a868
KH
319 (which "ncgen3")))
320 (("PREFERENCES\\['task_manager_path'\\] = ''")
30d0f7fa 321 (format #f "PREFERENCES['task_manager_path'] = '~a'"
f250a868
KH
322 (which "task_manager")))
323 ;; Show documentation as PDF
324 (("PREFERENCES\\['documentation_style'\\] = 'html'")
325 "PREFERENCES['documentation_style'] = 'pdf'") ))))))
357328d2 326 (home-page "http://dirac.cnrs-orleans.fr/nMOLDYN.html")
f250a868
KH
327 (synopsis "Analysis software for Molecular Dynamics trajectories")
328 (description "nMOLDYN is an interactive analysis program for Molecular Dynamics
329simulations. It is especially designed for the computation and decomposition of
330neutron scattering spectra, but also computes other quantities. The software
331is currently not actively maintained and works only with Python 2 and
332NumPy < 1.9.")
333 (license license:cecill)))
348edd91 334
1c560401
VL
335(define-public tng
336 (package
337 (name "tng")
338 (version "1.8.2")
339 (source (origin
340 (method git-fetch)
341 (uri (git-reference
b0e7b699 342 (url "https://github.com/gromacs/tng")
1c560401
VL
343 (commit (string-append "v" version))))
344 (file-name (git-file-name name version))
345 (sha256
346 (base32
347 "1apf2n8nb34z09xarj7k4jgriq283l769sakjmj5aalpbilvai4q"))))
348 (build-system cmake-build-system)
349 (inputs
350 `(("zlib" ,zlib)))
351 (arguments
352 `(#:phases
353 (modify-phases %standard-phases
354 (add-after 'unpack 'remove-bundled-zlib
355 (lambda _
356 (delete-file-recursively "external")
357 #t))
358 (replace 'check
359 (lambda _
360 (invoke "../build/bin/tests/tng_testing")
361 #t)))))
362 (home-page "https://github.com/gromacs/tng")
363 (synopsis "Trajectory Next Generation binary format manipulation library")
364 (description "TRAJNG (Trajectory next generation) is a program library for
365handling molecular dynamics (MD) trajectories. It can store coordinates, and
366optionally velocities and the H-matrix. Coordinates and velocities are
367stored with user-specified precision.")
368 (license license:bsd-3)))
369
06ed1dba
VL
370(define-public gromacs
371 (package
372 (name "gromacs")
373 (version "2020.2")
374 (source (origin
375 (method url-fetch)
376 (uri (string-append "http://ftp.gromacs.org/pub/gromacs/gromacs-"
377 version ".tar.gz"))
378 (sha256
379 (base32
380 "1wyjgcdl30wy4hy6jvi9lkq53bqs9fgfq6fri52dhnb3c76y8rbl"))
381 ;; Our version of tinyxml2 is far newer than the bundled one and
382 ;; require fixing `testutils' code. See patch header for more info
383 (patches (search-patches "gromacs-tinyxml2.patch"))))
384 (build-system cmake-build-system)
385 (arguments
386 `(#:configure-flags
387 (list "-DGMX_DEVELOPER_BUILD=on" ; Needed to run tests
388 ;; Unbundling
389 "-DGMX_USE_LMFIT=EXTERNAL"
390 "-DGMX_BUILD_OWN_FFTW=off"
391 "-DGMX_EXTERNAL_BLAS=on"
392 "-DGMX_EXTERNAL_LAPACK=on"
393 "-DGMX_EXTERNAL_TNG=on"
394 "-DGMX_EXTERNAL_ZLIB=on"
395 "-DGMX_EXTERNAL_TINYXML2=on"
396 (string-append "-DTinyXML2_DIR="
397 (assoc-ref %build-inputs "tinyxml2"))
398 ;; Workaround for cmake/FindSphinx.cmake version parsing that does
399 ;; not understand the guix-wrapped `sphinx-build --version' answer
400 (string-append "-DSPHINX_EXECUTABLE_VERSION="
401 ,(package-version python-sphinx)))
402 #:phases
403 (modify-phases %standard-phases
404 (add-after 'unpack 'fixes
405 (lambda* (#:key inputs #:allow-other-keys)
406 ;; Still bundled: part of gromacs, source behind registration
407 ;; but free software anyways
408 ;;(delete-file-recursively "src/external/vmd_molfile")
409 ;; Still bundled: threads-based OpenMPI-compatible fallback
410 ;; designed to be bundled like that
411 ;;(delete-file-recursively "src/external/thread_mpi")
412 ;; Unbundling
413 (delete-file-recursively "src/external/lmfit")
414 (delete-file-recursively "src/external/clFFT")
415 (delete-file-recursively "src/external/fftpack")
416 (delete-file-recursively "src/external/build-fftw")
417 (delete-file-recursively "src/external/tng_io")
418 (delete-file-recursively "src/external/tinyxml2")
419 (delete-file-recursively "src/external/googletest")
420 (copy-recursively (assoc-ref inputs "googletest-source")
421 "src/external/googletest")
422 ;; This test warns about the build host hardware, disable
423 (substitute* "src/gromacs/hardware/tests/hardwaretopology.cpp"
424 (("TEST\\(HardwareTopologyTest, HwlocExecute\\)")
425 "void __guix_disabled()"))
426 #t)))))
427 (native-inputs
428 `(("doxygen" ,doxygen)
429 ("googletest-source" ,(package-source googletest))
430 ("graphviz" ,graphviz)
431 ("pkg-config" ,pkg-config)
432 ("python" ,python)
433 ("python-pygments" ,python-pygments)
434 ("python-sphinx" ,python-sphinx)))
435 (inputs
436 `(("fftwf" ,fftwf)
437 ("hwloc" ,hwloc-2 "lib")
438 ("lmfit" ,lmfit)
439 ("openblas" ,openblas)
440 ("perl" ,perl)
441 ("tinyxml2" ,tinyxml2)
442 ("tng" ,tng)))
443 (home-page "http://www.gromacs.org/")
444 (synopsis "Molecular dynamics software package")
445 (description "GROMACS is a versatile package to perform molecular dynamics,
446i.e. simulate the Newtonian equations of motion for systems with hundreds to
447millions of particles. It is primarily designed for biochemical molecules like
448proteins, lipids and nucleic acids that have a lot of complicated bonded
449interactions, but since GROMACS is extremely fast at calculating the nonbonded
450interactions (that usually dominate simulations) many groups are also using it
451for research on non-biological systems, e.g. polymers. GROMACS supports all the
452usual algorithms you expect from a modern molecular dynamics implementation.")
453 (license license:lgpl2.1+)))
454
348edd91
KK
455(define-public openbabel
456 (package
457 (name "openbabel")
458 (version "2.4.1")
459 (source (origin
460 (method url-fetch)
461 (uri (string-append "mirror://sourceforge/" name "/" name "/"
462 version "/" name "-" version ".tar.gz"))
463 (sha256
464 (base32
eb5ece73
KK
465 "1z3d6xm70dpfikhwdnbzc66j2l49vq105ch041wivrfz5ic3ch90"))
466 (patches
467 (search-patches "openbabel-fix-crash-on-nwchem-output.patch"))))
348edd91
KK
468 (build-system cmake-build-system)
469 (arguments
470 `(#:configure-flags
471 (list "-DOPENBABEL_USE_SYSTEM_INCHI=ON"
472 (string-append "-DINCHI_LIBRARY="
473 (assoc-ref %build-inputs "inchi")
474 "/lib/inchi/libinchi.so.1")
475 (string-append "-DINCHI_INCLUDE_DIR="
476 (assoc-ref %build-inputs "inchi") "/include/inchi"))
477 #:test-target "test"))
478 (native-inputs
479 `(("pkg-config" ,pkg-config)))
480 (inputs
481 `(("eigen" ,eigen)
482 ("inchi" ,inchi)
483 ("libxml2" ,libxml2)
484 ("zlib" ,zlib)))
485 (home-page "http://openbabel.org/wiki/Main_Page")
486 (synopsis "Chemistry data manipulation toolbox")
487 (description
488 "Open Babel is a chemical toolbox designed to speak the many languages of
489chemical data. It's a collaborative project allowing anyone to search, convert,
490analyze, or store data from molecular modeling, chemistry, solid-state
491materials, biochemistry, or related areas.")
492 (license license:gpl2)))
ead60993
KK
493
494(define-public spglib
495 (package
496 (name "spglib")
497 (version "1.16.0")
498 (source
499 (origin
500 (method git-fetch)
501 (uri (git-reference
502 (url "https://github.com/spglib/spglib")
503 (commit (string-append "v" version))))
504 (sha256
505 (base32 "1kzc956m1pnazhz52vspqridlw72wd8x5l3dsilpdxl491aa2nws"))
506 (file-name (git-file-name name version))))
507 (build-system cmake-build-system)
508 (arguments
509 '(#:test-target "check"
510 #:phases
511 (modify-phases %standard-phases
512 (add-after 'unpack 'patch-header-install-dir
513 (lambda _
514 ;; As of the writing of this package, CMake and GNU build systems
515 ;; install the header to two different location. This patch makes
516 ;; the CMake build system's choice of header directory compatible
517 ;; with the GNU build system's choice and with what avogadrolibs
518 ;; expects.
519 ;; See https://github.com/spglib/spglib/issues/75 and the relevant
520 ;; part of https://github.com/OpenChemistry/avogadroapp/issues/97.
521 (substitute* "CMakeLists.txt"
522 (("\\$\\{CMAKE_INSTALL_INCLUDEDIR\\}" include-dir)
523 (string-append include-dir "/spglib")))
524 #t)))))
525 (home-page "https://spglib.github.io/spglib/index.html")
526 (synopsis "Library for crystal symmetry search")
527 (description "Spglib is a library for finding and handling crystal
528symmetries written in C. Spglib can be used to:
529
530@enumerate
531@item Find symmetry operations
532@item Identify space-group type
533@item Wyckoff position assignment
534@item Refine crystal structure
535@item Find a primitive cell
536@item Search irreducible k-points
537@end enumerate")
538 (license license:bsd-3)))