Skip to content

Commit

Permalink
updated htslib, test, misc.
Browse files Browse the repository at this point in the history
  • Loading branch information
atks committed Jul 28, 2015
1 parent 4aed644 commit c070d74
Show file tree
Hide file tree
Showing 16 changed files with 764 additions and 171 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ SOURCES = align\
motif_map\
multi_partition\
needle\
normalize\
ordered_bcf_overlap_matcher\
ordered_region_overlap_matcher\
partition\
Expand Down Expand Up @@ -96,7 +97,6 @@ SOURCES = align\
tbx_ordered_reader\
ahmm\
xcmp\
normalize\

SOURCESONLY = main.cpp

Expand Down
30 changes: 14 additions & 16 deletions annotate_indels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,6 @@ class Igor : Program
std::clog << " [m] mode " << mode << "\n";
print_boo_op(" [d] debug ", debug);
print_ref_op(" [r] ref FASTA file ", ref_fasta_file);

std::clog << " [m] mode dfsdasdad " << mode << "\n";


print_boo_op(" [x] override tag ", override_tag);
print_boo_op(" [v] add vntr record ", add_vntr_record);

Expand All @@ -205,18 +201,19 @@ class Igor : Program

void insert_vntr_record(bcf_hdr_t* h, bcf1_t *v, Variant& variant)
{
// bcf_update_info_string(h, v, MOTIF.c_str(), vntr.motif.c_str());
// bcf_update_info_string(h, v, RU.c_str(), vntr.ru.c_str());
// bcf_update_info_float(h, v, RL.c_str(), &vntr.rl, 1);
// bcf_update_info_string(h, v, REF.c_str(), vntr.repeat_tract.seq.c_str());
// bcf_update_info_int32(h, v, REFPOS.c_str(), &vntr.repeat_tract.pos1, 1);
// kstring_t new_alleles = {0,0,0};
// kputs(vntr.repeat_tract.seq.c_str(), &new_alleles);
// kputc(',', &new_alleles);
// kputs("<VNTR>", &new_alleles);
// bcf_update_alleles_str(h, v, new_alleles.s);
// bcf_set_pos1(v, vntr.repeat_tract.pos1);
// if (new_alleles.m) free(new_alleles.s);
VNTR& vntr = variant.vntr;
bcf_update_info_string(h, v, MOTIF.c_str(), vntr.motif.c_str());
bcf_update_info_string(h, v, RU.c_str(), vntr.ru.c_str());
bcf_update_info_float(h, v, RL.c_str(), &vntr.rl, 1);
bcf_update_info_string(h, v, REF.c_str(), vntr.repeat_tract.seq.c_str());
bcf_update_info_int32(h, v, REFPOS.c_str(), &vntr.repeat_tract.pos1, 1);
kstring_t new_alleles = {0,0,0};
kputs(vntr.repeat_tract.seq.c_str(), &new_alleles);
kputc(',', &new_alleles);
kputs("<VNTR>", &new_alleles);
bcf_update_alleles_str(h, v, new_alleles.s);
bcf_set_pos1(v, vntr.repeat_tract.pos1);
if (new_alleles.m) free(new_alleles.s);
}

void annotate_indels()
Expand All @@ -240,6 +237,7 @@ class Igor : Program

if (add_vntr_record)
{

insert_vntr_record(odr->hdr, v, variant);
odw->write(v);
v = odw->get_bcf1_from_pool();
Expand Down
2 changes: 1 addition & 1 deletion lib/htslib/cram/cram_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ int cram_dependent_data_series(cram_fd *fd,
fd->decode_md = 0;

if (fd->required_fields & SAM_QUAL)
hdr->data_series |= CRAM_SEQ;
hdr->data_series |= CRAM_QUAL;

if (fd->required_fields & SAM_AUX)
hdr->data_series |= CRAM_RG | CRAM_TL | CRAM_aux;
Expand Down
11 changes: 9 additions & 2 deletions lib/htslib/cram/cram_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3014,6 +3014,9 @@ int cram_write_container(cram_fd *fd, cram_container *c) {
static int cram_flush_container2(cram_fd *fd, cram_container *c) {
int i, j;

if (c->curr_slice > 0 && !c->slices)
return -1;

//fprintf(stderr, "Writing container %d, sum %u\n", c->record_counter, sum);

/* Write the container struct itself */
Expand Down Expand Up @@ -4255,7 +4258,7 @@ int cram_eof(cram_fd *fd) {
* Returns 0 on success
* -1 on failure
*/
int cram_set_option(cram_fd *fd, enum cram_option opt, ...) {
int cram_set_option(cram_fd *fd, enum hts_fmt_option opt, ...) {
int r;
va_list args;

Expand All @@ -4273,7 +4276,7 @@ int cram_set_option(cram_fd *fd, enum cram_option opt, ...) {
* Returns 0 on success
* -1 on failure
*/
int cram_set_voption(cram_fd *fd, enum cram_option opt, va_list args) {
int cram_set_voption(cram_fd *fd, enum hts_fmt_option opt, va_list args) {
refs_t *refs;

if (!fd)
Expand Down Expand Up @@ -4406,6 +4409,10 @@ int cram_set_voption(cram_fd *fd, enum cram_option opt, va_list args) {
fd->required_fields = va_arg(args, int);
break;

case HTS_OPT_COMPRESSION_LEVEL:
fd->level = va_arg(args, int);
break;

default:
fprintf(stderr, "Unknown CRAM option code %d\n", opt);
return -1;
Expand Down
4 changes: 2 additions & 2 deletions lib/htslib/cram/cram_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ int cram_eof(cram_fd *fd);
* Returns 0 on success;
* -1 on failure
*/
int cram_set_option(cram_fd *fd, enum cram_option opt, ...);
int cram_set_option(cram_fd *fd, enum hts_fmt_option opt, ...);

/*! Sets options on the cram_fd.
*
Expand All @@ -620,7 +620,7 @@ int cram_set_option(cram_fd *fd, enum cram_option opt, ...);
* Returns 0 on success;
* -1 on failure
*/
int cram_set_voption(cram_fd *fd, enum cram_option opt, va_list args);
int cram_set_voption(cram_fd *fd, enum hts_fmt_option opt, va_list args);

/*!
* Attaches a header to a cram_fd.
Expand Down
6 changes: 4 additions & 2 deletions lib/htslib/cram/cram_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,10 @@ enum cram_fields {
#define CRAM_CIGAR (CRAM_FN | CRAM_FP | CRAM_FC | CRAM_DL | CRAM_IN | \
CRAM_SC | CRAM_HC | CRAM_PD | CRAM_RS | CRAM_RL | CRAM_BF)

#define CRAM_SEQ (CRAM_CIGAR | CRAM_BA | CRAM_QS | CRAM_BS | \
CRAM_RL | CRAM_AP | CRAM_BB | CRAM_QQ)
#define CRAM_SEQ (CRAM_CIGAR | CRAM_BA | CRAM_BS | \
CRAM_RL | CRAM_AP | CRAM_BB)

#define CRAM_QUAL (CRAM_CIGAR | CRAM_RL | CRAM_AP | CRAM_QS | CRAM_QQ)

/* BF bitfields */
/* Corrected in 1.1. Use bam_flag_swap[bf] and BAM_* macros for 1.0 & 1.1 */
Expand Down
Loading

0 comments on commit c070d74

Please sign in to comment.