Use htsFormat to replace htsFile's is_foo flags

Add an htsFormat member to htsFile, readable via hts_get_format().
Use hts_detect_format() within hts_hopen(fname, "r"), and fill in the
format based on mode letters for "w".

The htsFormat settings are clearer than the old is_foo flags, so begin
recoding SAM/BAM/CRAM and VCF/BCF tests to use fp->format.format (within
htslib; hts_get_format(fp)->format elsewhere) instead.  However several
of the flags are used directly outside htslib (see notes in htslib/hts.h)
so even though they are unused within htslib they cannot be removed
unless/until libhts.so's soversion is changed.

The is_be, is_compressed, and is_kstream flags are not used in samtools
or bcftools and we assume they are not used in other third-party code,
so they are safe to remove (and is_kstream has been removed).
Add htsfile utility

Note that hts_format_description() may possibly need to change to return
a string that the user must free() before release.  Manpage to follow.
Merge origin/develop, replacing htsFile.type by .format

Use the followups mentioned in abd1efb rather than the alternatives
via htsFile.type -- in particular, retain is_cram for the sake of
libhts.so binary compatibility.  The -i option added to tabix now
duplicates htsfile functionality, and can be removed in due course.
Parse SAM aux 'i' values > 2^31 correctly

BAM can represent 'i' values from -2^31 and 'I' values up to 2^32-1.
Especially on machines where long is 32 bits, we need to consider
positive and negative values carefully and separately to parse this
whole range correctly.

Addresses samtools/hts-specs#36 -- even if the spec doesn't require
this (which may soon change), as a quality of implementation issue
htslib should support the same range in SAM and BAM.
Sped up cram_index_load some 200 fold by replacing sscanf with our own
number decoding.
Fixed an incorrect EOF-style case when seeking multiple times.

When asking to fetch data for a specific chr:range, if the current
container entirely fits within the range but the next container is
outside the range then it sets the fd->ooc (out of containers) flag to
prevent subsequent containers from being decoded, to mark the end of
the sub-query.

However this then causes a subsequent cram_seek to also fail as the
ooc flag is still set. We now clear this on every new seek.
Fix of memmove bug in bcf_remove_filter()
Buffer overflow error in synced_bcf_reader.c

clearly, out is being accessed at location nout, so it should be at least size nout+1.
Merge pull request #142 from reinders/patch-1

Buffer overflow error in synced_bcf_reader.c
Fix compilation when ALLOW_UAC is not defined
bcf_sr_add_reader(): do not increment nreaders or perform any reallocs upon file open errors

This avoids a segfault if bcf_sr_destroy() is called after bcf_sr_add_reader()
when a file couldn't be opened.
Merge pull request #144 from broadinstitute/broad_bcf_sr_add_reader_segfault_fix

bcf_sr_add_reader(): do not increment nreaders or perform any reallocs upon file open errors
bcf_sr_get_header() macro for accessing the synced readers' headers
Add IDX to hdr tags of different type, fixes issue https://github.com/samtools/bcftools/issues/141
Amended/removed comments about scram_* API.
Merge short read() bug fix from upstream

See attractivechaos/klib@8d8d1a19f0c69b53d5ed8d9f6592dfa4b91c23f3
and lh3/seqtk#43.
Fix ks_getuntil2() extra empty record at EOF bug

When the stream is an exact multiple of the buffer size, ks_getuntil2()
was returning a final empty record when it should have returned -1.
Fixed by moving the "EOF => return -1" check to after the read loop.

Fixes samtools/samtools#318.  See upstream PR attractivechaos/klib#39.
bcf_hdr_subset: Return NULL on duplicate sample names
Sanity check to detect broken GT fields in bcf_calc_ac()
Add seq_nt16_int[], equivalent to the old API's bam_nt16_nt4_table[]

Also improve descriptions of the usage of all three tables.