Sha256: 8549d816be07c3132777928e0d1b0bda227d0fcf2e6eeb74f154f0f33aca1306

Contents?: true

Size: 969 Bytes

Versions: 4

Compression:

Stored size: 969 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, :required => true
    method_option :output,  :type => :string, :required => true

    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

        begin
          records = Dna.new File.open(fasta_file)
        rescue
          ohai "skipping #{fasta_file} (empty?)"
          next
        end

        records.each_slice(2) do |l, r|
          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

4 entries across 4 versions & 1 rubygems

Version Path
lederhosen-0.1.2 lib/lederhosen/tasks/join.rb
lederhosen-0.1.1 lib/lederhosen/tasks/join.rb
lederhosen-0.1.0 lib/lederhosen/tasks/join.rb
lederhosen-0.0.11 lib/lederhosen/tasks/join.rb