Skip to content

Commit

Permalink
switched htslib to samtools/htslib master
Browse files Browse the repository at this point in the history
  • Loading branch information
walaj committed May 12, 2017
2 parents d98da4e + 38c98e3 commit c53bd03
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
url = https://github.com/jwalabroad/fermi-lite
[submodule "htslib"]
path = htslib
url = https://github.com/walaj/htslib
branch = develop
url = https://github.com/samtools/htslib
branch = master
[submodule "bwa"]
path = bwa
url = https://github.com/jwalabroad/bwa
Expand Down
20 changes: 20 additions & 0 deletions SeqLib/BamRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,13 @@ class BamRecord {
*/
bool GetZTag(const std::string& tag, std::string& s) const;

/** Get a string of either Z, f or i type. Useful if tag type not known at compile time.
* @param tag Name of the tag. eg "XP"
* @param s The string to be filled in with the tag information
* @return Returns true if the tag is present and is either Z or i, even if empty. Return false if no tag or not Z or i.
*/
bool GetTag(const std::string& tag, std::string& s) const;

/** Get a vector of type int from a Z tag delimited by "^"
* Smart-tags allow one to store vectors of strings, ints or doubles in the alignment tags, and
* do not require an additional data structure on top of bseq1_t.
Expand Down Expand Up @@ -711,6 +718,19 @@ class BamRecord {
return true;
}

/** Get a float (f) tag
* @param tag Name of the tag. eg "AS"
* @param t Value to be filled in with the tag value.
* @return Return true if the tag exists.
*/
inline bool GetFloatTag(const std::string& tag, float& t) const {
uint8_t* p = bam_aux_get(b.get(),tag.c_str());
if (!p)
return false;
t = bam_aux2f(p);
return true;
}

/** Add a string (Z) tag
* @param tag Name of the tag. eg "XP"
* @param val Value for the tag
Expand Down
2 changes: 1 addition & 1 deletion htslib
Submodule htslib updated 88 files
+0 −5 .gitignore
+11 −7 INSTALL
+28 −62 Makefile
+0 −14 NEWS
+2 −3 README.md
+159 −611 bgzf.c
+4 −30 bgzip.c
+38 −0 config.h.in
+30 −12 config.mk.in
+6,431 −0 configure
+41 −47 configure.ac
+22 −86 cram/cram_codecs.c
+0 −4 cram/cram_codecs.h
+48 −123 cram/cram_decode.c
+403 −481 cram/cram_encode.c
+0 −10 cram/cram_encode.h
+0 −16 cram/cram_external.c
+63 −71 cram/cram_index.c
+2 −2 cram/cram_index.h
+91 −194 cram/cram_io.c
+1 −73 cram/cram_io.h
+259 −7 cram/cram_stats.c
+17 −36 cram/cram_structs.h
+1 −0 cram/open_trace_file.c
+0 −2 cram/pooled_alloc.h
+46 −29 cram/rANS_static.c
+2 −3 cram/sam_header.c
+1 −1 cram/string_alloc.c
+757 −0 cram/thread_pool.c
+218 −0 cram/thread_pool.h
+0 −2 cram/vlen.h
+35 −6 cram/zfio.c
+0 −194 errmod.c
+20 −10 faidx.c
+3 −64 hfile.c
+1 −0 hfile_internal.h
+259 −0 hfile_irods.c
+66 −14 hfile_libcurl.c
+19 −129 hts.c
+3 −5 htslib.mk
+5 −29 htslib/bgzf.h
+7 −30 htslib/cram.h
+83 −68 htslib/faidx.h
+72 −113 htslib/hfile.h
+6 −86 htslib/hts.h
+0 −1 htslib/knetfile.h
+1 −2 htslib/ksort.h
+68 −30 htslib/kstring.h
+0 −2 htslib/regidx.h
+5 −52 htslib/sam.h
+3 −18 htslib/synced_bcf_reader.h
+2 −5 htslib/tbx.h
+0 −281 htslib/thread_pool.h
+6 −59 htslib/vcf.h
+2 −3 htslib/vcf_sweep.h
+2 −3 htslib/vcfutils.h
+0 −1 htslib_vars.mk
+1 −1 knetfile.c
+4 −6 kstring.c
+9 −1 plugin.c
+0 −285 probaln.c
+0 −199 realn.c
+4 −5 regidx.c
+10 −96 sam.c
+4 −35 synced_bcf_reader.c
+4 −8 tabix.1
+5 −11 tbx.c
+ test/aux#aux_java.cram
+2 −2 test/auxf#values.sam
+ test/auxf#values_java.cram
+0 −1 test/bgziptest.txt
+ test/bgziptest.txt.gz
+ test/bgziptest.txt.gz.gzi
+11 −11 test/compare_sam.pl
+2 −2 test/cross_validate.sh
+0 −6 test/formatmissing-out.vcf
+0 −6 test/formatmissing.vcf
+1 −9 test/hfile.c
+0 −12 test/md#1.sam
+0 −3 test/md.fa
+0 −1 test/md.fa.fai
+1 −11 test/sam.c
+5 −5 test/test-regidx.c
+25 −44 test/test.pl
+1 −19 test/test_view.c
+0 −1,350 thread_pool.c
+0 −165 thread_pool_internal.h
+62 −114 vcf.c
5 changes: 3 additions & 2 deletions src/BamReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ bool BamReader::GetNextRecord(BamRecord& r) {

// try and get the next read
int32_t status = m_bams.begin()->second.load_read(r);
if (status == 0)
if (status >= 0)
return true;
if (status == -1) {
// didn't find anything, clear it
Expand Down Expand Up @@ -270,7 +270,7 @@ bool BamReader::GetNextRecord(BamRecord& r) {
tb->empty = true;
tb->mark_for_closure = true; // no more reads in this BAM
continue;
} else if (status != 0) { // error sent back from sam_read1
} else if (status < 0) { // error sent back from sam_read1
// run time error
std::stringstream ss;
ss << "sam_read1 return status: " << status << " file: " << bam->first;
Expand Down Expand Up @@ -328,6 +328,7 @@ std::string BamReader::PrintRegions() const {

if (hts_itr.get() == NULL) {
valid = sam_read1(fp.get(), m_hdr.get_(), b);

if (valid < 0) {

#ifdef DEBUG_WALKER
Expand Down
20 changes: 20 additions & 0 deletions src/BamRecord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,26 @@ namespace SeqLib {
bam_aux_append(b.get(), tag.data(), 'Z', val.length()+1, (uint8_t*)val.c_str());
}

bool BamRecord::GetTag(const std::string& tag, std::string& s) const {
if (GetZTag(tag, s))
return true;
int32_t t;
if (GetIntTag(tag, t)) {
std::stringstream ss;
ss << t;
s = ss.str();
return true;
}
float f;
if (GetFloatTag(tag, f)) {
std::stringstream ss;
ss << f;
s = ss.str();
return true;
}
return false;
}

bool BamRecord::GetZTag(const std::string& tag, std::string& s) const {
uint8_t* p = bam_aux_get(b.get(),tag.c_str());
if (!p)
Expand Down

0 comments on commit c53bd03

Please sign in to comment.