bio-twobit 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f121452dd047fd5b0c0f771536ae366ca7fc04e0ed93f245303cc2c9a3e8f76
4
- data.tar.gz: db79e13148b8b11440f1fd0bd8436af2ea10fb8291e6dcd84bb7dc3d68950783
3
+ metadata.gz: ec7f8c720eed6e69a7e0829e7a46237e49532a5dc3124c57ee0c574f36e79a46
4
+ data.tar.gz: b46dcf07bd2c34993b57a91e4743d45579285727146fe5ea269dab848e6e6a7f
5
5
  SHA512:
6
- metadata.gz: 4de59a4065d22a9f1324759acc8183629b29f0c112d2e7475b3f2da65ca6c390829d6debbfc42af3fa46a1a7c30935ab4beeae666d8d7b880fe83d29879b675c
7
- data.tar.gz: 3047c3084492ad1ea39f73713baff896c19a095f197cb665067d64d23a2f58d80aa801a9a5319b182d36d38a0c40c708620bbeec9d84aba3dfc27fd033074048
6
+ metadata.gz: 071f082fca0cde51ff22be152f5b6a33837dbf9acdc39dfa9c7caa96fe141a065290febb17f1c5fc45b26a01caacd8d350334f9950885bd5f8a1fe7fae0e5ee4
7
+ data.tar.gz: 7a6753959f1a7bd188341e64c3dc9176de7f240cc214334ba155a9e706a5cbb997a02c2355626831435bf2b5b0755a31e412902f095a9900cd87a3413043d6cc
data/Gemfile CHANGED
@@ -11,4 +11,4 @@ gem "rake-compiler"
11
11
 
12
12
  gem "test-unit"
13
13
 
14
- gem "rubocop"
14
+ gem "rubocop"
data/bio-twobit.gemspec CHANGED
@@ -24,6 +24,4 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
  spec.extensions = ["ext/bio/twobit/extconf.rb"]
27
-
28
- # spec.add_dependency "example-gem", "~> 1.0"
29
27
  end
@@ -125,6 +125,20 @@ twobit_close(VALUE self)
125
125
  return Qnil;
126
126
  }
127
127
 
128
+ static VALUE
129
+ twobit_closed_question_mark(VALUE self)
130
+ {
131
+ TwoBit *tb = getTwoBit(self);
132
+ if (tb)
133
+ {
134
+ return Qfalse;
135
+ }
136
+ else
137
+ {
138
+ return Qtrue;
139
+ }
140
+ }
141
+
128
142
  static VALUE
129
143
  twobit_info(VALUE self)
130
144
  {
@@ -351,7 +365,8 @@ twobit_hard_masked_blocks(VALUE self, VALUE chrom, VALUE rbstart, VALUE rbend)
351
365
  {
352
366
  char *ch;
353
367
  TwoBit *tb;
354
- unsigned long startl = 0, endl = 0, totalBlocks = 0, tid;
368
+ long tid = -1;
369
+ unsigned long startl = 0, endl = 0, totalBlocks = 0;
355
370
  uint32_t i, len, start, end, blockStart, blockEnd;
356
371
  VALUE val, ary;
357
372
 
@@ -428,7 +443,8 @@ twobit_soft_masked_blocks(VALUE self, VALUE chrom, VALUE rbstart, VALUE rbend)
428
443
  {
429
444
  char *ch;
430
445
  TwoBit *tb;
431
- unsigned long startl = 0, endl = 0, totalBlocks = 0, tid;
446
+ long tid = -1;
447
+ unsigned long startl = 0, endl = 0, totalBlocks = 0;
432
448
  uint32_t i, len, start, end, blockStart, blockEnd;
433
449
  VALUE val, ary;
434
450
 
@@ -515,6 +531,7 @@ void Init_twobit(void)
515
531
 
516
532
  rb_define_private_method(mTwoBit, "initialize_raw", twobit_init, 2);
517
533
  rb_define_method(mTwoBit, "close", twobit_close, 0);
534
+ rb_define_method(mTwoBit, "closed?", twobit_closed_question_mark, 0);
518
535
  rb_define_method(mTwoBit, "info", twobit_info, 0);
519
536
  rb_define_method(mTwoBit, "chroms", twobit_chroms, 0);
520
537
  rb_define_private_method(mTwoBit, "sequence_raw", twobit_sequence, 3);
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bio
4
4
  class TwoBit
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
data/lib/bio/twobit.rb CHANGED
@@ -4,21 +4,40 @@ require_relative "twobit/version"
4
4
  require_relative "twobit/twobit"
5
5
 
6
6
  module Bio
7
+ # Reader for .2bit files (i.e., from UCSC genome browser)
7
8
  class TwoBit
8
- class << self
9
- alias open new
9
+ def self.open(*args, **kwargs)
10
+ file = new(*args, **kwargs)
11
+ return file unless block_given?
12
+
13
+ begin
14
+ yield file
15
+ ensure
16
+ file.close
17
+ end
18
+ file
10
19
  end
11
20
 
12
21
  def initialize(fname, masked: false)
13
- mskd = masked ? 1 : 0
14
- initialize_raw(fname, mskd)
15
- if block_given?
16
- begin
17
- yield self
18
- ensure
19
- close
20
- end
22
+ raise "TwoBit::new() does not take block; use TwoBit::open() instead" if block_given?
23
+
24
+ @fname = fname
25
+ if masked
26
+ mskd = 1
27
+ @masked = true
28
+ else
29
+ mskd = 0
30
+ @masked = false
21
31
  end
32
+ initialize_raw(fname, mskd)
33
+ end
34
+
35
+ def path
36
+ @fname
37
+ end
38
+
39
+ def masked?
40
+ @masked
22
41
  end
23
42
 
24
43
  def sequence(chrom, start = 0, stop = 0)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-twobit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-18 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a Ruby binding for lib2bit(https://github.com/dpryan79/lib2bit),
14
14
  which provides high-speed access to genomic data in 2bit file format.
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  requirements: []
55
- rubygems_version: 3.2.22
55
+ rubygems_version: 3.3.3
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: A ruby library for accessing 2bit files