Commit c045c254 authored by Aaron's avatar Aaron
Browse files

Relax pairing req's for bamtobed and pairtobed

parent 4f74da50
......@@ -271,11 +271,17 @@ void ConvertBamToBedpe(const string &bamFile, const bool &useEditDistance) {
if (bam1.Name != bam2.Name) {
while (bam1.Name != bam2.Name)
{
if (bam1.IsPaired())
{
cerr << "*****WARNING: Query " << bam1.Name
<< " is marked as paired, but it's mate does not occur"
<< " next to it in your BAM file. Skipping. " << endl;
}
bam1 = bam2;
reader.GetNextAlignment(bam2);
}
}
else if (bam1.IsPaired() == true) {
else if (bam1.IsPaired() && bam1.IsPaired()) {
PrintBedPE(bam1, bam2, refs, useEditDistance);
}
}
......
......@@ -410,20 +410,23 @@ void BedIntersectPE::IntersectBamPE(string bamFile) {
// rip through the BAM file and convert each mapped entry to BEDPE
BamAlignment bam1, bam2;
while (reader.GetNextAlignment(bam1)) {
// the alignment must be paired
if (bam1.IsPaired() == true) {
// grab the second alignment for the pair.
reader.GetNextAlignment(bam2);
// require that the alignments are from the same query
if (bam1.Name == bam2.Name) {
ProcessBamBlock(bam1, bam2, refs, writer);
}
else {
cerr << "*****ERROR: BAM must be sorted by query name. " << endl;
exit(1);
reader.GetNextAlignment(bam2);
if (bam1.Name != bam2.Name) {
while (bam1.Name != bam2.Name)
{
if (bam1.IsPaired())
{
cerr << "*****WARNING: Query " << bam1.Name
<< " is marked as paired, but it's mate does not occur"
<< " next to it in your BAM file. Skipping. " << endl;
}
bam1 = bam2;
reader.GetNextAlignment(bam2);
}
}
else if (bam1.IsPaired() && bam1.IsPaired()) {
ProcessBamBlock(bam1, bam2, refs, writer);
}
}
// close up
reader.Close();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment