Skip to content

Commit

Permalink
Add similar check for different sequencing technologies
Browse files Browse the repository at this point in the history
Unsure if stricly necessary, but seems like an error to map the same
read group ID to different PL. Previously the map entry was blindly
over-written. Add tests for this.
  • Loading branch information
sambrightman committed Sep 15, 2016
1 parent ee1ba6a commit 53f594b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
20 changes: 20 additions & 0 deletions src/AlleleParser.cpp
Expand Up @@ -149,6 +149,26 @@ void AlleleParser::getSequencingTechnologies(void) {
cerr << "no sequencing technology specified in @RG tag (no PL: in @RG tag) " << endl << headerLine << endl;
}
} else {
map<string, string>::iterator s = readGroupToTechnology.find(readGroupID);
if (s != readGroupToTechnology.end()) {
if (s->second != tech) {
ERROR("multiple technologies (PL) map to the same read group (RG)" << endl
<< endl
<< "technologies " << tech << " and " << s->second << " map to " << readGroupID << endl
<< endl
<< "As freebayes operates on a virtually merged stream of its input files," << endl
<< "it will not be possible to determine what technology an alignment belongs to" << endl
<< "at runtime." << endl
<< endl
<< "To resolve the issue, ensure that RG ids are unique to one technology" << endl
<< "across all the input files to freebayes." << endl
<< endl
<< "See bamaddrg (https://github.com/ekg/bamaddrg) for a method which can" << endl
<< "add RG tags to alignments." << endl);
exit(1);
}
// if it's the same technology and RG combo, no worries
}
readGroupToTechnology[readGroupID] = tech;
technologies[tech] = true;
}
Expand Down
11 changes: 10 additions & 1 deletion test/t/02_multi_bam.t
Expand Up @@ -5,7 +5,7 @@ source ./bash-tap/bash-tap-bootstrap

PATH=../bin:$PATH # for freebayes

plan tests 5
plan tests 7

ref=$(basename $0).ref

Expand Down Expand Up @@ -60,11 +60,20 @@ bam1=$(make_bam "id1" "sample1" "platform1")
bam2=$(make_bam "id2" "sample2" "platform2")
is "$(run_freebayes -f ${ref} ${bam1} ${bam2})" "${expected}" "freebayes calls from two BAMs with different samples for different read groups"

bam1=$(make_bam "id1" "sample1" "platform1")
bam2=$(make_bam "id2" "sample1" "platform2")
is "$(run_freebayes -f ${ref} ${bam1} ${bam2})" "${expected}" "freebayes calls from two BAMs with different technologies for different read groups"

bam1=$(make_bam "id1" "sample1" "platform1")
bam2=$(make_bam "id1" "sample2" "platform1")
expected='ERROR\(freebayes\): multiple samples \(SM\) map to the same read group \(RG\)'
like "$(run_freebayes -f ${ref} ${bam1} ${bam2})" "${expected}" "freebayes rejects two BAMs with different samples for same read groups"

bam1=$(make_bam "id1" "sample1" "platform1")
bam2=$(make_bam "id1" "sample1" "platform2")
expected='ERROR\(freebayes\): multiple technologies \(PL\) map to the same read group \(RG\)'
like "$(run_freebayes -f ${ref} ${bam1} ${bam2})" "${expected}" "freebayes rejects two BAMs with different technologies for same read groups"

bam1=$(make_bam "id1" "sample1" "platform1")
bam2=$(make_bam "id2" "sample2" "platform2" "" "C")
expected=$(cat <<END
Expand Down

0 comments on commit 53f594b

Please sign in to comment.