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.

158 lines
7.3 KiB

  1. (define-module (gn packages ratspub)
  2. #:use-module ((guix licenses) #:prefix license:)
  3. #:use-module (guix utils)
  4. #:use-module (gnu packages)
  5. #:use-module (guix packages)
  6. #:use-module (guix git-download)
  7. #:use-module (guix build-system python)
  8. #:use-module (gnu packages admin)
  9. #:use-module (gnu packages bioinformatics)
  10. #:use-module (gn packages javascript)
  11. #:use-module (gnu packages machine-learning)
  12. #:use-module (gnu packages python-crypto)
  13. #:use-module (gnu packages python-web)
  14. #:use-module (gnu packages python-xyz)
  15. #:use-module (gn packages web))
  16. (define-public ratspub
  17. (package
  18. (name "ratspub")
  19. (version "0.3.1")
  20. (source (origin
  21. (method git-fetch)
  22. (uri (git-reference
  23. (url "https://github.com/chen42/ratspub.git")
  24. (commit (string-append "v" version))))
  25. (file-name (git-file-name name version))
  26. (sha256
  27. (base32
  28. "1ii3721mqd3dbpjkhqi7yqjd9bqcf0g19kdbb8265pmbfjjsg164"))
  29. (modules '((guix build utils)))
  30. (snippet
  31. '(begin (substitute* "server.py"
  32. ;; Keep the service running on port 4200
  33. (("4201") "4200")
  34. ;; Backport to python-keras-2.2.4
  35. (("learning_rate") "lr") )
  36. #t))))
  37. (build-system python-build-system)
  38. (arguments
  39. `(#:tests? #f ; no test suite
  40. #:phases
  41. (modify-phases %standard-phases
  42. (delete 'configure)
  43. (delete 'build)
  44. (add-after 'unpack 'patch-sources
  45. (lambda* (#:key inputs outputs #:allow-other-keys)
  46. (let ((out (assoc-ref outputs "out"))
  47. (inetutils (assoc-ref inputs "inetutils")))
  48. (substitute* '("templates/cytoscape.html"
  49. "templates/tableview.html"
  50. "templates/tableview0.html"
  51. "templates/userarchive.html")
  52. (("script src=.*")
  53. "script src=\"/static/cytoscape.min.js\"></script>\n"))
  54. (substitute* "templates/layout.html"
  55. (("https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css.*")
  56. "/static/bootstrap.min.css\">\n")
  57. (("https://.*.bootstrapcdn.com/bootstrap/4.*/js/bootstrap.min.js.*")
  58. "/static/bootstrap.min.js\"></script>\n")
  59. (("https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css")
  60. "/static/font-awesome.min.css")
  61. (("https://code.jquery.com/jquery-3.2.1.slim.min.js.*")
  62. "/static/jquery.slim.min.js\"></script>\n")
  63. ;(("https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js.*")
  64. ; "/static/popper.min.js\"></script>\n")
  65. )
  66. (substitute* "ratspub.py"
  67. (("hostname") (string-append inetutils "/bin/hostname"))))
  68. #t))
  69. (replace 'install
  70. (lambda* (#:key outputs #:allow-other-keys)
  71. (let ((out (assoc-ref outputs "out")))
  72. (copy-recursively "." out))
  73. #t))
  74. (add-after 'install 'install-javascript
  75. (lambda* (#:key inputs outputs #:allow-other-keys)
  76. (let ((out (assoc-ref outputs "out"))
  77. (awesome (assoc-ref inputs "font-awesome"))
  78. (bootstrap (assoc-ref inputs "bootstrap"))
  79. (cytoscape (assoc-ref inputs "cytoscape"))
  80. (jquery (assoc-ref inputs "jquery"))
  81. ;(js-popper (assoc-ref inputs "js-popper"))
  82. )
  83. (symlink (string-append awesome
  84. "/share/web/font-awesomecss/font-awesome.min.css")
  85. (string-append out "/static/font-awesome.min.css"))
  86. (symlink (string-append bootstrap
  87. "/share/web/bootstrap/css/bootstrap.min.css")
  88. (string-append out "/static/bootstrap.min.css"))
  89. (symlink (string-append bootstrap
  90. "/share/web/bootstrap/js/bootstrap.min.js")
  91. (string-append out "/static/bootstrap.min.js"))
  92. (symlink (string-append cytoscape
  93. "/share/genenetwork2/javascript/cytoscape/cytoscape.min.js")
  94. (string-append out "/static/cytoscape.min.js"))
  95. (symlink (string-append jquery
  96. "/share/web/jquery/jquery.slim.min.js")
  97. (string-append out "/static/jquery.slim.min.js"))
  98. ;(symlink (string-append js-popper
  99. ; "/share/web/popper/popper.min.js")
  100. ; (string-append out "/static/popper.min.js"))
  101. )
  102. #t))
  103. (add-after 'install 'wrap-executable
  104. (lambda* (#:key inputs outputs #:allow-other-keys)
  105. (let ((out (assoc-ref outputs "out"))
  106. (path (getenv "PYTHONPATH")))
  107. (wrap-program (string-append out "/server.py")
  108. `("PATH" ":" prefix (,(dirname (which "edirect.pl"))
  109. ,(dirname (which "dirname"))
  110. ,(dirname (which "grep"))
  111. ,(dirname (which "sed"))))
  112. `("PYTHONPATH" ":" prefix (,path))))
  113. #t)))))
  114. (inputs
  115. `(("edirect" ,edirect)
  116. ("inetutils" ,inetutils)
  117. ("python-bcrypt" ,python-bcrypt)
  118. ("python-flask-sqlalchemy" ,python-flask-sqlalchemy)
  119. ("python-keras" ,python-keras-for-ratspub)
  120. ("python-nltk" ,python-nltk)
  121. ("tensorflow" ,tensorflow)))
  122. (native-inputs
  123. `(("bootstrap" ,web-bootstrap)
  124. ("cytoscape" ,javascript-cytoscape)
  125. ("font-awesome" ,web-font-awesome)
  126. ("jquery" ,web-jquery)
  127. ;("js-popper" ,js-popper) ; empty output
  128. ))
  129. (home-page "http://rats.pub/")
  130. (synopsis "Relationship with Addiction Through Searches of PubMed")
  131. (description
  132. "RatsPub searches PubMed to find sentences that contain the query terms
  133. (i.e., gene symbols) and drug addiction-related keywords. These gene-keyword
  134. relationships are presented as an interactive graph that can efficiently answer
  135. the question \"What do we know about these genes and addiction?\". Data from
  136. @acronym{EBI GWAS, European Bioinformatics Institute Genome-Wide Association
  137. Studies} catalog are also included in the search to better answer this
  138. question.")
  139. (license license:expat)))
  140. ;; We want a copy of python-keras with the AUC optimizer backported.
  141. ;; We skip the tests because we "test in production".
  142. ;; That's a lie. The test suite just takes a long time to run.
  143. (define-public python-keras-for-ratspub
  144. (hidden-package
  145. (package
  146. (inherit python-keras)
  147. (source
  148. (origin
  149. (inherit (package-source python-keras))
  150. (patches (search-patches "keras-auc-optimizer.patch"))))
  151. (arguments
  152. (substitute-keyword-arguments (package-arguments python-keras)
  153. ((#:phases phases)
  154. `(modify-phases ,phases
  155. (delete 'check))))))))