Sha256: 88f07a929186e8ba871ceb0241b7022c211bf1bf04254ee6adce9cc332fbeaf2

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

#!/usr/bin/env ruby

require 'bio-maf'
require 'optparse'
require 'ostruct'

options = OpenStruct.new
options.parser = Bio::MAF::Parser

OptionParser.new do |opts|
  opts.banner = "Usage: maf_to_fasta [options] <maf> <fasta>"
  opts.separator ""
  opts.separator "Options:"
  opts.on("-p", "--profile PROF", "Profile with PerfTools") do |prof|
    options.prof = prof
  end
  opts.on("--ruby-prof PATH", "Profile with ruby-prof") do |path|
    options.ruby_prof = path
  end
  opts.on("--profile-gc", "Profile GC") do |prof|
    options.profile_gc = true
  end
  opts.on("--parser PARSER", "parser") do |name|
    options.parser = Bio::MAF.const_get(name)
  end
end.parse!(ARGV)

src_path = ARGV.shift
dst_path = ARGV.shift

if options.prof
  require 'perftools'
  PerfTools::CpuProfiler.start(options.prof)
elsif options.ruby_prof
  require 'ruby-prof'
  RubyProf.start
end

if options.profile_gc
  GC::Profiler.enable
end

parser = options.parser.new(src_path)
File.open(dst_path, 'w') do |outf|
  writer = Bio::MAF::FASTAWriter.new(outf)

  parser.each_block do |block|
    writer.write_block(block)
  end
end

if options.profile_gc
  $stderr.puts GC::Profiler.result
  GC::Profiler.disable
end

if options.prof
  PerfTools::CpuProfiler.stop
elsif options.ruby_prof
  res = RubyProf.stop
  printer = RubyProf::FlatPrinter.new(res)
  File.open(options.ruby_prof, 'w') do |f|
    printer.print(f)
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bio-maf-1.0.1-java bin/maf_to_fasta
bio-maf-1.0.1 bin/maf_to_fasta
bio-maf-1.0.0-java bin/maf_to_fasta
bio-maf-1.0.0 bin/maf_to_fasta
bio-maf-0.3.2-java bin/maf_to_fasta
bio-maf-0.3.2 bin/maf_to_fasta
bio-maf-0.3.1 bin/maf_to_fasta