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
348 |
# File 'ext/htslib_native/native_bcf.c', line 348
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
334 |
# File 'ext/htslib_native/native_bcf.c', line 334
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);v->file=hts_open(StringValueCStr(v->path),StringValueCStr(mode));if(!v->file)rb_syserr_fail_str(ENOENT,path);return o;}
|
Instance Method Details
#close ⇒ Object
335 |
# File 'ext/htslib_native/native_bcf.c', line 335
static VALUE native_bcf_file_close(VALUE self){ruby_bcf_file_t*v=get_bcf_file(self,1);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){hts_close(v->file);v->file=NULL;}return Qnil;}
|
#closed? ⇒ Boolean
336 |
# File 'ext/htslib_native/native_bcf.c', line 336
static VALUE native_bcf_file_closed(VALUE self){return get_bcf_file(self,1)->file?Qfalse:Qtrue;}
|
#file_format ⇒ Object
342 |
# File 'ext/htslib_native/native_bcf.c', line 342
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
343 |
# File 'ext/htslib_native/native_bcf.c', line 343
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
347 |
# File 'ext/htslib_native/native_bcf.c', line 347
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
346 |
# File 'ext/htslib_native/native_bcf.c', line 346
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
350 |
# File 'ext/htslib_native/native_bcf.c', line 350
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
349 |
# File 'ext/htslib_native/native_bcf.c', line 349
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
338 |
# File 'ext/htslib_native/native_bcf.c', line 338
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_begin(v);rb_thread_call_without_gvl(bcf_read_without_gvl,&a,RUBY_UBF_IO,NULL);v->active_io=0;return INT2NUM(a.result);}
|
#read_header ⇒ Object
337 |
# File 'ext/htslib_native/native_bcf.c', line 337
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_begin(v);rb_thread_call_without_gvl(bcf_read_header_without_gvl,&a,RUBY_UBF_IO,NULL);v->active_io=0;return wrap_bcf_header(a.result);}
|
#seek(offset) ⇒ Object
344 |
# File 'ext/htslib_native/native_bcf.c', line 344
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
341 |
# File 'ext/htslib_native/native_bcf.c', line 341
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
345 |
# File 'ext/htslib_native/native_bcf.c', line 345
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
340 |
# File 'ext/htslib_native/native_bcf.c', line 340
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_begin(v);rb_thread_call_without_gvl(bcf_write_without_gvl,&a,RUBY_UBF_IO,NULL);v->active_io=0;return INT2NUM(a.result);}
|
#write_header(header) ⇒ Object
339 |
# File 'ext/htslib_native/native_bcf.c', line 339
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_begin(v);rb_thread_call_without_gvl(bcf_write_header_without_gvl,&a,RUBY_UBF_IO,NULL);v->active_io=0;return INT2NUM(a.result);}
|