File: SequentialZmwGroupQuery_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 (72 lines) | stat: -rw-r--r-- 2,742 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
#include <string>

#include <gtest/gtest.h>

#include <alignment/query/SequentialZmwGroupQuery.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 TestSequentialZmwGroupQuery(const std::string& fn, const std::vector<int>& expected)
{
    EXPECT_NO_THROW({
        std::vector<int> counts;
        SequentialZmwGroupQuery qQuery(fn);
        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();
            for (const BamRecord& record : records) {
                EXPECT_EQ(holeNumber, record.HoleNumber());
                EXPECT_EQ(movieName, record.MovieName());
            }
        }
        EXPECT_EQ(expected, counts);
    });
}

static void TestNoneConstSequentialZmwGroupQuery(const std::string& fn,
                                                 const std::vector<int>& expected)
{
    EXPECT_NO_THROW({
        std::vector<int> counts;
        SequentialZmwGroupQuery qQuery(fn);
        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();
            for (BamRecord& record : records) {
                EXPECT_EQ(holeNumber, record.HoleNumber());
                EXPECT_EQ(movieName, record.MovieName());
            }
        }
        EXPECT_EQ(expected, counts);
    });
}

TEST(SequentialZmwGroupQueryTest, CountQSizes)
{
    std::string fn = bamFile1;
    std::vector<int> expected({2, 2, 10, 2, 3, 1, 2, 2, 3, 4, 1, 3, 1, 1, 2,  2,
                               2, 2, 1,  1, 1, 2, 2, 2, 3, 8, 1, 3, 2, 1, 15, 2,
                               1, 3, 1,  2, 2, 1, 3, 3, 2, 2, 1, 2, 2, 1, 1,  1});
    TestSequentialZmwGroupQuery(fn, expected);
    TestNoneConstSequentialZmwGroupQuery(fn, expected);
}

TEST(SequentialZmwGroupQueryTest, Chunking)
{
    std::string fn = testChunking;
    std::vector<int> 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});
    TestSequentialZmwGroupQuery(fn, expected);
}