Class: HTS::Native::PileupHandle
- Inherits:
-
Object
- Object
- HTS::Native::PileupHandle
- Defined in:
- ext/htslib_native/native_bam.c
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.open(file_value, header_value, region_value, beg_value, end_value, max_value) ⇒ Object
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 |
# File 'ext/htslib_native/native_bam.c', line 797
static VALUE native_pileup_open(VALUE klass, VALUE file_value, VALUE header_value,
VALUE region_value, VALUE beg_value, VALUE end_value, VALUE max_value) {
ruby_pileup_t *value;
ruby_bam_file_t *file = get_file(file_value, 0);
VALUE object;
get_header(header_value);
object = TypedData_Make_Struct(klass, ruby_pileup_t, &pileup_type, value);
value->pileup = NULL;
value->iterator = NULL;
value->file = file_value;
value->header = header_value;
RB_OBJ_WRITE(object, &value->file, file_value);
RB_OBJ_WRITE(object, &value->header, header_value);
if (!NIL_P(region_value)) {
if (!file->index) rb_raise(rb_eRuntimeError, "index file is required to use region pileup");
if (NIL_P(beg_value) && NIL_P(end_value))
value->iterator = sam_itr_querys(file->index, get_header(header_value)->pointer, StringValueCStr(region_value));
else
value->iterator = sam_itr_queryi(file->index,
sam_hdr_name2tid(get_header(header_value)->pointer, StringValueCStr(region_value)),
NUM2LL(beg_value), NUM2LL(end_value));
if (!value->iterator) rb_raise(rb_eRuntimeError, "failed to query pileup region");
}
value->pileup = bam_plp_init(native_pileup_read, value);
if (!value->pileup) rb_raise(rb_eNoMemError, "bam_plp_init failed");
if (!NIL_P(max_value)) bam_plp_set_maxcnt(value->pileup, NUM2INT(max_value));
return object;
}
|
Instance Method Details
#close ⇒ Object
874 875 876 877 878 879 |
# File 'ext/htslib_native/native_bam.c', line 874
static VALUE native_pileup_close(VALUE self) {
ruby_pileup_t *value = get_pileup(self, 1);
if (value->pileup) { bam_plp_destroy(value->pileup); value->pileup = NULL; }
if (value->iterator) { hts_itr_destroy(value->iterator); value->iterator = NULL; }
return Qnil;
}
|
#next ⇒ Object
854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 |
# File 'ext/htslib_native/native_bam.c', line 854
static VALUE native_pileup_next(VALUE self) {
ruby_pileup_t *value = get_pileup(self, 0);
int tid = -1, count = 0;
hts_pos_t position = -1;
const bam_pileup1_t *entries = bam_plp64_auto(value->pileup, &tid, &position, &count);
VALUE result;
if (!entries) {
if (count < 0) rb_raise(rb_eRuntimeError, "HTSlib pileup error");
return Qnil;
}
result = rb_ary_new_capa(3);
rb_ary_push(result, INT2NUM(tid));
rb_ary_push(result, LL2NUM(position));
rb_ary_push(result, pileup_rows(entries, count));
return result;
}
|
#reset ⇒ Object
870 871 872 873 |
# File 'ext/htslib_native/native_bam.c', line 870
static VALUE native_pileup_reset(VALUE self) {
bam_plp_reset(get_pileup(self, 0)->pileup);
return Qnil;
}
|