Class: Qu::Seqcluster::Options
- Inherits:
-
Object
- Object
- Qu::Seqcluster::Options
- Defined in:
- lib/qu/seqcluster/options.rb
Instance Attribute Summary collapse
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(argv) ⇒ Options
constructor
A new instance of Options.
- #parse_opts(argv) ⇒ Object
Constructor Details
#initialize(argv) ⇒ Options
Returns a new instance of Options.
26 27 28 |
# File 'lib/qu/seqcluster/options.rb', line 26 def initialize(argv) @opts = parse_opts(argv) end |
Instance Attribute Details
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
24 25 26 |
# File 'lib/qu/seqcluster/options.rb', line 24 def opts @opts end |
Instance Method Details
#parse_opts(argv) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/qu/seqcluster/options.rb', line 31 def parse_opts(argv) = Seqcluster:: OptionParser.new do |opts| opts. = "#{PROGRAM} [#{VERSION}]: Cluster DNA/RNA based on k-mer algorithm Usage: #{PROGRAM} -i seq.fasta -k 9 -c 0.9" opts.separator "" opts.separator "Required options:" opts.separator "" opts.on('-i', '--in File', String, 'Input sequence file in fasta format.') do |value| if File.directory?(value) $stderr.puts "Error: #{value} is a direcotry." exit end unless File.exists?(value) $stderr.puts "Error: #{value} is not exists." exit end .in = value end opts.separator "" opts.separator "Optional options:" opts.separator "" opts.on('-k', '--kvalue Integer', Integer, "K value, default is #{.kvalue}.") do |value| .kvalue = value end opts.on("-o", "--out File", String, "Output file name for storing the results, default is screen.") do |value| .out = File.open(value, 'w') end opts.on('-c', '--cutoff Float', Float, "Cutoff value for the similarity for cluster, default is #{.cutoff}.") do |value| .cutoff = value end opts.separator "" opts.separator "" opts.on("-h", "--help", "Show this message and quit") do puts opts exit end opts.on("-v", "--version", "Show version") do puts "#{PROGRAM} #{VERSION}" exit end opts.separator "" opts.separator "Author: Wubin Qu <[email protected]>" opts.separator "" begin argv = ["-h"] if argv.empty? opts.parse!(argv) rescue OptionParser::ParseError => e $stderr.puts e., "\n", opts exit end if .in.nil? $stderr.puts "Error: option -i required." exit end end return end |