This implementation follows the specifications of GFA-spec.
To parse a file in GFA format:
require "gfa"
my_gfa = GFA.load("assembly.gfa")
To load GFA strings line-by-line:
require "gfa"
my_gfa = GFA.new
fh = File.open("assembly.gfa", "r")
fh.each do |ln|
my_gfa << ln
end
fh.close
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 "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"
and run bundle install
from your shell.