Revision ce46b4faff6b71078d47975c72a8d62e56f6db62 authored by georgeG on 28 April 2013, 08:54:38 UTC, committed by georgeG on 28 April 2013, 08:54:38 UTC
1 parent 99d90c1
Raw File
bio-cd-hit-report
#!/usr/bin/env ruby

# BioRuby bio-cd-hit-report Plugin BioCdHitReport
# Author:: george githinji
# Copyright:: 2012

require_relative '../lib/bio-cd-hit-report'
require 'ostruct'
require 'optparse'

options = OpenStruct.new

OptionParser.new do |opts|
  opts.banner = 'USAGE: bio-cd-hit-report -i file.clstr [options] '

  opts.on('-h', 'Display this screen') do
    puts opts
    exit
  end

  opts.on('-i','--infile CLUSTERFILE', 'cluster file') do |infile|
    options.infile = infile
  end

  opts.on('-o','--outfile OUTPUTFILE', 'output file') do |outfile|
    options.outfile = outfile
  end

  opts.on('-m','--members') do
    options.members = true
  end

  opts.on('-c','--clusterid CLUSTERID',Integer,'cluster id') do |clusterid|
    options.cluster_id = clusterid
  end

end.parse!

clusterfile = options.infile
outfile     = options.outfile
cluster_id  = options.cluster_id

report = Bio::CdHitReport.new(clusterfile)

def print_members(report)
 report.clusters.map{|c| "#{c.cluster_id}:#{c.members}"}
end

def find_members_for(report,cluster_id)
  report.get_members(cluster_id)
end


begin
  unless cluster_id.nil?
    $stdout.puts find_members_for(report,cluster_id)
  else
    $stdout.puts print_members(report) if options.members
  end
end

back to top