Raise error if give @HD SO:coordinate to 'samtools fixmate'

The (minimal) documentation does tell you 'samtools fixmate' requires query name
sorted reads (in fact grouped by query name is enough), but doesn't actually raise
an error if given coordinate sorted reads (it just silently fails to fix them).

This change raises an explicit error is the @HD line contains SO:coordinate
Catch overflow in n_cigar and give an explicit error.

Due to the use of an unsigned 16bit integer, BAM
files can only hold reads with up to 65535 CIGAR
operators. SAM does not have this limit, but the
samtools implementation (reasonably) also has the
same 16bit limit.

Prior to this fix a very long CIGAR read would
give a confusing 'unmatched CIGAR operation'
warning and then abort with a core dump.
Don't set text-is-cached flag if reading headers encountered EOF

Only set is_first (i.e., some SAM record text has already been read
in) if a column of the following SAM record has actually been pre-read.
This will not be the case if there are no records at all, only headers.

Fixes #113 (hattip @kmsquire).
Merge pull request #20, fixmate aborts on SO:coordinate
Fix buffer overflow
Remove double fclose()

This fixes issue #47 for the legacy non-HTSlib code branch.
Silence -Wstrict-prototypes warnings in main header files

Fixes issue #45 for the legacy non-HTSlib code branch.
Merge cigar length check (PR #39)

Revise Peter's patch to use parse_error(), as per other CIGAR-related
errors and so that samtools view has a non-zero exit status.
Fix control of compression level in bam_merge_core2

(Fixed on develop by 3ef90e939e170880431b880641034c8d78f885b2.)
Merge mpileup test fix: Remove temporary hack, view -C -T now works

(Fix the fix: BSD and POSIX getopt() require options to appear before
non-option arguments.)
Fix bug in merge for sorting large files

Fix missing flags that are required when merging large sorted files.
Add a few missing comments.

Signed-off-by: Martin O. Pollard <mp15@sanger.ac.uk>
Fix fixmate's properly paired check, add sam/cram output, add tests

Previously fixmates did not take into account whether a read was on forward or reverse strand
when determining it's position for properly paired check, and added testcase for this.
Stole code from bam_sort to that we can optionally output SAM or CRAM (may be a bad idea for
name sorted files but will deal with this later; may also need reference).
Add tests to test harness.

Signed-off-by: Martin O. Pollard <mp15@sanger.ac.uk>
Add mpileup --output option to redirect output to a file
Add mpileup -o FILE as a shorthand for --output

Unfortunately -o INT already means --open-prob.  As a tremendous hack
for the sake of UI convenience and consistency (-o meaning --output is
very widespread), we choose between the two by whether the argument
looks like an integer.

Typical filenames (e.g. "foo.bam" or even "15.cram") don't, and
"-o ./123" or "--output 123" are documented workarounds if the user
actually wants a numeric filename.
Updated calling section of samtools man page
mpileup: New optional FORMAT/DPR and INFO/DPR annotations
mpileup: Output symbolic <X> allele instead of VCF-incompatible X
Save the right error text (fixes cut-and-pasto)
Added CRAM reference information and an example.
Update license file

Rename to LICENSE, as the filename COPYING usually suggests GPL.
(Use git diff -M40% to see this commit as a rename.)

Use the less ambiguous term "MIT/Expat" license, as there are several
different licenses sometimes called the "MIT license".

Update years in the copyright notice, and add note about year ranges.

Reformat the last paragraph -- there are no text changes.