#!/usr/bin/env ruby require 'optparse' require 'english' require 'genevalidator' require 'genevalidator/get_raw_sequences' require 'genevalidator/json_to_gv_results' require 'genevalidator/version' opt = {} opt_parser = OptionParser.new do |opts| opts.banner = <', Array, 'The Validations to be applied.', 'Validation Options Available (separated by coma):', ' all = All validations (default),', ' lenc = Length validation by clusterization,', ' lenr = Length validation by ranking,', ' merge = Analyse gene merge,', ' dup = Check for duplications,', ' frame = Open reading frame (ORF) validation,', ' orf = Main ORF validation,', ' align = Validating based on multiple alignment') do |val| opt[:validations] = val end opt[:db] = 'swissprot -remote' opts.on('-d', '--db [BLAST_DATABASE]', 'Path to the BLAST database', 'GeneValidator also supports remote databases:', 'e.g. genevalidator -d "swissprot -remote" Input_File') do |db| opt[:db] = db end opts.on('-e', '--extract_raw_seqs', 'Produces a fasta file of the raw sequences of all BLAST hits in the', 'supplied BLAST output file. This fasta file can then be provided to', 'GeneValidator with the "-r", "--raw_sequences" argument') do opt[:extract_raw_seqs] = true end opts.on('-j', '--json_file [JSON_FILE]', 'Generate HTML report from a JSON file (or a subset of a JSON file)', 'produced by GeneValidator') do |json| opt[:json_file] = json end opts.on('-x', '--blast_xml_file [BLAST_XML_FILE]', 'Provide GeneValidator with a pre-computed BLAST XML output', 'file (BLAST -outfmt option 5).') do |blast_xml_file| opt[:blast_xml_file] = blast_xml_file end opts.on('-t', '--blast_tabular_file [BLAST_TABULAR_FILE]', 'Provide GeneValidator with a pre-computed BLAST tabular output', 'file. (BLAST -outfmt option 6).') do |blast_tabular_file| opt[:blast_tabular_file] = blast_tabular_file end # default blast tabular columns opts.on('-o', '--blast_tabular_options [BLAST_TABULAR_OPTIONS]', 'Custom format used in BLAST -outfmt argument', 'See BLAST+ manual pages for more details') do |blast_table_options| opt[:blast_tabular_options] = blast_table_options end opt[:num_threads] = 1 opts.on('-n', '--num_threads num_of_threads', 'Specify the number of processor threads to use when running', 'BLAST and Mafft within GeneValidator.') do |num_threads| opt[:num_threads] = num_threads end opts.on('-r', '--raw_sequences [raw_seq]', 'Supply a fasta file of the raw sequences of all BLAST hits present', 'in the supplied BLAST XML or BLAST tabular file.') do |raw_seq| opt[:raw_sequences] = raw_seq end opts.on('-b', '--binaries [binaries]', Array, 'Path to BLAST and MAFFT bin folders (is added to $PATH variable)', 'To be provided as follows:', 'e.g. genevalidator -b /blast/bin/path/ -b /mafft/bin/path/') do |bin| (opt[:bin] ||= []).concat(bin) end opts.on('--version', 'The version of GeneValidator that you are running.') do puts GeneValidator::VERSION exit end opts.on('-h', '--help', 'Show this screen.') do $stderr.puts opt_parser exit end end begin opt_parser.parse!(ARGV) if ARGV.length > 1 $stderr.puts 'Error: you must specify a single fasta input file instead' \ ' of ' + ARGV.length.to_s + ".\n" exit 1 elsif ARGV.length == 0 && opt[:extract_raw_seqs].nil? && opt[:json_file].nil? $stderr.puts opt_parser exit 1 end rescue OptionParser::ParseError $stderr.print 'Error: ' + $ERROR_INFO.to_s + "\n" exit 1 end opt[:input_fasta_file] = ARGV[0] start = Time.now if opt[:extract_raw_seqs] && opt[:raw_sequences].nil? GeneValidator.opt = opt GeneValidator.config = {} # GVArgValidation.run_raw_seqs GeneValidator::RawSequences.run elsif opt[:json_file] GeneValidator.opt = opt # GVArgValidation.run_json_to_gv_results GeneValidator::JsonToGVResults.run else GeneValidator.init(opt) GeneValidator.run end $stderr.puts "Total running time: #{(Time.now - start).round(3)}s" $stderr.puts # a blank line