-
Notifications
You must be signed in to change notification settings - Fork 5
/
get_id_ReptileDB.m
50 lines (40 loc) · 1.07 KB
/
get_id_ReptileDB.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
%% get_id_ReptileDB
% gets id of accepted species name in ReptileDB
%%
function id = get_id_ReptileDB(my_pet, open)
% created 2021/08/02 by Bas Kooijman
%% Syntax
% id = <../get_id_ReptileDB.m *get_id_ReptileDB*>(my_pet, open)
%% Description
% Gets identifier for ReptileDB
%
% 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 in ReptileDB
%% Remarks
% Outputs empty strings if identification was not successful.
%% Example of use
% id = get_id_ReptileDB('Lacerta_schreiberi',1)
address = 'https://reptile-database.reptarium.cz/species?';
if ~exist('open','var')
open = 0;
end
if ~isempty(strfind(my_pet, '_'));
nm = strsplit(my_pet,'_'); % genus, species
elseif ~isempty(strfind(my_pet, ' '));
nm = strsplit(my_pet,' '); % genus, species
end
genus = nm{1}; species = nm{2};
id = ['genus=', genus, '&species=', species];
check = urlread([address, id]);
if ~isempty(strfind(check,'was not found'))
id = ''; return
end
if open
web([address, id],'-browser');
end