[Bio] / FigKernelScripts / p3-count.pl Repository:
ViewVC logotype

View of /FigKernelScripts/p3-count.pl

Parent Directory Parent Directory | Revision Log Revision Log

Revision 1.2 - (download) (as text) (annotate)
Fri Mar 16 01:24:56 2018 UTC (20 months, 1 week ago) by parrello
Branch: MAIN
Changes since 1.1: +1 -1 lines
Changes copied from SEEDtk project.

=head1 Count Distinct Values

    p3-count.pl [options]

This simple script outputs the number of distinct values in the specified input column.

=head2 Parameters

The standard input can be overridden using the options in L<P3Utils/ih_options>.

Additional command-line options are those given in L<P3Utils/col_options> to specify the column to count.


use strict;
use P3DataAPI;
use P3Utils;

# Get the command-line options.
my $opt = P3Utils::script_opts('', P3Utils::col_options(), P3Utils::ih_options(),
# Get access to PATRIC.
my $p3 = P3DataAPI->new();
# Open the input file.
my $ih = P3Utils::ih($opt);
# Read the incoming headers.
my ($outHeaders, $keyCol) = P3Utils::process_headers($ih, $opt);
# Form the full header set and write it out.
if (! $opt->nohead) {
# The keys will be counted in here.
my %keys;
# Loop through the input.
while (! eof $ih) {
    my $couplets = P3Utils::get_couplets($ih, $keyCol, $opt);
    for my $couplets (@$couplets) {
        my ($key) = $couplets->[0];
        $keys{$key} = 1;
my $count = scalar keys %keys;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3