This repository has been archived by the owner on Jan 3, 2020. It is now read-only.
forked from zotero/translators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDryad Digital Repository.js
323 lines (301 loc) · 12.4 KB
/
Dryad Digital Repository.js
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
{
"translatorID": "7a81d945-7d9c-4f8c-bd7b-4226c1cab40e",
"label": "Dryad Digital Repository",
"creator": "Nathan Day",
"target": "^https?://(www\\.)?datadryad\\.org/",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2015-06-23 02:09:11"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2014 Dryad Digital Repository
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see <http://www.gnu.org/licenses/>.
***** END LICENSE BLOCK *****
*/
function detectWeb(doc, url) {
// Dryad search page
if (url.indexOf('/discover?') != -1) {
return getSearchResults(doc, true) ? 'multiple' : false;
} else {
var result = ZU.xpathText(doc,'//meta[@name="DC.type"][1]/@content');
// Dryad data package
if (result === 'Article') {
return 'journalArticle';
// Dryad data file
} else if (result === 'Dataset') {
//return 'dataset';
return 'journalArticle';
}
}
return false;
}
function doWeb(doc, url) {
var itemType = detectWeb(doc, url);
if (itemType === 'journalArticle') {
scrape(doc, url);
} else if (itemType === 'multiple') {
Zotero.selectItems(getSearchResults(doc), function(items) {
if (!items) return true;
var urls = [];
for (var i in items) {
urls.push(i);
}
ZU.processDocuments(urls, scrape);
})
}
}
function getSearchResults(doc, checkOnly) {
var results = ZU.xpath(doc, '//li[contains(@class,"ds-artifact-item")]/div/a'),
items = {},
found = false;
for (var i=0; i<results.length; i++) {
var title = results[i].getElementsByClassName('artifact-title')[0];
if (!title) continue;
if (checkOnly) return true;
found = true;
title = ZU.trimInternal(title.textContent).replace(/^Data From:\s*/i, '');
items[results[i].href] = title;
}
return found ? items : false;
}
function scrape(doc, url) {
var package_doi = ZU.xpathText(doc, '//meta[@name="DCTERMS.isPartOf"]/@content');
var translator = Zotero.loadTranslator('web');
// use the Embedded Metadata translator
translator.setTranslator('951c027d-74ac-47d4-a107-9c3069ab7b48');
translator.setDocument(doc);
translator.setHandler('itemDone', function(obj, item) {
var itemDoi = item.url.replace(/^.*?doi:/, '');
item.DOI = itemDoi;
item.url = ''; // the doi value is to be used in lieu of the url
item.itemType = 'journalArticle';
// signal a dataset until supported per
// https://www.zotero.org/support/dev/translators/datasets
item.extra = '{:itemType: dataset}';
item.archive = 'Dryad Digital Repository';
item.attachments = [];
item.shortTitle = '';
// Add a .seeAlso value if this is a page for a single data file,
// rather than for a data package collection.
// This is a data file if there is a DCTERMS.isPartOf property.
if (package_doi && package_doi !== 'doi:' + itemDoi) {
item.seeAlso = [package_doi.substring(4)];
}
item.itemID = itemDoi; // internal value for seeAlso relation
item.complete();
});
translator.translate();
// Value for page's possible DCTERMS.isPartOf <meta> tag,
// minus the initial 'doi:'.
// This value is used to set the seeAlso value for a data-file record.
if (package_doi) {
ZU.processDocuments('http://datadryad.org/resource/' + package_doi, scrape);
}
}
/** BEGIN TEST CASES **/
var testCases = [
{
"type": "web",
"url": "http://datadryad.org/resource/doi:10.5061/dryad.9025",
"items": [
{
"itemType": "journalArticle",
"title": "Data from: Phylogenetic analyses of mitochondrial and nuclear data in haematophagous flies support the paraphyly of the genus Stomoxys (Diptera: Muscidae)",
"creators": [
{
"firstName": "Najla",
"lastName": "Dsouli",
"creatorType": "author"
},
{
"firstName": "Frédéric",
"lastName": "Delsuc",
"creatorType": "author"
},
{
"firstName": "Johan",
"lastName": "Michaux",
"creatorType": "author"
},
{
"firstName": "Eric",
"lastName": "De Stordeur",
"creatorType": "author"
},
{
"firstName": "Arnaud",
"lastName": "Couloux",
"creatorType": "author"
},
{
"firstName": "Michel",
"lastName": "Veuille",
"creatorType": "author"
},
{
"firstName": "Gérard",
"lastName": "Duvallet",
"creatorType": "author"
}
],
"date": "2011-02-13",
"DOI": "10.5061/dryad.9025",
"abstractNote": "The genus Stomoxys Geoffroy (Diptera; Muscidae) contains species of parasitic flies that are of medical and economic importance. We conducted a phylogenetic analysis including 10 representative species of the genus including multiple exemplars, together with the closely related genera Prostomoxys Zumpt, Haematobosca Bezzi, and Haematobia Lepeletier & Serville. Phylogenetic relationships were inferred using maximum likelihood and Bayesian methods from DNA fragments from the cytochrome c oxidase subunit I (COI, 753 bp) and cytochrome b (CytB, 587 bp) mitochondrial genes, and the nuclear ribosomal internal transcribed spacer 2 (ITS2, 426 bp). The combination of mitochondrial and nuclear data strongly supports the paraphyly of the genus Stomoxys because of the inclusion of Prostomoxys saegerae Zumpt. This unexpected result suggests that Prostomoxys should be renamed into Stomoxys. Also, the deep molecular divergence observed between the subspecies Stomoxys niger niger Macquart and S. niger bilineatus Grünbreg led us to propose that they should rather be considered as distinct species, in agreement with ecological data. Bayesian phylogenetic analyses support three distinct lineages within the genus Stomoxys with a strong biogeographical component. The first lineage consists solely of the divergent Asian species S. indicus Picard which appears as the sister-group to all remaining Stomoxys species. The second clade groups the strictly African species Stomoxys inornatus Grünbreg, Stomoxys transvittatus Villeneuve, Stomoxys omega Newstead, and Stomoxys pallidus Roubaud. Finally, the third clade includes both African occurring and more widespread species such as the livestock pest Stomoxys calcitrans Linnaeus. Divergence time estimates indicate that the genus Stomoxys originated in the late Oligocene around 30 million years ago, with the major lineages diversifying in the Early Miocene between 20 and 15 million years ago at a time when temperate forests developed in the Northern Hemisphere.",
"archive": "Dryad Digital Repository",
"extra": "{:itemType: dataset}",
"itemID": "10.5061/dryad.9025",
"libraryCatalog": "datadryad.org",
"attachments": [],
"tags": [
"Molecular dating",
"Phylogenetic relationship",
"Stomoxys flies"
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://datadryad.org/resource/doi:10.5061/dryad.9025/2",
"items": [
{
"itemType": "journalArticle",
"title": "Dsouli-InfectGenetEvol11 phylogram",
"creators": [
{
"firstName": "Najla",
"lastName": "Dsouli",
"creatorType": "author"
},
{
"firstName": "Frédéric",
"lastName": "Delsuc",
"creatorType": "author"
},
{
"firstName": "Johan",
"lastName": "Michaux",
"creatorType": "author"
},
{
"firstName": "Eric",
"lastName": "De Stordeur",
"creatorType": "author"
},
{
"firstName": "Arnaud",
"lastName": "Couloux",
"creatorType": "author"
},
{
"firstName": "Michel",
"lastName": "Veuille",
"creatorType": "author"
},
{
"firstName": "Gérard",
"lastName": "Duvallet",
"creatorType": "author"
}
],
"date": "2011-03-31",
"DOI": "10.5061/dryad.9025/2",
"abstractNote": "This phylogram is the 50% majority\r\nrule consensus tree presented in Figure 1. It was obtained with Bayesian inference using MrBayes under the GTR + G model. Numbers at nodes indicate posterior probabilities (PP).",
"archive": "Dryad Digital Repository",
"extra": "{:itemType: dataset}",
"itemID": "10.5061/dryad.9025/2",
"libraryCatalog": "datadryad.org",
"rights": "http://creativecommons.org/publicdomain/zero/1.0/",
"attachments": [],
"tags": [
"Molecular dating",
"Phylogenetic relationship",
"Stomoxys flies"
],
"notes": [],
"seeAlso": [
"10.5061/dryad.9025"
]
},
{
"itemType": "journalArticle",
"title": "Data from: Phylogenetic analyses of mitochondrial and nuclear data in haematophagous flies support the paraphyly of the genus Stomoxys (Diptera: Muscidae)",
"creators": [
{
"firstName": "Najla",
"lastName": "Dsouli",
"creatorType": "author"
},
{
"firstName": "Frédéric",
"lastName": "Delsuc",
"creatorType": "author"
},
{
"firstName": "Johan",
"lastName": "Michaux",
"creatorType": "author"
},
{
"firstName": "Eric",
"lastName": "De Stordeur",
"creatorType": "author"
},
{
"firstName": "Arnaud",
"lastName": "Couloux",
"creatorType": "author"
},
{
"firstName": "Michel",
"lastName": "Veuille",
"creatorType": "author"
},
{
"firstName": "Gérard",
"lastName": "Duvallet",
"creatorType": "author"
}
],
"date": "2011-02-13",
"DOI": "10.5061/dryad.9025",
"abstractNote": "The genus Stomoxys Geoffroy (Diptera; Muscidae) contains species of parasitic flies that are of medical and economic importance. We conducted a phylogenetic analysis including 10 representative species of the genus including multiple exemplars, together with the closely related genera Prostomoxys Zumpt, Haematobosca Bezzi, and Haematobia Lepeletier & Serville. Phylogenetic relationships were inferred using maximum likelihood and Bayesian methods from DNA fragments from the cytochrome c oxidase subunit I (COI, 753 bp) and cytochrome b (CytB, 587 bp) mitochondrial genes, and the nuclear ribosomal internal transcribed spacer 2 (ITS2, 426 bp). The combination of mitochondrial and nuclear data strongly supports the paraphyly of the genus Stomoxys because of the inclusion of Prostomoxys saegerae Zumpt. This unexpected result suggests that Prostomoxys should be renamed into Stomoxys. Also, the deep molecular divergence observed between the subspecies Stomoxys niger niger Macquart and S. niger bilineatus Grünbreg led us to propose that they should rather be considered as distinct species, in agreement with ecological data. Bayesian phylogenetic analyses support three distinct lineages within the genus Stomoxys with a strong biogeographical component. The first lineage consists solely of the divergent Asian species S. indicus Picard which appears as the sister-group to all remaining Stomoxys species. The second clade groups the strictly African species Stomoxys inornatus Grünbreg, Stomoxys transvittatus Villeneuve, Stomoxys omega Newstead, and Stomoxys pallidus Roubaud. Finally, the third clade includes both African occurring and more widespread species such as the livestock pest Stomoxys calcitrans Linnaeus. Divergence time estimates indicate that the genus Stomoxys originated in the late Oligocene around 30 million years ago, with the major lineages diversifying in the Early Miocene between 20 and 15 million years ago at a time when temperate forests developed in the Northern Hemisphere.",
"archive": "Dryad Digital Repository",
"extra": "{:itemType: dataset}",
"itemID": "10.5061/dryad.9025",
"libraryCatalog": "datadryad.org",
"attachments": [],
"tags": [
"Molecular dating",
"Phylogenetic relationship",
"Stomoxys flies"
],
"notes": [],
"seeAlso": []
}
]
},
{
"type": "web",
"url": "http://datadryad.org/discover?query=&submit=Go&fq=dc.subject%3APhylogenetic+relationship&filtertype=*&filter=&rpp=5&sort_by=score&order=DESC",
"items": "multiple"
}
]
/** END TEST CASES **/