bio-twobit 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7f121452dd047fd5b0c0f771536ae366ca7fc04e0ed93f245303cc2c9a3e8f76
4
+ data.tar.gz: db79e13148b8b11440f1fd0bd8436af2ea10fb8291e6dcd84bb7dc3d68950783
5
+ SHA512:
6
+ metadata.gz: 4de59a4065d22a9f1324759acc8183629b29f0c112d2e7475b3f2da65ca6c390829d6debbfc42af3fa46a1a7c30935ab4beeae666d8d7b880fe83d29879b675c
7
+ data.tar.gz: 3047c3084492ad1ea39f73713baff896c19a095f197cb665067d64d23a2f58d80aa801a9a5319b182d36d38a0c40c708620bbeec9d84aba3dfc27fd033074048
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in bio-twobit.gemspec
6
+ gemspec
7
+
8
+ gem "rake"
9
+
10
+ gem "rake-compiler"
11
+
12
+ gem "test-unit"
13
+
14
+ gem "rubocop"
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 kojix2
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,98 @@
1
+ # bio-twobit
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/bio-twobit.svg)](https://badge.fury.io/rb/bio-twobit)
4
+ [![test](https://github.com/ruby-on-bioc/bio-twobit/actions/workflows/ci.yml/badge.svg)](https://github.com/ruby-on-bioc/bio-twobit/actions/workflows/ci.yml)
5
+ [![dics](https://img.shields.io/badge/docs-stable-blue.svg)](https://rubydoc.info/gems/bio-twobit)
6
+ [![DOI](https://zenodo.org/badge/436454379.svg)](https://zenodo.org/badge/latestdoi/436454379)
7
+
8
+ Ruby bindings to [lib2bit](https://github.com/dpryan79/lib2bit) / [py2bit](https://github.com/deeptools/py2bit).
9
+
10
+ ## Installation
11
+
12
+ ```sh
13
+ gem install bio-twobit
14
+ ```
15
+
16
+ ## Usage
17
+
18
+ Downlaod BSgenome.Hsapiens.UCSC.hg38
19
+
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
23
+ ```
24
+
25
+ Quick Start
26
+
27
+ ```ruby
28
+ require 'bio/twobit'
29
+
30
+ hg38 = Bio::TwoBit.open("BSgenome.Hsapiens.UCSC.hg38/inst/extdata/single_sequences.2bit")
31
+
32
+ hg38.info
33
+ # {"file_size"=>818064875,
34
+ # "nChroms"=>640,
35
+ # "sequence_length"=>3272116950,
36
+ # "hard_masked_length"=>161368694,
37
+ # "soft_masked_length"=>0}
38
+
39
+ hg38.chroms.take(5)
40
+ # [["chr1", 248956422],
41
+ # ["chr2", 242193529],
42
+ # ["chr3", 198295559],
43
+ # ["chr4", 190214555],
44
+ # ["chr5", 181538259]]
45
+
46
+ hg38.sequence("chr1", 50000, 50050)
47
+ # "AAACAGGTTAATCGCCACGACATAGTAGTATTTAGAGTTACTAGTAAGCC"
48
+
49
+ hg38.bases("chr1", 10000, 10100)
50
+ # {"A"=>0.34, "C"=>0.49, "T"=>0.17, "G"=>0.0}
51
+
52
+ hg38.bases("chr1", 10000, 10100, fraction: false)
53
+ # {"A"=>34, "C"=>49, "T"=>17, "G"=>0}
54
+
55
+ hg38.bases("chr1")
56
+ # {"A"=>0.26940569141052323,
57
+ # "C"=>0.19302592242428676,
58
+ # "T"=>0.2701041550155312,
59
+ # "G"=>0.19325280952182064}
60
+
61
+ hg38.hard_masked_blocks("chr1", 0, 1000000)
62
+ # [[0, 10000], [207666, 257666], [297968, 347968], [535988, 585988]]
63
+ ```
64
+
65
+ The 2-bit file must be closed explicitly. Alternatively, you can use a block. (If you forget to close the file, it will probably be closed by GC).
66
+
67
+ ```ruby
68
+ # Explicitly close the file.
69
+ tb = Bio::TwoBit.open("test/fixtures/foo.2bit")
70
+ tb.close
71
+
72
+ # You can also use blocks.
73
+ Bio::TwoBit.open("test/fixtures/foo.2bit") do |t|
74
+ p t.info
75
+ end
76
+ ```
77
+
78
+ If you would like to include information about soft-masked bases, you need to manually specify `masked: true`
79
+
80
+ ```ruby
81
+ tb = Bio::TwoBit.open("test/fixtures/foo.2bit")
82
+ tb.sequence("chr1", 60, 72)
83
+ # => "GTAGCTAGCTGA"
84
+
85
+ tb = Bio::TwoBit.open("test/fixtures/foo.2bit", masked: true)
86
+ tb.sequence("chr1", 60, 72)
87
+ # => "GTagctagctGA"
88
+ tb.soft_masked_blocks("chr1")
89
+ # => [[62, 70]]
90
+ ```
91
+
92
+ ## Development
93
+
94
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-on-bioc/bio-twobit.
95
+
96
+ ## License
97
+
98
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ require "rake/extensiontask"
17
+
18
+ task build: :compile
19
+
20
+ Rake::ExtensionTask.new("twobit") do |ext|
21
+ ext.lib_dir = "lib/bio/twobit"
22
+ ext.ext_dir = "ext/bio/twobit"
23
+ end
24
+
25
+ task default: %i[clobber compile test rubocop]
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/bio/twobit/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "bio-twobit"
7
+ spec.version = Bio::TwoBit::VERSION
8
+ spec.authors = ["kojix2"]
9
+ spec.email = ["2xijok@gmail.com"]
10
+
11
+ spec.summary = "A ruby library for accessing 2bit files"
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."
14
+ spec.homepage = "https://github.com/ruby-on-bioc/bio-twobit"
15
+ spec.license = "MIT"
16
+ spec.required_ruby_version = ">= 2.6.0"
17
+
18
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
19
+ `git ls-files -z`.split("\x0").reject do |f|
20
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
21
+ end
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+ spec.extensions = ["ext/bio/twobit/extconf.rb"]
27
+
28
+ # spec.add_dependency "example-gem", "~> 1.0"
29
+ end