-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathget_id_WoRMS.m
52 lines (42 loc) · 1.38 KB
/
get_id_WoRMS.m
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
%% get_id_WoRMS
% gets id of accepted species name in World Register of Marine Species
%%
function [id, name_status, accepted_name] = get_id_WoRMS(my_pet, open)
% created 2021/08/01 by Bas Kooijman, modified 2021/08/26
%% Syntax
% [id, name_status, accepted_name] = <../get_id_WoRMS.m *get_id_WoRMS*>(my_pet, open)
%% Description
% Gets identifier for the accepted species name in the World Register of Marine Species
%
% Input:
%
% * my_pet: character string with name of a taxon
% * open: optional boolean for opening in browser (default: 0)
%
% Output:
%
% * id: character string with id of accepted name in WoRMS
% * name_status: character status of the name my_pet in WoRMS
% * accepted_name: character string with accepted name
%% Remarks
% Outputs empty strings if identification was not successful.
%% Example of use
% [id, stat, nm] = get_id_WoRMS('Squalus_acanthias')
if ~exist('open','var')
open = 0;
end
try
% AphiaID suggested by Bart Vanhoorne [email protected]
url = webread(['https://www.marinespecies.org/rest/AphiaRecordsByName/', strrep(my_pet, '_', '%20'), '?marine_only=0&like=false']);
id = num2str(url.valid_AphiaID);
name_status = url.status;
accepted_name = url.valid_name;
if open
address = 'https://marinespecies.org/aphia.php?p=taxdetails&id=';
web([address, id],'-browser');
end
catch
id = '';
name_status = '';
accepted_name = '';
end