Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADAM-369] Improve debug output for indel realigner #369

Merged
merged 1 commit into from
Sep 16, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import scala.collection.immutable.{ NumericRange, TreeSet }
import scala.collection.mutable
import scala.util.Random

private[rdd] object RealignIndels {
private[rdd] object RealignIndels extends Serializable with Logging {

/**
* Realigns an RDD of reads.
Expand Down Expand Up @@ -181,9 +181,17 @@ private[rdd] object RealignIndels {
* From a set of reads, returns the reference sequence that they overlap.
*/
def getReferenceFromReads(reads: Iterable[RichAlignmentRecord]): (String, Long, Long) = {
var tossedReads = 0

// get reference and range from a single read
val readRefs = reads.map((r: RichAlignmentRecord) => {
(r.mdTag.get.getReference(r), r.getStart.toLong to r.getEnd)
val readRefs = reads.flatMap((r: RichAlignmentRecord) => {
if (r.mdTag.isDefined) {
Some((r.mdTag.get.getReference(r), r.getStart.toLong to r.getEnd))
} else {
log.warn("Discarding read " + r.record.getReadName + " during reference re-creation.")
tossedReads += 1
None
}
})
.toSeq
.sortBy(_._2.head)
Expand All @@ -196,7 +204,8 @@ private[rdd] object RealignIndels {
(reference._1 + refReads._1.substring((reference._2 - refReads._2.head).toInt), refReads._2.end)
} else {
// there is a gap in the sequence
throw new IllegalArgumentException("Current sequence has a gap at " + reference._2 + "with " + refReads._2.head + "," + refReads._2.end + ".")
throw new IllegalArgumentException("Current sequence has a gap at " + reference._2 + "with " + refReads._2.head + "," + refReads._2.end +
". Discarded " + tossedReads + " in region when reconstructing region; reads may not have MD tag attached.")
}
})

Expand Down