File: PbiFilterZmwGroupQuery_gtest.cpp

package info (click to toggle)
pbseqlib 5.3.5%2Bdfsg-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,148 kB
  • sloc: cpp: 77,259; python: 331; sh: 103; makefile: 41
file content (83 lines) | stat: -rw-r--r-- 3,223 bytes parent folder | download | duplicates (4)
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
#include <string>

#include <gtest/gtest.h>

#include <alignment/query/PbiFilterZmwGroupQuery.h>
#include <pbdata/testdata.h>

using namespace PacBio;
using namespace PacBio::BAM;

static const std::string testChunking = xmlFile1;
static const std::string testNoFilter = xmlFile2;

static void TestPbiFilterZmwGroupQuery(const std::string& fn, const std::vector<size_t>& expected,
                                       const int32_t min_zmw, const int32_t max_zmw)
{
    EXPECT_NO_THROW({
        PbiFilterZmwGroupQuery qQuery(fn);

        std::vector<size_t> counts;
        for (const std::vector<BamRecord>& records : qQuery) {
            counts.push_back(records.size());
            EXPECT_GT(records.size(), 0u);
            std::string movieName = records[0].MovieName();
            int32_t holeNumber = records[0].HoleNumber();
            EXPECT_TRUE(holeNumber >= min_zmw);
            EXPECT_TRUE(holeNumber <= max_zmw);
            for (const BamRecord& record : records) {
                EXPECT_EQ(holeNumber, record.HoleNumber());
                EXPECT_EQ(movieName, record.MovieName());
            }
        }
        EXPECT_EQ(expected, counts);
    });
}

static void TestNoneConstPbiFilterZmwGroupQuery(const std::string& fn,
                                                const std::vector<size_t>& expected,
                                                const int32_t min_zmw, const int32_t max_zmw)
{
    EXPECT_NO_THROW({
        PbiFilterZmwGroupQuery qQuery(fn);

        std::vector<size_t> counts;
        for (std::vector<BamRecord>& records : qQuery) {
            counts.push_back(records.size());
            EXPECT_GT(records.size(), 0u);
            std::string movieName = records[0].MovieName();
            int32_t holeNumber = records[0].HoleNumber();
            EXPECT_TRUE(holeNumber >= min_zmw);
            EXPECT_TRUE(holeNumber <= max_zmw);
            for (BamRecord& record : records) {
                EXPECT_EQ(holeNumber, record.HoleNumber());
                EXPECT_EQ(movieName, record.MovieName());
            }
        }
        EXPECT_EQ(expected, counts);
    });
}

TEST(PbiFilterZmwGroupQueryTest, GetNext)
{
    std::string fn = testChunking;
    std::vector<size_t> expected({2, 21, 13, 1, 5, 13, 1, 34, 12, 2, 20, 5, 3, 7, 11});
    const int32_t min_zmw = 55;
    const int32_t max_zmw = 1816;
    TestPbiFilterZmwGroupQuery(fn, expected, min_zmw, max_zmw);
    TestNoneConstPbiFilterZmwGroupQuery(fn, expected, min_zmw, max_zmw);
}

TEST(PbiFilterZmwGroupQueryTest, NoFilter)
{
    std::string fn = testNoFilter;
    std::vector<size_t> expected(
        {2,  21, 13, 1,  5,  13, 1,  34, 12, 2,  20, 5,  3,  7,  11, 14, 6,  8,  23, 53, 17, 21, 7,
         5,  35, 3,  26, 6,  21, 37, 26, 59, 2,  6,  30, 34, 32, 2,  14, 3,  24, 1,  15, 1,  12, 26,
         6,  3,  1,  9,  3,  21, 12, 10, 24, 3,  6,  1,  6,  17, 34, 11, 24, 4,  11, 1,  10, 8,  10,
         20, 3,  4,  6,  27, 5,  2,  21, 3,  14, 1,  9,  5,  30, 37, 6,  1,  26, 7,  7,  32});
    const int32_t min_zmw = 0;
    const int32_t max_zmw = 1000000;
    TestPbiFilterZmwGroupQuery(fn, expected, min_zmw, max_zmw);
    TestNoneConstPbiFilterZmwGroupQuery(fn, expected, min_zmw, max_zmw);
}