Browse Source

segfault

master
Pjotr Prins 3 years ago
parent
commit
90b90e0e54
  1. 67
      test/read_bam_file.d

67
test/read_bam_file.d

@ -147,73 +147,6 @@ CigarOperation[] cigarFromString(string cigar) {
assert(bf.header.getSequenceIndex("large") == 2);
assert(bf.header.sequences["small"].length == 65536);
// Time to kick in GC
import core.memory;
stderr.writeln("**** Calling GC");
GC.collect();
stderr.writeln("**** Past calling GC");
{
// stderr.writeln("Testing alignment parsing...");
fn = buildPath(dirName(__FILE__), "data", "ex1_header.bam");
bf = new BamReader(fn);
auto reads2 = bf.reads;
auto read = reads2.front;
assert(equal(read.sequence, "CTCAAGGTTGTTGCAAGGGGGTCTATGTGAACAAA"));
assert(equal(map!"cast(char)(a + 33)"(read.base_qualities),
"<<<7<<<;<<<<<<<<8;;<7;4<;<;;;;;94<;"));
assert(bf.reference(read.ref_id).name == "chr1");
assert(read.name == "EAS56_57:6:190:289:82");
assert(read.flag == 69);
assert(read.position == 99);
assert(read.mapping_quality == 0);
reads2.popFront();
reads2.popFront();
assert(reads2.front.cigarString() == "35M");
assert(reads2.front.to!string() == "EAS51_64:3:190:727:308 99 chr1 103 99 35M = 263 195 GGTGCAGAGCCGAGTCACGGGGTTGCCAGCACAGG <<<<<<<<<<<<<<<<<<<<<<<<<<<::<<<844 MF:i:18 Aq:i:73 NM:i:0 UQ:i:0 H0:i:1 H1:i:0");
assert(bf.header.getSequenceIndex("chr1") == read.ref_id);
}
assert(bf.reads.front.name == "EAS56_57:6:190:289:82");
stderr.writeln("**** Calling GCx");
GC.collect();
stderr.writeln("**** Past calling GCx");
// stderr.writeln("Testing tag parsing...");
fn = buildPath(dirName(__FILE__), "data", "tags.bam");
bf = new BamReader(fn);
foreach (alignment; bf.reads) {
auto name = alignment.name;
assert(name[0..4] == "tag_");
char[] tag;
name = name[4..$];
while (name[0] != ':') {
tag ~= name[0];
name = name[1..$];
}
name = name[1..$];
auto value = alignment[tag.idup].toSam();
if (name != value) {
stderr.writeln("tag: ", tag, "\tname: ", name, "\tvalue: ", value);
stderr.writeln("value bam_typeid: ", alignment[tag.idup].bam_typeid);
}
assert(name == value);
}
// stderr.writeln("Testing exception handling...");
fn = buildPath(dirName(__FILE__), "data", "duplicated_block_size.bam");
assertThrown!BgzfException(new BamReader(fn));
fn = buildPath(dirName(__FILE__), "data", "no_block_size.bam");
assertThrown!BgzfException(new BamReader(fn));
fn = buildPath(dirName(__FILE__), "data", "wrong_extra_gzip_length.bam");
assertThrown!BgzfException(new BamReader(fn));
fn = buildPath(dirName(__FILE__), "data", "wrong_bc_subfield_length.bam");
assertThrown!BgzfException(reduce!"a+b.sequence_length"(0, (new BamReader(fn)).reads!withoutOffsets));
fn = buildPath(dirName(__FILE__), "data", "corrupted_zlib_archive.bam");
import bio.core.utils.zlib;
assertThrown!ZlibException(walkLength((new BamReader(fn)).reads));
// stderr.writeln("Testing random access...");
}

Loading…
Cancel
Save