Sha256: cea13d6ac1989bd2628d78e025725719b09c87c9c2220910c784445695190536

Contents?: true

Size: 1.22 KB

Versions: 6

Compression:

Stored size: 1.22 KB

Contents

##
# GET REPRESENTATIVE READS
#

module Lederhosen
  class CLI

    desc "rep_reads extract representative reads for each cluster to a fasta file",
         "--clusters=clusters.uc --joined=joined.fasta --output=representative_reads.fasta"

    method_option :clusters, :type => :string, :required => true
    method_option :output,   :type => :string, :required => true
    method_option :joined,   :type => :string, :required => true

    def rep_reads
      input        = options[:clusters]
      output       = options[:output]
      joined_reads = options[:joined]


      # Load cluster table!
      clstr_info      = Helpers.load_uc_file input     
      clstr_counts    = clstr_info[:clstr_counts] # clstr_counts[:clstr][sample.to_i] = reads
      seed_to_clstrnr = clstr_info[:seed_to_clstrnr]
      samples         = clstr_info[:samples]

      out_handle = File.open("#{output}", 'w')

      File.open(joined_reads) do |handle|
        records = Dna.new handle
        records.each do |dna|
          clstrnr = seed_to_clstrnr[dna.name]
          unless clstrnr.nil?
            dna.name = "#{dna.name}:cluster-#{clstrnr}"
            out_handle.puts dna
          end
        end
      end
      
      out_handle.close
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lederhosen-0.1.2 lib/lederhosen/tasks/rep_reads.rb
lederhosen-0.1.1 lib/lederhosen/tasks/rep_reads.rb
lederhosen-0.1.0 lib/lederhosen/tasks/rep_reads.rb
lederhosen-0.0.11 lib/lederhosen/tasks/rep_reads.rb
lederhosen-0.0.10 lib/lederhosen/tasks/rep_reads.rb
lederhosen-0.0.9 lib/lederhosen/tasks/rep_reads.rb