Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pubmed
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
crawlers
pubmed
Commits
233fb199
Commit
233fb199
authored
Jan 18, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[refactoring] add default-extensions to packages, some refactoring
parent
a9d8e08a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
51 additions
and
23 deletions
+51
-23
Main.hs
app/Main.hs
+0
-2
crawlerPubMed.cabal
crawlerPubMed.cabal
+17
-5
package.yaml
package.yaml
+11
-0
PUBMED.hs
src/PUBMED.hs
+23
-9
Client.hs
src/PUBMED/Client.hs
+0
-5
Parser.hs
src/PUBMED/Parser.hs
+0
-2
No files found.
app/Main.hs
View file @
233fb199
{-# LANGUAGE OverloadedStrings #-}
module
Main
where
import
PUBMED
(
getMetadataWith
)
...
...
crawlerPubMed.cabal
View file @
233fb199
cabal-version: 1.12
-- This file has been generated from package.yaml by hpack version 0.3
1.2
.
-- This file has been generated from package.yaml by hpack version 0.3
4.4
.
--
-- see: https://github.com/sol/hpack
--
-- hash: 4bb73f43a66d509480c9a672fe457ad8be7cb2d27c8b0892e234b8ac088a2a44
name: crawlerPubMed
version: 0.1.0.0
...
...
@@ -30,10 +28,16 @@ library
PUBMED
PUBMED.Client
PUBMED.Parser
PUBMED.Test
other-modules:
Paths_crawlerPubMed
hs-source-dirs:
src
default-extensions:
DataKinds
MultiParamTypeClasses
OverloadedStrings
TypeOperators
build-depends:
attoparsec
, base >=4.7 && <5
...
...
@@ -56,10 +60,13 @@ library
executable crawlerPubMed-exe
main-is: Main.hs
other-modules:
Paths_crawlerPubMed
hs-source-dirs:
app
default-extensions:
DataKinds
MultiParamTypeClasses
OverloadedStrings
TypeOperators
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
attoparsec
...
...
@@ -89,6 +96,11 @@ test-suite crawlerPubMed-test
Paths_crawlerPubMed
hs-source-dirs:
test
default-extensions:
DataKinds
MultiParamTypeClasses
OverloadedStrings
TypeOperators
ghc-options: -threaded -rtsopts -with-rtsopts=-N
build-depends:
attoparsec
...
...
package.yaml
View file @
233fb199
...
...
@@ -14,6 +14,12 @@ extra-source-files:
# synopsis: Short description of your package
# category: Web
default-extensions
:
-
DataKinds
-
MultiParamTypeClasses
-
OverloadedStrings
-
TypeOperators
# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
...
...
@@ -51,6 +57,10 @@ executables:
-
-with-rtsopts=-N
dependencies
:
-
crawlerPubMed
# https://stackoverflow.com/questions/67519851/multiple-files-use-the-same-module-name
when
:
-
condition
:
false
other-modules
:
Paths_crawlerPubMed
tests
:
crawlerPubMed-test
:
...
...
@@ -62,3 +72,4 @@ tests:
-
-with-rtsopts=-N
dependencies
:
-
crawlerPubMed
src/PUBMED.hs
View file @
233fb199
{-# LANGUAGE OverloadedStrings #-}
module
PUBMED
where
import
Prelude
hiding
(
takeWhile
)
...
...
@@ -26,6 +24,17 @@ import qualified Data.ByteString as DB
import
qualified
Data.Text
as
T
import
qualified
Data.List
as
List
pmHost
::
String
pmHost
=
"eutils.ncbi.nlm.nih.gov"
pmSearchPath
::
String
pmSearchPath
=
"entrez/eutils"
pmPort
::
Int
pmPort
=
443
defaultEnv
=
do
manager'
<-
newManager
tlsManagerSettings
pure
$
mkClientEnv
manager'
$
BaseUrl
Https
pmHost
pmPort
pmSearchPath
-- | API main function
getMetadataWith
::
Text
->
Maybe
Limit
->
IO
(
Either
Text
[
PubMed
])
getMetadataWith
=
runSimpleFindPubmedAbstractRequest
...
...
@@ -72,10 +81,10 @@ runSimpleFetchPubmedAbstractRequest ::
[
Integer
]
->
IO
(
Either
Text
[
PubMed
])
runSimpleFetchPubmedAbstractRequest
ids
=
do
manager'
<-
newManager
tlsManagerSettings
env
<-
defaultEnv
res
<-
runClientM
(
fetch
(
Just
"pubmed"
)
(
Just
"abstract"
)
ids
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"eutils.ncbi.nlm.nih.gov"
443
"entrez/eutils"
)
env
case
res
of
(
Left
err
)
->
pure
(
Left
.
T
.
pack
$
show
err
)
(
Right
(
BsXml
abs
))
->
...
...
@@ -89,13 +98,18 @@ runSimpleFetchPubmedAbstractRequest ids = do
runSimpleFindPubmedAbstractRequest
::
Text
->
Maybe
Limit
->
IO
(
Either
Text
[
PubMed
])
runSimpleFindPubmedAbstractRequest
query
limit
=
do
manager'
<-
newManager
tlsManagerSettings
eDocIds
<-
searchDocIds
query
limit
case
eDocIds
of
Left
err
->
pure
$
Left
err
Right
docIds
->
runMultipleFPAR
docIds
searchDocIds
::
Text
->
Maybe
Limit
->
IO
(
Either
Text
[
Integer
])
searchDocIds
query
limit
=
do
env
<-
defaultEnv
res
<-
runClientM
(
search
(
Just
query
)
limit
)
(
mkClientEnv
manager'
$
BaseUrl
Https
"eutils.ncbi.nlm.nih.gov"
443
"entrez/eutils"
)
env
case
res
of
(
Left
err
)
->
pure
(
Left
$
T
.
pack
$
show
err
)
(
Right
(
BsXml
docs
))
->
do
let
docIds
=
runParser
parseDocId
docs
runMultipleFPAR
docIds
pure
$
Right
$
runParser
parseDocId
docs
src/PUBMED/Client.hs
View file @
233fb199
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module
PUBMED.Client
where
import
Servant.API
...
...
src/PUBMED/Parser.hs
View file @
233fb199
{-# LANGUAGE OverloadedStrings #-}
module
PUBMED.Parser
where
import
Text.XML.Stream.Parse
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment