<commit_before>#!/usr/bin/env perl

=head1 NAME 
                                                                       
kewfetch_plantCvalues.pl - Fetch C-values for a plant family  

=head1 SYNOPSIS    
 
kewfetch_plantCvalues.pl -f familyname -e email -o resultsfile

=head1 DESCRIPTION
                                                                   
A web client to fetch C-values for a plant family from the Kew 
Royal Botanic Gardens database. Returns a file sorted by ascending 
genome size for each species in the database as in the example shown
below. The data in each column are family, subfamily, tribe, genus, 
species, chromosome number, ploidy level, and genome size (listed as 
1C (Mbp) estimates). Note that some species have no ploidy level or 
chromosome number estimate as in the first two species in the example 
below. This is because these values are not listed in the Kew database. 
Also note that the subfamily and tribe for some species is not listed, 
as with the third and fourth species below, because these species are 
not in the NCBI Entrez Taxonomy database. Please note that neither of 
these features are because of an error with this script, but rather a 
reflection of what information is present in each database. In addition,
the subfamily and tribe may actually be incorrect because these values
are missing from NCBI so the taxonomic rank that is expected to be subfamily
and tribe is printed.

ASTERACEAE      Cichorioideae   Hypochaeridinae Leontodon       longirostris                    391
ASTERACEAE      Asteroideae     Senecioninae    Pericallis      appendiculata   60      6       533
ASTERACEAE                                      Taraxacum       linearisquameum 16      2       866
ASTERACEAE                                      Centaurea       cuneifolia      18      2       870


(...)

=head1 DEPENDENCIES

This client uses URI to format data for a request, and LWP::UserAgent 
and HTTP GET to perform a request.

Tested with:

(to be added later)

=head1 LICENSE

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

=head1 AUTHOR 

<NAME>                                                

=head1 CONTACT
 
statonse at gmail dot com

=head1 REQUIRED ARGUMENTS

=over 2

=item -d, --db

The database to search. Can be one of Angiosperm, Gymnosperm,
Pteridophyte, Bryophyte, Algae. Case is not important but the 
database MUST be spelled correctly.

=item -f, --family

The name of the plant family to search for.

=item -e, --email

An email must be used to fill out the query form online.

=back

=head1 OPTIONS

=over 2

=item -h, --help

Print a usage statement. 

=item -m, --man

Print the full documentation.

=cut      

# TODO: take options to search any family, gymnosperm for example. DONE

#
# INCLUDES
#
use 5.010;
use strict;
use warnings;
use Getopt::Long;
use File::Basename;
use Bio::DB::Taxonomy;
use URI;
use LWP::UserAgent;
use HTTP::Request::Common qw(GET);
use Pod::Usage;
use Time::HiRes qw(gettimeofday);
#use Term::ProgressBar::Simple;

# given/when emits warnings in v5.18+
no if $] >= 5.018, 'warnings', "experimental::switch";

#
# VARIABLE SCOPE
#
my $family;
my $email;
my $outfile;
my $help;
my $man;
my $db;
my $Kew_response = "LWP_Client_Kew_Royal_Botanic_Gardens_Plant-Cvalues_Database.html"; # XHTML

#
# Set Opts
#
GetOptions(
	   'f|family=s'     => \$family,
	   'e|email=s'      => \$email,
	   'o|outfile=s'    => \$outfile,
	   'd|db:s'         => \$db,
	   'h|help'         => \$help,
	   'm|man'          => \$man,
	  );

pod2usage( -verbose => 1 ) if $help;<commit_msg>add appropriate handling of warnings in 5.18+<commit_after>#!/usr/bin/env perl

=head1 NAME 
                                                                       
kewfetch_plantCvalues.pl - Fetch C-values for a plant family  

=head1 SYNOPSIS    
 
kewfetch_plantCvalues.pl -f familyname -e email -o resultsfile

=head1 DESCRIPTION
                                                                   
A web client to fetch C-values for a plant family from the Kew 
Royal Botanic Gardens database. Returns a file sorted by ascending 
genome size for each species in the database as in the example shown
below. The data in each column are family, subfamily, tribe, genus, 
species, chromosome number, ploidy level, and genome size (listed as 
1C (Mbp) estimates). Note that some species have no ploidy level or 
chromosome number estimate as in the first two species in the example 
below. This is because these values are not listed in the Kew database. 
Also note that the subfamily and tribe for some species is not listed, 
as with the third and fourth species below, because these species are 
not in the NCBI Entrez Taxonomy database. Please note that neither of 
these features are because of an error with this script, but rather a 
reflection of what information is present in each database. In addition,
the subfamily and tribe may actually be incorrect because these values
are missing from NCBI so the taxonomic rank that is expected to be subfamily
and tribe is printed.

ASTERACEAE      Cichorioideae   Hypochaeridinae Leontodon       longirostris                    391
ASTERACEAE      Asteroideae     Senecioninae    Pericallis      appendiculata   60      6       533
ASTERACEAE                                      Taraxacum       linearisquameum 16      2       866
ASTERACEAE                                      Centaurea       cuneifolia      18      2       870


(...)

=head1 DEPENDENCIES

This client uses URI to format data for a request, and LWP::UserAgent 
and HTTP GET to perform a request.

Tested with:

(to be added later)

=head1 LICENSE

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

=head1 AUTHOR 

<NAME>                                                

=head1 CONTACT
 
statonse at gmail dot com

=head1 REQUIRED ARGUMENTS

=over 2

=item -d, --db

The database to search. Can be one of Angiosperm, Gymnosperm,
Pteridophyte, Bryophyte, Algae. Case is not important but the 
database MUST be spelled correctly.

=item -f, --family

The name of the plant family to search for.

=item -e, --email

An email must be used to fill out the query form online.

=back

=head1 OPTIONS

=over 2

=item -h, --help

Print a usage statement. 

=item -m, --man

Print the full documentation.

=cut      

# TODO: take options to search any family, gymnosperm for example. DONE

#
# INCLUDES
#
use 5.010;
use strict;
use warnings;
use Getopt::Long;
use File::Basename;
use Bio::DB::Taxonomy;
use URI;
use LWP::UserAgent;
use HTTP::Request::Common qw(GET);
use Pod::Usage;
use Time::HiRes qw(gettimeofday);

# given/when emits warnings in v5.18+
no if $] >= 5.018, 'warnings', "experimental::smartmatch";

#
# VARIABLE SCOPE
#
my $family;
my $email;
my $outfile;
my $help;
my $man;
my $db;
my $Kew_response = "LWP_Client_Kew_Royal_Botanic_Gardens_Plant-Cvalues_Database.html"; # XHTML

#
# Set Opts
#
GetOptions(
	   'f|family=s'     => \$family,
	   'e|email=s'      => \$email,
	   'o|outfile=s'    => \$outfile,
	   'd|db:s'         => \$db,
	   'h|help'         => \$help,
	   'm|man'          => \$man,
	  );

pod2usage( -verbose => 1 ) if $help;
{'fraction_non_alphanumeric': 0.06673114119922631, 'fraction_numerical': 0.011726305609284332, 'mean_word_length': 2.6477072310405645, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2263781', 'n_tokens_mistral': 2573, 'n_tokens_neox': 2381, 'n_words': 1073}