| 1 | package Net::WoRMS; | ||||||||||||||||||||||||||||
| 2 | # ====================================================================== | ||||||||||||||||||||||||||||
| 3 | # (C) 2012 by A. Weidauer | ||||||||||||||||||||||||||||
| 4 | # Contact: alex.weidauer@huckfinn.de | ||||||||||||||||||||||||||||
| 5 | # ====================================================================== | ||||||||||||||||||||||||||||
| 6 | # ABSTRACT: provides functions to query the "World Register of Marine Specie | ||||||||||||||||||||||||||||
| 7 | =head1 NAME | ||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | Net::WoRMS provides functions to query the "World Register of Marine Species". | ||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | =head1 VERSION | ||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | version 1.6 | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | Net::WoRMS bundles WEB access, parsing and formatting capabilities for | ||||||||||||||||||||||||||||
| 18 | the tool L<query-worms|https://metacpan.org>, to harvest information | ||||||||||||||||||||||||||||
| 19 | form the "World Register of Marine Species" -- | ||||||||||||||||||||||||||||
| 20 | L<http://www.marinespecies.org>. The module was built around the module | ||||||||||||||||||||||||||||
| 21 | L<SOAP::Lite> and is OO implemented using L<Moo>. | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | =cut | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # ====================================================================== | ||||||||||||||||||||||||||||
| 26 | 2 | ▶ | use v5.20; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 27 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 28 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 29 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 30 | 2 | ▶ | use open qw(:std :utf8); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 2 | our $VERSION = 1.6; | |||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 MODULE DEPENDENCIES | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | The module uses the packages: | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =over | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =item L<Data::Dumper> | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | Debugging purposes | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =item L<Moo> | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | Object oriented extension for the module | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | =item L<MooX::Types::MooseLike::Base> | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | Minimal type system for L<Moo> | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | =item L<SOAP::Lite> | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | is used for the WEB access and parsing capabilities to retrieve data | ||||||||||||||||||||||||||||
| 55 | from L<http://www.marinespecies.org>. | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =item L<Syntax::Keyword::Match> | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | to end the switch-case/while-given madness | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | =back | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | =cut | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | # Modules ------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 66 | 2 | ▶ | use Moo; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 2 | ▶ | use MooX::Types::MooseLike::Base qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 68 | 2 | ▶ | use SOAP::Lite; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 69 | 2 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # Modern Perl ---------------------------------------------------------- | ||||||||||||||||||||||||||||
| 72 | 2 | ▶ | use Syntax::Keyword::Match; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 73 | 2 | ▶ | use feature qw(signatures); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 74 | 2 | ▶ | no warnings 'once'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 75 | 2 | ▶ | no warnings 'experimental'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 76 | 2 | ▶ | no warnings 'experimental::signatures'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | =head1 GLOBAL VARIABLES and CONSTANTS | ||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||
| 80 | =over | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =item $END_POINT = 'http://www.marinespecies.org/aphia.php?p=soap' | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | The access point to retrieve data via the Simple Object Access Protocol. | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =item $APHIA_NS = 'http://aphia/v1.0' | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Namespace and corresponding URI. In the development context these | ||||||||||||||||||||||||||||
| 89 | variables are considered as a constants. There are methods to change | ||||||||||||||||||||||||||||
| 90 | these values but never tested. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =item$FORMAT ='TEXT' | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | FORMAT defines the default output format. | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =item @ORDER_SCORE = qw/APHIA_ID ... / | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | The array holds field names for SQL related output. | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =item @ORDER_DOT = qw/APHIA.ID ... / | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | The array holds field names for TEXT and CSV related output. | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =item %FORMATS = ( TEXT => 1, SQL => 2, CSV => 3) | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | The format hash mostly for validation. | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =item %ORDER_HASH | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | Dictionary to sort and translate the retrieved field names from the | ||||||||||||||||||||||||||||
| 111 | WoRMS database and bring them into a consistent form. | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | =item @TYPE | ||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||
| 115 | Type array corresponding to C<@ORDER_SCORE/@ORDER_DOT> and the | ||||||||||||||||||||||||||||
| 116 | C<%ORDER_HASH> to handle quotes and C<NULL> values. | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =back | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | # GLOBALS ============================================================== | ||||||||||||||||||||||||||||
| 123 | 2 | my $END_POINT = 'http://www.marinespecies.org/aphia.php?p=soap'; | |||||||||||||||||||||||||||
| 124 | 2 | my $APHIA_NS = 'http://aphia/v1.0'; | |||||||||||||||||||||||||||
| 125 | 2 | my $APHIA_URI = $APHIA_NS; | |||||||||||||||||||||||||||
| 126 | 2 | my $FORMAT = 'TEXT'; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | # Field name dump output | ||||||||||||||||||||||||||||
| 129 | 2 | my @ORDER_SCORE = | |||||||||||||||||||||||||||
| 130 | qw/APHIA_ID NAME AUTHOR RANK STATUS VALID_APHIA_ID VALID_NAME | ||||||||||||||||||||||||||||
| 131 | VALID_AUTHOR RNK_KINGDOM RNK_PHYLUM RNK_CLASS RNK_ORDER | ||||||||||||||||||||||||||||
| 132 | RNK_FAMILY RNK_GENUS CITATION/; | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | # Field names SQL / CSV | ||||||||||||||||||||||||||||
| 135 | 2 | my @ORDER_DOT = | |||||||||||||||||||||||||||
| 136 | qw/APHIA.ID NAME AUTHOR RANK STATUS VALID.APHIA.ID VALID.NAME | ||||||||||||||||||||||||||||
| 137 | VALID.AUTHOR KINGDOM PHYLUM CLASS ORDER | ||||||||||||||||||||||||||||
| 138 | FAMILY GENUS CITATION/; | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 2 | my %FORMATS = ( TEXT => 1, SQL => 2, CSV => 3); | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | # SOAP entry mapping to field names - WoRMS keys are a mess | ||||||||||||||||||||||||||||
| 143 | 2 | my %ORDER_HASH = ( | |||||||||||||||||||||||||||
| 144 | "AphiaID" => 0, "scientificname" => 1, "authority" => 2, | ||||||||||||||||||||||||||||
| 145 | "rank" => 3, "status" => 4, | ||||||||||||||||||||||||||||
| 146 | "valid_AphiaID" => 5, "valid_name" => 6, "valid_authority" => 7, | ||||||||||||||||||||||||||||
| 147 | "kingdom" => 8, "phylum" => 9, "class" => 10, | ||||||||||||||||||||||||||||
| 148 | "order" => 11, "family" => 12, "genus" => 13, | ||||||||||||||||||||||||||||
| 149 | "citation" => 14,); | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | # Data types of the fields | ||||||||||||||||||||||||||||
| 152 | # Index 0 1 2 3 4 5 6 7 8 9 | ||||||||||||||||||||||||||||
| 153 | 2 | my @TYPE = qw (INT STR STR STR STR INT STR STR STR STR | |||||||||||||||||||||||||||
| 154 | STR STR STR STR STR); | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =head1 FIELDS | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | =over | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | =item Debug: BOOL | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | Flag to switch to the debugging mode. | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | =item Format: STR | ||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | Field holds the current output format. The tags "TEXT|SQL|CSV" are | ||||||||||||||||||||||||||||
| 167 | allowed. | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | =item EndPoint: STR (URI) | ||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | The current SOAP endpoint defaults to C<$END_POINT>. | ||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | =item AphiaNS and AphiaURI: STR (URI) | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | The current namespace and corresponding URI, defaulting to $APHIA_NS. | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | =item Soap | ||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | The SOAP access client instance generate by L<SOAP::Lite>. | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | =back | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | =cut | ||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | # FIELDS =============================================================== | ||||||||||||||||||||||||||||
| 186 | 2 | has Debug => ( is => 'rwp', isa => Int, default => 0 ); | |||||||||||||||||||||||||||
| 187 | 2 | has Format => ( is => 'rwp', isa => Str, default => $FORMAT ); | |||||||||||||||||||||||||||
| 188 | 2 | has EndPoint => ( is => 'rwp', isa => Str, default => $END_POINT ); | |||||||||||||||||||||||||||
| 189 | 2 | has AphiaNS => ( is => 'rwp', isa => Str, default => $APHIA_NS ); | |||||||||||||||||||||||||||
| 190 | 2 | has AphiaURI => ( is => 'rwp', isa => Str, default => $APHIA_URI ); | |||||||||||||||||||||||||||
| 191 | 2 | has Soap => ( | |||||||||||||||||||||||||||
| 192 | is => 'rwp', | ||||||||||||||||||||||||||||
| 193 | ); | ||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||
| 195 | # METHODS ============================================================== | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | =head1 METHODS | ||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | =over | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | =item init() | ||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | Initializes the SOAP client. | ||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | Note: All C<change*(...)> functions must be used before the | ||||||||||||||||||||||||||||
| 206 | initialization phase. | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | =back | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | =cut | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 1 | ▶ | sub init($self) { | ||||||||||||||||||||||||||
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 213 | 1 | $self->_set_Soap( SOAP::Lite->new( | |||||||||||||||||||||||||||
| 214 | uri => $self->AphiaURI, | ||||||||||||||||||||||||||||
| 215 | proxy => $self->EndPoint)); | ||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | ▶ | sub _checkInit($self, $what) { | ||||||||||||||||||||||||||
|
Subroutine
_checkInit: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 219 | 0 | ▶ | die "You have to change the '$what' before the ". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | "initialization of the connection!" if $self->Soap; | ||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | =head2 CHANGE METHODS | ||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | =over | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | =item changeEndPoint($uri) | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | Change the end point for the soap client (don't change). | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | =item changeAphiaURI($uri) | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | Change the namespace URI for the soap client (don't change). | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | =item changeAphiaNS($uri) | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | Change the namespace soap soap client (don't change). | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | =item changeDebug($flag) | ||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||
| 241 | Demand debugging capabilities. | ||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||
| 243 | =item changeFormat($format) | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | Changes the output format. Valid formats are TEXT|CSV|SQL. | ||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | =item getFormats() | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | Get the format dictionary for validation. | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | =back | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | =cut | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | # Function to configure the net access -------------------------------- | ||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | ▶ | sub changeEndPoint($self, $endPoint) { | ||||||||||||||||||||||||||
|
Subroutine
changeEndPoint: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 258 | 0 | $self->_checkInit('END.POINT'); | |||||||||||||||||||||||||||
| 259 | 0 | $self->_set_EndPoint($endPoint); | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | 0 | ▶ | sub changeAphiaURI($self, $aphiaUri) { | ||||||||||||||||||||||||||
|
Subroutine
changeAphiaURI: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 263 | 0 | $self->_checkInit('APHIA.URI'); | |||||||||||||||||||||||||||
| 264 | 0 | $self->_set_AphiaURI($aphiaUri); | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub changeAphiaNS($self, $aphiaNS) { | ||||||||||||||||||||||||||
|
Subroutine
changeAphiaNS: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 268 | 0 | $self->_checkInit('APHIA.NS'); | |||||||||||||||||||||||||||
| 269 | 0 | $self->_set_AphiaNS($aphiaNS); | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 0 | ▶ | sub changeDebug($self, $debug) { | ||||||||||||||||||||||||||
|
Subroutine
changeDebug: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 273 | 0 | $self->_checkInit('DEBUG'); | |||||||||||||||||||||||||||
| 274 | 0 | $self->_set_Debug($debug); | |||||||||||||||||||||||||||
| 275 | } | ||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||
| 277 | 0 | ▶ | sub changeFormat($self, $format) { | ||||||||||||||||||||||||||
|
Subroutine
changeFormat: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 278 | 0 | $self->_checkInit('FORMAT'); | |||||||||||||||||||||||||||
| 279 | 0 | $self->_set_Format($format); | |||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 0 | ▶ | sub getFormats($self) { return \%FORMATS; } | ||||||||||||||||||||||||||
|
Subroutine
getFormats: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | =head2 QUERY METHODS | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | =over | ||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | =item checkSoap() | ||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | Check if the soap client is running. The function stops the calling | ||||||||||||||||||||||||||||
| 292 | program C<(die ...)> in case of an error. | ||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||
| 294 | =item checkError($soapResponse) | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | Checks the SOAP query result. The function stops the calling program in | ||||||||||||||||||||||||||||
| 297 | case of an communication error. | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | =item checkDebug($queryResult) | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | Prints the query result (dictionary) via L<Data::Dumper> to C<STDERR> if | ||||||||||||||||||||||||||||
| 302 | the debug flag is set. | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | =item searchSpeciesID($name, $print) | ||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||
| 306 | Function to find a species by a certain name. The if the flag C<$print> | ||||||||||||||||||||||||||||
| 307 | is set. The result will be written to C<STDOUT> on the given format. | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | =item getRecordByID($aphiaID) | ||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||
| 311 | Retrieves a record for a given AphiaID and returns a dictionary or | ||||||||||||||||||||||||||||
| 312 | 'dies' with an error. | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | =item getBlockChildrenByID($AphiaID, $offs) | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | Retrieve a set of taxon records under an given AphiaID for a defined | ||||||||||||||||||||||||||||
| 317 | offset in the query ensemble. The offset addresses a paging pattern. | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | =item getChildrenByID($aphiaID) | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | Retrieves all children under a given AphiaID using the method | ||||||||||||||||||||||||||||
| 322 | C<getBlockChildrenID(...)> and prints the result to C<STDOUT> using the | ||||||||||||||||||||||||||||
| 323 | method C<printRecord(...)>. | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | =item printRecord($record, $first, $last, $spc) | ||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||
| 327 | Prints a record to C<STDOUT> and handles indentation by C<$spc> as well | ||||||||||||||||||||||||||||
| 328 | as header and trailing aspects by using the flags C<$first> and C<$last>. | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | =back | ||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | =cut | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | # Query functions ------------------------------------------------------ | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 3 | ▶ | sub checkSoap($self) { | ||||||||||||||||||||||||||
|
Subroutine
checkSoap: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 337 | 3 | my $res = $self->Soap; | |||||||||||||||||||||||||||
| 338 | 3 | ▶ | die "Missing connection!" if not $res; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | 3 | return $res; | |||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 2 | ▶ | sub checkError($self, $response) { | ||||||||||||||||||||||||||
|
Subroutine
checkError: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 343 | 2 | ▶ | die "ERROR: ".$response->faultstring."!\n" if $response->fault; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | 1 | ▶ | sub checkDebug($self, $result) { | ||||||||||||||||||||||||||
|
Subroutine
checkDebug: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||||||||||||||||||||
| 347 | 1 | ▶ | print STDERR "DGB BEGIN:\n",Dumper($result),"EOF\n" if $self->Debug; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | # Request to WORMS for a specific taxon by name ------------------------ | ||||||||||||||||||||||||||||
| 351 | 1 | ▶ | sub searchSpeciesID($self, $name, $print) { | ||||||||||||||||||||||||||
|
Subroutine
searchSpeciesID: called CC=7 SCAR=29.4
Pod
documented
| |||||||||||||||||||||||||||||
| 352 | 1 | my $con = $self->checkSoap; | |||||||||||||||||||||||||||
| 353 | 1 | my $response = $con->call( | |||||||||||||||||||||||||||
| 354 | SOAP::Data->name("getAphiaID")->attr({ "xmlns" => $APHIA_NS}) | ||||||||||||||||||||||||||||
| 355 | => SOAP::Data->name("ScientificName" => $name)) ; | ||||||||||||||||||||||||||||
| 356 | 1 | $self->checkError($response); | |||||||||||||||||||||||||||
| 357 | 1 | my $aphia_id = $response->result; | |||||||||||||||||||||||||||
| 358 | 1 | ▶ | die "ERROR: Unknown species with the NAME: '$name'!" if not $aphia_id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 359 | 1 | ▶ | if ($print) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 360 | match($self->Format: eq) { | ||||||||||||||||||||||||||||
| 361 | case('TEXT') { | ||||||||||||||||||||||||||||
| 362 | 0 | ▶ | print "INT APHIA.ID ", $aphia_id, "\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||
| 364 | case('SQL') { | ||||||||||||||||||||||||||||
| 365 | 0 | ▶ | print "APHIA_ID = ", $aphia_id, "\n" | ||||||||||||||||||||||||||
|
Condition0%0/3
$(Syntax::Keyword::Match/topic) eq "CSV" and do {
print $aphia_id, "\n" if $aphia_id
}
MC/DC0%0/2
$(Syntax::Keyword::Match/topic) eq "CSV" and do {
print $aphia_id, "\n" if $aphia_id
}
$(Syntax::Keyword::Match/topic) eq "CSV"
do {
print $aphia_id, "\n" if $aphia_id
}
Truth table0%0/3
A and B
A= $(Syntax::Keyword::Match/topic) eq "CSV"B= do {
print $aphia_id, "\n" if $aphia_id
}
| |||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | 0 | ▶ | case ('CSV') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 368 | 0 | ▶ | print $aphia_id, "\n" if $aphia_id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||
| 372 | 1 | return $aphia_id; | |||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | # Request to WORMS for a specific taxon by AphiaID --------------------- | ||||||||||||||||||||||||||||
| 376 | 1 | ▶ | sub getRecordByID($self, $id) { | ||||||||||||||||||||||||||
|
Subroutine
getRecordByID: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 377 | 1 | my $con = $self->checkSoap; | |||||||||||||||||||||||||||
| 378 | 1 | my $response = $con->call( | |||||||||||||||||||||||||||
| 379 | SOAP::Data->name("getAphiaRecordByID")->attr({ "xmlns" => $APHIA_NS}) | ||||||||||||||||||||||||||||
| 380 | => SOAP::Data->name("AphiaID") -> value($id)) ; | ||||||||||||||||||||||||||||
| 381 | 1 | $self->checkError($response); | |||||||||||||||||||||||||||
| 382 | 1 | my $result = $response->result; | |||||||||||||||||||||||||||
| 383 | 1 | $self->checkDebug($result); | |||||||||||||||||||||||||||
| 384 | 1 | return $result; | |||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||
| 387 | # @TODO THIS REQUEST DONT WORK ----------------------------------------- | ||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub getBlockChildrenByID($self, $id, $offs) { | ||||||||||||||||||||||||||
|
Subroutine
getBlockChildrenByID: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 389 | 0 | my $con = $self->checkSoap; | |||||||||||||||||||||||||||
| 390 | 0 | my $response = $con->call( | |||||||||||||||||||||||||||
| 391 | SOAP::Data->name("getAphiaChildrenByID")->attr({ 'xmlns' => $APHIA_NS}) | ||||||||||||||||||||||||||||
| 392 | => SOAP::Data->name("AphiaID") -> value($id), | ||||||||||||||||||||||||||||
| 393 | => SOAP::Data->name("offset") -> value($offs), | ||||||||||||||||||||||||||||
| 394 | => SOAP::Data->name("marine_only") -> value("false") | ||||||||||||||||||||||||||||
| 395 | ) ; | ||||||||||||||||||||||||||||
| 396 | 0 | $self->checkError($response); | |||||||||||||||||||||||||||
| 397 | 0 | my $result = $response->result; | |||||||||||||||||||||||||||
| 398 | 0 | $self->checkDebug($result); | |||||||||||||||||||||||||||
| 399 | 0 | return $result; | |||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | # DONT WORK ------------------------------------------------------------ | ||||||||||||||||||||||||||||
| 403 | 0 | ▶ | sub searchFuzzy($self, $name, $offs, $fuzzy) { | ||||||||||||||||||||||||||
|
Subroutine
searchFuzzy: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 404 | 0 | my $con = $self->checkSoap; | |||||||||||||||||||||||||||
| 405 | # print $name, $offs, $FUZZY, "\n"; | ||||||||||||||||||||||||||||
| 406 | 0 | my $response = $con->call( | |||||||||||||||||||||||||||
| 407 | SOAP::Data->name("getAphiaRecords")->attr({ 'xmlns' => $APHIA_NS}) | ||||||||||||||||||||||||||||
| 408 | => SOAP::Data->name("scientificname") -> value($name), | ||||||||||||||||||||||||||||
| 409 | => SOAP::Data->name("offset") -> value($offs), | ||||||||||||||||||||||||||||
| 410 | => SOAP::Data->name("marine_only") -> value("false"), | ||||||||||||||||||||||||||||
| 411 | => SOAP::Data->name("like") -> value($fuzzy)); | ||||||||||||||||||||||||||||
| 412 | 0 | $self->checkError($response); | |||||||||||||||||||||||||||
| 413 | 0 | my $result = $response->result; | |||||||||||||||||||||||||||
| 414 | 0 | $self->checkDebug($result); | |||||||||||||||||||||||||||
| 415 | 0 | return $result; | |||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | # ====================================================================== | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 0 | ▶ | sub getChildrenByID($self, $sid) { | ||||||||||||||||||||||||||
|
Subroutine
getChildrenByID: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||
| 421 | 0 | my $offs=0; my $total = 0; my $num=1; | |||||||||||||||||||||||||||
| 422 | 0 | ▶ | print "\nWORMS.CHILDREN ID $sid \n" if $FORMAT eq "DUMP"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | 0 | ▶ | while ($num > 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 424 | 0 | my $found = $self->getBlockChildrenByID($sid, $offs); | |||||||||||||||||||||||||||
| 425 | 0 | ▶ | last if not $found; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 426 | 0 | my @recs = @$found; | |||||||||||||||||||||||||||
| 427 | 0 | ▶ | if (@recs) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 428 | 0 | $num = @recs; | |||||||||||||||||||||||||||
| 429 | 0 | foreach my $rec (@recs) { | |||||||||||||||||||||||||||
| 430 | 0 | $total++; | |||||||||||||||||||||||||||
| 431 | 0 | $self->printRecord($rec, $total==1, 1," "); | |||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||
| 433 | 0 | $offs +=$num+1; | |||||||||||||||||||||||||||
| 434 | 0 | } else { $num=0; } | |||||||||||||||||||||||||||
| 435 | # print "---- $num $offs $total -----\n"; | ||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||
| 437 | match($self->Format: eq) { | ||||||||||||||||||||||||||||
| 438 | 0 | ▶ | case('TEXT') { print "EOF\n" } | ||||||||||||||||||||||||||
|
Condition0%0/3
$(Syntax::Keyword::Match/topic) eq "SQL" and do {
print ";\n" if $total > 0
}
MC/DC0%0/2
$(Syntax::Keyword::Match/topic) eq "SQL" and do {
print ";\n" if $total > 0
}
$(Syntax::Keyword::Match/topic) eq "SQL"
do {
print ";\n" if $total > 0
}
Truth table0%0/3
A and B
A= $(Syntax::Keyword::Match/topic) eq "SQL"B= do {
print ";\n" if $total > 0
}
| |||||||||||||||||||||||||||||
| 439 | 0 | ▶ | case('SQL' ) { print ";\n" if $total >0; } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||
| 441 | 0 | ▶ | } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | # Output service routine record DUMP, CSV and SQL ---------------------- | ||||||||||||||||||||||||||||
| 444 | # @TODO this is a mess rewrite | ||||||||||||||||||||||||||||
| 445 | 0 | ▶ | sub printRecord($self, $record, $first, $last, $spc) { | ||||||||||||||||||||||||||
|
Subroutine
printRecord: not called CC=28 SCAR=67.0
Pod
documented
| |||||||||||||||||||||||||||||
| 446 | # asign header section | ||||||||||||||||||||||||||||
| 447 | 0 | ▶ | my @head = ($self->Format eq 'TEXT') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 448 | ? @ORDER_DOT : @ORDER_SCORE; | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | 0 | my $num_fields = $#head; | |||||||||||||||||||||||||||
| 451 | 0 | my @data = (); my @quote = (); | |||||||||||||||||||||||||||
| 452 | # NULL and quotation | ||||||||||||||||||||||||||||
| 453 | 0 | for my $i (0..$num_fields) { | |||||||||||||||||||||||||||
| 454 | # Handle empty fields | ||||||||||||||||||||||||||||
| 455 | 0 | ▶ | $data[$i] = ( $self->Format eq 'SQL') ? 'NULL' : 'NA'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 456 | 0 | ▶ | $quote[$i] = ( $TYPE[$i] eq 'STR' ) ? "'" : ''; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | 0 | my %rechash = %$record; | |||||||||||||||||||||||||||
| 460 | 0 | my $id = $rechash{AphiaID}; | |||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||
| 462 | # return if $record{status} =~ "deleted"; | ||||||||||||||||||||||||||||
| 463 | # print %rechash, "\n"; | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 0 | ▶ | print "\n", $spc, "WORMS ID $id \n" if $self->Format eq 'TEXT'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 466 | 0 | ▶ | if ($first && $self->Format eq "SQL") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$first and $self->Format eq "SQL"
MC/DC0%0/2
$first and $self->Format eq "SQL"
$first
$self->Format eq "SQL"
Truth table0%0/3
A and B
A= $firstB= $self->Format eq "SQL"
| |||||||||||||||||||||||||||||
| 467 | 0 | print "INSERT INTO WORMS_TABLE\n("; | |||||||||||||||||||||||||||
| 468 | 0 | print join(",",@head), ") VALUES\n("; | |||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||
| 470 | 0 | ▶ | if (!$first && $self->Format eq "SQL") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $first and $self->Format eq "SQL"
MC/DC0%0/2
not $first and $self->Format eq "SQL"
not $first
$self->Format eq "SQL"
Truth table0%0/3
not(A) and B
A= not $firstB= $self->Format eq "SQL"
| |||||||||||||||||||||||||||||
| 471 | 0 | print ",\n("; | |||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | 0 | ▶ | if ($first && $self->Format eq "CSV") { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$first and $self->Format eq "CSV"
MC/DC0%0/2
$first and $self->Format eq "CSV"
$first
$self->Format eq "CSV"
Truth table0%0/3
A and B
A= $firstB= $self->Format eq "CSV"
| |||||||||||||||||||||||||||||
| 474 | 0 | print join(",",@head), "\n"; | |||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | 0 | foreach my $k (keys %rechash) { | |||||||||||||||||||||||||||
| 478 | 0 | my $value = $rechash{$k}; | |||||||||||||||||||||||||||
| 479 | 0 | ▶ | $value //= ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$value //= ""
MC/DC0%0/1
$value //= ""
$value
Truth table0%0/2
A
A= $value
| |||||||||||||||||||||||||||||
| 480 | 0 | $value =~ s/'/\\'/g; | |||||||||||||||||||||||||||
| 481 | 0 | my $i = $ORDER_HASH{$k}; | |||||||||||||||||||||||||||
| 482 | 0 | ▶ | if (! defined($i)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 483 | 0 | ▶ | print "NO MATCH ",$k,"\n" if $self->Debug > 2; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 484 | 0 | next; | |||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||
| 486 | 0 | ▶ | if ($i>=0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 487 | # $data[i] = sprintf("%16s %d %8s %16s %s%s%s", | ||||||||||||||||||||||||||||
| 488 | # $k, $i, $TYPE[$i],$head[$i],$quote[$i], $value, $quote[$i]) | ||||||||||||||||||||||||||||
| 489 | 0 | ▶ | $data[$i] = sprintf("%s%8s %16s %s%s%s", | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 490 | $spc, $TYPE[$i],$head[$i],$quote[$i], $value, $quote[$i]) | ||||||||||||||||||||||||||||
| 491 | if $self->Format eq "TEXT"; | ||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | 0 | ▶ | $data[$i] = $quote[$i].$value.$quote[$i] | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 494 | if $self->Format eq "SQL"; | ||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||
| 496 | 0 | ▶ | $data[$i] = $quote[$i].$value.$quote[$i] | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 497 | if $self->Format eq "CSV"; | ||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||
| 500 | 0 | ▶ | print join(",", @data), "\n" if $self->Format eq "CSV"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 501 | 0 | ▶ | print join(",", @data), ")" if !$last && $self->Format eq "SQL"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $last and $self->Format eq "SQL"
MC/DC0%0/2
not $last and $self->Format eq "SQL"
not $last
$self->Format eq "SQL"
Truth table0%0/3
not(A) and B
A= not $lastB= $self->Format eq "SQL"
| |||||||||||||||||||||||||||||
| 502 | 0 | ▶ | print join(",", @data), ");\n" if $last && $self->Format eq "SQL"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$last and $self->Format eq "SQL"
MC/DC0%0/2
$last and $self->Format eq "SQL"
$last
$self->Format eq "SQL"
Truth table0%0/3
A and B
A= $lastB= $self->Format eq "SQL"
| |||||||||||||||||||||||||||||
| 503 | 0 | ▶ | print join("\n", @data) if $self->Format eq "TEXT"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 504 | 0 | ▶ | print "\n", $spc,"EOF\n" if $last && $self->Format eq "TEXT"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$last and $self->Format eq "TEXT"
MC/DC0%0/2
$last and $self->Format eq "TEXT"
$last
$self->Format eq "TEXT"
Truth table0%0/3
A and B
A= $lastB= $self->Format eq "TEXT"
| |||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||
| 507 | # WORMS dump Data ------------------------------------------------------ | ||||||||||||||||||||||||||||
| 508 | 0 | ▶ | sub printRecordDef($self, $record, $spc) { | ||||||||||||||||||||||||||
|
Subroutine
printRecordDef: not called CC=17 SCAR=57.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 509 | 0 | my %rechash = %$record; | |||||||||||||||||||||||||||
| 510 | 0 | my $id = $rechash{AphiaID}; | |||||||||||||||||||||||||||
| 511 | # return if $record{status} =~ "deleted"; | ||||||||||||||||||||||||||||
| 512 | # print %rechash, "\n"; | ||||||||||||||||||||||||||||
| 513 | 0 | print "\n", $spc, "WORMS ID $id \n"; | |||||||||||||||||||||||||||
| 514 | 0 | foreach my $k (keys %rechash) { | |||||||||||||||||||||||||||
| 515 | 0 | my $value = $rechash{$k}; | |||||||||||||||||||||||||||
| 516 | 0 | $value =~ s/'/\\'/g; # Franzoesische Authoren unerwuenscht | |||||||||||||||||||||||||||
| 517 | 0 | ▶ | print $spc, " INT APHIA.ID ", $value, "\n" if $k =~ m/^AphiaID/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 518 | 0 | ▶ | print $spc, " STR AUTHOR '",$value, "'\n" if $k =~ m/^authority/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 519 | 0 | ▶ | print $spc, " STR NAME '",$value, "'\n" if $k =~ m/^scientificname/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 520 | 0 | ▶ | print $spc, " STR RANK '",$value, "'\n" if $k =~ m/^rank/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 521 | 0 | ▶ | print $spc, " STR STATUS '",$value, "'\n" if $k =~ m/^status/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 522 | 0 | ▶ | print $spc, " STR CITE '",$value, "'\n" if $k =~ m/^citation/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 523 | 0 | ▶ | print $spc, " INT VALID.APHIA.ID ", $value, "\n" if $k =~ m/^valid_AphiaID/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 524 | 0 | ▶ | print $spc, " STR VALID.NAME '",$value, "'\n" if $k =~ m/^valid_name/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 525 | 0 | ▶ | print $spc, " STR VALID.AUTHOR '",$value, "'\n" if $k =~ m/^valid_authority/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 526 | 0 | ▶ | print $spc, " STR KINGDOM '",$value, "'\n" if $k =~ m/^kingdom/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 527 | 0 | ▶ | print $spc, " STR PHYLUM '",$value, "'\n" if $k =~ m/^phylum/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 528 | 0 | ▶ | print $spc, " STR CLASS '",$value, "'\n" if $k =~ m/^class/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 529 | 0 | ▶ | print $spc, " STR ORDER '",$value, "'\n" if $k =~ m/^order/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 530 | 0 | ▶ | print $spc, " STR FAMILY '",$value, "'\n" if $k =~ m/^family/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 531 | 0 | ▶ | print $spc, " STR GENUS '",$value, "'\n" if $k =~ m/^genus/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 532 | } | ||||||||||||||||||||||||||||
| 533 | 0 | print $spc, "EOF \n"; | |||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||
| 536 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | Alexander Weidauer E<lt>alex.weidauer@huckfinn.deE<gt> | ||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||
| 540 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | Copyright (C) 2012 by Alexander Weidauer | ||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||
| 544 | This program is free software: you can redistribute it and/or modify it | ||||||||||||||||||||||||||||
| 545 | under the terms of the GNU General Public License as published by the | ||||||||||||||||||||||||||||
| 546 | Free Software Foundation, either version 3 of the License, or any later | ||||||||||||||||||||||||||||
| 547 | version. | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | This program is distributed in the hope that it will be useful, but | ||||||||||||||||||||||||||||
| 550 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||
| 551 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||||||||||||||||||||||||||||
| 552 | General Public License for more details. | ||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||
| 554 | You should have received a copy of the GNU General Public License along | ||||||||||||||||||||||||||||
| 555 | with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||
| 557 | =cut | ||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||
| 559 | 2 | 1; | |||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||
| 561 | # EOF ================================================================== | ||||||||||||||||||||||||||||