Sha256: fece7a34fcc79e58098eb7934212ebb820446f1949d9b0e198734e6757a9062b

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

##
# MAKE TABLES
#

SEP = ','

module Lederhosen
  class CLI

    desc "otu_table",
         "--clusters=clusters.uc --output=otu_prefix"

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

    def otu_table
      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
      clstrnr_to_seed = clstr_info[:clstrnr_to_seed]
      samples         = clstr_info[:samples]

      # print OTU abundancy matrix
      
      File.open("#{output}.csv", 'w') do |h|
        samples  = samples.sort
        clusters = clstr_counts.keys

        # print header
        head = samples.join(SEP)
        h.puts "-" + SEP + head

        # start printing clusters
        clusters.each do |cluster|
          h.print "cluster-#{cluster}"
          samples.each do |sample|
            h.print "#{SEP}#{clstr_counts[cluster][sample]}"
          end
          h.print "\n"
        end
          
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lederhosen-0.1.4 lib/lederhosen/tasks/otu_table.rb
lederhosen-0.1.3 lib/lederhosen/tasks/otu_table.rb