ruby-igv 0.0.3 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -6
- data/lib/igv/version.rb +3 -1
- data/lib/igv.rb +35 -21
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e0cb49945b7684826529fbdd82ae84de01c45f3b309f1cf41e096dab651ca261
|
4
|
+
data.tar.gz: a345c80a98c564cf7de1cb62768214f8273abf033b1c24ebb8575bb69fe00026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db09a0dc972eb58b3c90412be2a7503015ca3b32152ea2f4be89065833ed94d674fb4bce97a19a5ba8721b59be14b8c8beb00849db865d6b9ee9cfe3ea0afffc
|
7
|
+
data.tar.gz: b97c8c53963c3a9460a38c06bde171fd5f9494c7bdbc8b575ded5b17a854b0038ac421da45628f42865d9cecef7824485adc80e92af9281541bac6dc96466102
|
data/README.md
CHANGED
@@ -1,21 +1,22 @@
|
|
1
|
-
#
|
1
|
+
# ruby-igv
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/ruby-igv.svg)](https://badge.fury.io/rb/ruby-igv)
|
4
4
|
[![Docs Latest](https://img.shields.io/badge/docs-latest-blue.svg)](https://rubydoc.info/gems/ruby-igv)
|
5
5
|
[![The MIT License](https://img.shields.io/badge/license-MIT-orange.svg)](LICENSE.txt)
|
6
|
-
|
7
|
-
Using [Integrative Genomics Viewer (IGV)](http://software.broadinstitute.org/software/igv/) with the Ruby language.
|
8
|
-
|
9
|
-
Based on [brentp/bio-playground/igv](https://github.com/brentp/bio-playground).
|
6
|
+
[![DOI](https://zenodo.org/badge/281373245.svg)](https://zenodo.org/badge/latestdoi/281373245)
|
10
7
|
|
11
8
|
## Installation
|
12
9
|
|
10
|
+
Requirement: [IGV (Integrative Genomics Viewer)](http://software.broadinstitute.org/software/igv/) and [Ruby](https://github.com/ruby/ruby).
|
11
|
+
|
13
12
|
```ruby
|
14
13
|
gem install ruby-igv
|
15
14
|
```
|
16
15
|
|
17
16
|
## Usage
|
18
17
|
|
18
|
+
[Enable IGV to listen on the port](https://software.broadinstitute.org/software/igv/Preferences#Advanced): Preference > Advanced > Enable port
|
19
|
+
|
19
20
|
```ruby
|
20
21
|
igv = IGV.new
|
21
22
|
igv.genome 'hg19'
|
@@ -23,9 +24,13 @@ igv.load 'http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeUwR
|
|
23
24
|
igv.go 'chr18:78,016,233-78,016,640'
|
24
25
|
igv.save '/tmp/r/region.svg'
|
25
26
|
igv.save '/tmp/r/region.png'
|
26
|
-
igv.
|
27
|
+
igv.snapshot_dir = '/tmp/r2/'
|
28
|
+
igv.save 'region.jpg' # save to /tmp/r2/region.png
|
29
|
+
igv.send 'echo' # whatever you want
|
27
30
|
```
|
28
31
|
|
32
|
+
See [the list of Batch commands](https://github.com/igvteam/igv/wiki/Batch-commands).
|
33
|
+
|
29
34
|
## Contributing
|
30
35
|
|
31
36
|
* [Report bugs](https://github.com/kojix2/ruby-igv/issues)
|
@@ -33,6 +38,16 @@ igv.send 'echo' #whatever
|
|
33
38
|
* Write, clarify, or fix documentation
|
34
39
|
* Suggest or add new features
|
35
40
|
|
41
|
+
```
|
42
|
+
Do you need commit rights to my repository?
|
43
|
+
Do you want to get admin rights and take over the project?
|
44
|
+
If so, please feel free to contact me @kojix2.
|
45
|
+
```
|
46
|
+
|
47
|
+
## Acknowledgement
|
48
|
+
This gem is strongly inspired by a Python script developed by Brent Pedersen.
|
49
|
+
* [brentp/bio-playground/igv](https://github.com/brentp/bio-playground).
|
50
|
+
|
36
51
|
## License
|
37
52
|
|
38
53
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/igv/version.rb
CHANGED
data/lib/igv.rb
CHANGED
@@ -1,15 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'igv/version'
|
2
4
|
require 'socket'
|
3
5
|
require 'fileutils'
|
4
6
|
|
7
|
+
# The Integrative Genomics Viewer (IGV)
|
8
|
+
# https://software.broadinstitute.org/software/igv/
|
5
9
|
class IGV
|
6
10
|
class Error < StandardError; end
|
7
11
|
|
8
|
-
attr_reader :host, :port, :snapshot_dir, :
|
12
|
+
attr_reader :host, :port, :snapshot_dir, :history
|
13
|
+
|
9
14
|
def initialize(host: '127.0.0.1', port: 60_151, snapshot_dir: Dir.pwd)
|
10
15
|
@host = host
|
11
16
|
@port = port
|
12
|
-
@
|
17
|
+
@history = []
|
13
18
|
connect
|
14
19
|
set_snapshot_dir(snapshot_dir)
|
15
20
|
end
|
@@ -25,16 +30,25 @@ class IGV
|
|
25
30
|
end
|
26
31
|
|
27
32
|
def go(position)
|
28
|
-
send
|
33
|
+
send "goto #{position}"
|
29
34
|
end
|
30
35
|
alias goto go
|
31
36
|
|
32
37
|
def genome(name_or_path)
|
33
|
-
|
38
|
+
path = File.expand_path(name_or_path)
|
39
|
+
if File.exist?(path)
|
40
|
+
send "genome #{path}"
|
41
|
+
else
|
42
|
+
send "genome #{name_or_path}"
|
43
|
+
end
|
34
44
|
end
|
35
45
|
|
36
46
|
def load(path_or_url)
|
37
|
-
|
47
|
+
if URI.parse(path_or_url).scheme
|
48
|
+
send "load #{path_or_url}"
|
49
|
+
else
|
50
|
+
send "load #{File.expand_path(path_or_url)}"
|
51
|
+
end
|
38
52
|
end
|
39
53
|
|
40
54
|
def region(contig, start, end_)
|
@@ -42,28 +56,18 @@ class IGV
|
|
42
56
|
end
|
43
57
|
|
44
58
|
def sort(option = 'base')
|
45
|
-
|
46
|
-
send 'sort ' + option
|
47
|
-
else
|
59
|
+
unless %w[base position strand quality sample readGroup].include? option
|
48
60
|
raise 'options is one of: base, position, strand, quality, sample, and readGroup.'
|
49
61
|
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def snapshot_dir=(snapshot_dir)
|
53
|
-
snapshot_dir = File.expand_path(snapshot_dir)
|
54
|
-
return if snapshot_dir == @snaphot_dir
|
55
62
|
|
56
|
-
|
57
|
-
send "snapshotDirectory #{snapshot_dir}"
|
58
|
-
@snapshot_dir = snapshot_dir
|
63
|
+
send "sort #{option}"
|
59
64
|
end
|
60
|
-
alias set_snapshot_dir snapshot_dir=
|
61
65
|
|
62
|
-
def expand(
|
66
|
+
def expand(track = '')
|
63
67
|
send "expand #{track}"
|
64
68
|
end
|
65
69
|
|
66
|
-
def collapse(
|
70
|
+
def collapse(track = '')
|
67
71
|
send "collapse #{track}"
|
68
72
|
end
|
69
73
|
|
@@ -77,18 +81,28 @@ class IGV
|
|
77
81
|
alias quit exit
|
78
82
|
|
79
83
|
def send(cmd)
|
80
|
-
@
|
84
|
+
@history << cmd
|
81
85
|
@socket.puts(cmd.encode(Encoding::UTF_8))
|
82
86
|
@socket.gets&.chomp("\n")
|
83
87
|
end
|
84
88
|
|
89
|
+
def snapshot_dir=(snapshot_dir)
|
90
|
+
snapshot_dir = File.expand_path(snapshot_dir)
|
91
|
+
return if snapshot_dir == @snaphot_dir
|
92
|
+
|
93
|
+
FileUtils.mkdir_p(snapshot_dir)
|
94
|
+
send "snapshotDirectory #{snapshot_dir}"
|
95
|
+
@snapshot_dir = snapshot_dir
|
96
|
+
end
|
97
|
+
alias set_snapshot_dir snapshot_dir=
|
98
|
+
|
85
99
|
def save(file_path = nil)
|
86
100
|
if file_path
|
87
101
|
# igv assumes the path is just a single filename, but
|
88
102
|
# we can set the snapshot dir. then just use the filename.
|
89
103
|
dir_path = File.dirname(file_path)
|
90
104
|
set_snapshot_dir(File.expand_path(dir_path)) if dir_path != '.'
|
91
|
-
send
|
105
|
+
send "snapshot #{File.basename(file_path)}"
|
92
106
|
else
|
93
107
|
send 'snapshot'
|
94
108
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-igv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kojix2
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description:
|
69
|
+
description: Control IGV (Integrative Genomics Viewer) with Ruby.
|
70
70
|
email:
|
71
71
|
- 2xijok@gmail.com
|
72
72
|
executables: []
|
@@ -89,15 +89,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
89
|
requirements:
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: 2.
|
92
|
+
version: '2.4'
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
|
-
rubygems_version: 3.
|
99
|
+
rubygems_version: 3.3.7
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
|
-
summary:
|
102
|
+
summary: Control IGV (Integrative Genomics Viewer) with Ruby.
|
103
103
|
test_files: []
|