|
| 1 | +#! /usr/bin/env ruby |
| 2 | + |
| 3 | +require 'trollop' |
| 4 | +require 'transrate' |
| 5 | + |
| 6 | +opts = Trollop::options do |
| 7 | + version "v0.0.1a" |
| 8 | + banner <<-EOS |
| 9 | +
|
| 10 | +Transrate v0.0.1a by Richard Smith <[email protected]> |
| 11 | +
|
| 12 | +DESCRIPTION: |
| 13 | +Analyse a de-novo transcriptome |
| 14 | +assembly using three kinds of metrics: |
| 15 | +
|
| 16 | +1. contig-based |
| 17 | +2. read-mapping |
| 18 | +3. reference-based |
| 19 | +
|
| 20 | +Please make sure USEARCH and bowtie2 are both installed |
| 21 | +and in the PATH. |
| 22 | +
|
| 23 | +Bug reports and feature requests at: |
| 24 | +https://github.com/blahah/transrate |
| 25 | +
|
| 26 | +USAGE: |
| 27 | +transrate <options> |
| 28 | +
|
| 29 | +OPTIONS: |
| 30 | +
|
| 31 | +EOS |
| 32 | + opt :assembly, "assembly file in FASTA format", :required => true, :type => String |
| 33 | + opt :reference, "reference proteome file in FASTA format", :required => true, :type => String |
| 34 | + opt :left, "left reads file in FASTQ format", :type => String |
| 35 | + opt :right, "right reads file in FASTQ format", :type => String |
| 36 | + opt :insertsize, "mean insert size", :default => 200, :type => Integer |
| 37 | + opt :insertsd, "insert size standard deviation", :default => 50, :type => Integer |
| 38 | + opt :threads, "number of threads to use", :default => 8, :type => Integer |
| 39 | +end |
| 40 | + |
| 41 | +def pretty_print_hash hash, width |
| 42 | + hash.map{ |k, v| "#{k.to_s}#{" " * (width - (k.length + v.to_i.to_s.length))}#{v.to_i}" }.join("\n") |
| 43 | +end |
| 44 | + |
| 45 | +include Transrate |
| 46 | + |
| 47 | +a = Assembly.new opts.assembly |
| 48 | +r = Assembly.new opts.reference |
| 49 | + |
| 50 | +puts "\n\nAnalysing assembly: #{opts.assembly}\n\n" |
| 51 | + |
| 52 | +puts "calculating contig stats..." |
| 53 | +t0 = Time.now |
| 54 | +contig_results = a.basic_stats |
| 55 | +puts "...done in #{Time.now - t0} seconds" |
| 56 | + |
| 57 | +read_results = nil |
| 58 | +if (opts.left && opts.right) |
| 59 | + puts "\ncalculating read diagnostics..." |
| 60 | + t0 = Time.now |
| 61 | + read_metrics = ReadMetrics.new a |
| 62 | + read_results = read_metrics.run(opts.left, opts.right) |
| 63 | + puts "...done in #{Time.now - t0} seconds" |
| 64 | +else |
| 65 | + puts "\nno reads provided, skipping read diagnostics" |
| 66 | +end |
| 67 | + |
| 68 | +puts "\ncalculating comparative metrics..." |
| 69 | +t0 = Time.now |
| 70 | +comparative_metrics = ComparativeMetrics.new(a, r) |
| 71 | +comparative_results = comparative_metrics.run |
| 72 | +puts "...done in #{Time.now - t0} seconds" |
| 73 | + |
| 74 | +report_width = 30 |
| 75 | + |
| 76 | +if contig_results |
| 77 | + puts "\n\n" |
| 78 | + puts "Contig metrics:" |
| 79 | + puts "-" * report_width |
| 80 | + puts pretty_print_hash(contig_results, report_width) |
| 81 | +end |
| 82 | + |
| 83 | +if read_results |
| 84 | + puts "\n\n" |
| 85 | + puts "Read mapping metrics:" |
| 86 | + puts "-" * report_width |
| 87 | + puts pretty_print_hash(read_results, report_width) |
| 88 | +end |
| 89 | + |
| 90 | +if comparative_results |
| 91 | + puts "\n\n" |
| 92 | + puts "Comparative metrics:" |
| 93 | + puts "-" * report_width |
| 94 | + puts pretty_print_hash(comparative_results, report_width) |
| 95 | +end |
0 commit comments