Sha256: 4aa8190a98e300c0593b7da205b5e6bb154af6abd2f1ca5dd9c5c67735abd2a3

Contents?: true

Size: 969 Bytes

Versions: 2

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 |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.10 lib/lederhosen/tasks/join.rb
lederhosen-0.0.9 lib/lederhosen/tasks/join.rb