Merge pull request #27 from jkbonfield/develop

Fixed CRAM to code with the 0x800 supplementary flag.
vcf: New bcf_hdr_printf() call
Merge branch 'bcftools+calling' into develop
Move cram_seek() from cram_index.c to cram_io.c

Now all direct access to cram_fd::fp is within cram_io.c.
Use hFILE underneath cram_fd, and add cram_dopen()

For compatibility with the non-htslib CRAM codebase, cram_structs.h
declares a cram_FILE which underlies cram_fd and may be either hFILE
or stdio's FILE.
vcf: Print a comprehensible error message if unsupported version of BCF is encountered
hts_open(fname, "r") detects format by peeking at the input

The file format mode letters (especially "b", "c", but also "z" and "u")
are now ignored by hts_open() when opening files for reading.  Instead
the file format is determined by peeking at the underlying hFILE.

The supplied mode is now used as the mode argument of all hopen(),
bgzf_open(), cram_open(), etc calls inside hts_open(), so additional
mode letters understood by the latter are propagated to them.
Merge branch 'io' into develop
Tab, newline, etc are not control characters

A bgzipped file starting with "@HD\t" is a bgzipped text file.
Require lowercase [rw] mode letters in bgzf_open() etc
Limit input hFILE buffers to 32K [temporary hack version]

Eventually we hope instead to add some high-level hints to the
hts_open() mode string: random access => one block buffer;
many files open => very small buffer; and so on.
Fix tbx_itr_next() when given a textual (is_kstream) htsFile

Previously to use a tabix index with a .vcf.gz file, you would open
the VCF_GZ with hts_open("rb") so as to have a BGZF*-based htsFile
(and remember not to use bcf_hdr_read() or bcf_read() with it!).
This doesn't work when the non-is_bin format is auto-detected.

Now tbx_itr_next() works with either kind of htsFile, though the kstream_t
is not currently kept synchronised, so you still shouldn't use bcf_read()
once you've started jumping around.  Eventually htsFile will probably stop
using kstream_t and this will be tidied up.

Thus bcf_sr_open_reader() no longer needs to reopen the file after
reading the header.
test.pl: fail if any tests fail
hts_open(fname, "r") now works in both cases; no need for "rb"
Format detection: non-compressed binaries; is_compressed setting

Detect non-BGZF-compressed binary formats, e.g., raw non-compressed BCF.

When a BGZF-compressed or gzipped stream has been detected, set
is_compressed so client code (within htslib) can determine what format
they are reading by examining is_bin/is_compressed/is_cram.
bcf_sr_open_reader(): Auto-detect input file format

Set reader->type to the format as detected by hts_open() rather than
using hts_file_type() and bcf_sr_open_reader()'s type parameter, which
is susceptible to user error when input is from standard input.

Previously e.g. "bcftools subset - < test.bcf" (user omitted "-b") would
read test.bcf as VCF and fail with a parse error.  Now that hts_open()
correctly opens test.bcf as a BGZF-based binary, reading it as VCF
crashes -- so now it is important that reader->type corresponds to the
format detected by hts_open().

The type parameter is now unused.  Options such as "subset -b" are now
unnecessary.
The file type not necessary any more when opening synced reader
Merge branch 'develop' into bcftools+calling
Reverted a fix of "chr:pos-pos" index queries, the original version now works.
Merge branch 'develop' of https://github.com/samtools/htslib into develop

Conflicts:
	cram/cram_io.c