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.
fall over if a bed file given as an option cannot be read
Fixed script for parsing BLAST output
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).
Fixed a few bugs in blast2sam.pl script, added POD documentation
Adds *~ (emacs backup files) and core to .gitignore.
Adds tests for samtools view.

Adds .sam, .fa, .fa.fai and .bed files as test data for the view command.
Adds tests in the test.pl script.  Exercises most options, apart from -B,
-@, -L, -t, -T and -s.  Most tests work by taking the test/dat/view.001.sam
and modifying it in the same way as samtools is expected to, and then
comparing the result.  BAM and CRAM conversions are tested by converting
back to SAM and checking that the output is equivalent to the original copy.
Merge branch 'develop' into develop_testing
Turns on CRAM region tests, now that CRAM indexing is supported.
Adds -L (BED file reading) tests.

Also fixes missing increment of $test.
Adds tests for the -t, -T and -B options.

-B tests are fairly limited due to the poor definition of the B operator.

-t and -T test SAM and BAM conversion.  CRAM is not fully supported for
these options yet, so ignored for now.  -t is unlikely to work for CRAM
anyway, as it needs the full reference sequence.
Adds more region tests.

These tests use an input file with 1bp reads, so out-by-one errors should be
easy to spot.
Rolls converting back to SAM into run_view_test

This allows the removal of the separate tests which just convert back to
SAM and compares with another file.
Adds CRAM conversion using the MD5 REF_CACHE.
Merge branch 'develop' into develop_testing
Strips out -x / -X tests as -X is deprecated and -x has been repurposed.
Merge pull request #20, fixmate aborts on SO:coordinate
Adds more optional fields in test file, and more -R / -r checks.

Updates sam_compare function to deal with optional fields in different
orders.  Adds more optional fields to the view.001.sam file including ones
that do intresting things with htslib issue #63.

Adds tests to see what happens when -R and -r are used together on the
samtools view command line.  This is samtools issue #152.

Also removes the flag conversion subroutine, which is no longer needed.
Adds tests for the new -x tag stripping option.

Includes tests for single and multiple -x arguments, and mixing -x with
-r (samtools issue #153: -r disables -x).  Also tries to filter by read
group and strip RG tags.  This currently doesn't work due to issue #153,
but should do once that has been fixed as long as tag stripping is still
done after the filtering stages.

Includes a few bugfixes to the tag stripping code in filter_sam.