Sha256: 8b9513848efecf6c17f778581084e6fe19969a036c234d4128fb4d9d540362e9

Contents?: true

Size: 1.37 KB

Versions: 2

Compression:

Stored size: 1.37 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_command "blastp"
Aai.check_command "makeblastdb"
Aai.check_command "parallel"

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

2 entries across 2 versions & 1 rubygems

Version Path
aai-0.2.1 exe/aai
aai-0.2.0 exe/aai