forked from RECETOX/galaxytools
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaoptk_download_publication_data.xml
More file actions
148 lines (124 loc) · 5.3 KB
/
Copy pathaoptk_download_publication_data.xml
File metadata and controls
148 lines (124 loc) · 5.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<tool id="aoptk_download_publication_data" name="aoptk download publication data" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="25.1" license="MIT">
<description>Download publication data - full text publications and figures, abstracts, or PDFs.</description>
<macros>
<import>macros.xml</import>
</macros>
<requirements>
<expand macro="requirements"/>
</requirements>
<command detect_errors="exit_code"><![CDATA[
python3 '${download_publication_data}'
]]></command>
<configfiles>
<configfile name="download_publication_data">
import os
from Bio import Entrez
with open("$input_file", "r") as f:
ids = [line.strip() for line in f.readlines()]
email = os.environ.get("EMAIL")
api_key = os.environ.get("NCBI_API_KEY")
#if $literature.database == "pmc":
from aoptk.literature.databases.pmc import PMC
Entrez.email = email
Entrez.api_key = api_key
database = PMC.__new__(PMC)
database.storage = "./"
database.figure_storage = "./figures"
database.id_list = ids
#elif $literature.database == "europepmc":
from aoptk.literature.databases.europepmc import EuropePMC
database = EuropePMC("", storage = "./", figure_storage="./figures")
database.id_list = ids
#elif $literature.database == "pubmed":
from aoptk.literature.databases.pubmed import PubMed
Entrez.email = email
Entrez.api_key = api_key
database = PubMed.__new__(PubMed)
database.id_list = ids
#else:
raise ValueError("Select valid database.")
#end if
#if $literature.type_choice == "publications":
publications = database.get_publications()
for publication in publications:
print(publication.figures)
with open(f"{publication.id}.txt", "w") as f:
f.write(publication.full_text)
#elif $literature.type_choice == "abstracts":
abstracts = database.get_abstracts()
for abstract in abstracts:
with open(f"{abstract.id}.txt", "w") as f:
f.write(abstract.text)
#elif $literature.type_choice == "pdfs":
pdfs = database.get_pdfs()
#else:
raise ValueError("Select valid data type.")
#end if
</configfile>
</configfiles>
<inputs>
<param name="input_file" type="data" format="txt" label="List of IDs to search for." help="Input text file with IDs to search for." />
<conditional name="literature">
<param name="database" type="select" label="Select which database to search." help="PubMed only accepts searches with up to 10 000 results. No limit for Europe PMC and PMC.">
<option value="pmc" selected="true">PMC</option>
<option value="pubmed">PubMed</option>
<option value="europepmc">Europe PMC</option>
</param>
<when value="pubmed">
<param name="type_choice" type="select" label="Data type">
<option value="abstracts">Abstracts</option>
</param>
</when>
<when value="europepmc">
<param name="type_choice" type="select" label="Data type">
<option value="publications">Full text publications</option>
<option value="abstracts">Abstracts</option>
</param>
</when>
<when value="pmc">
<param name="type_choice" type="select" label="Data type">
<option value="publications">Full text publications</option>
<option value="pdfs">PDFs</option>
</param>
</when>
</conditional>
</inputs>
<outputs>
<collection name="text" type="list" label="Downloaded ${database} ${type_choice}" format="txt">
<filter>literature['type_choice'] == 'publications' or literature['type_choice'] == 'abstracts'</filter>
<discover_datasets pattern="(?P<designation>.*)\.txt$" ext="txt" />
</collection>
<collection name="pdfs" type="list" label="Downloaded ${database} PDFs" format="pdf">
<filter>literature['type_choice'] == 'pdfs'</filter>
<discover_datasets pattern="(?P<designation>.*)\.pdf$" ext="pdf" />
</collection>
</outputs>
<tests>
<test expect_num_outputs="1">
<param name="literature|database" value="pmc"/>
<param name="literature|type_choice" value="publications"/>
<param name="input_file" value="test-data/ids.txt"/>
<output_collection name="text" type="list" count="2"/>
</test>
<test expect_num_outputs="1">
<param name="literature|database" value="europepmc"/>
<param name="literature|type_choice" value="abstracts"/>
<param name="input_file" value="test-data/ids.txt"/>
<output_collection name="text" type="list" count="2"/>
</test>
<test expect_num_outputs="1">
<param name="literature|database" value="pmc"/>
<param name="literature|type_choice" value="pdfs"/>
<param name="input_file" value="test-data/ids.txt"/>
<output_collection name="pdfs" type="list" count="2"/>
</test>
</tests>
<help><![CDATA[
Download Publication Data
=========================
Tools to download publication data - full text publications (including abstracts) and figures, abstracts, or PDFs.
]]></help>
<citations>
<citation type="doi">10.5281/zenodo.20036704</citation>
</citations>
</tool>