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

#TODO: - Handle compressed input.
#      - Consider removing the text output since it is redundant with the JSON output now; this 
#        would simplify the usage.

use 5.010;
use strict;
use warnings;
use autodie;
use Sort::Naturally;
use Bio::DB::HTS::Faidx;
use Bio::GFF3::LowLevel qw(gff3_parse_feature gff3_format_feature);
use List::Util          qw(uniq);
use Tephra::Annotation::Util;
use Statistics::Descriptive;
use JSON ();
use Getopt::Long;
#use Data::Dump::Color;

my %opts;
GetOptions(\%opts, 'gfffile|i=s', 'genome|g=s', 'json|j=s', 'split|s', 'compactjson');

my $usage = "\nUSAGE: $0 -i tephra_transposons.gff3 -g genome.fas -j stats.json <--split>

Notes on usage:

* The optional '--split' argument will split each superfamily into separate GFF3 and FASTA files.

* The default JSON output is pretty-printed for reading, but the '--compactjson' argument will
print a compact, space-free file if this is not for human consumption.

* A human readable structured representation of the stats will be printed to STDOUT, 
which is a good thing to save with the GFF3 like so:

$0 -i tephra_transposons.gff3 -g genome.fas \
  -j tephra_transposons.gff3.stats.json --split > tephra_transposons.gff3.stats\n\n";

unless ($opts{gfffile} && -e $opts{gfffile}) {
    say STDERR "\nERROR: --gfffile argument is missing or the file does not exist. Check input.\n";
    say STDERR $usage;
    exit(1);
}<commit_msg>update todo for handling compressed input<commit_after>#!/usr/bin/env perl

#TODO: - Consider removing the text output since it is redundant with the JSON output now; this 
#        would simplify the usage.

use 5.010;
use strict;
use warnings;
use autodie;
use Sort::Naturally;
use Bio::DB::HTS::Faidx;
use Bio::GFF3::LowLevel qw(gff3_parse_feature gff3_format_feature);
use List::Util          qw(uniq);
use Tephra::Annotation::Util;
use Statistics::Descriptive;
use JSON ();
use Getopt::Long;
#use Data::Dump::Color;

my %opts;
GetOptions(\%opts, 'gfffile|i=s', 'genome|g=s', 'json|j=s', 'split|s', 'compactjson');

my $usage = "\nUSAGE: $0 -i tephra_transposons.gff3.gz -g genome.fas.gz -j stats.json <--split>

Notes on usage:

* The optional '--split' argument will split each superfamily into separate GFF3 and FASTA files.

* The default JSON output is pretty-printed for reading, but the '--compactjson' argument will
print a compact, space-free file if this is not for human consumption.

* A human readable structured representation of the stats will be printed to STDOUT, 
which is a good thing to save with the GFF3 like so:

$0 -i tephra_transposons.gff3 -g genome.fas \
  -j tephra_transposons.gff3.stats.json --split > tephra_transposons.gff3.stats\n\n";

unless ($opts{gfffile} && -e $opts{gfffile}) {
    say STDERR "\nERROR: --gfffile argument is missing or the file does not exist. Check input.\n";
    say STDERR $usage;
    exit(1);
}
{'fraction_non_alphanumeric': 0.12045298558682224, 'fraction_numerical': 0.01098146877144818, 'mean_word_length': 4.2428057553956835, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2485552', 'n_tokens_mistral': 1038, 'n_tokens_neox': 1000, 'n_words': 346}