Class: IGV
- Inherits:
-
Object
- Object
- IGV
- Defined in:
- lib/igv.rb,
lib/igv/version.rb
Overview
The Integrative Genomics Viewer (IGV) software.broadinstitute.org/software/igv/
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION =
'0.0.6'
Instance Attribute Summary collapse
-
#history ⇒ Object
readonly
Returns the value of attribute history.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#snapshot_dir ⇒ Object
Returns the value of attribute snapshot_dir.
Instance Method Summary collapse
- #clear ⇒ Object
- #collapse(track = '') ⇒ Object
-
#connect ⇒ Object
def self.start end.
- #exit ⇒ Object (also: #quit)
- #expand(track = '') ⇒ Object
- #genome(name_or_path) ⇒ Object
- #go(position) ⇒ Object (also: #goto)
-
#initialize(host: '127.0.0.1', port: 60_151, snapshot_dir: Dir.pwd) ⇒ IGV
constructor
A new instance of IGV.
- #load(path_or_url) ⇒ Object
- #region(contig, start, end_) ⇒ Object
- #save(file_path = nil) ⇒ Object (also: #snapshot)
- #send(cmd) ⇒ Object
- #sort(option = 'base') ⇒ Object
Constructor Details
#initialize(host: '127.0.0.1', port: 60_151, snapshot_dir: Dir.pwd) ⇒ IGV
Returns a new instance of IGV.
14 15 16 17 18 19 20 |
# File 'lib/igv.rb', line 14 def initialize(host: '127.0.0.1', port: 60_151, snapshot_dir: Dir.pwd) @host = host @port = port @history = [] connect set_snapshot_dir(snapshot_dir) end |
Instance Attribute Details
#history ⇒ Object (readonly)
Returns the value of attribute history.
12 13 14 |
# File 'lib/igv.rb', line 12 def history @history end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
12 13 14 |
# File 'lib/igv.rb', line 12 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
12 13 14 |
# File 'lib/igv.rb', line 12 def port @port end |
#snapshot_dir ⇒ Object
Returns the value of attribute snapshot_dir.
12 13 14 |
# File 'lib/igv.rb', line 12 def snapshot_dir @snapshot_dir end |
Instance Method Details
#clear ⇒ Object
74 75 76 |
# File 'lib/igv.rb', line 74 def clear send 'clear' end |
#collapse(track = '') ⇒ Object
70 71 72 |
# File 'lib/igv.rb', line 70 def collapse(track = '') send "collapse #{track}" end |
#connect ⇒ Object
def self.start end
25 26 27 28 29 30 |
# File 'lib/igv.rb', line 25 def connect @socket&.close @socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM) addr = Socket.sockaddr_in(port, host) @socket.connect(addr) end |
#exit ⇒ Object Also known as: quit
78 79 80 |
# File 'lib/igv.rb', line 78 def exit send 'exit' end |
#expand(track = '') ⇒ Object
66 67 68 |
# File 'lib/igv.rb', line 66 def (track = '') send "expand #{track}" end |
#genome(name_or_path) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/igv.rb', line 37 def genome(name_or_path) path = File.(name_or_path) if File.exist?(path) send "genome #{path}" else send "genome #{name_or_path}" end end |
#go(position) ⇒ Object Also known as: goto
32 33 34 |
# File 'lib/igv.rb', line 32 def go(position) send "goto #{position}" end |
#load(path_or_url) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/igv.rb', line 46 def load(path_or_url) if URI.parse(path_or_url).scheme send "load #{path_or_url}" else send "load #{File.(path_or_url)}" end end |
#region(contig, start, end_) ⇒ Object
54 55 56 |
# File 'lib/igv.rb', line 54 def region(contig, start, end_) send ['region', contig, start, end_].join(' ') end |
#save(file_path = nil) ⇒ Object Also known as: snapshot
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/igv.rb', line 99 def save(file_path = nil) if file_path # igv assumes the path is just a single filename, but # we can set the snapshot dir. then just use the filename. dir_path = File.dirname(file_path) set_snapshot_dir(File.(dir_path)) if dir_path != '.' send "snapshot #{File.basename(file_path)}" else send 'snapshot' end end |
#send(cmd) ⇒ Object
83 84 85 86 87 |
# File 'lib/igv.rb', line 83 def send(cmd) @history << cmd @socket.puts(cmd.encode(Encoding::UTF_8)) @socket.gets&.chomp("\n") end |
#sort(option = 'base') ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/igv.rb', line 58 def sort(option = 'base') unless %w[base position strand quality sample readGroup].include? option raise 'options is one of: base, position, strand, quality, sample, and readGroup.' end send "sort #{option}" end |