<commit_before><commit_msg>test script for sequence storage<commit_after>#!/usr/bin/env perl

use 5.012;
use strict;
use warnings;
use Data::Dump qw(dd);
use TestUtils;
use SeqStore;
use SeqIO;

use Test::More tests => 4;

my $test = TestUtils->new;
#my $seq_num = 1;

my $fa_arr = $test->fasta_constructor(0);
my $fq_arr = $test->fastq_constructor(0);

dd $fa_arr;
exit;

for my $fa (@$fa_arr) {
    my $seqio = SeqIO->new( file => $fa);
    my $fh = $seqio->get_fh;
    while (my $seq = $seqio->next_seq($fh)) {
	if ($seq->has_id && $seq->has_seq && !$seq->has_qual) {
	    my $memstore = SeqStore->new( file => $fa, in_memory => 1 );
	    {
		my ($seqs, $seqct) = $memstore->store_seq;
		ok( $seqct == 3, 'There are exactly three sequences being stored in memory');
		my $idct = scalar (keys %$seqs);
		ok( $seqct == $idct, 'The same number of sequences were read and stored in memory');
	    }
	    my $diskstore = SeqStore->new( file => $fa, in_memory => 0 );
	    {
		my ($seqs, $seqct) = $diskstore->store_seq;
		ok( $seqct == 3, 'There are exactly three sequences being stored on file');
		my $idct = scalar (keys %$seqs);
		ok( $seqct == $idct, 'The same number of sequences were read and stored on file');
	    }
	}
    }
    unlink $fa;
}

#for my $fq (@$fq_arr) {
#    my $seqio = SeqIO->new( file => $fq );
#    my $store = SeqStore->new( file => $infile , in_memory => 1 );
#    my ($seqs, $seqct) = $store->store_seq;
#
#    unlink $fq;
#}

#dd $seqs;
#say $seqct, " sequences in $infile";



{'fraction_non_alphanumeric': 0.1804910418049104, 'fraction_numerical': 0.008626410086264101, 'mean_word_length': 3.4352941176470586, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 28, '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': '7267370', 'n_tokens_mistral': 625, 'n_tokens_neox': 594, 'n_words': 175}