bio-twobit 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +11 -0
- data/README.md +42 -4
- data/ext/bio/twobit/twobit.c +409 -412
- data/lib/bio/twobit/cache_path.rb +32 -0
- data/lib/bio/twobit/downloader.rb +282 -0
- data/lib/bio/twobit/metadata.rb +9 -0
- data/lib/bio/twobit/reference_genome.rb +24 -0
- data/lib/bio/twobit/references/danrer10.rb +16 -0
- data/lib/bio/twobit/references/danrer11.rb +16 -0
- data/lib/bio/twobit/references/dm6.rb +16 -0
- data/lib/bio/twobit/references/hg19.rb +16 -0
- data/lib/bio/twobit/references/hg38.rb +16 -0
- data/lib/bio/twobit/references/hs1.rb +16 -0
- data/lib/bio/twobit/references/mm10.rb +16 -0
- data/lib/bio/twobit/references/mm39.rb +16 -0
- data/lib/bio/twobit/references/mm9.rb +16 -0
- data/lib/bio/twobit/version.rb +1 -1
- data/lib/bio/twobit.rb +55 -9
- metadata +16 -7
- data/.rubocop.yml +0 -13
- data/Gemfile +0 -14
- data/Rakefile +0 -25
- data/bio-twobit.gemspec +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54ca968d6522ecade29dea715e43dda98eff1c2ea8fff65f446dd5e5ea19b357
|
4
|
+
data.tar.gz: 76def4a53e2df05f421a927334bb4441de477ca77409b0e37bbd99bda79ac657
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed21093a59367927ce28bc45ddba7bad0bc0d497e3516f41de9a6cc127d510a562a621ad892db9946894c48124c142cc05fcd9861adc25c649a9d32336438245
|
7
|
+
data.tar.gz: f0091bf42601a641c49a1de4751fc2c79f1c2059db50e2891a34738700dbc6166deaf46e0f8f16a95b506fdaf60eb2e2e2a035e1258c34c99cb4e4027f67ffc2
|
data/LICENSE.txt
CHANGED
@@ -19,3 +19,14 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
19
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
20
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
THE SOFTWARE.
|
22
|
+
|
23
|
+
Code from red-datasets is used for automatic file download and caching
|
24
|
+
https://github.com/red-data-tools/red-datasets
|
25
|
+
|
26
|
+
Copyright 2017 Kouhei Sutou <kou@clear-code.com>
|
27
|
+
|
28
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
29
|
+
|
30
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
31
|
+
|
32
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -13,6 +13,9 @@ Ruby bindings to [lib2bit](https://github.com/dpryan79/lib2bit) / [py2bit](https
|
|
13
13
|
gem install bio-twobit
|
14
14
|
```
|
15
15
|
|
16
|
+
Linux and macOS are supported.
|
17
|
+
Windows is currently not supported.
|
18
|
+
|
16
19
|
## Usage
|
17
20
|
|
18
21
|
Downlaod BSgenome.Hsapiens.UCSC.hg38
|
@@ -21,7 +24,7 @@ Downlaod BSgenome.Hsapiens.UCSC.hg38
|
|
21
24
|
wget http://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.2bit
|
22
25
|
```
|
23
26
|
|
24
|
-
Quick Start
|
27
|
+
### Quick Start
|
25
28
|
|
26
29
|
```ruby
|
27
30
|
require 'bio/twobit'
|
@@ -44,10 +47,19 @@ hg38.chroms.take(5)
|
|
44
47
|
# ["chr3", 198295559],
|
45
48
|
# ["chr4", 190214555],
|
46
49
|
# ["chr5", 181538259]]
|
50
|
+
```
|
51
|
+
|
52
|
+
Fetch a sequence
|
47
53
|
|
54
|
+
```ruby
|
48
55
|
hg38.sequence("chr1", 50000, 50050)
|
49
|
-
# "AAACAGGTTAATCGCCACGACATAGTAGTATTTAGAGTTACTAGTAAGCC"
|
56
|
+
# "AAACAGGTTAATCGCCACGACATAGTAGTATTTAGAGTTACTAGTAAGCC" # length 50
|
57
|
+
```
|
50
58
|
|
59
|
+
* The first number is the **(0-based)** position on the chromosome/contig where the sequence should begin.
|
60
|
+
* The second number is the **(1-based)** position on the chromosome where the sequence should end.
|
61
|
+
|
62
|
+
```ruby
|
51
63
|
hg38.bases("chr1", 10000, 10100)
|
52
64
|
# {"A"=>0.34, "C"=>0.49, "T"=>0.17, "G"=>0.0}
|
53
65
|
|
@@ -64,7 +76,7 @@ hg38.hard_masked_blocks("chr1", 0, 1000000)
|
|
64
76
|
# [[0, 10000], [207666, 257666], [297968, 347968], [535988, 585988]]
|
65
77
|
```
|
66
78
|
|
67
|
-
The 2-bit file must be closed explicitly. Alternatively, you can use a block.
|
79
|
+
The 2-bit file must be closed explicitly. Alternatively, you can use a block. Even if it is not closed, it will probably be closed by GC and there will be no problem. But this is not guaranteed.
|
68
80
|
|
69
81
|
```ruby
|
70
82
|
# Explicitly close the file.
|
@@ -81,7 +93,7 @@ end
|
|
81
93
|
tb.closed? # true / false
|
82
94
|
```
|
83
95
|
|
84
|
-
If you would like to include information about soft-masked bases, you need to
|
96
|
+
If you would like to include information about soft-masked bases, you need to specify `masked: true`
|
85
97
|
|
86
98
|
```ruby
|
87
99
|
tb = Bio::TwoBit.open("test/fixtures/foo.2bit")
|
@@ -99,6 +111,29 @@ tb.soft_masked_blocks("chr1")
|
|
99
111
|
tb.masked? # true / false
|
100
112
|
```
|
101
113
|
|
114
|
+
## hg19, hg38, hs1...
|
115
|
+
|
116
|
+
Some reference genomes are provided as classes in advance. These classes automatically download 2bit files from the UCSC site into a cache directory upon first use.
|
117
|
+
|
118
|
+
```ruby
|
119
|
+
hg19 = Bio::TwoBit::Hg19.new
|
120
|
+
hg38 = Bio::TwoBit::Hg38.new
|
121
|
+
hs1 = Bio::TwoBit::Hs1.new
|
122
|
+
```
|
123
|
+
|
124
|
+
Adding a new reference genome is easy. Add [here](https://github.com/ruby-on-bioc/bio-twobit/blob/main/lib/bio/twobit/references/template.erb) the id of the genome you want to use.
|
125
|
+
|
126
|
+
```
|
127
|
+
git clone https://github.com/ruby-on-bioc/bio-twobit
|
128
|
+
vi lib/bio/twobit/references/template.erb # Add your id to ids list.
|
129
|
+
ruby lib/bio/twobit/references/template.erb
|
130
|
+
rake install
|
131
|
+
```
|
132
|
+
|
133
|
+
If you want to use 2-bit files from locations other than UCSC, create your own classes [here](https://github.com/ruby-on-bioc/bio-twobit/tree/main/lib/bio/twobit/references).
|
134
|
+
|
135
|
+
Pull requests are welcome.
|
136
|
+
|
102
137
|
## Development
|
103
138
|
|
104
139
|
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-on-bioc/bio-twobit.
|
@@ -110,3 +145,6 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ruby-o
|
|
110
145
|
## License
|
111
146
|
|
112
147
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
148
|
+
|
149
|
+
Code from [Red Datasets](https://github.com/red-data-tools/red-datasets) is used for automatic file download and caching. (The MIT license)
|
150
|
+
|