Browse Source

added PerBaseInfo.constructFront method

remotes/georgeg/no_streams
lomereiter 10 years ago
parent
commit
7bd9a276a0
  1. 8
      bio/bam/baseinfo.d
  2. 19
      test/unittests.d

8
bio/bam/baseinfo.d

@ -199,6 +199,14 @@ struct PerBaseInfo(R, TagsAndOptions...) {
return _seq.empty;
}
/// Allows to construct front element in-place, avoiding a copy.
void constructFront(Result* addr)
{
addr.base = _seq.front;
foreach (t; Extensions)
populate!t(*addr);
}
Result front() @property {
Result r = void;
r.base = _seq.front;

19
test/unittests.d

@ -365,14 +365,17 @@ unittest {
auto bases = basesWith!Options(read,
arg!"flowOrder"(flow_order),
arg!"keySequence"(key_sequence));
assert(bases.front.md_operation.is_match);
assert(bases.front.md_operation.match == 309);
assert(bases.front.md_operation_offset == 0);
assert(bases.front.previous_md_operation.isNull);
assert(bases.front.next_md_operation.is_deletion);
assert(equal(bases.front.next_md_operation.deletion, "G"));
assert(equal(bases.front.cigar_after, read.cigar[1 .. $]));
typeof(bases.front) bfront;
bases.constructFront(&bfront);
assert(bfront.md_operation.is_match);
assert(bfront.md_operation.match == 309);
assert(bfront.md_operation_offset == 0);
assert(bfront.previous_md_operation.isNull);
assert(bfront.next_md_operation.is_deletion);
assert(equal(bfront.next_md_operation.deletion, "G"));
assert(equal(bfront.cigar_after, read.cigar[1 .. $]));
assert(equal(drop(map!"a.reference_base"(bases.save), 191),
"-CCCGATTGGTCGTTGCTTTACGCTGATTGGCGAGTCCGGGGAACGTACCTTTGCTATCAGTCCAGGCCACATGAACCAGCTGCGGGCTGAAAGCATTCCGGAAGATGTGATTGCCGGACCTCGGCACTGGTTCTCACCTCATATCTGGTGCGTTGCAAGCCGGGTGAACCCATGCCGGAAGCACCATGAAAGCCATTGAGTACGCGAAGAAATATA"));
assert(equal(bases.save, read.sequence));

Loading…
Cancel
Save