Debian Codegraph @

swig/perl5/t/test_mer_file.t

raw
1 # This file is part of Jellyfish.
2 #
3 # This work is dual-licensed under 3-Clause BSD License or GPL 3.0.
4 # You can choose between one of them if you use this work.
5 #
6 # `SPDX-License-Identifier: BSD-3-Clause OR GPL-3.0`
7
8 use strict;
9 use warnings;
10 use Test::More;
11
12 require_ok('jellyfish');
13 my $data = shift(@ARGV);
14
15 # Compare histo
16 {
17 my $rf = jellyfish::ReadMerFile->new($data . "/swig_perl.jf");
18 my @histo;
19 $histo[$rf->count]++ while($rf->next_mer);
20
21 open(my $io, "<", $data . "/swig_perl.histo");
22 my @jf_histo;
23 while(<$io>) {
24 my ($freq, $count) = split;
25 $jf_histo[$freq] = $count;
26 }
27
28 is_deeply(\@histo, \@jf_histo, "Histogram");
29 }
30
31 # Compare dump
32 {
33 my $rf = jellyfish::ReadMerFile->new($data . "/swig_perl.jf");
34 my $equal = open(my $io, "<", $data . "/swig_perl.dump");
35 while(<$io>) {
36 my ($mer, $count) = split;
37 $equal &&= $rf->next_mer;
38 $equal &&= ($mer eq $rf->mer);
39 $equal &&= ($count == $rf->count);
40 last unless $equal;
41 }
42 $equal &&= !$rf->next_mer;
43 ok($equal, "Dump");
44 }
45
46 # Query
47 {
48 my $rf = jellyfish::ReadMerFile->new($data . "/swig_perl.jf");
49 my $qf = jellyfish::QueryMerFile->new($data . "/swig_perl.jf");
50 my $good = 1;
51 while(my ($mer, $count) = $rf->each) {
52 $good &&= $count == $qf->get($mer) or
53 (ok($good, "Query mer") || last);
54 }
55 ok($good, "Query identical to read");
56 }
57
58 done_testing;