Skip to content

lmrodriguezr/gfa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Climate Test Coverage Build Status Gem Version

Graphical Fragment Assembly (GFA) for Ruby

This implementation follows the specifications of GFA-spec.

To load the library:

require 'gfa'

Parsing 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

Saving GFA

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

Visualizing GFA

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')

tiny_dg

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')

tiny_ug

Installation

gem install gfa

Or add the following line to your Gemfile:

gem 'gfa'

Author

Luis M. Rodriguez-R.

License

Artistic License 2.0.

About

Graphical Fragment Assembly (GFA) for Ruby

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages