Sha256: 7f7b0715cd8a58bdae17139759e4fc6d5279b72f5aba1fd1987a49c185ecffac

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

#!/usr/bin/env ruby

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

require "aai"
require "abort_if"
require "fileutils"
require "trollop"

include AbortIf
include AbortIf::Assert

Aai.extend Aai
Aai.extend Aai::Utils

version_banner =

opts = Trollop.options do
  version Aai::VERSION_BANNER

  banner <<-EOS

#{Aai::VERSION_BANNER}

  Seanie's AAI calculator.

  Each input file is treated as a file of ORFs for a single genome.

  Options:
  EOS

  opt(:infiles, "Input files", type: :strings)
  opt(:outdir, "Output directory", type: :string, default: ".")
  opt(:basename, "Base name for output file", type: :string,
      default: "aai_scores")
end

abort_if opts[:infiles].nil? || opts[:infiles].empty?,
         "No infiles given"

Aai.check_files opts[:infiles]

FileUtils.mkdir_p opts[:outdir]

seq_lengths, clean_fnames = Aai.process_input_seqs! opts[:infiles]

blast_db_basenames = Aai.make_blastdbs! clean_fnames

btabs = Aai.blast_permutations! clean_fnames, blast_db_basenames

best_hits = Aai.get_best_hits btabs, seq_lengths

one_way = Aai.one_way_aai best_hits

two_way = Aai.two_way_aai best_hits

aai_strings = Aai.aai_strings one_way, two_way

outf = File.join opts[:outdir], "#{opts[:basename]}.aai.txt"
File.open(outf, "w") do |f|
  Aai.aai_strings(one_way, two_way).each do |str|
    f.puts str
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
aai-0.1.0 exe/aai.rb