File: RangeUtils.hpp

package info (click to toggle)
pbseqlib 5.3.5%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,020 kB
  • sloc: cpp: 77,250; python: 331; sh: 103; makefile: 41
file content (58 lines) | stat: -rw-r--r-- 1,316 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
/*
 * ============================================================================
 *
 *       Filename:  RangeUtils.h
 *
 *    Description:  Parse a list of ranges separated by commas.
 *                  Designed for specifying a set of holeNumbers to analyze.
 *
 *        Version:  1.0
 *        Created:  05/02/2013 12:51:27 PM
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Yuan Li (yli), yli@pacificbiosciences.com
 *        Company:  Pacific Biosciences
 *
 * ============================================================================
 */

#include <algorithm>
#include <cstdlib>

#include <pbdata/Types.h>
#include <pbdata/StringUtils.hpp>

class Range
{
public:
    UInt start;  // Start position of a range, inclusive
    UInt end;    // End position of a range, inclusive

    Range(UInt pStart);

    Range(UInt pStart, UInt pEnd);

    bool contains(const UInt& query);

    bool operator<(const Range& pRange) const;
};

// Input is a comma-delimited string of ranges.
// e.g. 1,2,3,10-20
bool ParseRanges(std::string& rangesStr, std::vector<Range>& ranges);

class Ranges
{
public:
    std::vector<Range> ranges;
    Ranges(std::string rangesStr = "");

    bool setRanges(std::string rangesStr);

    int size();

    UInt max();

    bool contains(const UInt& query);
};