This implementation follows the specifications of GFA-spec.
To load the library:
require 'gfa'
To parse a file in GFA format:
my_gfa = GFA.load('assembly.gfa')
For large GFA files, you can also parse them in parallel:
my_gfa = GFA.load_parallel('large-graph.gfa', 4)
To load GFA strings line-by-line:
my_gfa = GFA.new
File.open('assembly.gfa', 'r') do |fh|
fh.each do |ln|
my_gfa << ln
end
end
After altering a GFA object, you can simply save it in a file as:
my_gfa.save('alt-assembly.gfa')
Or line-by-line as:
fh = File.open('alt-assembly.gfa', 'w')
my_gfa.each_line do |ln|
fh.puts ln
end
fh.close
Any GFA
object can be exported as an RGL
graph using the methods
adjacency_graph
and implicit_graph
. For example, you can render
tiny.gfa:
require 'rgl/dot'
my_gfa = GFA.load('data/tiny.gfa')
dg = my_gfa.implicit_graph
dg.write_to_graphic_file('jpg')
If you don't care about orientation, you can also build an undirected graph without orientation:
ug = my_gfa.implicit_graph(orient: false)
ug.write_to_graphic_file('jpg')
gem install gfa
Or add the following line to your Gemfile:
gem 'gfa'