bio-twobit 0.1.2 → 0.1.3

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: ec7f8c720eed6e69a7e0829e7a46237e49532a5dc3124c57ee0c574f36e79a46
4
- data.tar.gz: b46dcf07bd2c34993b57a91e4743d45579285727146fe5ea269dab848e6e6a7f
3
+ metadata.gz: 13e0df3d77589aedc725b0cffa8c5362ac749990a5eef6e1c10d0d137ae8e4d3
4
+ data.tar.gz: 56e92c1e74b96a040cc8c22c786f2c03d1f6fac7aabb969c34e9f0e81b496055
5
5
  SHA512:
6
- metadata.gz: 071f082fca0cde51ff22be152f5b6a33837dbf9acdc39dfa9c7caa96fe141a065290febb17f1c5fc45b26a01caacd8d350334f9950885bd5f8a1fe7fae0e5ee4
7
- data.tar.gz: 7a6753959f1a7bd188341e64c3dc9176de7f240cc214334ba155a9e706a5cbb997a02c2355626831435bf2b5b0755a31e412902f095a9900cd87a3413043d6cc
6
+ metadata.gz: d4b7fa2a849a682739b2ae9686000adf397ad972412df8ee965feb0c165df7743a94f1f4d1b7b7d6fba0066e4b7a12b9d5fff87f5db47c7d8a76bf6bd2753456
7
+ data.tar.gz: 593012ebcbb5eed16157ab6990db9f6cebcb9164c2b171eff04f3e5ebc4f88360c079c118d4e064f63d7205e113a1c889c3897cfdc92a59de8915d7b57df0aeb
data/README.md CHANGED
@@ -18,8 +18,7 @@ gem install bio-twobit
18
18
  Downlaod BSgenome.Hsapiens.UCSC.hg38
19
19
 
20
20
  ```sh
21
- wget https://bioconductor.org/packages/release/data/annotation/src/contrib/BSgenome.Hsapiens.UCSC.hg38_1.4.4.tar.gz
22
- tar xvf BSgenome.Hsapiens.UCSC.hg38_1.4.4.tar.gz
21
+ wget http://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.2bit
23
22
  ```
24
23
 
25
24
  Quick Start
@@ -27,7 +26,10 @@ Quick Start
27
26
  ```ruby
28
27
  require 'bio/twobit'
29
28
 
30
- hg38 = Bio::TwoBit.open("BSgenome.Hsapiens.UCSC.hg38/inst/extdata/single_sequences.2bit")
29
+ hg38 = Bio::TwoBit.open("hg38.2bit")
30
+
31
+ hg38.path
32
+ # "hg38.2bit"
31
33
 
32
34
  hg38.info
33
35
  # {"file_size"=>818064875,
@@ -75,6 +77,10 @@ Bio::TwoBit.open("test/fixtures/foo.2bit") do |t|
75
77
  end
76
78
  ```
77
79
 
80
+ ```ruby
81
+ tb.closed? # true / false
82
+ ```
83
+
78
84
  If you would like to include information about soft-masked bases, you need to manually specify `masked: true`
79
85
 
80
86
  ```ruby
@@ -89,10 +95,18 @@ tb.soft_masked_blocks("chr1")
89
95
  # => [[62, 70]]
90
96
  ```
91
97
 
98
+ ```ruby
99
+ tb.masked? # true / false
100
+ ```
101
+
92
102
  ## Development
93
103
 
94
104
  Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-on-bioc/bio-twobit.
95
105
 
106
+ Do you need commit rights to my repository?
107
+ Do you want to get admin rights and take over the project?
108
+ If so, please feel free to contact us @kojix2.
109
+
96
110
  ## License
97
111
 
98
112
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/bio-twobit.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "A ruby library for accessing 2bit files"
12
12
  spec.description = "This is a Ruby binding for lib2bit(https://github.com/dpryan79/lib2bit), " \
13
- "which provides high-speed access to genomic data in 2bit file format."
13
+ "which provides high-speed access to genomic data in 2bit file format."
14
14
  spec.homepage = "https://github.com/ruby-on-bioc/bio-twobit"
15
15
  spec.license = "MIT"
16
16
  spec.required_ruby_version = ">= 2.6.0"
@@ -20,8 +20,6 @@ Gem::Specification.new do |spec|
20
20
  (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
21
21
  end
22
22
  end
23
- spec.bindir = "exe"
24
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
23
  spec.require_paths = ["lib"]
26
24
  spec.extensions = ["ext/bio/twobit/extconf.rb"]
27
25
  end
@@ -278,6 +278,7 @@ uint8_t getByteMaskFromOffset(int offset) {
278
278
  void *twobitBasesWorker(TwoBit *tb, uint32_t tid, uint32_t start, uint32_t end, int fraction) {
279
279
  void *out;
280
280
  uint32_t tmp[4] = {0, 0, 0, 0}, len = end - start + (start % 4), i = 0, j = 0;
281
+ uint32_t seqLen = end - start;
281
282
  uint32_t blockStart, blockEnd, maskIdx = (uint32_t) -1, maskStart, maskEnd, foo;
282
283
  uint8_t *bytes = NULL, mask = 0, offset;
283
284
 
@@ -375,10 +376,10 @@ void *twobitBasesWorker(TwoBit *tb, uint32_t tid, uint32_t start, uint32_t end,
375
376
  //out is in TCAG order, since that's how 2bit is stored.
376
377
  //However, for whatever reason I went with ACTG in the first release...
377
378
  if(fraction) {
378
- ((double*) out)[0] = ((double) tmp[2])/((double) len);
379
- ((double*) out)[1] = ((double) tmp[1])/((double) len);
380
- ((double*) out)[2] = ((double) tmp[0])/((double) len);
381
- ((double*) out)[3] = ((double) tmp[3])/((double) len);
379
+ ((double*) out)[0] = ((double) tmp[2])/((double) seqLen);
380
+ ((double*) out)[1] = ((double) tmp[1])/((double) seqLen);
381
+ ((double*) out)[2] = ((double) tmp[0])/((double) seqLen);
382
+ ((double*) out)[3] = ((double) tmp[3])/((double) seqLen);
382
383
  } else {
383
384
  ((uint32_t*) out)[0] = tmp[2];
384
385
  ((uint32_t*) out)[1] = tmp[1];
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bio
4
4
  class TwoBit
5
- VERSION = "0.1.2"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
data/lib/bio/twobit.rb CHANGED
@@ -40,19 +40,33 @@ module Bio
40
40
  @masked
41
41
  end
42
42
 
43
+ # Since "end" is a reserved word in Ruby, use "stop" instead.
44
+
43
45
  def sequence(chrom, start = 0, stop = 0)
46
+ raise ArgumentError, "negative start position" if start.negative?
47
+ raise ArgumentError, "negative stop position" if stop.negative?
48
+
44
49
  sequence_raw(chrom, start, stop)
45
50
  end
46
51
 
47
52
  def bases(chrom, start = 0, stop = 0, fraction: true)
53
+ raise ArgumentError, "negative start position" if start.negative?
54
+ raise ArgumentError, "negative stop position" if stop.negative?
55
+
48
56
  bases_raw(chrom, start, stop, fraction ? 1 : 0)
49
57
  end
50
58
 
51
59
  def hard_masked_blocks(chrom, start = 0, stop = 0)
60
+ raise ArgumentError, "negative start position" if start.negative?
61
+ raise ArgumentError, "negative stop position" if stop.negative?
62
+
52
63
  hard_masked_blocks_raw(chrom, start, stop)
53
64
  end
54
65
 
55
66
  def soft_masked_blocks(chrom, start = 0, stop = 0)
67
+ raise ArgumentError, "negative start position" if start.negative?
68
+ raise ArgumentError, "negative stop position" if stop.negative?
69
+
56
70
  soft_masked_blocks_raw(chrom, start, stop)
57
71
  end
58
72
  end
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.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - kojix2
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-14 00:00:00.000000000 Z
11
+ date: 2022-07-29 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.3.3
55
+ rubygems_version: 3.3.7
56
56
  signing_key:
57
57
  specification_version: 4
58
58
  summary: A ruby library for accessing 2bit files