lib/scaffolder/test/helpers.rb in scaffolder-test-helpers-0.1.0 vs lib/scaffolder/test/helpers.rb in scaffolder-test-helpers-0.2.0

- old
+ new

@@ -1,37 +1,33 @@ require 'tempfile' require 'bio' require 'scaffolder' +require 'scaffolder/test/sequence' +require 'scaffolder/test/unresolved' + module Scaffolder::Test module Helpers - def write_sequence_file(entries,file = Tempfile.new("sequence").path) - File.open(file,'w') do |tmp| - make_sequence(entries).each do |entry| - seq = Bio::Sequence.new(entry[:sequence]) - tmp.print(seq.output(:fasta,:header => entry[:name])) - end - end - file + def generate_scaffold_files(entries) + [write_scaffold_file(entries),write_sequence_file(entries)] end def write_scaffold_file(entries,file = Tempfile.new("scaffold").path) - File.open(file,'w'){|tmp| tmp.print(YAML.dump(make_scaffold(entries)))} + File.open(file,'w') do |tmp| + tmp.print(YAML.dump(entries.map{|e| e.to_hash })) + end file end - def make_scaffold(entries) - entries.map do |entry| - {'sequence' => {'source' => (entry['name'] || entry[:name]) }} + def write_sequence_file(entries,file = Tempfile.new("sequence").path) + File.open(file,'w') do |tmp| + entries.each do |entry| + tmp.puts(entry.to_fasta) if entry.respond_to? :to_fasta + end end + file end - def make_sequence(entries) - entries.map do |entry| - {:name => (entry['name'] || entry[:name]), - :sequence => (entry['nucleotides'] || entry[:nucleotides]) } - end.flatten - end end end