| 1 |
#include <pbcopper/data/MappedRead.h> |
| 2 |
|
| 3 |
#include <cassert> |
| 4 |
|
| 5 |
#include <string> |
| 6 |
#include <utility> |
| 7 |
#include <vector> |
| 8 |
|
| 9 |
#include <gtest/gtest.h> |
| 10 |
|
| 11 |
// clang-format off |
| 12 |
|
| 13 |
namespace MappedReadTests { |
| 14 |
|
| 15 |
using Cigar = PacBio::Data::Cigar; |
| 16 |
using Frames = PacBio::Data::Frames; |
| 17 |
using GapBehavior = PacBio::Data::GapBehavior; |
| 18 |
using MappedRead = PacBio::Data::MappedRead; |
| 19 |
using Orientation = PacBio::Data::Orientation; |
| 20 |
using QualityValues = PacBio::Data::QualityValues; |
| 21 |
using Read = PacBio::Data::Read; |
| 22 |
using SoftClipBehavior = PacBio::Data::SoftClipBehavior; |
| 23 |
using Strand = PacBio::Data::Strand; |
| 24 |
|
| 25 |
const PacBio::Data::SNR baseSNR{0.0, 0.0, 0.0, 0.0}; |
| 26 |
|
| 27 |
// generic result holder for various requested states |
| 28 |
template <typename T> |
| 29 |
struct Result |
| 30 |
{ |
| 31 |
public: |
| 32 |
Result(std::initializer_list<T> init) : d_(init) { assert(12 == init.size()); } |
| 33 |
|
| 34 |
T ForwardGenomic() const { return d_.at(0); } |
| 35 |
T ForwardNative() const { return d_.at(1); } |
| 36 |
T ForwardGenomicAligned() const { return d_.at(2); } |
| 37 |
T ForwardNativeAligned() const { return d_.at(3); } |
| 38 |
T ForwardGenomicAlignedClipped() const { return d_.at(4); } |
| 39 |
T ForwardNativeAlignedClipped() const { return d_.at(5); } |
| 40 |
T ReverseGenomic() const { return d_.at(6); } |
| 41 |
T ReverseNative() const { return d_.at(7); } |
| 42 |
T ReverseGenomicAligned() const { return d_.at(8); } |
| 43 |
T ReverseNativeAligned() const { return d_.at(9); } |
| 44 |
T ReverseGenomicAlignedClipped() const { return d_.at(10); } |
| 45 |
T ReverseNativeAlignedClipped() const { return d_.at(11); } |
| 46 |
|
| 47 |
private: |
| 48 |
std::vector<T> d_; |
| 49 |
}; |
| 50 |
|
| 51 |
template<typename DataType, typename MakeReadType, typename FetchDataType> |
| 52 |
void CheckAlignedResults(const DataType& input, |
| 53 |
const Cigar& cigar, |
| 54 |
const Result<DataType>& e, |
| 55 |
const MakeReadType& makeRead, |
| 56 |
const FetchDataType& fetchData) |
| 57 |
{ |
| 58 |
{ // map to forward strand |
| 59 |
const MappedRead mr = makeRead(input, cigar, Strand::FORWARD); |
| 60 |
EXPECT_EQ(e.ForwardGenomic(), fetchData(mr, Orientation::GENOMIC, GapBehavior::IGNORE, SoftClipBehavior::KEEP)); |
| 61 |
EXPECT_EQ(e.ForwardNative(), fetchData(mr, Orientation::NATIVE, GapBehavior::IGNORE, SoftClipBehavior::KEEP)); |
| 62 |
EXPECT_EQ(e.ForwardGenomicAligned(), fetchData(mr, Orientation::GENOMIC, GapBehavior::SHOW, SoftClipBehavior::KEEP)); |
| 63 |
EXPECT_EQ(e.ForwardNativeAligned(), fetchData(mr, Orientation::NATIVE, GapBehavior::SHOW, SoftClipBehavior::KEEP)); |
| 64 |
EXPECT_EQ(e.ForwardGenomicAlignedClipped(), fetchData(mr, Orientation::GENOMIC, GapBehavior::SHOW, SoftClipBehavior::REMOVE)); |
| 65 |
EXPECT_EQ(e.ForwardNativeAlignedClipped(), fetchData(mr, Orientation::NATIVE, GapBehavior::SHOW, SoftClipBehavior::REMOVE)); |
| 66 |
} |
| 67 |
{ // map to reverse strand |
| 68 |
const MappedRead mr = makeRead(input, cigar, Strand::REVERSE); |
| 69 |
EXPECT_EQ(e.ReverseGenomic(), fetchData(mr, Orientation::GENOMIC, GapBehavior::IGNORE, SoftClipBehavior::KEEP)); |
| 70 |
EXPECT_EQ(e.ReverseNative(), fetchData(mr, Orientation::NATIVE, GapBehavior::IGNORE, SoftClipBehavior::KEEP)); |
| 71 |
EXPECT_EQ(e.ReverseGenomicAligned(), fetchData(mr, Orientation::GENOMIC, GapBehavior::SHOW, SoftClipBehavior::KEEP)); |
| 72 |
EXPECT_EQ(e.ReverseNativeAligned(), fetchData(mr, Orientation::NATIVE, GapBehavior::SHOW, SoftClipBehavior::KEEP)); |
| 73 |
EXPECT_EQ(e.ReverseGenomicAlignedClipped(), fetchData(mr, Orientation::GENOMIC, GapBehavior::SHOW, SoftClipBehavior::REMOVE)); |
| 74 |
EXPECT_EQ(e.ReverseNativeAlignedClipped(), fetchData(mr, Orientation::NATIVE, GapBehavior::SHOW, SoftClipBehavior::REMOVE)); |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
void CheckAlignedSequence(const std::string& cigar, |
| 79 |
const std::string& input, |
| 80 |
const Result<std::string>& expected) |
| 81 |
{ |
| 82 |
// make mapped record w/ SEQ (native orientation) |
| 83 |
auto makeRead = [](std::string newSeq, |
| 84 |
const Cigar& newCigar, |
| 85 |
const Strand newStrand) |
| 86 |
{ |
| 87 |
Read r{"", std::move(newSeq), QualityValues{}, baseSNR}; |
| 88 |
MappedRead mr{std::move(r)}; |
| 89 |
mr.Cigar = newCigar; |
| 90 |
mr.Strand = newStrand; |
| 91 |
return mr; |
| 92 |
}; |
| 93 |
|
| 94 |
auto fetchSeq = [](const MappedRead& mr, |
| 95 |
const Orientation orientation, |
| 96 |
const GapBehavior gapBehavior, |
| 97 |
const SoftClipBehavior softClipBehavior) |
| 98 |
{ |
| 99 |
return mr.AlignedSequence(orientation, gapBehavior, softClipBehavior); |
| 100 |
}; |
| 101 |
|
| 102 |
CheckAlignedResults(input, Cigar{cigar}, expected, makeRead, fetchSeq); |
| 103 |
} |
| 104 |
|
| 105 |
void CheckAlignedQualities(const std::string& cigar, |
| 106 |
const QualityValues& input, |
| 107 |
const Result<QualityValues>& expected) |
| 108 |
{ |
| 109 |
// make mapped record w/ QUAL (native orientation) |
| 110 |
auto makeRead = [](QualityValues newQuals, |
| 111 |
const Cigar& newCigar, |
| 112 |
const Strand newStrand) |
| 113 |
{ |
| 114 |
Read r{"", "", newQuals, baseSNR}; |
| 115 |
MappedRead mr{std::move(r)}; |
| 116 |
mr.Cigar = newCigar; |
| 117 |
mr.Strand = newStrand; |
| 118 |
return mr; |
| 119 |
}; |
| 120 |
|
| 121 |
auto fetchQual = [](const MappedRead& mr, |
| 122 |
const Orientation orientation, |
| 123 |
const GapBehavior gapBehavior, |
| 124 |
const SoftClipBehavior softClipBehavior) |
| 125 |
{ |
| 126 |
return mr.AlignedQualities(orientation, gapBehavior, softClipBehavior); |
| 127 |
}; |
| 128 |
|
| 129 |
CheckAlignedResults(input, Cigar{cigar}, expected, makeRead, fetchQual); |
| 130 |
} |
| 131 |
|
| 132 |
void CheckAlignedFrames(const std::string& cigar, |
| 133 |
const Frames& input, |
| 134 |
const Result<Frames>& expected) |
| 135 |
{ |
| 136 |
// make mapped record w/ IPD & PulseWidth (native orientation) |
| 137 |
auto makeRead = [](const Frames& newFrames, |
| 138 |
const Cigar& newCigar, |
| 139 |
const Strand newStrand) |
| 140 |
{ |
| 141 |
Read r{"", "", QualityValues{}, baseSNR}; |
| 142 |
r.IPD = newFrames; |
| 143 |
r.PulseWidth = newFrames; |
| 144 |
MappedRead mr{std::move(r)}; |
| 145 |
mr.Cigar = newCigar; |
| 146 |
mr.Strand = newStrand; |
| 147 |
return mr; |
| 148 |
}; |
| 149 |
|
| 150 |
auto fetchIPD = [](const MappedRead& mr, |
| 151 |
const Orientation orientation, |
| 152 |
const GapBehavior gapBehavior, |
| 153 |
const SoftClipBehavior softClipBehavior) |
| 154 |
{ |
| 155 |
return mr.AlignedIPD(orientation, gapBehavior, softClipBehavior); |
| 156 |
}; |
| 157 |
|
| 158 |
auto fetchPulseWidth = [](const MappedRead& mr, |
| 159 |
const Orientation orientation, |
| 160 |
const GapBehavior gapBehavior, |
| 161 |
const SoftClipBehavior softClipBehavior) |
| 162 |
{ |
| 163 |
return mr.AlignedPulseWidth(orientation, gapBehavior, softClipBehavior); |
| 164 |
}; |
| 165 |
|
| 166 |
CheckAlignedResults(input, Cigar{cigar}, expected, makeRead, fetchIPD); |
| 167 |
CheckAlignedResults(input, Cigar{cigar}, expected, makeRead, fetchPulseWidth); |
| 168 |
} |
| 169 |
|
| 170 |
} // namespace MappedReadTests |
| 171 |
|
| 172 |
TEST(Data_MappedRead, unmapped_strand_returns_input_sequence) |
| 173 |
{ |
| 174 |
const std::string seq{"GATTACA"}; |
| 175 |
|
| 176 |
PacBio::Data::Read r{"", seq, {}, MappedReadTests::baseSNR}; |
| 177 |
PacBio::Data::MappedRead mr{std::move(r)}; |
| 178 |
mr.Cigar = {"7="}; |
| 179 |
mr.Strand = PacBio::Data::Strand::UNMAPPED; |
| 180 |
EXPECT_EQ(seq, mr.AlignedSequence()); |
| 181 |
} |
| 182 |
|
| 183 |
TEST(Data_MappedRead, empty_cigar_returns_input_sequence) |
| 184 |
{ |
| 185 |
const std::string seq{"GATTACA"}; |
| 186 |
|
| 187 |
PacBio::Data::Read r{"", seq, {}, MappedReadTests::baseSNR}; |
| 188 |
PacBio::Data::MappedRead mr{std::move(r)}; |
| 189 |
mr.Strand = PacBio::Data::Strand::FORWARD; |
| 190 |
EXPECT_EQ(seq, mr.AlignedSequence()); |
| 191 |
} |
| 192 |
|
| 193 |
TEST(Data_MappedRead, can_fetch_aligned_sequence) |
| 194 |
{ |
| 195 |
{ |
| 196 |
SCOPED_TRACE("CIGAR: 4=3D4="); |
| 197 |
MappedReadTests::CheckAlignedSequence( |
| 198 |
"4=3D4=", // CIGAR |
| 199 |
"AACCGTTA", // native input |
| 200 |
{ |
| 201 |
"AACCGTTA", // forward strand, genomic |
| 202 |
"AACCGTTA", // forward strand, native |
| 203 |
"AACC---GTTA", // forward strand, genomic, aligned |
| 204 |
"AACC---GTTA", // forward strand, native, aligned |
| 205 |
"AACC---GTTA", // forward strand, genomic, aligned + clipped |
| 206 |
"AACC---GTTA", // forward strand, native, aligned + clipped |
| 207 |
"TAACGGTT", // reverse strand, genomic |
| 208 |
"AACCGTTA", // reverse strand, native |
| 209 |
"TAAC---GGTT", // reverse strand, genomic, aligned |
| 210 |
"AACC---GTTA", // reverse strand, native, aligned |
| 211 |
"TAAC---GGTT", // reverse strand, genomic, aligned + clipped |
| 212 |
"AACC---GTTA" // reverse strand, native, aligned + clipped |
| 213 |
} |
| 214 |
); |
| 215 |
} |
| 216 |
{ |
| 217 |
SCOPED_TRACE("CIGAR: 4=1D2I2D4="); |
| 218 |
MappedReadTests::CheckAlignedSequence( |
| 219 |
"4=1D2I2D4=", // CIGAR |
| 220 |
"ATCCTAGGTT", // native input |
| 221 |
{ |
| 222 |
"ATCCTAGGTT", // forward strand, genomic |
| 223 |
"ATCCTAGGTT", // forward strand, native |
| 224 |
"ATCC-TA--GGTT", // forward strand, genomic, aligned |
| 225 |
"ATCC-TA--GGTT", // forward strand, native, aligned |
| 226 |
"ATCC-TA--GGTT", // forward strand, genomic, aligned + clipped |
| 227 |
"ATCC-TA--GGTT", // forward strand, native, aligned + clipped |
| 228 |
"AACCTAGGAT", // reverse strand, genomic |
| 229 |
"ATCCTAGGTT", // reverse strand, native |
| 230 |
"AACC-TA--GGAT", // reverse strand, genomic, aligned |
| 231 |
"ATCC--TA-GGTT", // reverse strand, native, aligned |
| 232 |
"AACC-TA--GGAT", // reverse strand, genomic, aligned + clipped |
| 233 |
"ATCC--TA-GGTT" // reverse strand, native, aligned + clipped |
| 234 |
} |
| 235 |
); |
| 236 |
} |
| 237 |
{ |
| 238 |
SCOPED_TRACE("CIGAR: 4=1D2P2I2P2D4="); |
| 239 |
MappedReadTests::CheckAlignedSequence( |
| 240 |
"4=1D2P2I2P2D4=", // CIGAR |
| 241 |
"ATCCTAGGTT", // native input |
| 242 |
{ |
| 243 |
"ATCCTAGGTT", // forward strand, genomic |
| 244 |
"ATCCTAGGTT", // forward strand, native |
| 245 |
"ATCC-**TA**--GGTT", // forward strand, genomic, aligned |
| 246 |
"ATCC-**TA**--GGTT", // forward strand, native, aligned |
| 247 |
"ATCC-**TA**--GGTT", // forward strand, genomic, aligned + clipped |
| 248 |
"ATCC-**TA**--GGTT", // forward strand, native, aligned + clipped |
| 249 |
"AACCTAGGAT", // reverse strand, genomic |
| 250 |
"ATCCTAGGTT", // reverse strand, native |
| 251 |
"AACC-**TA**--GGAT", // reverse strand, genomic, aligned |
| 252 |
"ATCC--**TA**-GGTT", // reverse strand, native, aligned |
| 253 |
"AACC-**TA**--GGAT", // reverse strand, genomic, aligned + clipped |
| 254 |
"ATCC--**TA**-GGTT" // reverse strand, native, aligned + clipped |
| 255 |
} |
| 256 |
); |
| 257 |
} |
| 258 |
{ |
| 259 |
SCOPED_TRACE("CIGAR: 2S4=3D4=3S"); |
| 260 |
MappedReadTests::CheckAlignedSequence( |
| 261 |
"2S4=3D4=3S", // CIGAR |
| 262 |
"TTAACCGTTACCG", // native input |
| 263 |
{ |
| 264 |
"TTAACCGTTACCG", // forward strand, genomic |
| 265 |
"TTAACCGTTACCG", // forward strand, native |
| 266 |
"TTAACC---GTTACCG", // forward strand, genomic, aligned |
| 267 |
"TTAACC---GTTACCG", // forward strand, native, aligned |
| 268 |
"AACC---GTTA", // forward strand, genomic, aligned + clipped |
| 269 |
"AACC---GTTA", // forward strand, native, aligned + clipped |
| 270 |
"CGGTAACGGTTAA", // reverse strand, genomic |
| 271 |
"TTAACCGTTACCG", // reverse strand, native |
| 272 |
"CGGTAA---CGGTTAA", // reverse strand, genomic, aligned |
| 273 |
"TTAACCG---TTACCG", // reverse strand, native, aligned |
| 274 |
"GTAA---CGGT", // reverse strand, genomic, aligned + clipped |
| 275 |
"ACCG---TTAC" // reverse strand, native, aligned + clipped |
| 276 |
} |
| 277 |
); |
| 278 |
} |
| 279 |
{ |
| 280 |
SCOPED_TRACE("CIGAR: 2H4=3D4=3H"); |
| 281 |
MappedReadTests::CheckAlignedSequence( |
| 282 |
"2H4=3D4=3H", // CIGAR |
| 283 |
"AACCGTTA", // native input |
| 284 |
{ |
| 285 |
"AACCGTTA", // forward strand, genomic |
| 286 |
"AACCGTTA", // forward strand, native |
| 287 |
"AACC---GTTA", // forward strand, genomic, aligned |
| 288 |
"AACC---GTTA", // forward strand, native, aligned |
| 289 |
"AACC---GTTA", // forward strand, genomic, aligned + clipped |
| 290 |
"AACC---GTTA", // forward strand, native, aligned + clipped |
| 291 |
"TAACGGTT", // reverse strand, genomic |
| 292 |
"AACCGTTA", // reverse strand, native |
| 293 |
"TAAC---GGTT", // reverse strand, genomic, aligned |
| 294 |
"AACC---GTTA", // reverse strand, native, aligned |
| 295 |
"TAAC---GGTT", // reverse strand, genomic, aligned + clipped |
| 296 |
"AACC---GTTA" // reverse strand, native, aligned + clipped |
| 297 |
} |
| 298 |
); |
| 299 |
} |
| 300 |
{ |
| 301 |
SCOPED_TRACE("CIGAR: 2H2S4=3D4=3S3H"); |
| 302 |
MappedReadTests::CheckAlignedSequence( |
| 303 |
"2H2S4=3D4=3S3H", // CIGAR |
| 304 |
"TTAACCGTTACCG", // native input |
| 305 |
{ |
| 306 |
"TTAACCGTTACCG", // forward strand, genomic |
| 307 |
"TTAACCGTTACCG", // forward strand, native |
| 308 |
"TTAACC---GTTACCG", // forward strand, genomic, aligned |
| 309 |
"TTAACC---GTTACCG", // forward strand, native, aligned |
| 310 |
"AACC---GTTA", // forward strand, genomic, aligned + clipped |
| 311 |
"AACC---GTTA", // forward strand, native, aligned + clipped |
| 312 |
"CGGTAACGGTTAA", // reverse strand, genomic |
| 313 |
"TTAACCGTTACCG", // reverse strand, native |
| 314 |
"CGGTAA---CGGTTAA", // reverse strand, genomic, aligned |
| 315 |
"TTAACCG---TTACCG", // reverse strand, native, aligned |
| 316 |
"GTAA---CGGT", // reverse strand, genomic, aligned + clipped |
| 317 |
"ACCG---TTAC" // reverse strand, native, aligned + clipped |
| 318 |
} |
| 319 |
); |
| 320 |
} |
| 321 |
} |
| 322 |
|
| 323 |
TEST(Data_MappedRead, unmapped_strand_returns_input_qualities) |
| 324 |
{ |
| 325 |
const PacBio::Data::QualityValues quals{"@@@@@@@"}; |
| 326 |
|
| 327 |
PacBio::Data::Read r{"", "", quals, MappedReadTests::baseSNR}; |
| 328 |
PacBio::Data::MappedRead mr{std::move(r)}; |
| 329 |
mr.Cigar = {"7="}; |
| 330 |
mr.Strand = PacBio::Data::Strand::UNMAPPED; |
| 331 |
EXPECT_EQ(quals, mr.AlignedQualities()); |
| 332 |
} |
| 333 |
|
| 334 |
TEST(Data_MappedRead, empty_cigar_returns_input_qualities) |
| 335 |
{ |
| 336 |
const PacBio::Data::QualityValues quals{"@@@@@@@"}; |
| 337 |
|
| 338 |
PacBio::Data::Read r{"", "", quals, MappedReadTests::baseSNR}; |
| 339 |
PacBio::Data::MappedRead mr{r}; |
| 340 |
mr.Strand = PacBio::Data::Strand::FORWARD; |
| 341 |
EXPECT_EQ(quals, mr.AlignedQualities()); |
| 342 |
} |
| 343 |
|
| 344 |
TEST(Data_MappedRead, can_fetch_aligned_qualities) |
| 345 |
{ |
| 346 |
using QualityValues = PacBio::Data::QualityValues; |
| 347 |
|
| 348 |
{ |
| 349 |
SCOPED_TRACE("CIGAR: 4=3D4="); |
| 350 |
MappedReadTests::CheckAlignedQualities( |
| 351 |
"4=3D4=", // CIGAR |
| 352 |
QualityValues{"?]?]?]?@"}, // native input |
| 353 |
{ |
| 354 |
QualityValues{"?]?]?]?@"}, // forward strand, genomic |
| 355 |
QualityValues{"?]?]?]?@"}, // forward strand, native |
| 356 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, genomic, aligned |
| 357 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, native, aligned |
| 358 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, genomic, aligned + clipped |
| 359 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, native, aligned + clipped |
| 360 |
QualityValues{"@?]?]?]?"}, // reverse strand, genomic |
| 361 |
QualityValues{"?]?]?]?@"}, // reverse strand, native |
| 362 |
QualityValues{"@?]?!!!]?]?"}, // reverse strand, genomic, aligned |
| 363 |
QualityValues{"?]?]!!!?]?@"}, // reverse strand, native, aligned |
| 364 |
QualityValues{"@?]?!!!]?]?"}, // reverse strand, genomic, aligned + clipped |
| 365 |
QualityValues{"?]?]!!!?]?@"} // reverse strand, native, aligned + clipped |
| 366 |
} |
| 367 |
); |
| 368 |
} |
| 369 |
{ |
| 370 |
SCOPED_TRACE("CIGAR: 4=1D2I2D4="); |
| 371 |
MappedReadTests::CheckAlignedQualities( |
| 372 |
"4=1D2I2D4=", // CIGAR |
| 373 |
QualityValues{"?]?]87?]?@"}, // native input |
| 374 |
{ |
| 375 |
QualityValues{"?]?]87?]?@"}, // forward strand, genomic |
| 376 |
QualityValues{"?]?]87?]?@"}, // forward strand, native |
| 377 |
QualityValues{"?]?]!87!!?]?@"}, // forward strand, genomic, aligned |
| 378 |
QualityValues{"?]?]!87!!?]?@"}, // forward strand, native, aligned |
| 379 |
QualityValues{"?]?]!87!!?]?@"}, // forward strand, genomic, aligned + clipped |
| 380 |
QualityValues{"?]?]!87!!?]?@"}, // forward strand, native, aligned + clipped |
| 381 |
QualityValues{"@?]?78]?]?"}, // reverse strand, genomic |
| 382 |
QualityValues{"?]?]87?]?@"}, // reverse strand, native |
| 383 |
QualityValues{"@?]?!78!!]?]?"}, // reverse strand, genomic, aligned |
| 384 |
QualityValues{"?]?]!!87!?]?@"}, // reverse strand, native, aligned |
| 385 |
QualityValues{"@?]?!78!!]?]?"}, // reverse strand, genomic, aligned + clipped |
| 386 |
QualityValues{"?]?]!!87!?]?@"} // reverse strand, native, aligned + clipped |
| 387 |
} |
| 388 |
); |
| 389 |
} |
| 390 |
{ |
| 391 |
SCOPED_TRACE("CIGAR: 4=1D2P2I2P2D4="); |
| 392 |
MappedReadTests::CheckAlignedQualities( |
| 393 |
"4=1D2P2I2P2D4=", // CIGAR |
| 394 |
QualityValues{"?]?]87?]?@"}, // native input |
| 395 |
{ |
| 396 |
QualityValues{"?]?]87?]?@"}, // forward strand, genomic |
| 397 |
QualityValues{"?]?]87?]?@"}, // forward strand, native |
| 398 |
QualityValues{"?]?]!!!87!!!!?]?@"}, // forward strand, genomic, aligned |
| 399 |
QualityValues{"?]?]!!!87!!!!?]?@"}, // forward strand, native, aligned |
| 400 |
QualityValues{"?]?]!!!87!!!!?]?@"}, // forward strand, genomic, aligned + clipped |
| 401 |
QualityValues{"?]?]!!!87!!!!?]?@"}, // forward strand, native, aligned + clipped |
| 402 |
QualityValues{"@?]?78]?]?"}, // reverse strand, genomic |
| 403 |
QualityValues{"?]?]87?]?@"}, // reverse strand, native |
| 404 |
QualityValues{"@?]?!!!78!!!!]?]?"}, // reverse strand, genomic, aligned |
| 405 |
QualityValues{"?]?]!!!!87!!!?]?@"}, // reverse strand, native, aligned |
| 406 |
QualityValues{"@?]?!!!78!!!!]?]?"}, // reverse strand, genomic, aligned + clipped |
| 407 |
QualityValues{"?]?]!!!!87!!!?]?@"} // reverse strand, native, aligned + clipped |
| 408 |
} |
| 409 |
); |
| 410 |
} |
| 411 |
{ |
| 412 |
SCOPED_TRACE("CIGAR: 3S4=3D4=3S"); |
| 413 |
MappedReadTests::CheckAlignedQualities( |
| 414 |
"3S4=3D4=3S", // CIGAR |
| 415 |
QualityValues{"vvv?]?]?]?@xxx"}, // native input |
| 416 |
{ |
| 417 |
QualityValues{"vvv?]?]?]?@xxx"}, // forward strand, genomic |
| 418 |
QualityValues{"vvv?]?]?]?@xxx"}, // forward strand, native |
| 419 |
QualityValues{"vvv?]?]!!!?]?@xxx"}, // forward strand, genomic, aligned |
| 420 |
QualityValues{"vvv?]?]!!!?]?@xxx"}, // forward strand, native, aligned |
| 421 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, genomic, aligned, clipped |
| 422 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, native, aligned, clipped |
| 423 |
QualityValues{"xxx@?]?]?]?vvv"}, // reverse strand, genomic |
| 424 |
QualityValues{"vvv?]?]?]?@xxx"}, // reverse strand, native |
| 425 |
QualityValues{"xxx@?]?!!!]?]?vvv"}, // reverse strand, genomic, aligned |
| 426 |
QualityValues{"vvv?]?]!!!?]?@xxx"}, // reverse strand, native, aligned |
| 427 |
QualityValues{"@?]?!!!]?]?"}, // reverse strand, genomic, aligned, clipped |
| 428 |
QualityValues{"?]?]!!!?]?@"} // reverse strand, native, aligned, clipped |
| 429 |
} |
| 430 |
); |
| 431 |
} |
| 432 |
{ |
| 433 |
SCOPED_TRACE("CIGAR: 2H4=3D4=3H"); |
| 434 |
MappedReadTests::CheckAlignedQualities( |
| 435 |
"2H4=3D4=3H", // CIGAR |
| 436 |
QualityValues{"?]?]?]?@"}, // native input |
| 437 |
{ |
| 438 |
QualityValues{"?]?]?]?@"}, // forward strand, genomic |
| 439 |
QualityValues{"?]?]?]?@"}, // forward strand, native |
| 440 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, genomic, aligned |
| 441 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, native, aligned |
| 442 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, genomic, aligned, clipped |
| 443 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, native, aligned, clipped |
| 444 |
QualityValues{"@?]?]?]?"}, // reverse strand, genomic |
| 445 |
QualityValues{"?]?]?]?@"}, // reverse strand, native |
| 446 |
QualityValues{"@?]?!!!]?]?"}, // reverse strand, genomic, aligned |
| 447 |
QualityValues{"?]?]!!!?]?@"}, // reverse strand, native, aligned |
| 448 |
QualityValues{"@?]?!!!]?]?"}, // reverse strand, genomic, aligned, clipped |
| 449 |
QualityValues{"?]?]!!!?]?@"} // reverse strand, native, aligned, clipped |
| 450 |
} |
| 451 |
); |
| 452 |
} |
| 453 |
{ |
| 454 |
SCOPED_TRACE("CIGAR: 2H3S4=3D4=3S3H"); |
| 455 |
MappedReadTests::CheckAlignedQualities( |
| 456 |
"2H3S4=3D4=3S3H", // CIGAR |
| 457 |
QualityValues{"vvv?]?]?]?@xxx"}, // native input |
| 458 |
{ |
| 459 |
QualityValues{"vvv?]?]?]?@xxx"}, // forward strand, genomic |
| 460 |
QualityValues{"vvv?]?]?]?@xxx"}, // forward strand, native |
| 461 |
QualityValues{"vvv?]?]!!!?]?@xxx"}, // forward strand, genomic, aligned |
| 462 |
QualityValues{"vvv?]?]!!!?]?@xxx"}, // forward strand, native, aligned |
| 463 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, genomic, aligned, clipped |
| 464 |
QualityValues{"?]?]!!!?]?@"}, // forward strand, native, aligned, clipped |
| 465 |
QualityValues{"xxx@?]?]?]?vvv"}, // reverse strand, genomic |
| 466 |
QualityValues{"vvv?]?]?]?@xxx"}, // reverse strand, native |
| 467 |
QualityValues{"xxx@?]?!!!]?]?vvv"}, // reverse strand, genomic, aligned |
| 468 |
QualityValues{"vvv?]?]!!!?]?@xxx"}, // reverse strand, native, aligned |
| 469 |
QualityValues{"@?]?!!!]?]?"}, // reverse strand, genomic, aligned, clipped |
| 470 |
QualityValues{"?]?]!!!?]?@"} // reverse strand, native, aligned, clipped |
| 471 |
} |
| 472 |
); |
| 473 |
} |
| 474 |
} |
| 475 |
|
| 476 |
|
| 477 |
TEST(Data_MappedRead, unmapped_strand_returns_input_frames) |
| 478 |
{ |
| 479 |
const PacBio::Data::Frames frames {10, 20, 10, 20, 10, 20, 10}; |
| 480 |
|
| 481 |
PacBio::Data::Read r{"", "", {}, MappedReadTests::baseSNR}; |
| 482 |
r.IPD = frames; |
| 483 |
r.PulseWidth = frames; |
| 484 |
PacBio::Data::MappedRead mr{std::move(r)}; |
| 485 |
mr.Cigar = {"7="}; |
| 486 |
mr.Strand = PacBio::Data::Strand::UNMAPPED; |
| 487 |
|
| 488 |
EXPECT_EQ(frames, mr.AlignedIPD()); |
| 489 |
EXPECT_EQ(frames, mr.AlignedPulseWidth()); |
| 490 |
} |
| 491 |
|
| 492 |
TEST(Data_MappedRead, empty_cigar_returns_input_frames) |
| 493 |
{ |
| 494 |
const PacBio::Data::Frames frames {10, 20, 10, 20, 10, 20, 10}; |
| 495 |
|
| 496 |
PacBio::Data::Read r{"", "", {}, MappedReadTests::baseSNR}; |
| 497 |
r.IPD = frames; |
| 498 |
r.PulseWidth = frames; |
| 499 |
PacBio::Data::MappedRead mr{std::move(r)}; |
| 500 |
mr.Strand = PacBio::Data::Strand::FORWARD; |
| 501 |
|
| 502 |
EXPECT_EQ(frames, mr.AlignedIPD()); |
| 503 |
EXPECT_EQ(frames, mr.AlignedPulseWidth()); |
| 504 |
} |
| 505 |
|
| 506 |
TEST(Data_MappedRead, can_fetch_aligned_frames) |
| 507 |
{ |
| 508 |
{ |
| 509 |
SCOPED_TRACE("CIGAR: 4=3D4="); |
| 510 |
MappedReadTests::CheckAlignedFrames( |
| 511 |
"4=3D4=", // CIGAR |
| 512 |
{ 10, 20, 10, 20, 10, 20, 10, 30 }, // native input |
| 513 |
{ |
| 514 |
{ 10, 20, 10, 20, 10, 20, 10, 30 }, // forward strand, genomic |
| 515 |
{ 10, 20, 10, 20, 10, 20, 10, 30 }, // forward strand, native |
| 516 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, genomic, aligned |
| 517 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, native, aligned |
| 518 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, genomic, aligned, clipped |
| 519 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, native, aligned, clipped |
| 520 |
{ 30, 10, 20, 10, 20, 10, 20, 10 }, // reverse strand, genomic |
| 521 |
{ 10, 20, 10, 20, 10, 20, 10, 30 }, // reverse strand, native |
| 522 |
{ 30, 10, 20, 10, 0, 0, 0, 20, 10, 20, 10 }, // reverse strand, genomic, aligned |
| 523 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // reverse strand, native, aligned |
| 524 |
{ 30, 10, 20, 10, 0, 0, 0, 20, 10, 20, 10 }, // reverse strand, genomic, aligned, clipped |
| 525 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 } // reverse strand, native, aligned, clipped |
| 526 |
} |
| 527 |
); |
| 528 |
} |
| 529 |
{ |
| 530 |
SCOPED_TRACE("CIGAR: 4=1D2I2D4="); |
| 531 |
MappedReadTests::CheckAlignedFrames( |
| 532 |
"4=1D2I2D4=", // CIGAR |
| 533 |
{ 10, 20, 10, 20, 80, 70, 10, 20, 10, 30 }, // native input |
| 534 |
{ |
| 535 |
{ 10, 20, 10, 20, 80, 70, 10, 20, 10, 30 }, // forward strand, genomic |
| 536 |
{ 10, 20, 10, 20, 80, 70, 10, 20, 10, 30 }, // forward strand, native |
| 537 |
{ 10, 20, 10, 20, 0, 80, 70, 0, 0, 10, 20, 10, 30 }, // forward strand, genomic, aligned |
| 538 |
{ 10, 20, 10, 20, 0, 80, 70, 0, 0, 10, 20, 10, 30 }, // forward strand, native, aligned |
| 539 |
{ 10, 20, 10, 20, 0, 80, 70, 0, 0, 10, 20, 10, 30 }, // forward strand, genomic, aligned, clipped |
| 540 |
{ 10, 20, 10, 20, 0, 80, 70, 0, 0, 10, 20, 10, 30 }, // forward strand, native, aligned, clipped |
| 541 |
{ 30, 10, 20, 10, 70, 80, 20, 10, 20, 10 }, // reverse strand, genomic |
| 542 |
{ 10, 20, 10, 20, 80, 70, 10, 20, 10, 30 }, // reverse strand, native |
| 543 |
{ 30, 10, 20, 10, 0, 70, 80, 0, 0, 20, 10, 20, 10 }, // reverse strand, genomic, aligned |
| 544 |
{ 10, 20, 10, 20, 0, 0, 80, 70, 0, 10, 20, 10, 30 }, // reverse strand, native, aligned |
| 545 |
{ 30, 10, 20, 10, 0, 70, 80, 0, 0, 20, 10, 20, 10 }, // reverse strand, genomic, aligned, clipped |
| 546 |
{ 10, 20, 10, 20, 0, 0, 80, 70, 0, 10, 20, 10, 30 } // reverse strand, native, aligned, clipped |
| 547 |
} |
| 548 |
); |
| 549 |
} |
| 550 |
{ |
| 551 |
SCOPED_TRACE("CIGAR: 4=1D2P2I2P2D4="); |
| 552 |
MappedReadTests::CheckAlignedFrames( |
| 553 |
"4=1D2P2I2P2D4=", // CIGAR |
| 554 |
{ 10, 20, 10, 20, 80, 70, 10, 20, 10, 30 }, // native input |
| 555 |
{ |
| 556 |
{ 10, 20, 10, 20, 80, 70, 10, 20, 10, 30 }, // forward strand, genomic |
| 557 |
{ 10, 20, 10, 20, 80, 70, 10, 20, 10, 30 }, // forward strand, native |
| 558 |
{ 10, 20, 10, 20, 0, 0, 0, 80, 70, 0, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, genomic, aligned |
| 559 |
{ 10, 20, 10, 20, 0, 0, 0, 80, 70, 0, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, native, aligned |
| 560 |
{ 10, 20, 10, 20, 0, 0, 0, 80, 70, 0, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, genomic, aligned, clipped |
| 561 |
{ 10, 20, 10, 20, 0, 0, 0, 80, 70, 0, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, native, aligned, clipped |
| 562 |
{ 30, 10, 20, 10, 70, 80, 20, 10, 20, 10 }, // reverse strand, genomic |
| 563 |
{ 10, 20, 10, 20, 80, 70, 10, 20, 10, 30 }, // reverse strand, native |
| 564 |
{ 30, 10, 20, 10, 0, 0, 0, 70, 80, 0, 0, 0, 0, 20, 10, 20, 10 }, // reverse strand, genomic, aligned |
| 565 |
{ 10, 20, 10, 20, 0, 0, 0, 0, 80, 70, 0, 0, 0, 10, 20, 10, 30 }, // reverse strand, native, aligned |
| 566 |
{ 30, 10, 20, 10, 0, 0, 0, 70, 80, 0, 0, 0, 0, 20, 10, 20, 10 }, // reverse strand, genomic, aligned, clipped |
| 567 |
{ 10, 20, 10, 20, 0, 0, 0, 0, 80, 70, 0, 0, 0, 10, 20, 10, 30 } // reverse strand, native, aligned, clipped |
| 568 |
} |
| 569 |
); |
| 570 |
} |
| 571 |
{ |
| 572 |
SCOPED_TRACE("CIGAR: 3S4=3D4=3S"); |
| 573 |
MappedReadTests::CheckAlignedFrames( |
| 574 |
"3S4=3D4=3S", // CIGAR |
| 575 |
{ 40, 40, 40, 10, 20, 10, 20, 10, 20, 10, 30, 50, 50, 50 }, // native input |
| 576 |
{ |
| 577 |
{ 40, 40, 40, 10, 20, 10, 20, 10, 20, 10, 30, 50, 50, 50 }, // forward strand, genomic |
| 578 |
{ 40, 40, 40, 10, 20, 10, 20, 10, 20, 10, 30, 50, 50, 50 }, // forward strand, native |
| 579 |
{ 40, 40, 40, 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30, 50, 50, 50 }, // forward strand, genomic, aligned |
| 580 |
{ 40, 40, 40, 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30, 50, 50, 50 }, // forward strand, native, aligned |
| 581 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, genomic, aligned, clipped |
| 582 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, native, aligned, clipped |
| 583 |
{ 50, 50, 50, 30, 10, 20, 10, 20, 10, 20, 10, 40, 40, 40 }, // reverse strand, genomic |
| 584 |
{ 40, 40, 40, 10, 20, 10, 20, 10, 20, 10, 30, 50, 50, 50 }, // reverse strand, native |
| 585 |
{ 50, 50, 50, 30, 10, 20, 10, 0, 0, 0, 20, 10, 20, 10, 40, 40, 40 }, // reverse strand, genomic, aligned |
| 586 |
{ 40, 40, 40, 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30, 50, 50, 50 }, // reverse strand, native, aligned |
| 587 |
{ 30, 10, 20, 10, 0, 0, 0, 20, 10, 20, 10 }, // reverse strand, genomic, aligned, clipped |
| 588 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 } // reverse strand, native, aligned, clipped |
| 589 |
} |
| 590 |
); |
| 591 |
} |
| 592 |
{ |
| 593 |
SCOPED_TRACE("CIGAR: 2H4=3D4=3H"); |
| 594 |
MappedReadTests::CheckAlignedFrames( |
| 595 |
"2H4=3D4=3H", // CIGAR |
| 596 |
{ 10, 20, 10, 20, 10, 20, 10, 30 }, // native input |
| 597 |
{ |
| 598 |
{ 10, 20, 10, 20, 10, 20, 10, 30 }, // forward strand, genomic |
| 599 |
{ 10, 20, 10, 20, 10, 20, 10, 30 }, // forward strand, native |
| 600 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, genomic, aligned |
| 601 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, native, aligned |
| 602 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, genomic, aligned, clipped |
| 603 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, native, aligned, clipped |
| 604 |
{ 30, 10, 20, 10, 20, 10, 20, 10 }, // reverse strand, genomic |
| 605 |
{ 10, 20, 10, 20, 10, 20, 10, 30 }, // reverse strand, native |
| 606 |
{ 30, 10, 20, 10, 0, 0, 0, 20, 10, 20, 10 }, // reverse strand, genomic, aligned |
| 607 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // reverse strand, native, aligned |
| 608 |
{ 30, 10, 20, 10, 0, 0, 0, 20, 10, 20, 10 }, // reverse strand, genomic, aligned, clipped |
| 609 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 } // reverse strand, native, aligned, clipped |
| 610 |
} |
| 611 |
); |
| 612 |
} |
| 613 |
{ |
| 614 |
SCOPED_TRACE("CIGAR: 2H3S4=3D4=3S3H"); |
| 615 |
MappedReadTests::CheckAlignedFrames( |
| 616 |
"2H3S4=3D4=3S3H", // CIGAR |
| 617 |
{ 40, 40, 40, 10, 20, 10, 20, 10, 20, 10, 30, 50, 50, 50 }, // native input |
| 618 |
{ |
| 619 |
{ 40, 40, 40, 10, 20, 10, 20, 10, 20, 10, 30, 50, 50, 50 }, // forward strand, genomic |
| 620 |
{ 40, 40, 40, 10, 20, 10, 20, 10, 20, 10, 30, 50, 50, 50 }, // forward strand, native |
| 621 |
{ 40, 40, 40, 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30, 50, 50, 50 }, // forward strand, genomic, aligned |
| 622 |
{ 40, 40, 40, 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30, 50, 50, 50 }, // forward strand, native, aligned |
| 623 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, genomic, aligned, clipped |
| 624 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 }, // forward strand, native, aligned, clipped |
| 625 |
{ 50, 50, 50, 30, 10, 20, 10, 20, 10, 20, 10, 40, 40, 40 }, // reverse strand, genomic |
| 626 |
{ 40, 40, 40, 10, 20, 10, 20, 10, 20, 10, 30, 50, 50, 50 }, // reverse strand, native |
| 627 |
{ 50, 50, 50, 30, 10, 20, 10, 0, 0, 0, 20, 10, 20, 10, 40, 40, 40 }, // reverse strand, genomic, aligned |
| 628 |
{ 40, 40, 40, 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30, 50, 50, 50 }, // reverse strand, native, aligned |
| 629 |
{ 30, 10, 20, 10, 0, 0, 0, 20, 10, 20, 10 }, // reverse strand, genomic, aligned, clipped |
| 630 |
{ 10, 20, 10, 20, 0, 0, 0, 10, 20, 10, 30 } // reverse strand, native, aligned, clipped |
| 631 |
} |
| 632 |
); |
| 633 |
} |
| 634 |
} |
| 635 |
|
| 636 |
// clang-format on |