Sha256: 8b16aff94b97233de32dd3618858d5f0f68d56aa32e3f3722beafd3588724d22

Contents?: true

Size: 881 Bytes

Versions: 2

Compression:

Stored size: 881 Bytes

Contents

module Lederhosen
  class CLI

    ##
    # PAIRED-END READ WORK-AROUND (JOIN THEM)
    #
    desc "join reads end-to-end",
         "--trimmed=trimmed/*.fasta --output=joined.fasta"

    method_option :trimmed, :type => :string, :default => 'trimmed/*,fasta'
    method_option :output,  :type => :string, :default => 'joined.fasta'

    def join

      trimmed = Dir[options[:trimmed]]
      output = options[:output]

      fail "no reads in #{trimmed}" if trimmed.length == 0

      output = File.open(output, 'w')

      pbar = ProgressBar.new "joining", trimmed.length

      trimmed.each do |fasta_file|
        pbar.inc
        records = Dna.new File.open(fasta_file)
        records.each_slice(2) do |r, l|
          output.puts ">#{r.name}:#{File.basename(fasta_file, '.fasta')}\n#{r.sequence.reverse+l.sequence}"
        end
      end
      pbar.finish
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lederhosen-0.0.5 lib/lederhosen/tasks/join.rb
lederhosen-0.0.4 lib/lederhosen/tasks/join.rb