lh3/bwa — pull request #19 by jmarshall (2013-06-14 13:19:52+00:00)
Title: Check that input files are name-sorted and the names of paired reads match

This is an updated and simplified version of a patch that I have posted to bio-bwa-help a couple of times. Occasionally due to user error or intermittent system failure, the input files in paired mapping get desynchronised and unrelated reads with different names are mapped as a pair, leading to havoc in insert size statistics and incorrect mate flags and coordinates in the output.

This patch simply aborts if two paired reads have different names (after any `/1` or `/2` have already been stripped off). It checks when the reads are printed to the SAM output (thus doesn't impact performance much as the names are already in cache memory), but could be reworked to check when the input files are read, though this would be more complicated.

I've also included a couple of cosmetic and user-error-preventing patches as separate commits.