Sha256: b2595a668376f5ce02056e0dbd0219faae954381454dd3d654254cd85786d7f1

Contents?: true

Size: 1.31 KB

Versions: 11

Compression:

Stored size: 1.31 KB

Contents

#!/usr/bin/env ruby

Signal.trap("PIPE", "EXIT")

require "tree_clusters"
require "trollop"

opts = Trollop.options do
  version TreeClusters::VERSION

  banner <<-EOS

  Lala.

  Options:
  EOS

  opt(:tree,
      "Newick tree file",
      type: :string)
  opt(:mapping,
      "Mapping file",
      type: :string)

  opt(:outdir,
      "Output directory",
      default: ".")
  opt(:base,
      "Basename for output",
      default: "snazzy_clades")
end

TreeClusters.extend TreeClusters

tree          = NewickTree.fromFile opts[:tree]
metadata      = TreeClusters.read_mapping_file opts[:mapping]
snazzy_clades = TreeClusters.snazzy_clades tree, metadata

clades_fname  = File.join opts[:outdir],
                          "#{opts[:base]}.snazzy_clades.txt"
members_fname = File.join opts[:outdir],
                          "#{opts[:base]}.snazzy_clades_clade_members.txt"

File.open(clades_fname, "w") do |info_f|
  File.open(members_fname, "w") do |members_f|
    snazzy_clades.each_with_index do |(clade, info), idx|
      clade_id = "clade_#{idx+1}___#{clade.name}"

      info_f.puts [clade_id,
                   info.count,
                   info.map { |pair| pair.join("|")}].join "\t"

      members_f.puts [clade_id,
                      clade.all_leaves.count,
                      clade.all_leaves].join "\t"
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
tree_clusters-0.8.3 exe/snazzy_clades
tree_clusters-0.8.2 exe/snazzy_clades
tree_clusters-0.8.1 exe/snazzy_clades
tree_clusters-0.8.0 exe/snazzy_clades
tree_clusters-0.7.0 exe/snazzy_clades
tree_clusters-0.6.0 exe/snazzy_clades
tree_clusters-0.5.2 exe/snazzy_clades
tree_clusters-0.5.1 exe/snazzy_clades
tree_clusters-0.5.0 exe/snazzy_clades
tree_clusters-0.4.0 exe/snazzy_clades
tree_clusters-0.3.1 exe/snazzy_clades