Browse Source

fixed a bug in baseinfo.d; added another example

remotes/georgeg/bam_output_redesign
lomereiter 10 years ago
parent
commit
141596884c
  1. 2
      bio/bam/baseinfo.d
  2. 34
      examples/example2.d
  3. BIN
      test/data/b7_295_chunk.bam

2
bio/bam/baseinfo.d

@ -370,7 +370,7 @@ template CIGARbaseInfo(R) {
if (_current_cigar_op.is_query_consuming)
break;
if (_current_cigar_op.is_reference_consuming)
_ref_pos += _current_cigar_op.length;
_ref_pos -= _current_cigar_op.length;
}
}
}

34
examples/example2.d

@ -0,0 +1,34 @@
// run example: rdmd -I.. example2.d
import bio.bam.reader;
import bio.bam.baseinfo;
import std.stdio;
import std.range : take, drop;
import std.algorithm : find;
void main() {
auto bam = new BamReader("../test/data/b7_295_chunk.bam");
// get read group information by name
auto rg = bam.header.read_groups["9IKNG"];
auto read = find!(r => r.name == "9IKNG:00592:01791")(bam.reads).front;
// fetch information about flow calls from FZ & ZF tags
auto bases = basesWith!"FZ"(read, arg!"flowOrder"(rg.flow_order),
arg!"keySequence"(rg.key_sequence));
// end of read contains a few indel errors
foreach (baseinfo; bases.drop(350).take(32)) {
writefln("%s\tflow: %3d\tintensity: %.2f\t\tref. pos.: %6d\tCIGAR op.: %s",
baseinfo.base,
baseinfo.flow_call.flow_index,
baseinfo.flow_call.intensity,
baseinfo.position,
baseinfo.cigar_operation);
// notice that because the read is on reverse strand,
// reference position decreases during the iteration
}
}

BIN
test/data/b7_295_chunk.bam

Binary file not shown.
Loading…
Cancel
Save