| 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 |
jellyfish::MerDNA::k(int(rand(100)) + 10); |
| 14 |
|
| 15 |
my @bases = ("A", "C", "G", "T", "a", "c", "g", "t"); |
| 16 |
my $str; |
| 17 |
for(my $i = 0; $i < 1000; $i++) { |
| 18 |
$str .= $bases[int(rand(8))]; |
| 19 |
} |
| 20 |
|
| 21 |
my $count = 0; |
| 22 |
my $m2 = jellyfish::MerDNA->new; |
| 23 |
my $mers = jellyfish::string_mers($str); |
| 24 |
my $good_mers = 1; |
| 25 |
my $good_strs = 1; |
| 26 |
while($mers->next_mer) { |
| 27 |
my $mstr = uc(substr($str, $count, jellyfish::MerDNA::k())); |
| 28 |
$m2->set($mstr); |
| 29 |
$good_strs &&= $mers->mer == $m2; |
| 30 |
$good_mers &&= $mers->mer eq $mstr; |
| 31 |
$count++; |
| 32 |
} |
| 33 |
ok($good_mers, "Mers equal"); |
| 34 |
ok($good_strs, "Strs equal"); |
| 35 |
ok($count == length($str) - jellyfish::MerDNA::k() + 1, "Number of mers"); |
| 36 |
|
| 37 |
done_testing; |