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
708 709 710 711 712 713 714 715 716 717 718 |
# File 'ext/htslib_native/native_bam.c', line 708
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
749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
# File 'ext/htslib_native/native_bam.c', line 749
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;
VALUE mods_storage = 0;
if (max <= 0) rb_raise(rb_eArgError, "max_mods must be positive");
mods = ALLOCV_N(hts_base_mod, mods_storage, max);
count = bam_mods_at_qpos(get_record(value->record)->pointer, NUM2INT(position), value->state, mods, max);
if (count < 0) {
ALLOCV_END(mods_storage);
raise_base_mod_error("bam_mods_at_qpos");
}
VALUE result = count > 0 ? base_mod_array(mods, count < max ? count : max) : Qnil;
ALLOCV_END(mods_storage);
return result;
}
|
#close ⇒ Object
719 720 721 722 723 724 |
# File 'ext/htslib_native/native_bam.c', line 719
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
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 |
# File 'ext/htslib_native/native_bam.c', line 765
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;
VALUE mods_storage = 0;
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 = ALLOCV_N(hts_base_mod, mods_storage, 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));
}
}
if (count < 0) {
ALLOCV_END(mods_storage);
raise_base_mod_error("bam_next_basemod");
}
ALLOCV_END(mods_storage);
return self;
}
|
#parse(flags) ⇒ Object
725 726 727 728 |
# File 'ext/htslib_native/native_bam.c', line 725
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
805 806 807 808 809 810 811 |
# File 'ext/htslib_native/native_bam.c', line 805
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
812 813 814 815 816 817 818 819 820 |
# File 'ext/htslib_native/native_bam.c', line 812
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
788 789 790 791 792 793 794 |
# File 'ext/htslib_native/native_bam.c', line 788
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;
}
|