You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

831 lines
36 KiB

  1. ;; Bioinformatics module
  2. (define-module (gn packages genenetwork)
  3. #:use-module ((guix licenses) #:prefix license:)
  4. #:use-module (guix packages)
  5. #:use-module (guix utils)
  6. #:use-module (guix download)
  7. #:use-module (guix git-download)
  8. #:use-module (guix build-system cargo)
  9. #:use-module (guix build-system gnu)
  10. #:use-module (guix build-system python)
  11. #:use-module (guix build-system trivial)
  12. #:use-module (guix graph)
  13. #:use-module (guix scripts graph)
  14. #:use-module (guix store)
  15. #:use-module (gnu packages)
  16. #:use-module (gnu packages base)
  17. #:use-module (gnu packages bioconductor)
  18. #:use-module (gnu packages bioinformatics)
  19. #:use-module (gnu packages bootstrap)
  20. #:use-module (gnu packages check)
  21. #:use-module (gnu packages cran)
  22. #:use-module (gnu packages crates-io)
  23. #:use-module (gnu packages compression)
  24. #:use-module (gnu packages databases)
  25. #:use-module (gnu packages ghostscript)
  26. #:use-module (gnu packages graphviz)
  27. #:use-module (gnu packages python)
  28. #:use-module (gnu packages python-check)
  29. #:use-module (gnu packages python-crypto)
  30. #:use-module (gnu packages python-science)
  31. #:use-module (gnu packages python-web)
  32. #:use-module (gnu packages python-xyz)
  33. #:use-module (gnu packages rdf)
  34. #:use-module (gnu packages rust)
  35. #:use-module (gnu packages scheme)
  36. #:use-module (gnu packages statistics)
  37. #:use-module (gnu packages version-control)
  38. #:use-module (gnu packages vim)
  39. #:use-module (gnu packages web)
  40. #:use-module (gnu packages wget)
  41. #:use-module (gnu packages xml)
  42. #:use-module (past packages python)
  43. #:use-module (gn packages bioinformatics)
  44. #:use-module (gn packages twint)
  45. #:use-module (gn packages databases)
  46. #:use-module (gn packages elixir)
  47. #:use-module (gn packages gemma)
  48. #:use-module (gn packages javascript)
  49. #:use-module (gn packages phewas)
  50. #:use-module (gn packages python)
  51. #:use-module (gn packages python24)
  52. #:use-module (gn packages statistics)
  53. #:use-module (gn packages web)
  54. #:use-module (srfi srfi-1))
  55. (define-public python2-qtlreaper
  56. (let ((commit "442c217b90393380a8634ff8636b44992f5c53dd"))
  57. (package
  58. (name "python2-qtlreaper")
  59. (version (string-append "1.11-gn2-" (string-take commit 7) ))
  60. (source (origin
  61. (method git-fetch)
  62. (uri (git-reference
  63. ;; (url "https://github.com/genenetwork/genenetwork2.git")
  64. (url "https://github.com/pjotrp/QTLreaper.git")
  65. (commit commit)))
  66. (file-name (string-append name "-" (string-take commit 7)))
  67. (sha256
  68. (base32
  69. "1rrbm1ap2zzyjxmrs9aa1d18sgiba5dhj1fmkl7wmab06jv3j1hm"))))
  70. (build-system python-build-system)
  71. (arguments
  72. `(#:python ,python-2
  73. #:tests? #f)) ; no 'setup.py test' really!
  74. (home-page "http://qtlreaper.sourceforge.net/")
  75. (synopsis "Scan expression data for QTLs")
  76. (description
  77. "Batch-oriented version of WebQTL. It requires, as input,
  78. expression data from members of a set of recombinant inbred lines and
  79. genotype information for the same lines. It searches for an
  80. association between each expression trait and all genotypes and
  81. evaluates that association by a permutation test. For the permutation
  82. test, it performs only as many permutations as are necessary to define
  83. the empirical P-value to a reasonable precision. It also performs
  84. bootstrap resampling to estimate the confidence region for the
  85. location of a putative QTL.")
  86. (license license:gpl2+))))
  87. (define-public python24-qtlreaper
  88. (let ((commit "442c217b90393380a8634ff8636b44992f5c53dd"))
  89. (package
  90. (name "python24-qtlreaper")
  91. (version (git-version "1.11" "gn1" commit))
  92. (source (origin
  93. (method git-fetch)
  94. (uri (git-reference
  95. ;; (url "https://github.com/genenetwork/genenetwork2.git")
  96. (url "https://github.com/pjotrp/QTLreaper.git")
  97. (commit commit)))
  98. (file-name (git-file-name name version))
  99. (sha256
  100. (base32
  101. "1rrbm1ap2zzyjxmrs9aa1d18sgiba5dhj1fmkl7wmab06jv3j1hm"))))
  102. (build-system python-build-system)
  103. (arguments
  104. `(#:python ,python-2.4
  105. #:phases
  106. (modify-phases %standard-phases
  107. (add-after 'unpack 'make-max-markername-size-larger
  108. (lambda _
  109. (substitute* "Src/dataset.c"
  110. (("512") "2048"))
  111. #t))
  112. (replace 'check
  113. (lambda* (#:key inputs outputs #:allow-other-keys)
  114. (add-installed-pythonpath inputs outputs)
  115. (invoke "python" "test/runtest.py"))))))
  116. (native-inputs
  117. `(("python24-setuptools" ,python24-setuptools)))
  118. (home-page "http://qtlreaper.sourceforge.net/")
  119. (synopsis "Scan expression data for QTLs")
  120. (description
  121. "Batch-oriented version of WebQTL. It requires, as input,
  122. expression data from members of a set of recombinant inbred lines and
  123. genotype information for the same lines. It searches for an
  124. association between each expression trait and all genotypes and
  125. evaluates that association by a permutation test. For the permutation
  126. test, it performs only as many permutations as are necessary to define
  127. the empirical P-value to a reasonable precision. It also performs
  128. bootstrap resampling to estimate the confidence region for the
  129. location of a putative QTL.")
  130. (license license:gpl2+))))
  131. ;; Reintroduced python2-gunicorn because we are running GN with python2
  132. ;; right now. Please keep it until we migrate to Python3 fully!
  133. (define-public python-gunicorn-gn
  134. (package
  135. (name "python-gunicorn-gn")
  136. (version "19.9.0")
  137. (source
  138. (origin
  139. (method url-fetch)
  140. (uri (pypi-uri "gunicorn" version))
  141. (sha256
  142. (base32
  143. "1wzlf4xmn6qjirh5w81l6i6kqjnab1n1qqkh7zsj1yb6gh4n49ps"))))
  144. (build-system python-build-system)
  145. (inputs
  146. `(("python-mock" ,python-mock)))
  147. (arguments
  148. '(#:phases
  149. (modify-phases %standard-phases
  150. (add-after 'unpack 'loosen-verion-restrictions
  151. (lambda _
  152. (substitute* "requirements_test.txt"
  153. (("coverage.*") "coverage\n")
  154. (("pytest.*") "pytest\n")
  155. (("pytest-cov.*") "pytest-cov\n"))
  156. #t)))))
  157. (native-inputs
  158. `(("python-coverage" ,python-coverage)
  159. ("python-pytest" ,python-pytest)
  160. ("python-pytest-cov" ,python-pytest-cov)))
  161. (home-page "https://gunicorn.org")
  162. (synopsis "WSGI HTTP Server for UNIX")
  163. (description "Gunicorn 'Green Unicorn' is a Python WSGI HTTP Server for
  164. UNIX. It's a pre-fork worker model ported from Ruby's Unicorn project. The
  165. Gunicorn server is broadly compatible with various web frameworks, simply
  166. implemented, light on server resource usage, and fairly speedy.")
  167. (license license:expat)))
  168. (define-public python2-gunicorn-gn
  169. (package-with-python2 python-gunicorn-gn))
  170. (define-public rust-qtlreaper
  171. (let ((commit "2e7fed6d45b0b602d80fa2a55835f96ef1cba9e3")
  172. (revision "1"))
  173. (package
  174. (name "rust-qtlreaper")
  175. (version "0.1.4")
  176. (source
  177. (origin
  178. (method git-fetch)
  179. (uri (git-reference
  180. (url "https://github.com/chfi/rust-qtlreaper.git")
  181. (commit commit)))
  182. (file-name (git-file-name name version))
  183. (sha256
  184. (base32
  185. "0h70aalsplmc6xn1w7ha102n3bsi3gqkbnbrjvjm2za37c07gv0g"))))
  186. (build-system cargo-build-system)
  187. (arguments
  188. `(#:cargo-inputs
  189. (("rust-rand" ,rust-rand-0.6)
  190. ("rust-structopt" ,rust-structopt-0.2)
  191. ("rust-rayon" ,rust-rayon-1)
  192. ("rust-serde" ,rust-serde-1)
  193. ("rust-serde-json" ,rust-serde-json-1)
  194. ("rust-ndarray" ,rust-ndarray-0.12))
  195. #:phases
  196. (modify-phases %standard-phases
  197. ;; Test results vary based on the machine running them.
  198. (replace 'check
  199. (lambda _
  200. (or (assoc-ref %standard-phases 'check)
  201. (begin
  202. (substitute* "src/geneobject.rs"
  203. ;; array![Genotype::Unk, Genotype::Unk, Genotype::Pat]
  204. (("0.3421367343627405") "0.3421367343627406")
  205. ;; array![Genotype::Unk, Genotype::Unk, Genotype::Unk]
  206. (("-0.3223330030526561") "-0.32233300305265566"))
  207. (assoc-ref %standard-phases 'check)))
  208. #t)))))
  209. (home-page "https://github.com/chfi/rust-qtlreaper")
  210. (synopsis "Reimplementation of genenetwork/QTLReaper in Rust")
  211. (description "Reimplementation of genenetwork/QTLReaper in Rust")
  212. (license #f))))
  213. (define-public gfautil
  214. (package
  215. (name "gfautil")
  216. (version "0.1.0")
  217. (source
  218. (origin
  219. (method url-fetch)
  220. (uri (crate-uri "gfautil" version))
  221. (file-name
  222. (string-append name "-" version ".tar.gz"))
  223. (sha256
  224. (base32
  225. "0cgiis9v1nd4m7zxvgsz8jf8ijv4d8fa5wb7cpnjshksb8z7xh69"))))
  226. (build-system cargo-build-system)
  227. (arguments
  228. `(#:rust ,rust-1.42
  229. #:cargo-inputs
  230. (("rust-bstr" ,rust-bstr-0.2)
  231. ("rust-clap" ,rust-clap-2)
  232. ("rust-gfa" ,rust-gfa-0.6)
  233. ("rust-handlegraph" ,rust-handlegraph-0.3)
  234. ("rust-rayon" ,rust-rayon-1)
  235. ("rust-serde" ,rust-serde-1)
  236. ("rust-structopt" ,rust-structopt-0.3))))
  237. (home-page "https://github.com/chfi/rs-gfa-utils")
  238. (synopsis "Command line tools for working with GFA files")
  239. (description
  240. "This package provides command line tools for working with @acronym{GFA,
  241. Graphical Fragment Assembly} files and related formats.")
  242. (license license:expat)))
  243. (define-public genenetwork2
  244. (let ((commit "1538ffd33af19e6ac922b4ee85fe701408968dfd"))
  245. (package
  246. (name "genenetwork2")
  247. (version (string-append "2.11-guix-" (string-take commit 7) ))
  248. (source (origin
  249. (method git-fetch)
  250. (uri (git-reference
  251. (url "https://pjotrp@gitlab.com/genenetwork/gn2_diet.git")
  252. (commit commit)))
  253. (file-name (string-append name "-" version))
  254. (sha256
  255. (base32
  256. "0ji929xgzypyhchcfy9xa1sz04w322ibs2khc8s3qiddxjqdglrz"))))
  257. (propagated-inputs
  258. `(;; propagated for development purposes
  259. ("python" ,python-2) ;; probably superfluous
  260. ("coreutils" ,coreutils)
  261. ("git" ,git)
  262. ("which" ,which)
  263. ("grep" ,grep)
  264. ("r" ,r)
  265. ("r-ctl" ,r-ctl)
  266. ; ("r-phewas" ,r-phewas)
  267. ("r-qtl" ,r-qtl)
  268. ("r-wgcna" ,r-wgcna)
  269. ("redis" ,redis)
  270. ("mariadb" ,mariadb)
  271. ("gemma" ,gemma-gn2)
  272. ("gemma-wrapper" ,gemma-wrapper)
  273. ; ("genenetwork2-files-small" ,genenetwork2-files-small)
  274. ("plink-ng-gn" ,plink-ng-gn)
  275. ; ("pylmm-gn2" ,pylmm-gn2)
  276. ("racket-minimal" ,racket-minimal)
  277. ("rust-qtlreaper" ,rust-qtlreaper)
  278. ("nginx" ,nginx)
  279. ("python-twint" ,python-twint)
  280. ("python2-coverage" ,python2-coverage)
  281. ("python2-flask" ,python2-flask)
  282. ("python2-gunicorn-gn" ,python2-gunicorn-gn)
  283. ("python2-pillow" ,python2-pillow) ;; - for later!
  284. ("python2-pil1" ,python2-pil1-gn)
  285. ("python2-piddle-gn" ,python2-piddle-gn)
  286. ("python2-cssselect" ,python2-cssselect)
  287. ("python2-elasticsearch" ,python2-elasticsearch)
  288. ; ("python2-htmlgen" ,python2-htmlgen)
  289. ("python2-htmlgen-gn" ,python2-htmlgen-gn)
  290. ("python2-jinja2" ,python2-jinja2)
  291. ("python2-sqlalchemy" ,python2-sqlalchemy)
  292. ("python2-flask-sqlalchemy" ,python2-flask-sqlalchemy)
  293. ("python2-setuptools" ,python2-setuptools)
  294. ("python2-scipy" ,python2-scipy)
  295. ("python2-lxml" ,python2-lxml)
  296. ("python2-mechanize" ,python2-mechanize)
  297. ("python2-mock" ,python2-mock)
  298. ("python2-mysqlclient" ,python2-mysqlclient)
  299. ("python2-nose" ,python-nose2)
  300. ("python2-numarray" ,python2-numarray)
  301. ("python2-numpy" ,python2-numpy)
  302. ("python2-pandas" ,python2-pandas)
  303. ("python2-parallel" ,python2-parallel)
  304. ("python2-parameterized" ,python2-parameterized)
  305. ("python2-passlib" ,python2-passlib)
  306. ("python2-redis" ,python2-redis)
  307. ("python2-requests" ,python2-requests)
  308. ("python2-rpy2" ,python2-rpy2)
  309. ("python2-simplejson" ,python2-simplejson)
  310. ("python2-pyyaml" ,python2-pyyaml)
  311. ("python-unittest2" ,python-unittest2)
  312. ("python2-xlsxwriter" ,python2-xlsxwriter)
  313. ("python2-qtlreaper" ,python2-qtlreaper)
  314. ;; All the external js dependencies
  315. ("javascript-twitter-post-fetcher" ,javascript-twitter-post-fetcher)
  316. ("javascript-cytoscape" ,javascript-cytoscape)
  317. ("javascript-panzoom" ,javascript-cytoscape-panzoom)
  318. ("javascript-qtip" ,javascript-cytoscape-qtip)
  319. ("javascript-chroma" ,javascript-chroma)
  320. ("javascript-d3-tip" ,javascript-d3-tip)
  321. ("javascript-jscolor" ,javascript-jscolor)
  322. ("javascript-colorbox" ,javascript-colorbox)
  323. ("javascript-jszip" ,javascript-jszip)
  324. ("js-jstat" ,js-jstat)
  325. ("js-md5" ,js-md5)
  326. ("js-parsley" ,js-parsley)
  327. ("javascript-plotly" ,javascript-plotly)
  328. ("javascript-typeahead" ,javascript-typeahead)
  329. ("js-underscore" ,js-underscore)
  330. ("js-smart-time-ago" ,js-smart-time-ago)
  331. ("javascript-nouislider" ,javascript-nouislider)
  332. ("javascript-purescript-genome-browser" ,javascript-purescript-genome-browser)
  333. ("javascript-ckeditor" ,javascript-ckeditor)
  334. ("javascript-datatables" ,javascript-datatables)
  335. ("javascript-datatables-scroller" ,javascript-datatables-scroller)
  336. ("javascript-datatables-buttons" ,javascript-datatables-buttons)
  337. ("javascript-datatables-buttons-bootstrap" ,javascript-datatables-buttons-bootstrap)
  338. ("javascript-datatables-plugins" ,javascript-datatables-plugins)
  339. ("javascript-datatables-col-reorder" ,javascript-datatables-col-reorder)
  340. ("javascript-datatables-col-resize" ,javascript-datatables-col-resize)
  341. ("javascript-datatables-buttons-styles" ,javascript-datatables-buttons-styles)
  342. ("javascript-shapiro-wilk" ,javascript-shapiro-wilk)
  343. ("javascript-underscore-string" ,javascript-underscore-string)
  344. ("javascript-qtip2" ,javascript-qtip2)
  345. ("javascript-d3js" ,javascript-d3js)
  346. ("javascript-nvd3" ,javascript-nvd3)
  347. ("javascript-bootstrap" ,javascript-bootstrap)
  348. ("javascript-jquery" ,javascript-jquery)
  349. ("javascript-zxcvbn-async" ,javascript-zxcvbn-async)
  350. ("javascript-jquery-ui" ,javascript-jquery-ui)
  351. ("javascript-jquery-cookie" ,javascript-jquery-cookie)
  352. ))
  353. (inputs
  354. `(("javascript-colorbox" ,(package-source javascript-colorbox))))
  355. (build-system python-build-system)
  356. (arguments
  357. `(#:python ,python-2
  358. #:phases
  359. (modify-phases %standard-phases
  360. (delete 'reset-gzip-timestamps)
  361. (add-after 'unpack 'fix-paths-scripts
  362. (lambda _
  363. (substitute* "bin/genenetwork2"
  364. (("/usr/bin/env") (which "env"))
  365. (("python ") (string-append (which "python2") " "))
  366. (("readlink") (which "readlink"))
  367. (("dirname") (which "dirname"))
  368. (("basename") (which "basename"))
  369. (("cat") (which "cat"))
  370. (("echo") (which "echo"))
  371. (("redis-server") (which "redis-server"))
  372. (("git") (which "git"))
  373. (("grep") (which "grep"))
  374. (("rm") (which "rm"))
  375. (("which") (which "which")) ; three whiches in a row!
  376. )
  377. #t))
  378. (add-after 'unpack 'patch-javascript
  379. (lambda* (#:key inputs #:allow-other-keys)
  380. (let ((colorbox (assoc-ref inputs "javascript-colorbox"))
  381. (gn2 "/share/genenetwork2/javascript/"))
  382. (delete-file-recursively "wqflask/wqflask/static/packages/colorbox")
  383. (copy-recursively colorbox "wqflask/wqflask/static/packages/colorbox")
  384. #t)))
  385. (add-before 'install 'fix-paths
  386. (lambda* (#:key inputs #:allow-other-keys)
  387. (let* (
  388. ; (datafiles (string-append (assoc-ref inputs "genenetwork2-files-small") "/share/genenetwork2"))
  389. ; (pylmmcmd (string-append (assoc-ref inputs "pylmm-gn2") "/bin/pylmm_redis"))
  390. (plink2cmd (string-append (assoc-ref inputs "plink-ng-gn") "/bin/plink2"))
  391. (gemmacmd (string-append (assoc-ref inputs "gemma") "/bin/gemma"))
  392. )
  393. (substitute* '("etc/default_settings.py")
  394. ; (("^GENENETWORK_FILES +=.*") (string-append "GENENETWORK_FILES = \"" datafiles "\"\n" ))
  395. ; (("^PYLMM_COMMAND =.*") (string-append "PYLMM_COMMAND = \"" pylmmcmd "\"\n" ))
  396. (("^PLINK_COMMAND =.*") (string-append "PLINK_COMMAND = \"" plink2cmd "\"\n" ))
  397. (("^GEMMA_COMMAND =.*") (string-append "GEMMA_COMMAND = \"" gemmacmd "\"\n" ))
  398. )
  399. ))))
  400. #:tests? #f)) ; no 'setup.py test'
  401. (home-page "http://genenetwork.org/")
  402. (synopsis "Full genenetwork services")
  403. (description "Genenetwork installation sumo.")
  404. (license license:agpl3+))))
  405. (define-public python3-genenetwork2
  406. (let ((commit "84cbf35adbb15c79638372d108308edb05f12683"))
  407. (package
  408. (inherit genenetwork2)
  409. (name "python3-genenetwork2")
  410. (version (string-append "3.11-guix-" (string-take commit 7) ))
  411. (source (origin
  412. (method git-fetch)
  413. (uri (git-reference
  414. (url "https://github.com/genenetwork/genenetwork2.git")
  415. (commit commit)))
  416. (file-name (string-append name "-" version))
  417. (sha256
  418. (base32
  419. "1402g129ghfh0xwfxjj1i7gbib2yl9rahf55caj7b1psy24ys87x"))))
  420. (native-inputs
  421. `(("graphviz" ,graphviz)))
  422. (propagated-inputs
  423. (let ((inputs (package-propagated-inputs genenetwork2)))
  424. `(,@(fold
  425. alist-delete inputs
  426. (map car
  427. (filter (lambda (x)
  428. (let ((name (car x)))
  429. (or (string-prefix? "python2" name)
  430. (string-prefix? "python-2" name)
  431. (string=? "python" name))))
  432. inputs)))
  433. ("python" ,python-wrapper)
  434. ("python-pillow" ,python-pillow)
  435. ("python-coverage" ,python-coverage)
  436. ("python-flask" ,python-flask)
  437. ("gunicorn" ,gunicorn)
  438. ("python-cssselect" ,python-cssselect)
  439. ("python-elasticsearch" ,python-elasticsearch)
  440. ("python-htmlgen" ,python-htmlgen)
  441. ("python-jinja2" ,python-jinja2)
  442. ("python-sqlalchemy" ,python-sqlalchemy)
  443. ("python-flask-sqlalchemy" ,python-flask-sqlalchemy)
  444. ("python-setuptools" ,python-setuptools)
  445. ("python-scipy" ,python-scipy)
  446. ("python-lxml" ,python-lxml)
  447. ("python-mechanize" ,python-mechanize)
  448. ("python-mysqlclient" ,python-mysqlclient)
  449. ("python-mypy" ,python-mypy)
  450. ("python-numpy" ,python-numpy)
  451. ("python-pandas" ,python-pandas)
  452. ("python-parameterized" ,python-parameterized)
  453. ("python-passlib" ,python-passlib)
  454. ("python-redis" ,python-redis)
  455. ("python-requests" ,python-requests)
  456. ("python-simplejson" ,python-simplejson)
  457. ("python-pyyaml" ,python-pyyaml)
  458. ("python-markdown" ,python-markdown)
  459. ("python-rdflib" ,python-rdflib)
  460. ;; TODO: Get rid of Python R bindings
  461. ("python-rpy2" ,python-rpy2-2.9)
  462. ("python-beautifulsoup4" ,python-beautifulsoup4)
  463. ;; Disable for now. Build fails on Penguin2
  464. ;; ("python-flask-socketio" ,python-flask-socketio)
  465. ("python-xlsxwriter" ,python-xlsxwriter))))
  466. (arguments
  467. (let ((python (specification->package "python-wrapper"))
  468. (args (package-arguments genenetwork2)))
  469. (substitute-keyword-arguments args
  470. ((#:python _) python)
  471. ((#:phases phases)
  472. `(modify-phases ,phases
  473. (add-after 'unpack 'fix-paths-scripts
  474. (lambda _
  475. (substitute* "bin/genenetwork2"
  476. (("/usr/bin/env") (which "env"))
  477. (("python ") (string-append (which "python3") " "))
  478. (("readlink") (which "readlink"))
  479. (("dirname") (which "dirname"))
  480. (("basename") (which "basename"))
  481. (("cat") (which "cat"))
  482. (("echo") (which "echo"))
  483. (("redis-server") (which "redis-server"))
  484. (("git") (which "git"))
  485. (("grep") (which "grep"))
  486. (("rm") (which "rm"))
  487. (("which") (which "which")))
  488. #t))
  489. (add-after 'install 'generate-graph
  490. (lambda* (#:key inputs outputs #:allow-other-keys)
  491. (call-with-output-file
  492. (string-append
  493. (assoc-ref outputs "out")
  494. "/lib/python3.8/site-packages"
  495. "/wqflask/dependency-graph.html")
  496. (lambda (port)
  497. (format
  498. port "~a"
  499. ,(call-with-output-string
  500. (lambda (p)
  501. (with-output-to-port p
  502. (lambda ()
  503. (run-with-store
  504. (open-connection)
  505. (export-graph
  506. (list this-package)
  507. p
  508. #:node-type %package-node-type
  509. #:backend %d3js-backend)))))))))))
  510. (add-after 'install 'generate-dag-svg-file
  511. (lambda* (#:key inputs outputs #:allow-other-keys)
  512. (let* ((output-dir
  513. (string-append
  514. (assoc-ref outputs "out")
  515. "/lib/python3.8/site-packages/wqflask/"))
  516. (dot-file
  517. (string-append
  518. output-dir
  519. "dependency-graph.dot"))
  520. (svg-file
  521. (string-append
  522. output-dir
  523. "dependency-graph.svg")))
  524. (begin
  525. (call-with-output-file
  526. dot-file
  527. (lambda (port)
  528. (format
  529. port "~a"
  530. ,(call-with-output-string
  531. (lambda (p)
  532. (with-output-to-port p
  533. (lambda ()
  534. (run-with-store
  535. (open-connection)
  536. (export-graph
  537. (list this-package)
  538. p
  539. #:node-type %package-node-type
  540. #:backend %graphviz-backend)))))))))
  541. (invoke "dot" "-Tsvg" "-o" svg-file dot-file)))))
  542. (add-after 'install 'generate-dependency-file
  543. (lambda* (#:key inputs outputs #:allow-other-keys)
  544. (call-with-output-file
  545. (string-append
  546. (assoc-ref outputs "out")
  547. "/lib/python3.8/site-packages"
  548. "/wqflask/DEPENDENCIES.md")
  549. (lambda (port)
  550. (format
  551. port "
  552. #### System Inputs (generated from ~a package defined in ~a)
  553. |Name | Description |
  554. |-----|-------------|
  555. ~a
  556. "
  557. ,(package-name this-package)
  558. (string-append
  559. "[genenetwork.scm]"
  560. "(http://git.genenetwork.org/"
  561. "guix-bioinformatics/guix-bioinformatics"
  562. "/src/branch/master/gn/packages/"
  563. "genenetwork.scm)")
  564. ,(apply
  565. string-append
  566. (map
  567. (lambda (input)
  568. (let* ((pkg (cadr input))
  569. (name (package-name pkg))
  570. (version (package-version pkg))
  571. (home-page (package-home-page pkg))
  572. (description (package-synopsis pkg)))
  573. (string-append
  574. "| **[" name "](" home-page ")** v"
  575. version"| "
  576. description " |\n")))
  577. (package-propagated-inputs this-package))))))))))))))))
  578. ;; ./pre-inst-env guix download http://files.genenetwork.org/raw_database/db_webqtl_s.zip
  579. ;; 0sscjh0wml2lx0mb43vf4chg9gpbfi7abpjxb34n3kyny9ll557x
  580. (define-public genenetwork2-files-small
  581. (let ((pfff "xx"))
  582. (package
  583. (name "genenetwork2-files-small")
  584. (version "1.0")
  585. (source
  586. (origin
  587. (method url-fetch)
  588. (uri "http://files.genenetwork.org/data_files/gn2_data_s-20160303-C9E672ECED1F51B915DE419B5B2C524E.tar.lz4")
  589. (file-name (string-append name "-" pfff))
  590. (sha256
  591. (base32 "058ymx3af6abdhdxyxj0i9qfvb6v7j091frjpp6jh4ahks7r23lj"))))
  592. (build-system trivial-build-system)
  593. (native-inputs `(("lz4" ,lz4)
  594. ("tar" ,tar)
  595. ("source" ,source)))
  596. (arguments
  597. `(#:modules ((guix build utils))
  598. #:builder
  599. (let* ((out (assoc-ref %outputs "out"))
  600. (name "gn2_data_s")
  601. (tarfn (string-append name ".tar"))
  602. (targetdir (string-append out "/share/genenetwork2/")))
  603. (begin
  604. (use-modules (guix build utils))
  605. (let ((source (assoc-ref %build-inputs "source"))
  606. (lz4unpack (string-append (assoc-ref %build-inputs "lz4") "/bin/lz4"))
  607. (tar (string-append (assoc-ref %build-inputs "tar") "/bin/tar")))
  608. (and
  609. (zero? (system* lz4unpack source "-d" tarfn))
  610. (zero? (system* tar "xf" tarfn))
  611. (mkdir-p targetdir)
  612. (copy-recursively name targetdir)))))))
  613. (home-page "http://genenetwork.org/")
  614. (synopsis "Small file archive to run on genenetwork")
  615. (description "Genenetwork genotype and mapping files.")
  616. (license license:agpl3+))))
  617. (define-public genenetwork2-database-small
  618. (let ((md5 "93e745e9c"))
  619. (package
  620. (name "genenetwork2-database-small")
  621. (version "1.0")
  622. (source
  623. (origin
  624. (method url-fetch)
  625. (uri "http://files.genenetwork.org/raw_database/db_webqtl_s.zip")
  626. (file-name (string-append name "-" md5))
  627. (sha256
  628. (base32 "0sscjh0wml2lx0mb43vf4chg9gpbfi7abpjxb34n3kyny9ll557x"))))
  629. (build-system trivial-build-system)
  630. (native-inputs `(("unzip" ,unzip)
  631. ("source" ,source)))
  632. (arguments
  633. `(#:modules ((guix build utils))
  634. #:builder (begin
  635. (use-modules (guix build utils))
  636. (let ((source (assoc-ref %build-inputs "source"))
  637. (unzip (string-append (assoc-ref %build-inputs "unzip") "/bin/unzip")))
  638. (and (mkdir "db")
  639. (zero? (system* unzip source "-d" "db"))
  640. (chdir "db"))))))
  641. (home-page "http://genenetwork.org/")
  642. (synopsis "Small database to run on genenetwork")
  643. (description "Genenetwork installation + database.")
  644. (license license:agpl3+))))
  645. (define-public python-reaper
  646. (let ((commit "63391333a6619771277bfffa9bd9d33811fa0d28"))
  647. (package
  648. (name "python-reaper")
  649. (version (string-append "0.0.1-"
  650. (string-take commit 7)))
  651. (source (origin
  652. (method git-fetch)
  653. (uri (git-reference
  654. (url "https://github.com/fredmanglis/reaper.git")
  655. (commit commit)))
  656. (file-name (git-file-name name version))
  657. (sha256
  658. (base32
  659. "1rq2qn0vrqd8k676yy8drm0zxzkj065ywhxjl0j1n2r25zifay7r"))))
  660. (build-system python-build-system)
  661. (arguments
  662. `(#:tests? #f))
  663. (home-page "https://github.com/fredmanglis/reaper")
  664. (synopsis "Parser for .geno files")
  665. (description "Parser for .geno files. It replaces the Python2 library
  666. written in C")
  667. (license license:agpl3+))))
  668. (define-public genenetwork1
  669. (let ((commit "acf65ac9ae4be395c07c1629758f7408bf4eab5f") ; June 3, 2020
  670. (revision "2"))
  671. (package
  672. (name "genenetwork1")
  673. (version (git-version "0.0.0" revision commit))
  674. (source (origin
  675. (method git-fetch)
  676. (uri (git-reference
  677. (url "https://github.com/genenetwork/genenetwork1.git")
  678. (commit commit)))
  679. (file-name (git-file-name name version))
  680. (sha256
  681. (base32
  682. "0xmmmjyvh80yd8b0cjrwpdmxl8k9zj5ly65r2g9aygx74njsp4fi"))))
  683. (build-system gnu-build-system)
  684. (native-inputs
  685. `(("ghostscript" ,ghostscript)
  686. ("graphviz" ,graphviz)
  687. ("python24" ,python-2.4)
  688. ("python-piddle" ,python24-piddle)
  689. ("wget" ,wget)))
  690. (arguments
  691. `(#:tests? #f ; no tests
  692. #:phases
  693. (modify-phases %standard-phases
  694. (delete 'configure)
  695. (delete 'build)
  696. (add-after 'patch-generated-file-shebangs 'patch-more-files
  697. (lambda* (#:key inputs #:allow-other-keys)
  698. (let ((piddle (assoc-ref inputs "python-piddle")))
  699. (substitute* "web/webqtl/networkGraph/networkGraphUtils.py"
  700. (("/usr/local/bin/neato") (which "neato"))
  701. (("/usr/local/bin/circo") (which "circo"))
  702. (("/usr/local/bin/twopi") (which "twopi"))
  703. (("/usr/local/bin/fdp") (which "fdp"))
  704. (("ps2pdf") (which "ps2pdf")))
  705. (substitute* "web/webqtl/maintainance/addRif.py"
  706. (("rm ") (string-append (which "rm") " "))
  707. (("wget ") (string-append (which "wget") " "))
  708. (("gunzip") (which "gunzip")))
  709. (substitute* "web/webqtl/misc/editHtmlPage.py"
  710. (("/bin/cp") (which "cp")))
  711. (substitute* "web/webqtl/geneWiki/AddGeneRIFPage.py"
  712. (("touch") (which "touch")))
  713. (substitute* '("web/webqtl/maintainance/addRif.py"
  714. "web/webqtl/networkGraph/networkGraphPage.py"
  715. "web/webqtl/utility/svg.py")
  716. (("/usr/bin/(env )?python") (which "python")))
  717. (substitute* "web/webqtl/base/webqtlConfigLocal.py"
  718. (("PythonPath.*")
  719. (string-append "PythonPath = '" (which "python") "'\n"))
  720. (("PIDDLE_FONT_PATH.*/lib")
  721. (string-append "PIDDLE_FONT_PATH = '" piddle "/lib"))))
  722. #t))
  723. (add-after 'patch-generated-file-shebangs 'changes-for-deployed-service
  724. (lambda* (#:key outputs #:allow-other-keys)
  725. (let ((out (assoc-ref outputs "out")))
  726. (substitute* "web/webqtl/base/webqtlConfigLocal.py"
  727. ;; Where GN1 is located: (GNROOT)
  728. (("/gnshare/gn") out)
  729. ;; Where the database is located: (sql_host)
  730. (("tux01") "localhost"))
  731. (substitute* '("web/webqtl/maintainance/QTL_Reaper_cal_lrs.py")
  732. (("128\\.169\\.5\\.59") "localhost"))
  733. ;; This directory (TMPDIR) is expected to be writable by apache.
  734. ;; /tmp is private inside the container.
  735. (symlink "/tmp" "web/tmp")
  736. ;; IMGDIR is expected to be writable.
  737. (symlink "/tmp" "web/image")
  738. (system "chmod 0777 web/tmp")
  739. ;; More writable locations:
  740. (substitute* (list "web/webqtl/collection/ExportSelectionDetailInfoPage.py"
  741. "web/webqtl/pairScan/DirectPlotPage.py"
  742. "web/webqtl/updateTrait/DataUpdatePage.py"
  743. "web/webqtl/utility/Plot.py")
  744. (("/gnshare/gn/web/debug_file.txt") "/tmp/debug_file.txt"))
  745. ;; We mount the genotypes folder (GENODIR) in the OS-config and
  746. ;; provide the symlink to that location from the package.
  747. ;; And now the directory is magically available!
  748. (symlink "/gnshare/gn/web/genotypes" "web/genotypes")
  749. (substitute* "web/webqtl/base/webqtlConfig.py"
  750. (("http://www.genenetwork.org") "http://gn1-test.genenetwork.org"))
  751. ;; Inside the gn1 container, there's some conflict when
  752. ;; importing the user module, therefore, as a hack, rename
  753. ;; user to useralt
  754. (mkdir "web/webqtl/useralt")
  755. (copy-recursively "web/webqtl/user" "web/webqtl/useralt")
  756. (substitute* '("web/webqtl/main.py")
  757. (("from user import") "from useralt import"))
  758. #t)))
  759. (add-after 'unpack 'use-local-links
  760. (lambda _
  761. (substitute* '("web/javascript/menu_items.js"
  762. "web/webqtl/maintainance/updateMenuJS.py")
  763. (("http://(www|gn1).genenetwork.org") ""))
  764. ;; Move this file out of the way while patching files.
  765. (rename-file "web/infoshare/manager/MDB-Free/index.html"
  766. "web/infoshare/manager/MDB-Free/index.htm")
  767. (substitute* (cons*
  768. "web/webqtl/base/indexBody.py"
  769. "web/webqtl/submitTrait/BatchSubmitPage.py"
  770. (find-files "web" "\\.html"))
  771. ((".*base href.*") "")
  772. (("(HREF|href)=\\\"http://(www.)?genenetwork.org")
  773. "href=\""))
  774. ;; Move this file back to its original location.
  775. (rename-file "web/infoshare/manager/MDB-Free/index.htm"
  776. "web/infoshare/manager/MDB-Free/index.html")
  777. (substitute* (cons*
  778. "web/humanCross.html"
  779. "web/webqtl/base/indexBody.py"
  780. "web/whats_new.html"
  781. (find-files "web/dbdoc" "\\.html"))
  782. (("src=\\\"http://www.genenetwork.org") "src=\""))
  783. #t))
  784. (replace 'install
  785. (lambda* (#:key outputs #:allow-other-keys)
  786. (copy-recursively "." (assoc-ref outputs "out"))
  787. #t)))))
  788. (home-page "http://www.genenetwork.org/webqtl/main.py")
  789. (synopsis
  790. "Combined database and data analysis software resource for systems genetics")
  791. (description "GeneNetwork is a group of linked data sets and tools used to
  792. study complex networks of genes, molecules, and higher order gene function and
  793. phenotypes. GeneNetwork combines more than 25 years of legacy data generated by
  794. hundreds of scientists together with sequence data (SNPs) and massive
  795. transcriptome data sets (expression genetic or eQTL data sets). The
  796. @dfn{quantitative trait locus} (QTL) mapping module that is built into GN is
  797. optimized for fast on-line analysis of traits that are controlled by
  798. combinations of gene
  799. variants and environmental factors. GeneNetwork can be used to study humans,
  800. mice (BXD, AXB, LXS, etc.), rats (HXB), Drosophila, and plant species (barley
  801. and Arabidopsis). Most of these population data sets are linked with dense
  802. genetic maps (genotypes) that can be used to locate the genetic modifiers that
  803. cause differences in expression and phenotypes, including disease susceptibility.")
  804. (license license:agpl3+))))