Debian Codegraph @

src/data/ReadId.cpp

raw
1 #include <pbcopper/data/ReadId.h>
2
3 #include <pbcopper/data/ReadName.h>
4
5 #include <ostream>
6 #include <sstream>
7 #include <string>
8
9 namespace PacBio {
10 namespace Data {
11
12 ReadId::ReadId(const std::string& readName) : ReadName{readName}
13 {
14 if (!readName.empty()) {
15 Data::ReadName rName{readName};
16 MovieName = rName.MovieName().ToStdString();
17 HoleNumber = static_cast<size_t>(rName.Zmw());
18 if (!rName.IsCCS()) {
19 ZmwInterval = rName.QueryInterval();
20 }
21 }
22 }
23
24 ReadId::ReadId(const std::string& movieName, size_t holeNumber)
25 : MovieName{movieName}, HoleNumber{holeNumber}
26 {}
27
28 ReadId::ReadId(const std::string& movieName, size_t holeNumber, const Interval& interval)
29 : MovieName{movieName}, HoleNumber{holeNumber}, ZmwInterval{interval}
30 {}
31
32 ReadId::ReadId(const std::shared_ptr<std::string>& movieName, size_t holeNumber)
33 : ReadId{*movieName, holeNumber}
34 {}
35
36 ReadId::ReadId(const std::shared_ptr<std::string>& movieName, size_t holeNumber,
37 const Interval& interval)
38 : ReadId{*movieName, holeNumber, interval}
39 {}
40
41 ReadId::operator std::string() const
42 {
43 std::ostringstream ss;
44 ss << *this;
45 return ss.str();
46 }
47
48 std::ostream& operator<<(std::ostream& os, const ReadId& id)
49 {
50 if (id.ReadName.empty()) {
51 os << id.MovieName << '/' << id.HoleNumber;
52 if (id.ZmwInterval) {
53 os << '/' << id.ZmwInterval->Start() << '_' << id.ZmwInterval->End();
54 }
55 } else {
56 os << id.ReadName;
57 }
58
59 return os;
60 }
61
62 } // namespace Data
63 } // namespace PacBio