| 1 | package Bio::Taxonomy::GlobalNames; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use JSON qw(encode_json); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use JSON::Parse qw(parse_json); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 3 | ▶ | use Moo::Lax; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 3 | ▶ | use REST::Client; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 3 | ▶ | use Scalar::Readonly; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||
| 16 | Bio::Taxonomy::GlobalNames - Perlish OO bindings to the L<Global Names Resolver|http://resolver.globalnames.org/> API | ||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||
| 18 | =head1 VERSION | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | Version 0.07 | ||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||
| 22 | =cut | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 3 | our $VERSION = '0.07'; | |||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||
| 26 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | use Bio::Taxonomy::GlobalNames; | ||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | # Provide the input data and parameters. | ||||||||||||||||||||||||||||||||
| 31 | my $query = Bio::Taxonomy::GlobalNames->new( | ||||||||||||||||||||||||||||||||
| 32 | names => $names, | ||||||||||||||||||||||||||||||||
| 33 | data_source_ids => $data_source_ids, | ||||||||||||||||||||||||||||||||
| 34 | resolve_once => $resolve_once, | ||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||
| 37 | my $output = $query->post(); # Perform a POST request and return the output. | ||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||
| 39 | # Go through the Output object. | ||||||||||||||||||||||||||||||||
| 40 | my @data = @{ $output->data }; | ||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||
| 42 | foreach my $datum (@data) | ||||||||||||||||||||||||||||||||
| 43 | { | ||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | # Check if a non-empty Results arrayref was returned. | ||||||||||||||||||||||||||||||||
| 46 | if ( my @results = @{ $datum->results } ) | ||||||||||||||||||||||||||||||||
| 47 | { | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | # Parse the Results objects. | ||||||||||||||||||||||||||||||||
| 50 | foreach my $result (@results) | ||||||||||||||||||||||||||||||||
| 51 | { | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | # Retrieve the canonical name and score for each result. | ||||||||||||||||||||||||||||||||
| 54 | my $canonical_name = $result->canonical_form; | ||||||||||||||||||||||||||||||||
| 55 | my $score = $result->score; | ||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||
| 62 | B<Bio::Taxonomy::GlobalNames> provides Perl objects and functions that | ||||||||||||||||||||||||||||||||
| 63 | interface with the Global Names Resolver web service. Using a REST client, | ||||||||||||||||||||||||||||||||
| 64 | input is sent to the service, whereas results are internally converted | ||||||||||||||||||||||||||||||||
| 65 | from JSON format to nested objects and returned to the user. | ||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||
| 67 | This module can be used for automated standardisation of species names, | ||||||||||||||||||||||||||||||||
| 68 | according to a variety of sources that can be manually selected, if needed. | ||||||||||||||||||||||||||||||||
| 69 | See also the example script, provided with this module. | ||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||
| 71 | =head2 Attributes for Bio::Taxonomy::GlobalNames objects | ||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||
| 73 | =over 1 | ||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | =item data | ||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | A string with a list of names delimited by new lines. | ||||||||||||||||||||||||||||||||
| 78 | You may optionally supply your local id for each name as: | ||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||
| 80 | 123|Parus major | ||||||||||||||||||||||||||||||||
| 81 | 125|Parus thruppi | ||||||||||||||||||||||||||||||||
| 82 | 126|Parus carpi | ||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | Names in the response will contain your supplied ids, facilitating integration. | ||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||
| 86 | B<The attributes 'data', 'file' and 'names' are mutually exclusive.> | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | =item data_source_ids | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | A string with a pipe-delimited list of data sources. | ||||||||||||||||||||||||||||||||
| 91 | See the list of L<data sources|http://resolver.globalnames.org/data_sources>. | ||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||
| 93 | =item file | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | A file B<in Unicode encoding> with a list of names delimited by new lines, | ||||||||||||||||||||||||||||||||
| 96 | similar to the 'data' attribute. | ||||||||||||||||||||||||||||||||
| 97 | This attribute is valid only when the post method is used. | ||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||
| 99 | B<The attributes 'data', 'file' and 'names' are mutually exclusive.> | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | =item names | ||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||
| 103 | A string with a list of names delimited by either pipe "|" or tab "\t". | ||||||||||||||||||||||||||||||||
| 104 | Use a pipe with the get method. | ||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||
| 106 | B<The attributes 'data', 'file' and 'names' are mutually exclusive.> | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | =item resolve_once | ||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||
| 110 | A string with a boolean (true/false) value. Default: 'false'. | ||||||||||||||||||||||||||||||||
| 111 | Find the first available match instead of matches across all data sources with all possible renderings of a name. | ||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||
| 113 | When 'true', response is rapid but incomplete. | ||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | =item with_context | ||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | A string with a boolean (true/false) value. Default: 'true'. | ||||||||||||||||||||||||||||||||
| 118 | Reduce the likelihood of matches to taxonomic homonyms. | ||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||
| 120 | When 'true', a common taxonomic context is calculated for all supplied names | ||||||||||||||||||||||||||||||||
| 121 | from matches in data sources that have classification tree paths. | ||||||||||||||||||||||||||||||||
| 122 | Names out of determined context are penalized during score calculation. | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | =back | ||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||
| 126 | =cut | ||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||
| 128 | ############################################### | ||||||||||||||||||||||||||||||||
| 129 | # Main object attributes with rw permissions. # | ||||||||||||||||||||||||||||||||
| 130 | ############################################### | ||||||||||||||||||||||||||||||||
| 131 | 3 | has file => ( | |||||||||||||||||||||||||||||||
| 132 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 133 | default => q{}, | ||||||||||||||||||||||||||||||||
| 134 | ); | ||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||
| 136 | 3 | has names => ( | |||||||||||||||||||||||||||||||
| 137 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 138 | default => q{}, | ||||||||||||||||||||||||||||||||
| 139 | ); | ||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | 3 | has data => ( | |||||||||||||||||||||||||||||||
| 142 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 143 | default => q{}, | ||||||||||||||||||||||||||||||||
| 144 | ); | ||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||
| 146 | 3 | has data_source_ids => ( | |||||||||||||||||||||||||||||||
| 147 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 148 | default => q{}, | ||||||||||||||||||||||||||||||||
| 149 | ); | ||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | has resolve_once => ( | ||||||||||||||||||||||||||||||||
| 152 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 153 | default => 'false', | ||||||||||||||||||||||||||||||||
| 154 | 3 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||
| 155 | 3 | ▶ | die "resolve_once may be either true or false!\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 156 | unless $_[0] =~ /^true|false$/; | ||||||||||||||||||||||||||||||||
| 157 | }, | ||||||||||||||||||||||||||||||||
| 158 | 3 | ); | |||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||
| 160 | has with_context => ( | ||||||||||||||||||||||||||||||||
| 161 | is => 'rw', | ||||||||||||||||||||||||||||||||
| 162 | default => 'true', | ||||||||||||||||||||||||||||||||
| 163 | 3 | ▶ | isa => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||
| 164 | 3 | ▶ | die "with_context may be either true or false!\n" | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 165 | unless $_[0] =~ /^true|false$/; | ||||||||||||||||||||||||||||||||
| 166 | }, | ||||||||||||||||||||||||||||||||
| 167 | 3 | ); | |||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||
| 169 | # Make sure that the website is up. | ||||||||||||||||||||||||||||||||
| 170 | sub _check_status | ||||||||||||||||||||||||||||||||
| 171 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
_check_status: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||
| 172 | 4 | my ($url) = @_; | |||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||
| 174 | 4 | my $ua = LWP::UserAgent->new( timeout => 5 ); | |||||||||||||||||||||||||||||||
| 175 | 4 | my $response = $ua->get($url); | |||||||||||||||||||||||||||||||
| 176 | 4 | ▶ | return $response->is_success ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||
| 179 | =head3 Methods for Bio::Taxonomy::GlobalNames objects | ||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||
| 181 | =over 1 | ||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | =item B<get> | ||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||
| 185 | Performs a GET request and returns an C<Output> object. | ||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||
| 187 | =back | ||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||
| 189 | =cut | ||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||
| 191 | sub get | ||||||||||||||||||||||||||||||||
| 192 | 1 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=6 SCAR=21.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 193 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | 1 | my $name; | |||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||
| 197 | # Make sure that only one source of names was given. | ||||||||||||||||||||||||||||||||
| 198 | 1 | ▶ | if ( $self->names ne q{} && $self->data ne q{} ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$self->names ne "" and $self->data ne ""
MC/DC0%0/2
$self->names ne "" and $self->data ne ""
$self->names ne ""
$self->data ne ""
Truth table33%1/3
A and B
A= $self->names ne ""B= $self->data ne ""
| |||||||||||||||||||||||||||||||||
| 199 | { | ||||||||||||||||||||||||||||||||
| 200 | 0 | die "The attributes 'names' and 'data' are mutually exclusive!\n"; | |||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||
| 202 | elsif ( $self->names ne q{} ) | ||||||||||||||||||||||||||||||||
| 203 | { | ||||||||||||||||||||||||||||||||
| 204 | 0 | my $proper_name = $self->names; | |||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||
| 206 | # Substitute space with '+'. | ||||||||||||||||||||||||||||||||
| 207 | 0 | $proper_name =~ s/ /+/g; | |||||||||||||||||||||||||||||||
| 208 | 0 | $name = '?names=' . $proper_name; | |||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||
| 210 | else | ||||||||||||||||||||||||||||||||
| 211 | { | ||||||||||||||||||||||||||||||||
| 212 | 1 | my $proper_data = $self->data; | |||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||
| 214 | # Substitute space with '+'. | ||||||||||||||||||||||||||||||||
| 215 | 1 | $proper_data =~ s/ /+/g; | |||||||||||||||||||||||||||||||
| 216 | 1 | $name = '?names=' . $proper_data; | |||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||
| 219 | 1 | my $gnr_url; | |||||||||||||||||||||||||||||||
| 220 | 1 | ▶ | if ( _check_status('http://resolver.globalnames.org/') ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 221 | { | ||||||||||||||||||||||||||||||||
| 222 | 1 | $gnr_url = 'http://resolver.globalnames.org/name_resolvers.json'; | |||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||
| 224 | elsif ( _check_status('http://resolver.globalnames.biodinfo.org') ) | ||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||
| 226 | 0 | $gnr_url = | |||||||||||||||||||||||||||||||
| 227 | 'http://resolver.globalnames.biodinfo.org/name_resolvers.json'; | ||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||
| 229 | else | ||||||||||||||||||||||||||||||||
| 230 | { | ||||||||||||||||||||||||||||||||
| 231 | 0 | die "The Global Names Resolver website is down.\n"; | |||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||
| 234 | # Create the target url. | ||||||||||||||||||||||||||||||||
| 235 | 1 | my $url = | |||||||||||||||||||||||||||||||
| 236 | $gnr_url | ||||||||||||||||||||||||||||||||
| 237 | . $name | ||||||||||||||||||||||||||||||||
| 238 | . '&resolve_once=' | ||||||||||||||||||||||||||||||||
| 239 | . $self->resolve_once | ||||||||||||||||||||||||||||||||
| 240 | . '&with_context=' | ||||||||||||||||||||||||||||||||
| 241 | . $self->with_context | ||||||||||||||||||||||||||||||||
| 242 | . '&data_source_ids=' | ||||||||||||||||||||||||||||||||
| 243 | . $self->data_source_ids; | ||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||
| 245 | # Create the REST client and perform a GET request. | ||||||||||||||||||||||||||||||||
| 246 | 1 | my $rest_client = REST::Client->new(); | |||||||||||||||||||||||||||||||
| 247 | 1 | $rest_client->GET($url); | |||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | # Parse the results in JSON format and return them | ||||||||||||||||||||||||||||||||
| 250 | # as an Output object. | ||||||||||||||||||||||||||||||||
| 251 | 1 | return Bio::Taxonomy::GlobalNames::Output::format_results( | |||||||||||||||||||||||||||||||
| 252 | parse_json( $rest_client->responseContent() ) ); | ||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||
| 255 | =over 1 | ||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | =item B<post> | ||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||
| 259 | Performs a POST request and returns an C<Output> object. | ||||||||||||||||||||||||||||||||
| 260 | If you are supplying an input file, you have to use the 'post' method. | ||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||
| 262 | =back | ||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||
| 264 | =cut | ||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||
| 266 | sub post | ||||||||||||||||||||||||||||||||
| 267 | 3 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
post: called CC=9 SCAR=23.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 268 | 3 | my $self = shift; | |||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||
| 270 | 3 | my $body = { | |||||||||||||||||||||||||||||||
| 271 | 'format' => 'json', | ||||||||||||||||||||||||||||||||
| 272 | 'data_source_ids' => $self->data_source_ids, | ||||||||||||||||||||||||||||||||
| 273 | 'resolve_once' => $self->resolve_once, | ||||||||||||||||||||||||||||||||
| 274 | 'with_context' => $self->with_context, | ||||||||||||||||||||||||||||||||
| 275 | }; | ||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||
| 277 | # Check the number of valid name sources provided. | ||||||||||||||||||||||||||||||||
| 278 | 3 | my $input_check = 0; | |||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||
| 280 | 3 | my @input_data = ( $self->file, $self->names, $self->data ); | |||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | 3 | foreach (@input_data) | |||||||||||||||||||||||||||||||
| 283 | { | ||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||
| 285 | # If the source is not empty, increment the counter. | ||||||||||||||||||||||||||||||||
| 286 | 9 | ▶ | if ( $_ ne q{} ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 287 | { | ||||||||||||||||||||||||||||||||
| 288 | 2 | $input_check++; | |||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | # If the counter is bigger than 1, die. | ||||||||||||||||||||||||||||||||
| 293 | 3 | ▶ | if ( $input_check > 1 ) | ||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||
| 294 | { | ||||||||||||||||||||||||||||||||
| 295 | 0 | die | |||||||||||||||||||||||||||||||
| 296 | "The attributes 'file', 'names' and 'data' are mutually exclusive!\n"; | ||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||
| 298 | ▶ | elsif ( $self->file ne q{} && -r $self->file ) | |||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->file ne "" and -r $self->file
MC/DC50%1/2
$self->file ne "" and -r $self->file
$self->file ne ""
-r $self->file
Truth table66%2/3
A and B
A= $self->file ne ""B= -r $self->file
| |||||||||||||||||||||||||||||||||
| 299 | { | ||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||
| 301 | # If a readable file was provided, read its content. | ||||||||||||||||||||||||||||||||
| 302 | 2 | local $/ = undef; | |||||||||||||||||||||||||||||||
| 303 | 2 | open my $fh, '<:encoding(UTF-8)', $self->file; | |||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||
| 305 | 2 | $body->{'data'} = <$fh>; | |||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||
| 307 | # Remove single and double quotes from the file's contents. | ||||||||||||||||||||||||||||||||
| 308 | 2 | $body->{'data'} =~ s/['"]//g; | |||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||
| 310 | 2 | close $fh; | |||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||
| 312 | elsif ( $self->names ne q{} ) | ||||||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||||||
| 314 | 0 | $body->{'names'} = $self->names; | |||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||
| 316 | else | ||||||||||||||||||||||||||||||||
| 317 | { | ||||||||||||||||||||||||||||||||
| 318 | 1 | $body->{'data'} = $self->data; | |||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||
| 321 | # Inform the server that we're sending JSON encoded content. | ||||||||||||||||||||||||||||||||
| 322 | 3 | my $headers = { Content_Type => 'application/json' }; | |||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||
| 324 | 3 | my $gnr_url; | |||||||||||||||||||||||||||||||
| 325 | 3 | ▶ | if ( _check_status('http://resolver.globalnames.org/') ) | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 326 | { | ||||||||||||||||||||||||||||||||
| 327 | 3 | $gnr_url = 'http://resolver.globalnames.org/name_resolvers'; | |||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | elsif ( _check_status('http://resolver.globalnames.biodinfo.org') ) | ||||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||||
| 331 | 0 | $gnr_url = 'http://resolver.globalnames.biodinfo.org/name_resolvers'; | |||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||
| 333 | else | ||||||||||||||||||||||||||||||||
| 334 | { | ||||||||||||||||||||||||||||||||
| 335 | 0 | die "The Global Names Resolver website is down.\n"; | |||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||
| 338 | # Encode data to JSON format, create the REST client and perform | ||||||||||||||||||||||||||||||||
| 339 | # a POST request. | ||||||||||||||||||||||||||||||||
| 340 | 3 | my $data = encode_json($body); | |||||||||||||||||||||||||||||||
| 341 | 3 | my $rest_client = REST::Client->new(); | |||||||||||||||||||||||||||||||
| 342 | 3 | $rest_client->POST( $gnr_url, ( $data, $headers ) ); | |||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||
| 344 | # Parse the results in JSON format and return them | ||||||||||||||||||||||||||||||||
| 345 | # as an Output object. | ||||||||||||||||||||||||||||||||
| 346 | 3 | return Bio::Taxonomy::GlobalNames::Output::format_results( | |||||||||||||||||||||||||||||||
| 347 | parse_json( $rest_client->responseContent() ) ); | ||||||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||
| 350 | =head2 Attributes for Output objects | ||||||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||||||
| 352 | =over 1 | ||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||
| 354 | =item $output->context | ||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||
| 356 | A C<Context> object, if 'with_context' parameter is set to true. | ||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||
| 358 | =item $output->data | ||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||
| 360 | An array reference of C<Data> objects, containing query input(s) and results. | ||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||
| 362 | my @data = @{ $output->data }; | ||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||
| 364 | =item $output->data_sources | ||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||
| 366 | An array reference of C<DataSources> objects, whose ids you used for name resolution. | ||||||||||||||||||||||||||||||||
| 367 | If no data sources were given, the array reference is empty. | ||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||
| 369 | my @data_sources = @{ $output->data_sources }; | ||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||
| 371 | =item $output->id | ||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||
| 373 | The resolver request id. Your request is stored temporarily in the remote database and is assigned an id. | ||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||
| 375 | =item $output->parameters | ||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||
| 377 | A C<Parameters> object, containing the parameters of the query. | ||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||
| 379 | =item $output->status B<or> $output->message | ||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||
| 381 | The final status of the request -- 'success' or 'failure'. | ||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||
| 383 | =item $output->status_message | ||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||
| 385 | The message associated with the status. | ||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||
| 387 | =item $output->url | ||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||
| 389 | The url at which you can access your results for 7 days. | ||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||
| 391 | =back | ||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||
| 393 | =cut | ||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||
| 395 | package Bio::Taxonomy::GlobalNames::Output; | ||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||
| 397 | 3 | ▶ | use Moo::Lax; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||
| 399 | ################################################# | ||||||||||||||||||||||||||||||||
| 400 | # Output object attributes with ro permissions. # | ||||||||||||||||||||||||||||||||
| 401 | ################################################# | ||||||||||||||||||||||||||||||||
| 402 | 3 | has status => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 403 | 3 | has data_sources => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 404 | 3 | has data => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 405 | 3 | has message => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 406 | 3 | has parameters => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 407 | 3 | has url => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 408 | 3 | has context => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 409 | 3 | has id => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 410 | 3 | has status_message => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||
| 412 | # Create an Output object with results and data as sub-objects. | ||||||||||||||||||||||||||||||||
| 413 | sub format_results | ||||||||||||||||||||||||||||||||
| 414 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
format_results: called CC=4 SCAR=14.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 415 | 4 | my ($input) = @_; | |||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||
| 417 | 4 | my @elements = qw( | |||||||||||||||||||||||||||||||
| 418 | status data_sources data message | ||||||||||||||||||||||||||||||||
| 419 | parameters url context id | ||||||||||||||||||||||||||||||||
| 420 | status_message | ||||||||||||||||||||||||||||||||
| 421 | ); | ||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||
| 423 | # If something isn't defined, set it as the empty string. | ||||||||||||||||||||||||||||||||
| 424 | 4 | foreach (@elements) | |||||||||||||||||||||||||||||||
| 425 | { | ||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||
| 427 | # Avoid readonly variables caused by JSON conversion. | ||||||||||||||||||||||||||||||||
| 428 | 36 | ▶ | if ( Scalar::Readonly::readonly( $input->{$_} ) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 429 | { | ||||||||||||||||||||||||||||||||
| 430 | 0 | Scalar::Readonly::readonly_off( $input->{$_} ); | |||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||
| 432 | 36 | ▶ | $input->{$_} //= q{}; | ||||||||||||||||||||||||||||||
|
Condition100%2/2
$input->{$_} //= ""
MC/DC100%1/1
$input->{$_} //= ""
$input->{$_}
Truth table100%2/2
A
A= $input->{$_}
| |||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||
| 435 | # Build the object. | ||||||||||||||||||||||||||||||||
| 436 | my $results_object = Bio::Taxonomy::GlobalNames::Output->new( | ||||||||||||||||||||||||||||||||
| 437 | 'status' => $input->{'status'}, | ||||||||||||||||||||||||||||||||
| 438 | 'data_sources' => | ||||||||||||||||||||||||||||||||
| 439 | Bio::Taxonomy::GlobalNames::Output::DataSources::object( | ||||||||||||||||||||||||||||||||
| 440 | $input->{'data_sources'} | ||||||||||||||||||||||||||||||||
| 441 | ), | ||||||||||||||||||||||||||||||||
| 442 | 'data' => | ||||||||||||||||||||||||||||||||
| 443 | Bio::Taxonomy::GlobalNames::Output::Data::object( $input->{'data'} ), | ||||||||||||||||||||||||||||||||
| 444 | 'message' => $input->{'message'}, | ||||||||||||||||||||||||||||||||
| 445 | 'parameters' => Bio::Taxonomy::GlobalNames::Output::Parameters::object( | ||||||||||||||||||||||||||||||||
| 446 | $input->{'parameters'} | ||||||||||||||||||||||||||||||||
| 447 | ), | ||||||||||||||||||||||||||||||||
| 448 | 'url' => $input->{'url'}, | ||||||||||||||||||||||||||||||||
| 449 | 'context' => Bio::Taxonomy::GlobalNames::Output::Context::object( | ||||||||||||||||||||||||||||||||
| 450 | $input->{'context'} | ||||||||||||||||||||||||||||||||
| 451 | ), | ||||||||||||||||||||||||||||||||
| 452 | 'id' => $input->{'id'}, | ||||||||||||||||||||||||||||||||
| 453 | 4 | 'status_message' => $input->{'status_message'} | |||||||||||||||||||||||||||||||
| 454 | ); | ||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||
| 456 | 0 | return $results_object; | |||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||
| 459 | =head2 Attributes for Data objects | ||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||
| 461 | =over 1 | ||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||
| 463 | =item $datum->results | ||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||
| 465 | An array reference of C<Results> objects. | ||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||
| 467 | my @results = @{ $datum->results }; | ||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||
| 469 | =item $datum->supplied_id | ||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||
| 471 | The id of the name string in the query (if provided). | ||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||
| 473 | =item $datum->supplied_name_string | ||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||
| 475 | The name string in the query. | ||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||
| 477 | =back | ||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||
| 479 | =cut | ||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||
| 481 | package Bio::Taxonomy::GlobalNames::Output::Data; | ||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||
| 483 | 3 | ▶ | use Moo::Lax; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||
| 485 | ################################################# | ||||||||||||||||||||||||||||||||
| 486 | # Data object attributes with ro permissions. # | ||||||||||||||||||||||||||||||||
| 487 | ################################################# | ||||||||||||||||||||||||||||||||
| 488 | 3 | has supplied_name_string => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 489 | 3 | has supplied_id => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 490 | 3 | has results => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||||||
| 492 | # Create an array of Data objects. | ||||||||||||||||||||||||||||||||
| 493 | sub object | ||||||||||||||||||||||||||||||||
| 494 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
object: called CC=6 SCAR=25.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 495 | 4 | my ($input) = @_; | |||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||
| 497 | 4 | my @results; | |||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||
| 499 | # If the input is empty, set it as an empty array. | ||||||||||||||||||||||||||||||||
| 500 | 4 | ▶ | if ( $input eq q{} ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 501 | { | ||||||||||||||||||||||||||||||||
| 502 | 4 | $input = []; | |||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||
| 504 | |||||||||||||||||||||||||||||||||
| 505 | # If the arrayref isn't empty... | ||||||||||||||||||||||||||||||||
| 506 | 4 | foreach my $species ( @{$input} ) | |||||||||||||||||||||||||||||||
| 507 | { | ||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||
| 509 | # If something isn't defined, set it as the empty string. | ||||||||||||||||||||||||||||||||
| 510 | 0 | for ( 'supplied_name_string', 'supplied_id', 'results' ) | |||||||||||||||||||||||||||||||
| 511 | { | ||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||
| 513 | # Avoid readonly variables caused by JSON conversion. | ||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | if ( Scalar::Readonly::readonly( $species->{$_} ) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 515 | { | ||||||||||||||||||||||||||||||||
| 516 | 0 | Scalar::Readonly::readonly_off( $species->{$_} ); | |||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | $species->{$_} //= q{}; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$species->{$_} //= ""
MC/DC0%0/1
$species->{$_} //= ""
$species->{$_}
Truth table0%0/2
A
A= $species->{$_}
| |||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||
| 521 | # Create the object. | ||||||||||||||||||||||||||||||||
| 522 | my $resulting_object = Bio::Taxonomy::GlobalNames::Output::Data->new( | ||||||||||||||||||||||||||||||||
| 523 | 'supplied_name_string' => $species->{'supplied_name_string'}, | ||||||||||||||||||||||||||||||||
| 524 | 'supplied_id' => $species->{'supplied_id'}, | ||||||||||||||||||||||||||||||||
| 525 | 'results' => | ||||||||||||||||||||||||||||||||
| 526 | Bio::Taxonomy::GlobalNames::Output::Data::Results::object( | ||||||||||||||||||||||||||||||||
| 527 | 0 | $species->{'results'} | |||||||||||||||||||||||||||||||
| 528 | ), | ||||||||||||||||||||||||||||||||
| 529 | ); | ||||||||||||||||||||||||||||||||
| 530 | 0 | push @results, $resulting_object; | |||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||
| 533 | 4 | return \@results; | |||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||
| 536 | =head2 Attributes for Results objects | ||||||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||||||
| 538 | =over 1 | ||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||
| 540 | =item $result->canonical_form | ||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||
| 542 | A "canonical" version of the name generated by the Global Names parser. | ||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||
| 544 | =item $result->classification_path | ||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||
| 546 | Tree path to the root if a name string was found within a data source classification. | ||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||
| 548 | =item $result->classification_path_ids | ||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||
| 550 | Tree path to the root using taxon_ids, if a name string was found within a data source classification. | ||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||
| 552 | =item $result->classification_path_ranks | ||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||
| 554 | =item $result->data_source_id | ||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||
| 556 | The id of the data source where a name was found. | ||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||
| 558 | =item $result->data_source_title | ||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||
| 560 | The title of the data source where a name was found. | ||||||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||||||
| 562 | =item $result->gni_uuid | ||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||
| 564 | An identifier for the found name string used in Global Names. | ||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||
| 566 | =item $result->local_id | ||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||
| 568 | Shows id local to the data source (if provided by the data source manager). | ||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||
| 570 | =item $result->match_type | ||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||
| 572 | Explains how resolver found the name. | ||||||||||||||||||||||||||||||||
| 573 | If the resolver cannot find names corresponding to the entire queried name string, | ||||||||||||||||||||||||||||||||
| 574 | it sequentially removes terminal portions of the name string until a match is found. | ||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||
| 576 | 1 - Exact match | ||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||
| 578 | 2 - Exact match by canonical form of a name | ||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||
| 580 | 3 - Fuzzy match by canonical form | ||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||
| 582 | 4 - Partial exact match by species part of canonical form | ||||||||||||||||||||||||||||||||
| 583 | |||||||||||||||||||||||||||||||||
| 584 | 5 - Partial fuzzy match by species part of canonical form | ||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||
| 586 | 6 - Exact match by genus part of a canonical form | ||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||
| 588 | =item $result->name_string | ||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||
| 590 | The name string found in this data source. | ||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||
| 592 | =item $result->prescore | ||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||
| 594 | Displays points used to calculate the score delimited by '|' -- | ||||||||||||||||||||||||||||||||
| 595 | "Match points|Author match points|Context points". | ||||||||||||||||||||||||||||||||
| 596 | Negative points decrease the final result. | ||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||
| 598 | =item $result->score | ||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||
| 600 | A confidence score calculated for the match. | ||||||||||||||||||||||||||||||||
| 601 | 0.5 means an uncertain result that will require investigation. | ||||||||||||||||||||||||||||||||
| 602 | Results higher than 0.9 correspond to 'good' matches. | ||||||||||||||||||||||||||||||||
| 603 | Results between 0.5 and 0.9 should be taken with caution. | ||||||||||||||||||||||||||||||||
| 604 | Results less than 0.5 are likely poor matches. | ||||||||||||||||||||||||||||||||
| 605 | The scoring is described in more details at L<http://resolver.globalnames.org/about>. | ||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||
| 607 | =item $result->taxon_id | ||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||
| 609 | An identifier supplied in the source Darwin Core Archive for the name string record. | ||||||||||||||||||||||||||||||||
| 610 | |||||||||||||||||||||||||||||||||
| 611 | =back | ||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||
| 613 | =cut | ||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||
| 615 | package Bio::Taxonomy::GlobalNames::Output::Data::Results; | ||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||
| 617 | 3 | ▶ | use Moo::Lax; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||
| 619 | ################################################## | ||||||||||||||||||||||||||||||||
| 620 | # Results object attributes with ro permissions. # | ||||||||||||||||||||||||||||||||
| 621 | ################################################## | ||||||||||||||||||||||||||||||||
| 622 | 3 | has data_source_title => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 623 | 3 | has match_type => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 624 | 3 | has gni_uuid => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 625 | 3 | has taxon_id => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 626 | 3 | has classification_path_ids => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 627 | 3 | has canonical_form => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 628 | 3 | has name_string => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 629 | 3 | has score => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 630 | 3 | has prescore => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 631 | 3 | has classification_path => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 632 | 3 | has classification_path_ranks => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 633 | 3 | has data_source_id => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 634 | 3 | has local_id => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 635 | |||||||||||||||||||||||||||||||||
| 636 | # Create an array of Results objects. | ||||||||||||||||||||||||||||||||
| 637 | sub object | ||||||||||||||||||||||||||||||||
| 638 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
object: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 639 | 0 | my ($input) = @_; | |||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||
| 641 | 0 | my @array = qw( | |||||||||||||||||||||||||||||||
| 642 | data_source_title match_type | ||||||||||||||||||||||||||||||||
| 643 | gni_uuid taxon_id | ||||||||||||||||||||||||||||||||
| 644 | classification_path_ids canonical_form | ||||||||||||||||||||||||||||||||
| 645 | name_string score | ||||||||||||||||||||||||||||||||
| 646 | prescore classification_path | ||||||||||||||||||||||||||||||||
| 647 | classification_path_ranks data_source_id | ||||||||||||||||||||||||||||||||
| 648 | local_id | ||||||||||||||||||||||||||||||||
| 649 | ); | ||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||
| 651 | 0 | my @results; | |||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||
| 653 | # If the input is empty, set it as an empty array. | ||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | if ( $input eq q{} ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 655 | { | ||||||||||||||||||||||||||||||||
| 656 | 0 | $input = []; | |||||||||||||||||||||||||||||||
| 657 | } | ||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||
| 659 | # If the arrayref isn't empty... | ||||||||||||||||||||||||||||||||
| 660 | 0 | foreach my $hit ( @{$input} ) | |||||||||||||||||||||||||||||||
| 661 | { | ||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||
| 663 | # If something isn't defined, set it as the empty string. | ||||||||||||||||||||||||||||||||
| 664 | 0 | foreach (@array) | |||||||||||||||||||||||||||||||
| 665 | { | ||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||
| 667 | # Avoid readonly variables caused by JSON conversion. | ||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | if ( Scalar::Readonly::readonly( $hit->{$_} ) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 669 | { | ||||||||||||||||||||||||||||||||
| 670 | 0 | Scalar::Readonly::readonly_off( $hit->{$_} ); | |||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | $hit->{$_} //= q{}; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$hit->{$_} //= ""
MC/DC0%0/1
$hit->{$_} //= ""
$hit->{$_}
Truth table0%0/2
A
A= $hit->{$_}
| |||||||||||||||||||||||||||||||||
| 673 | } | ||||||||||||||||||||||||||||||||
| 674 | |||||||||||||||||||||||||||||||||
| 675 | # Create the object. | ||||||||||||||||||||||||||||||||
| 676 | my $resulting_object = | ||||||||||||||||||||||||||||||||
| 677 | Bio::Taxonomy::GlobalNames::Output::Data::Results->new( | ||||||||||||||||||||||||||||||||
| 678 | 'data_source_title' => $hit->{'data_source_title'}, | ||||||||||||||||||||||||||||||||
| 679 | 'match_type' => $hit->{'match_type'}, | ||||||||||||||||||||||||||||||||
| 680 | 'gni_uuid' => $hit->{'gni_uuid'}, | ||||||||||||||||||||||||||||||||
| 681 | 'taxon_id' => $hit->{'taxon_id'}, | ||||||||||||||||||||||||||||||||
| 682 | 'classification_path_ids' => $hit->{'classification_path_ids'}, | ||||||||||||||||||||||||||||||||
| 683 | 'canonical_form' => $hit->{'canonical_form'}, | ||||||||||||||||||||||||||||||||
| 684 | 'name_string' => $hit->{'name_string'}, | ||||||||||||||||||||||||||||||||
| 685 | 'score' => $hit->{'score'}, | ||||||||||||||||||||||||||||||||
| 686 | 'prescore' => $hit->{'prescore'}, | ||||||||||||||||||||||||||||||||
| 687 | 'classification_path' => $hit->{'classification_path_ranks'}, | ||||||||||||||||||||||||||||||||
| 688 | 'data_source_id' => $hit->{'data_source_id'}, | ||||||||||||||||||||||||||||||||
| 689 | 0 | 'local_id' => $hit->{'local_id'}, | |||||||||||||||||||||||||||||||
| 690 | ); | ||||||||||||||||||||||||||||||||
| 691 | 0 | push @results, $resulting_object; | |||||||||||||||||||||||||||||||
| 692 | } | ||||||||||||||||||||||||||||||||
| 693 | |||||||||||||||||||||||||||||||||
| 694 | 0 | return \@results; | |||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||
| 697 | =head2 Attributes for DataSources objects | ||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||
| 699 | =over 1 | ||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||
| 701 | =item $data_source->id | ||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||
| 703 | The ID of the data source. | ||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||
| 705 | =item $data_source->title | ||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||
| 707 | The name of the data source. | ||||||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||||||
| 709 | =back | ||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||
| 711 | =cut | ||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||
| 713 | package Bio::Taxonomy::GlobalNames::Output::DataSources; | ||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||
| 715 | 3 | ▶ | use Moo::Lax; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||
| 717 | ###################################################### | ||||||||||||||||||||||||||||||||
| 718 | # DataSources object attributes with ro permissions. # | ||||||||||||||||||||||||||||||||
| 719 | ###################################################### | ||||||||||||||||||||||||||||||||
| 720 | 3 | has title => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 721 | 3 | has id => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||||||
| 723 | # Create an array of DataSources objects. | ||||||||||||||||||||||||||||||||
| 724 | sub object | ||||||||||||||||||||||||||||||||
| 725 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
object: called CC=6 SCAR=25.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 726 | 4 | my ($input) = @_; | |||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||
| 728 | 4 | my @results; | |||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||
| 730 | # If the input is empty, set it as the empty array. | ||||||||||||||||||||||||||||||||
| 731 | 4 | ▶ | if ( $input eq q{} ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 732 | { | ||||||||||||||||||||||||||||||||
| 733 | 4 | $input = []; | |||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||
| 736 | # If the arrayref isn't empty... | ||||||||||||||||||||||||||||||||
| 737 | 4 | foreach my $source ( @{$input} ) | |||||||||||||||||||||||||||||||
| 738 | { | ||||||||||||||||||||||||||||||||
| 739 | |||||||||||||||||||||||||||||||||
| 740 | # If something isn't defined, set it as the empty string. | ||||||||||||||||||||||||||||||||
| 741 | 0 | foreach ( 'title', 'id' ) | |||||||||||||||||||||||||||||||
| 742 | { | ||||||||||||||||||||||||||||||||
| 743 | |||||||||||||||||||||||||||||||||
| 744 | # Avoid readonly variables caused by JSON conversion. | ||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | if ( Scalar::Readonly::readonly( $source->{$_} ) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 746 | { | ||||||||||||||||||||||||||||||||
| 747 | 0 | Scalar::Readonly::readonly_off( $source->{$_} ); | |||||||||||||||||||||||||||||||
| 748 | } | ||||||||||||||||||||||||||||||||
| 749 | 0 | ▶ | $source->{$_} //= q{}; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$source->{$_} //= ""
MC/DC0%0/1
$source->{$_} //= ""
$source->{$_}
Truth table0%0/2
A
A= $source->{$_}
| |||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||||||
| 752 | # Create the object. | ||||||||||||||||||||||||||||||||
| 753 | my $resulting_object = | ||||||||||||||||||||||||||||||||
| 754 | Bio::Taxonomy::GlobalNames::Output::DataSources->new( | ||||||||||||||||||||||||||||||||
| 755 | 'title' => $source->{'title'}, | ||||||||||||||||||||||||||||||||
| 756 | 0 | 'id' => $source->{'id'}, | |||||||||||||||||||||||||||||||
| 757 | ); | ||||||||||||||||||||||||||||||||
| 758 | 0 | push @results, $resulting_object; | |||||||||||||||||||||||||||||||
| 759 | } | ||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||
| 761 | 4 | return \@results; | |||||||||||||||||||||||||||||||
| 762 | } | ||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||
| 764 | =head2 Attributes for Parameters objects | ||||||||||||||||||||||||||||||||
| 765 | |||||||||||||||||||||||||||||||||
| 766 | =over 1 | ||||||||||||||||||||||||||||||||
| 767 | |||||||||||||||||||||||||||||||||
| 768 | =item $parameters->best_match_only | ||||||||||||||||||||||||||||||||
| 769 | |||||||||||||||||||||||||||||||||
| 770 | =item $parameters->data_sources | ||||||||||||||||||||||||||||||||
| 771 | |||||||||||||||||||||||||||||||||
| 772 | An array reference of data source ids you used for name resolution. If no data sources were given, the arrayref is empty. | ||||||||||||||||||||||||||||||||
| 773 | |||||||||||||||||||||||||||||||||
| 774 | my @data_sources = @{ $parameters->data_sources }; | ||||||||||||||||||||||||||||||||
| 775 | |||||||||||||||||||||||||||||||||
| 776 | =item $parameters->header_only | ||||||||||||||||||||||||||||||||
| 777 | |||||||||||||||||||||||||||||||||
| 778 | =item $parameters->preferred_data_sources | ||||||||||||||||||||||||||||||||
| 779 | |||||||||||||||||||||||||||||||||
| 780 | =item $parameters->resolve_once | ||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||
| 782 | True if 'resolve_once' parameter is set to true and vice versa. | ||||||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||||||
| 784 | =item $parameters->with_context | ||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||
| 786 | True if 'with_context' parameter is set to true and vice versa. | ||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||
| 788 | =back | ||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||
| 790 | =cut | ||||||||||||||||||||||||||||||||
| 791 | |||||||||||||||||||||||||||||||||
| 792 | package Bio::Taxonomy::GlobalNames::Output::Parameters; | ||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||
| 794 | 3 | ▶ | use Moo::Lax; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||
| 796 | ##################################################### | ||||||||||||||||||||||||||||||||
| 797 | # Parameters object attributes with ro permissions. # | ||||||||||||||||||||||||||||||||
| 798 | ##################################################### | ||||||||||||||||||||||||||||||||
| 799 | 3 | has best_match_only => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 800 | 3 | has resolve_once => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 801 | 3 | has data_sources => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 802 | 3 | has header_only => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 803 | 3 | has with_context => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 804 | 3 | has preferred_data_sources => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||||||
| 806 | # Create the Parameters object. | ||||||||||||||||||||||||||||||||
| 807 | sub object | ||||||||||||||||||||||||||||||||
| 808 | 4 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
object: called CC=4 SCAR=21.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 809 | 4 | my ($input) = @_; | |||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||
| 811 | 4 | my @array = qw( | |||||||||||||||||||||||||||||||
| 812 | best_match_only resolve_once | ||||||||||||||||||||||||||||||||
| 813 | data_sources header_only | ||||||||||||||||||||||||||||||||
| 814 | with_context preferred_data_sources | ||||||||||||||||||||||||||||||||
| 815 | ); | ||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||
| 817 | # If something isn't defined, set it as the empty string. | ||||||||||||||||||||||||||||||||
| 818 | 4 | foreach (@array) | |||||||||||||||||||||||||||||||
| 819 | { | ||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||
| 821 | # Avoid readonly variables caused by JSON conversion. | ||||||||||||||||||||||||||||||||
| 822 | 4 | ▶ | if ( Scalar::Readonly::readonly( $input->{$_} ) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 823 | { | ||||||||||||||||||||||||||||||||
| 824 | 0 | Scalar::Readonly::readonly_off( $input->{$_} ); | |||||||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | $input->{$_} //= q{}; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$input->{$_} //= ""
MC/DC0%0/1
$input->{$_} //= ""
$input->{$_}
Truth table0%0/2
A
A= $input->{$_}
| |||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||
| 829 | # Create the object. | ||||||||||||||||||||||||||||||||
| 830 | my $result = Bio::Taxonomy::GlobalNames::Output::Parameters->new( | ||||||||||||||||||||||||||||||||
| 831 | 'best_match_only' => $input->{'best_match_only'}, | ||||||||||||||||||||||||||||||||
| 832 | 'resolve_once' => $input->{'resolve_once'}, | ||||||||||||||||||||||||||||||||
| 833 | 'data_sources' => $input->{'data_sources'}, | ||||||||||||||||||||||||||||||||
| 834 | 'header_only' => $input->{'header_only'}, | ||||||||||||||||||||||||||||||||
| 835 | 'with_context' => $input->{'with_context'}, | ||||||||||||||||||||||||||||||||
| 836 | 0 | 'preferred_data_sources' => $input->{'preferred_data_sources'}, | |||||||||||||||||||||||||||||||
| 837 | ); | ||||||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||||||
| 839 | 0 | return $result; | |||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||
| 842 | =head2 Attributes for Context objects | ||||||||||||||||||||||||||||||||
| 843 | |||||||||||||||||||||||||||||||||
| 844 | =over 1 | ||||||||||||||||||||||||||||||||
| 845 | |||||||||||||||||||||||||||||||||
| 846 | =item $context->context_clade | ||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||
| 848 | A lowest taxonomic level in the data source that contains 90% or more of all names found. | ||||||||||||||||||||||||||||||||
| 849 | If there are too few names to determine, this element remains empty. | ||||||||||||||||||||||||||||||||
| 850 | |||||||||||||||||||||||||||||||||
| 851 | =item $context->context_data_source_id | ||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||
| 853 | The id of a data source used to create the context. | ||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||
| 855 | =back | ||||||||||||||||||||||||||||||||
| 856 | |||||||||||||||||||||||||||||||||
| 857 | =cut | ||||||||||||||||||||||||||||||||
| 858 | |||||||||||||||||||||||||||||||||
| 859 | package Bio::Taxonomy::GlobalNames::Output::Context; | ||||||||||||||||||||||||||||||||
| 860 | |||||||||||||||||||||||||||||||||
| 861 | 3 | ▶ | use Moo::Lax; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||
| 863 | ################################################## | ||||||||||||||||||||||||||||||||
| 864 | # Context object attributes with ro permissions. # | ||||||||||||||||||||||||||||||||
| 865 | ################################################## | ||||||||||||||||||||||||||||||||
| 866 | 3 | has context_data_source_id => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 867 | 3 | has context_clade => ( is => 'ro', ); | |||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||
| 869 | # Create a Context object. | ||||||||||||||||||||||||||||||||
| 870 | sub object | ||||||||||||||||||||||||||||||||
| 871 | 0 | ▶ | { | ||||||||||||||||||||||||||||||
|
Subroutine
object: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 872 | 0 | my ($input) = @_; | |||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||
| 874 | # If the input is empty, set it as the empty array. | ||||||||||||||||||||||||||||||||
| 875 | 0 | ▶ | if ( $input eq q{} ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 876 | { | ||||||||||||||||||||||||||||||||
| 877 | 0 | $input = []; | |||||||||||||||||||||||||||||||
| 878 | } | ||||||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||||||
| 880 | # If something isn't defined, set it as the empty string. | ||||||||||||||||||||||||||||||||
| 881 | 0 | foreach ( 'context_data_source_id', 'context_clade' ) | |||||||||||||||||||||||||||||||
| 882 | { | ||||||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||||||
| 884 | # Avoid readonly variables caused by JSON conversion. | ||||||||||||||||||||||||||||||||
| 885 | 0 | ▶ | if ( Scalar::Readonly::readonly( $input->[0]->{$_} ) ) | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 886 | { | ||||||||||||||||||||||||||||||||
| 887 | 0 | Scalar::Readonly::readonly_off( $input->[0]->{$_} ); | |||||||||||||||||||||||||||||||
| 888 | } | ||||||||||||||||||||||||||||||||
| 889 | 0 | ▶ | $input->[0]->{$_} //= q{}; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$input->[0]{$_} //= ""
MC/DC0%0/1
$input->[0]{$_} //= ""
$input->[0]{$_}
Truth table0%0/2
A
A= $input->[0]{$_}
| |||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||||||
| 892 | # Create the object. | ||||||||||||||||||||||||||||||||
| 893 | my $result = Bio::Taxonomy::GlobalNames::Output::Context->new( | ||||||||||||||||||||||||||||||||
| 894 | 'context_data_source_id' => $input->[0]->{'context_data_source_id'}, | ||||||||||||||||||||||||||||||||
| 895 | 0 | 'context_clade' => $input->[0]->{'context_clade'}, | |||||||||||||||||||||||||||||||
| 896 | ); | ||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||
| 898 | 0 | return $result; | |||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||
| 901 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||
| 903 | Dimitrios - Georgios Kontopoulos, C<< <d.kontopoulos13 at imperial.ac.uk> >> | ||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||
| 905 | =head1 BUGS | ||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||
| 907 | Please report any bugs or feature requests to C<bug-bio-taxonomy-globalnames at rt.cpan.org>, or through | ||||||||||||||||||||||||||||||||
| 908 | the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Bio-Taxonomy-GlobalNames>. | ||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||
| 910 | I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. | ||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||
| 912 | =head1 SUPPORT | ||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||
| 914 | More details about Global Names Resolver's algorithm can be obtained from | ||||||||||||||||||||||||||||||||
| 915 | its L<website|http://resolver.globalnames.org/about>. | ||||||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||||||
| 917 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||
| 919 | perldoc Bio::Taxonomy::GlobalNames | ||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||
| 921 | You can also look for information at: | ||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||
| 923 | =over 4 | ||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||
| 925 | =item * RT: CPAN's request tracker (report bugs here) | ||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||
| 927 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Bio-Taxonomy-GlobalNames> | ||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||
| 929 | =item * AnnoCPAN: Annotated CPAN documentation | ||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||
| 931 | L<http://annocpan.org/dist/Bio-Taxonomy-GlobalNames> | ||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||
| 933 | =item * CPAN Ratings | ||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||
| 935 | L<http://cpanratings.perl.org/d/Bio-Taxonomy-GlobalNames> | ||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||
| 937 | =item * Search MetaCPAN | ||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||
| 939 | L<http://search.mcpan.org/dist/Bio-Taxonomy-GlobalNames/> | ||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||
| 941 | =item * GitHub | ||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||
| 943 | L<https://github.com/dgkontopoulos/Bio-Taxonomy-GlobalNames> | ||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||
| 945 | =back | ||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||
| 947 | =head1 LICENSE AND COPYRIGHT | ||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||
| 949 | Copyright 2013-14 Dimitrios - Georgios Kontopoulos. | ||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||
| 951 | This program is free software; you can redistribute it and/or modify it | ||||||||||||||||||||||||||||||||
| 952 | under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||
| 954 | =cut | ||||||||||||||||||||||||||||||||
| 955 | |||||||||||||||||||||||||||||||||
| 956 | 3 | 1; # End of Bio::Taxonomy::GlobalNames | |||||||||||||||||||||||||||||||