class IGV
The Integrative Genomics Viewer (IGV
) software.broadinstitute.org/software/igv/
Constants
- VERSION
Attributes
history[R]
host[R]
port[R]
snapshot_dir[R]
Public Class Methods
new(host: '127.0.0.1', port: 60_151, snapshot_dir: Dir.pwd)
click to toggle source
# 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
Public Instance Methods
clear()
click to toggle source
# File lib/igv.rb, line 74 def clear send 'clear' end
collapse(_track = '')
click to toggle source
# File lib/igv.rb, line 70 def collapse(_track = '') send "collapse #{track}" end
connect()
click to toggle source
def self.start end
# 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()
click to toggle source
# File lib/igv.rb, line 78 def exit send 'exit' end
Also aliased as: quit
expand(_track = '')
click to toggle source
# File lib/igv.rb, line 66 def expand(_track = '') send "expand #{track}" end
genome(name_or_path)
click to toggle source
# File lib/igv.rb, line 37 def genome(name_or_path) path = File.expand_path(name_or_path) if File.exist?(path) send "genome #{path}" else send "genome #{name_or_path}" end end
go(position)
click to toggle source
# File lib/igv.rb, line 32 def go(position) send "goto #{position}" end
Also aliased as: goto
load(path_or_url)
click to toggle source
# 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.expand_path(path_or_url)}" end end
region(contig, start, end_)
click to toggle source
# File lib/igv.rb, line 54 def region(contig, start, end_) send ['region', contig, start, end_].join(' ') end
save(file_path = nil)
click to toggle source
# 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.expand_path(dir_path)) if dir_path != '.' send "snapshot #{File.basename(file_path)}" else send 'snapshot' end end
Also aliased as: snapshot
send(cmd)
click to toggle source
# File lib/igv.rb, line 83 def send(cmd) @history << cmd @socket.puts(cmd.encode(Encoding::UTF_8)) @socket.gets&.chomp("\n") end
snapshot_dir=(snapshot_dir)
click to toggle source
# File lib/igv.rb, line 89 def snapshot_dir=(snapshot_dir) snapshot_dir = File.expand_path(snapshot_dir) return if snapshot_dir == @snaphot_dir FileUtils.mkdir_p(snapshot_dir) send "snapshotDirectory #{snapshot_dir}" @snapshot_dir = snapshot_dir end
Also aliased as: set_snapshot_dir
sort(option = 'base')
click to toggle source
# 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