-
Notifications
You must be signed in to change notification settings - Fork 23
/
stats_unittest.cpp
97 lines (83 loc) · 2.99 KB
/
stats_unittest.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#include "stats.h"
#include "gtest/gtest.h"
TEST(Stats, HumanReadable)
{
Stats s("test_files/stats_unittest.fasta");
string expected = "stats for test_files/stats_unittest.fasta\n\
sum = 21, n = 5, ave = 4.20, largest = 8\n\
N50 = 6, n = 2\n\
N60 = 6, n = 2\n\
N70 = 4, n = 3\n\
N80 = 4, n = 3\n\
N90 = 2, n = 4\n\
N100 = 1, n = 5\n\
N_count = 4\n\
Gaps = 2\n\
";
string got = s.toString(FORMAT_HUMAN);
EXPECT_EQ(0, expected.compare(got));
// Test gzipped input
Stats s2("test_files/stats_unittest.fasta.gz");
got = s.toString(FORMAT_HUMAN);
EXPECT_EQ(0, expected.compare(got));
}
TEST(Stats, Greppy)
{
Stats s("test_files/stats_unittest.fasta");
string expected = "test_files/stats_unittest.fasta\ttotal_length\t21\n\
test_files/stats_unittest.fasta\tnumber\t5\n\
test_files/stats_unittest.fasta\tmean_length\t4.20\n\
test_files/stats_unittest.fasta\tlongest\t8\n\
test_files/stats_unittest.fasta\tshortest\t1\n\
test_files/stats_unittest.fasta\tN_count\t4\n\
test_files/stats_unittest.fasta\tGaps\t2\n\
test_files/stats_unittest.fasta\tn10\t8\n\
test_files/stats_unittest.fasta\tn10n\t1\n\
test_files/stats_unittest.fasta\tn20\t8\n\
test_files/stats_unittest.fasta\tn20n\t1\n\
test_files/stats_unittest.fasta\tn30\t8\n\
test_files/stats_unittest.fasta\tn30n\t1\n\
test_files/stats_unittest.fasta\tn40\t6\n\
test_files/stats_unittest.fasta\tn40n\t2\n\
test_files/stats_unittest.fasta\tn50\t6\n\
test_files/stats_unittest.fasta\tn50n\t2\n\
test_files/stats_unittest.fasta\tn60\t6\n\
test_files/stats_unittest.fasta\tn60n\t2\n\
test_files/stats_unittest.fasta\tn70\t4\n\
test_files/stats_unittest.fasta\tn70n\t3\n\
test_files/stats_unittest.fasta\tn80\t4\n\
test_files/stats_unittest.fasta\tn80n\t3\n\
test_files/stats_unittest.fasta\tn90\t2\n\
test_files/stats_unittest.fasta\tn90n\t4\n\
";
string got = s.toString(FORMAT_GREPPY);
EXPECT_EQ(0, expected.compare(got));
// Test gzipped input
Stats s2("test_files/stats_unittest.fasta.gz");
got = s.toString(FORMAT_GREPPY);
EXPECT_EQ(0, expected.compare(got));
}
TEST(Stats, TabDelimited)
{
Stats s("test_files/stats_unittest.fasta");
string expected = "filename\ttotal_length\tnumber\tmean_length\tlongest\tshortest\tN_count\tGaps\tN50\tN50n\tN70\tN70n\tN90\tN90n\n\
test_files/stats_unittest.fasta\t21\t5\t4.20\t8\t1\t4\t2\t6\t2\t4\t3\t2\t4\n\
";
string got = s.toString(FORMAT_TAB);
EXPECT_EQ(0, expected.compare(got));
// Test gzipped input
Stats s2("test_files/stats_unittest.fasta.gz");
got = s.toString(FORMAT_TAB);
EXPECT_EQ(0, expected.compare(got));
}
TEST(Stats, TabDelimitedNoHeader)
{
Stats s("test_files/stats_unittest.fasta");
string expected = "test_files/stats_unittest.fasta\t21\t5\t4.20\t8\t1\t4\t2\t6\t2\t4\t3\t2\t4\n";
string got = s.toString(FORMAT_TAB_NO_HEAD);
EXPECT_EQ(0, expected.compare(got));
// Test gzipped input
Stats s2("test_files/stats_unittest.fasta.gz");
got = s.toString(FORMAT_TAB_NO_HEAD);
EXPECT_EQ(0, expected.compare(got));
}