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