Class: HTS::Native::BaseModHandle
- Inherits:
-
Object
- Object
- HTS::Native::BaseModHandle
- Defined in:
- ext/htslib_native/native_bam.c
Class Method Summary collapse
Instance Method Summary collapse
- #at(position, max_value) ⇒ Object
- #close ⇒ Object
- #each_raw(max_value) ⇒ Object
- #parse(flags) ⇒ Object
- #query(code_value) ⇒ Object
- #query_at(index_value) ⇒ Object
- #types ⇒ Object
Class Method Details
.open(record) ⇒ Object
666 667 668 669 670 671 672 673 674 675 676 |
# File 'ext/htslib_native/native_bam.c', line 666
static VALUE native_base_mod_open(VALUE klass, VALUE record) {
ruby_base_mod_t *value;
VALUE object;
get_record(record);
object = TypedData_Make_Struct(klass, ruby_base_mod_t, &base_mod_type, value);
value->state = hts_base_mod_state_alloc();
if (!value->state) rb_raise(rb_eNoMemError, "failed to allocate base modification state");
value->record = record;
RB_OBJ_WRITE(object, &value->record, record);
return object;
}
|
Instance Method Details
#at(position, max_value) ⇒ Object
700 701 702 703 704 705 706 707 708 709 710 |
# File 'ext/htslib_native/native_bam.c', line 700
static VALUE native_base_mod_at(VALUE self, VALUE position, VALUE max_value) {
ruby_base_mod_t *value = get_base_mod(self);
int max = NUM2INT(max_value), count;
hts_base_mod *mods;
if (max <= 0) rb_raise(rb_eArgError, "max_mods must be positive");
mods = ALLOC_N(hts_base_mod, max);
count = bam_mods_at_qpos(get_record(value->record)->pointer, NUM2INT(position), value->state, mods, max);
VALUE result = count > 0 ? base_mod_array(mods, count < max ? count : max) : Qnil;
xfree(mods);
return result;
}
|
#close ⇒ Object
677 678 679 680 681 682 |
# File 'ext/htslib_native/native_bam.c', line 677
static VALUE native_base_mod_close(VALUE self) {
ruby_base_mod_t *value;
TypedData_Get_Struct(self, ruby_base_mod_t, &base_mod_type, value);
if (value->state) { hts_base_mod_state_free(value->state); value->state = NULL; }
return Qnil;
}
|
#each_raw(max_value) ⇒ Object
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
# File 'ext/htslib_native/native_bam.c', line 711
static VALUE native_base_mod_each_raw(VALUE self, VALUE max_value) {
ruby_base_mod_t *value = get_base_mod(self);
int max = NUM2INT(max_value), count, position, index;
hts_base_mod *mods;
if (!rb_block_given_p()) rb_raise(rb_eArgError, "block is required");
if (max <= 0) rb_raise(rb_eArgError, "max_mods must be positive");
mods = ALLOC_N(hts_base_mod, max);
while ((count = bam_next_basemod(get_record(value->record)->pointer, value->state, mods, max, &position)) > 0) {
if (count > max) count = max;
for (index = 0; index < count; index++) {
rb_yield_values(5, INT2NUM(position), INT2NUM(mods[index].canonical_base),
INT2NUM(mods[index].modified_base), INT2NUM(mods[index].strand),
INT2NUM(mods[index].qual));
}
}
xfree(mods);
return self;
}
|
#parse(flags) ⇒ Object
683 684 685 686 |
# File 'ext/htslib_native/native_bam.c', line 683
static VALUE native_base_mod_parse(VALUE self, VALUE flags) {
ruby_base_mod_t *value = get_base_mod(self);
return INT2NUM(bam_parse_basemod2(get_record(value->record)->pointer, value->state, NUM2INT(flags)));
}
|
#query(code_value) ⇒ Object
746 747 748 749 750 751 752 |
# File 'ext/htslib_native/native_bam.c', line 746
static VALUE native_base_mod_query(VALUE self, VALUE code_value) {
ruby_base_mod_t *value = get_base_mod(self);
int code = NUM2INT(code_value), strand, implicit;
char canonical;
int result = bam_mods_query_type(value->state, code, &strand, &implicit, &canonical);
return base_mod_info(code, result, strand, implicit, canonical, 0);
}
|
#query_at(index_value) ⇒ Object
753 754 755 756 757 758 759 760 761 |
# File 'ext/htslib_native/native_bam.c', line 753
static VALUE native_base_mod_query_at(VALUE self, VALUE index_value) {
ruby_base_mod_t *value = get_base_mod(self);
int index = NUM2INT(index_value), strand, implicit, count = 0;
char canonical;
int result = bam_mods_queryi(value->state, index, &strand, &implicit, &canonical);
int *codes = bam_mods_recorded(value->state, &count);
int code = index >= 0 && index < count ? codes[index] : 0;
return base_mod_info(code, result, strand, implicit, canonical, 1);
}
|
#types ⇒ Object
729 730 731 732 733 734 735 |
# File 'ext/htslib_native/native_bam.c', line 729
static VALUE native_base_mod_types(VALUE self) {
ruby_base_mod_t *value = get_base_mod(self);
int count = 0, index, *codes = bam_mods_recorded(value->state, &count);
VALUE result = rb_ary_new_capa(count);
for (index = 0; index < count; index++) rb_ary_push(result, INT2NUM(codes[index]));
return result;
}
|