-
Notifications
You must be signed in to change notification settings - Fork 5
/
get_id_scorpion.m
55 lines (45 loc) · 1.11 KB
/
get_id_scorpion.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
52
53
54
%% get_id_scorpion
% gets id of accepted species name in scorpion-files
%%
function id = get_id_scorpion(my_pet, open)
% created 2021/08/13 by Bas Kooijman
%% Syntax
% id = <../get_id_scorpion.m *get_id_scorpion*>(my_pet, open)
%% Description
% Gets identifier for scorpion-files
%
% 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 scorpion-files
%% Remarks
% Outputs empty strings if identification was not successful.
%% Example of use
% id = get_id_scorpion('Smeringurus_mesaensis',1)
address = 'https://www.ntnu.no/ub/scorpion-files/';
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
[lineage, rank]= lineage_CoL(my_pet);
if isempty(lineage)
id = ''; return
end
family = lineage{ismember(rank,'Family')};
id = lower([family, '.php']);
try
urlread([address, id]);
catch
id = ''; return
end
if open
web([address, id],'-browser');
end