ruby-igv 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +38 -0
- data/lib/igv.rb +94 -0
- data/lib/igv/version.rb +3 -0
- metadata +103 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9610c6073f8aa07bc0a6d72ad5ea885caf0bca0810633cc51da6f56fdedb9162
|
4
|
+
data.tar.gz: 3e547657f35d6df732e555260cf3be51182eb1c153967aa18ed98f7896e85c28
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f41a575c7c740a008d099b3941a880b15a62c9b54bb3c2969677f36a98819f1fafcb16a0475a2da86c88bcfcf0d79dea149ca3f429a06bd49ac7a980d67c6582
|
7
|
+
data.tar.gz: 0126ef0bebc9e1b89d761a2f1acebd1f896498692320623fa27190cfcb91e17c8c08dbb8fbc39897a7957fde332534602abade7814b8694f8f02b80e2c230c84
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 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,38 @@
|
|
1
|
+
# Ruby-IGV
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/ruby-igv.svg)](https://badge.fury.io/rb/ruby-igv)
|
4
|
+
[![Docs Latest](https://img.shields.io/badge/docs-latest-blue.svg)](https://rubydoc.info/gems/ruby-igv)
|
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).
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem install ruby-igv
|
15
|
+
```
|
16
|
+
|
17
|
+
## Usage
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
igv = IGV.new
|
21
|
+
igv.genome 'hg19'
|
22
|
+
igv.load 'http://hgdownload.cse.ucsc.edu/goldenPath/hg19/encodeDCC/wgEncodeUwRepliSeq/wgEncodeUwRepliSeqK562G1AlnRep1.bam'
|
23
|
+
igv.go 'chr18:78,016,233-78,016,640'
|
24
|
+
igv.save '/tmp/r/region.svg'
|
25
|
+
igv.save '/tmp/r/region.png'
|
26
|
+
igv.send 'echo' #whatever
|
27
|
+
```
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
* [Report bugs](https://github.com/kojix2/ruby-igv/issues)
|
32
|
+
* Fix bugs and submit [pull requests](https://github.com/kojix2/ruby-igv/pulls)
|
33
|
+
* Write, clarify, or fix documentation
|
34
|
+
* Suggest or add new features
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/lib/igv.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'igv/version'
|
2
|
+
require 'socket'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'pathname'
|
5
|
+
|
6
|
+
class IGV
|
7
|
+
class Error < StandardError; end
|
8
|
+
|
9
|
+
attr_reader :host, :port, :snapshot_dir, :commands
|
10
|
+
def initialize(host: '127.0.0.1', port: 60_151, snapshot_dir: Dir.pwd)
|
11
|
+
@host = host
|
12
|
+
@port = port
|
13
|
+
@commands = []
|
14
|
+
connect
|
15
|
+
set_snapshot_dir(snapshot_dir)
|
16
|
+
end
|
17
|
+
|
18
|
+
# def self.start
|
19
|
+
# end
|
20
|
+
|
21
|
+
def connect
|
22
|
+
@socket&.close
|
23
|
+
@socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM)
|
24
|
+
addr = Socket.sockaddr_in(port, host)
|
25
|
+
@socket.connect(addr)
|
26
|
+
end
|
27
|
+
|
28
|
+
def go(position)
|
29
|
+
send 'goto ' + position
|
30
|
+
end
|
31
|
+
alias goto go
|
32
|
+
|
33
|
+
def genome(name_or_path)
|
34
|
+
send 'genome ' + name_or_path
|
35
|
+
end
|
36
|
+
|
37
|
+
def load(path_or_url)
|
38
|
+
send 'load ' + path_or_url
|
39
|
+
end
|
40
|
+
|
41
|
+
def region(contig, start, end_)
|
42
|
+
send ['region', contig, start, end_].join(' ')
|
43
|
+
end
|
44
|
+
|
45
|
+
def sort(option = 'base')
|
46
|
+
if %w[base position strand quality sample readGroup].include? option
|
47
|
+
send 'sort ' + option
|
48
|
+
else
|
49
|
+
raise 'options is one of: base, position, strand, quality, sample, and readGroup.'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def snapshot_dir=(snapshot_dir)
|
54
|
+
snapshot_dir = File.expand_path(snapshot_dir)
|
55
|
+
return if snapshot_dir == @snaphot_dir
|
56
|
+
|
57
|
+
FileUtils.mkdir_p(snapshot_dir)
|
58
|
+
send "snapshotDirectory #{snapshot_dir}"
|
59
|
+
@snapshot_dir = snapshot_dir
|
60
|
+
end
|
61
|
+
alias set_snapshot_dir snapshot_dir=
|
62
|
+
|
63
|
+
def expand(_track = '')
|
64
|
+
send "expand #{track}"
|
65
|
+
end
|
66
|
+
|
67
|
+
def collapse(_track = '')
|
68
|
+
send "collapse #{track}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def clear
|
72
|
+
send 'clear'
|
73
|
+
end
|
74
|
+
|
75
|
+
def send(cmd)
|
76
|
+
@commands << cmd
|
77
|
+
cmd += "\n"
|
78
|
+
@socket.puts(cmd.encode(Encoding::UTF_8))
|
79
|
+
@socket.readline.chomp("\n")
|
80
|
+
end
|
81
|
+
|
82
|
+
def save(file_path = nil)
|
83
|
+
if file_path
|
84
|
+
# igv assumes the path is just a single filename, but
|
85
|
+
# we can set the snapshot dir. then just use the filename.
|
86
|
+
dir_path = File.dirname(file_path)
|
87
|
+
set_snapshot_dir(File.expand_path(dir_path)) if dir_path != '.'
|
88
|
+
send 'snapshot ' + File.basename(file_path)
|
89
|
+
else
|
90
|
+
send 'snapshot'
|
91
|
+
end
|
92
|
+
end
|
93
|
+
alias snapshot save
|
94
|
+
end
|
data/lib/igv/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-igv
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- kojix2
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: colorize
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: test-unit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Operate IGV (Integrative Genomics Viewer) from Ruby.
|
70
|
+
email:
|
71
|
+
- 2xijok@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- LICENSE.txt
|
77
|
+
- README.md
|
78
|
+
- lib/igv.rb
|
79
|
+
- lib/igv/version.rb
|
80
|
+
homepage: https://github.com/kojix2/ruby-igv
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options: []
|
86
|
+
require_paths:
|
87
|
+
- lib
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 2.3.0
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
requirements: []
|
99
|
+
rubygems_version: 3.1.2
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
102
|
+
summary: Operate IGV (Integrative Genomics Viewer) from Ruby.
|
103
|
+
test_files: []
|