Class: HTS::Native::BcfFileHandle
- Inherits:
-
Object
- Object
- HTS::Native::BcfFileHandle
- Defined in:
- ext/htslib_native/native_bcf.c
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
- #file_format ⇒ Object
- #file_format_version ⇒ Object
- #index_loaded? ⇒ Boolean
- #load_index(index) ⇒ Object
- #query_interval(header, rid, beg, end) ⇒ Object
- #query_region(header, region) ⇒ Object
- #read(header, record) ⇒ Object
- #read_header ⇒ Object
- #seek(offset) ⇒ Object
- #set_threads(n) ⇒ Object
- #tell ⇒ Object
- #write(header, record) ⇒ Object
- #write_header(header) ⇒ Object
Class Method Details
.build_index(path, index, shift, threads) ⇒ Object
426 |
# File 'ext/htslib_native/native_bcf.c', line 426
static VALUE native_bcf_file_build_index(VALUE klass,VALUE path,VALUE index,VALUE shift,VALUE threads){return INT2NUM(bcf_index_build3(StringValueCStr(path),NIL_P(index)?NULL:StringValueCStr(index),NUM2INT(shift),NUM2INT(threads)));}
|
.open(path, mode) ⇒ Object
412 |
# File 'ext/htslib_native/native_bcf.c', line 412
static VALUE native_bcf_file_open(VALUE klass,VALUE path,VALUE mode) {ruby_bcf_file_t*v;VALUE o=TypedData_Make_Struct(klass,ruby_bcf_file_t,&bcf_file_type,v);v->index=NULL;v->tabix=NULL;v->active_io=0;v->path=rb_str_dup(StringValue(path));RB_OBJ_WRITE(o,&v->path,v->path);errno=0;v->file=hts_open(StringValueCStr(v->path),StringValueCStr(mode));if(!v->file)raise_bcf_open_error(path,errno);return o;}
|
Instance Method Details
#close ⇒ Object
413 |
# File 'ext/htslib_native/native_bcf.c', line 413
static VALUE native_bcf_file_close(VALUE self){ruby_bcf_file_t*v=get_bcf_file(self,1);int result=0;if(v->active_io)rb_raise(rb_eIOError,"cannot close BCF during active I/O");if(v->index){hts_idx_destroy(v->index);v->index=NULL;}if(v->tabix){tbx_destroy(v->tabix);v->tabix=NULL;}if(v->file){result=hts_close(v->file);v->file=NULL;}return INT2NUM(result);}
|
#closed? ⇒ Boolean
414 |
# File 'ext/htslib_native/native_bcf.c', line 414
static VALUE native_bcf_file_closed(VALUE self){return get_bcf_file(self,1)->file?Qfalse:Qtrue;}
|
#file_format ⇒ Object
420 |
# File 'ext/htslib_native/native_bcf.c', line 420
static VALUE native_bcf_file_format(VALUE self){const htsFormat*f=hts_get_format(get_bcf_file(self,0)->file);if(!f)return Qnil;switch(f->format){case vcf:return rb_str_new_cstr("vcf");case bcf:return rb_str_new_cstr("bcf");default:return rb_str_new_cstr("unknown_format");}}
|
#file_format_version ⇒ Object
421 |
# File 'ext/htslib_native/native_bcf.c', line 421
static VALUE native_bcf_file_version(VALUE self){const htsFormat*f=hts_get_format(get_bcf_file(self,0)->file);if(!f)return Qnil;if(f->version.minor==-1)return rb_sprintf("%d",f->version.major);return rb_sprintf("%d.%d",f->version.major,f->version.minor);}
|
#index_loaded? ⇒ Boolean
425 |
# File 'ext/htslib_native/native_bcf.c', line 425
static VALUE native_bcf_file_index_loaded(VALUE self){ruby_bcf_file_t*v=get_bcf_file(self,0);return(v->index||v->tabix)?Qtrue:Qfalse;}
|
#load_index(index) ⇒ Object
424 |
# File 'ext/htslib_native/native_bcf.c', line 424
static VALUE native_bcf_file_load_index(VALUE self,VALUE index){ruby_bcf_file_t*v=get_bcf_file(self,0);const htsFormat*f=hts_get_format(v->file);if(v->index){hts_idx_destroy(v->index);v->index=NULL;}if(v->tabix){tbx_destroy(v->tabix);v->tabix=NULL;}if(f&&f->format==vcf)v->tabix=NIL_P(index)?tbx_index_load3(StringValueCStr(v->path),NULL,HTS_IDX_SAVE_REMOTE):tbx_index_load2(StringValueCStr(v->path),StringValueCStr(index));else v->index=NIL_P(index)?bcf_index_load3(StringValueCStr(v->path),NULL,HTS_IDX_SAVE_REMOTE):bcf_index_load2(StringValueCStr(v->path),StringValueCStr(index));return(v->index||v->tabix)?Qtrue:Qfalse;}
|
#query_interval(header, rid, beg, end) ⇒ Object
428 |
# File 'ext/htslib_native/native_bcf.c', line 428
static VALUE native_bcf_file_query_interval(VALUE self,VALUE header,VALUE rid,VALUE beg,VALUE end){ruby_bcf_file_t*v=get_bcf_file(self,0);hts_itr_t*i=v->tabix?tbx_itr_queryi(v->tabix,NUM2INT(rid),NUM2LL(beg),NUM2LL(end)):bcf_itr_queryi(v->index,NUM2INT(rid),NUM2LL(beg),NUM2LL(end));return wrap_bcf_iterator(self,header,i,v->tabix!=NULL);}
|
#query_region(header, region) ⇒ Object
427 |
# File 'ext/htslib_native/native_bcf.c', line 427
static VALUE native_bcf_file_query_region(VALUE self,VALUE header,VALUE region){ruby_bcf_file_t*v=get_bcf_file(self,0);hts_itr_t*i;if(v->tabix)i=tbx_itr_querys(v->tabix,StringValueCStr(region));else i=bcf_itr_querys(v->index,get_bcf_header(header)->pointer,StringValueCStr(region));return wrap_bcf_iterator(self,header,i,v->tabix!=NULL);}
|
#read(header, record) ⇒ Object
416 |
# File 'ext/htslib_native/native_bcf.c', line 416
static VALUE native_bcf_file_read(VALUE self,VALUE header,VALUE record){ruby_bcf_file_t*v=get_bcf_file(self,0);bcf_io_args_t a={v->file,get_bcf_header(header)->pointer,get_bcf_record(record)->pointer,NULL,NULL,NULL,0};bcf_io_run(v,bcf_read_without_gvl,&a);return INT2NUM(a.result);}
|
#read_header ⇒ Object
415 |
# File 'ext/htslib_native/native_bcf.c', line 415
static VALUE native_bcf_file_read_header(VALUE self){ruby_bcf_file_t*v=get_bcf_file(self,0);bcf_header_read_args_t a={v->file,NULL};bcf_io_run(v,bcf_read_header_without_gvl,&a);return wrap_bcf_header(a.result);}
|
#seek(offset) ⇒ Object
422 |
# File 'ext/htslib_native/native_bcf.c', line 422
static VALUE native_bcf_file_seek(VALUE self,VALUE offset){htsFile*f=get_bcf_file(self,0)->file;return LL2NUM(f->is_bgzf?bgzf_seek(f->fp.bgzf,NUM2LL(offset),SEEK_SET):hseek(f->fp.hfile,NUM2LL(offset),SEEK_SET));}
|
#set_threads(n) ⇒ Object
419 |
# File 'ext/htslib_native/native_bcf.c', line 419
static VALUE native_bcf_file_set_threads(VALUE self,VALUE n){return INT2NUM(hts_set_threads(get_bcf_file(self,0)->file,NUM2INT(n)));}
|
#tell ⇒ Object
423 |
# File 'ext/htslib_native/native_bcf.c', line 423
static VALUE native_bcf_file_tell(VALUE self){htsFile*f=get_bcf_file(self,0)->file;return LL2NUM(f->is_bgzf?bgzf_tell(f->fp.bgzf):htell(f->fp.hfile));}
|
#write(header, record) ⇒ Object
418 |
# File 'ext/htslib_native/native_bcf.c', line 418
static VALUE native_bcf_file_write(VALUE self,VALUE header,VALUE record){ruby_bcf_file_t*v=get_bcf_file(self,0);bcf_io_args_t a={v->file,get_bcf_header(header)->pointer,get_bcf_record(record)->pointer,NULL,NULL,NULL,0};bcf_io_run(v,bcf_write_without_gvl,&a);return INT2NUM(a.result);}
|
#write_header(header) ⇒ Object
417 |
# File 'ext/htslib_native/native_bcf.c', line 417
static VALUE native_bcf_file_write_header(VALUE self,VALUE header){ruby_bcf_file_t*v=get_bcf_file(self,0);bcf_io_args_t a={v->file,get_bcf_header(header)->pointer,NULL,NULL,NULL,NULL,0};bcf_io_run(v,bcf_write_header_without_gvl,&a);return INT2NUM(a.result);}
|