Sha256: 1726e8d74afaed0ddb5a1d7762ce67ca0df237cb385657e70c773adcf5828131

Contents?: true

Size: 1.02 KB

Versions: 7

Compression:

Stored size: 1.02 KB

Contents

module Lederhosen
  class CLI

    ##
    # PAIRED-END READ WORK-AROUND (JOIN THEM)
    #
    desc "join",
         "join trimmed reads into a single file"

    method_option :trimmed, :type => :string, :required => true
    method_option :output,  :type => :string, :required => true

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

      ohai "joining #{File.dirname(trimmed.first)} saving to #{output}"

      ohno "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}:split=#{r.sequence.size}:sample=#{File.basename(fasta_file, '.fasta')}\n#{r.sequence.reverse+l.sequence}"
        end
      end
      pbar.finish
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lederhosen-0.3.9 lib/lederhosen/tasks/join.rb
lederhosen-0.3.8 lib/lederhosen/tasks/join.rb
lederhosen-0.3.7 lib/lederhosen/tasks/join.rb
lederhosen-0.3.6 lib/lederhosen/tasks/join.rb
lederhosen-0.3.5 lib/lederhosen/tasks/join.rb
lederhosen-0.3.4 lib/lederhosen/tasks/join.rb
lederhosen-0.3.3 lib/lederhosen/tasks/join.rb