lib/mspire/imzml/writer/commandline.rb in mspire-0.7.18 vs lib/mspire/imzml/writer/commandline.rb in mspire-0.8.0
- old
+ new
@@ -11,24 +11,26 @@
end
end
module Mspire::Imzml::Writer::Commandline
- def self.run(argv, progname=$0)
+ # generates the Trollop parser
+ def self.parser
+ return @parser if @parser
default_config = "config.yaml"
scan_patterns = %w(flyback meandering random)
scan_types = %w(horizontal vertical)
scan_direction = %w(left-right right-left bottom-up top-down none)
scan_sequence = %w(top-down bottom-up left-right right-left)
default_dims = '800x600'
default_pixel_size = '1x1'
matrix_application_types = %w(sprayed precoated printed drieddroplet)
- parser = Trollop::Parser.new do
+ @parser = Trollop::Parser.new do
banner <<-EOS
-usage: #{File.basename(progname)} [OPTIONS] <file>.mzML ..."
+usage: mspire to_imzml [OPTIONS] <file>.mzML ..."
output: <file>.imzML and <file>.ibd
* imzML docs:
http://www.maldi-msi.org/index.php?option=com_content&view=article&id=187&Itemid=67
* explanation of vocabulary (followed here):
@@ -41,10 +43,13 @@
opt :print_config, "print current options to #{default_config} and exit"
opt :omit_zeros, "remove zero values"
opt :combine, "combine all files and set the base name of resulting imzML and ibd files", :type => String
opt :outfile, "use a specific basename for the resulting file. Acts like --combine for multiple files", :type => String
+ text "\nediting:"
+ opt :trim_files, "determines the least number of spectra in a file and shortens all spectra to be the same length"
+
text "\nimaging:"
opt :continuous, "assumes m/z values are the same for every scan. The 'processed' storage format is used unless this flag is given."
opt :scan_pattern, scan_patterns.join('|'), :default => scan_patterns.first
opt :scan_type, scan_types.join('|'), :default => scan_types.first
opt :linescan_direction, scan_direction.join('|'), :default => scan_direction.first
@@ -74,12 +79,19 @@
# things to add: data types for m/z and intensity
# filters (cutoff / max # peaks, etc.)
# ms_level, etc.
end
+ end
- opts = parser.parse(argv)
+ def self.run(argv, globalopts)
+ begin
+ opts = parser.parse(argv)
+ rescue Trollop::HelpNeeded
+ return parser.educate
+ end
+
opts = Hash[YAML.load_file(opts[:config]).map {|k,v| [k.to_sym, v]}].merge(opts) if opts[:config]
opts[:combine] ||= opts.delete(:outfile)
if opts.delete(:print_config)
@@ -102,8 +114,5 @@
writer = Mspire::Imzml::Writer.new
writer.write(argv, opts)
end
end
-
-
-