class MSAbundanceSim::Commandline
Public Class Methods
create_parser()
click to toggle source
# File lib/ms_abundance_sim.rb, line 202 def create_parser defaults = MSAbundanceSim::DEFAULTS opts = MSAbundanceSim::DEFAULTS parser = OptionParser.new do |op| op.banner = "usage: #{File.basename(__FILE__)} [options] <file>.fasta ..." op.separator "generates files, each of this form: <file>_<n>_<case|control>" op.separator " where the specified percentage of proteins have altered abundance (for cases)." op.separator "" op.separator "output: (yaml indicating all the related derivative files)" op.separator " for 2 cases and 1 control the output for file.fasta would be: " op.separator " file.fasta:" op.separator " case:" op.separator " - file_0_case" op.separator " - file_1_case" op.separator " control:" op.separator " - file_2_control" op.separator "" op.separator "The file must have one or more abundances per protein entry (the protein" op.separator "sequence following the header line is optional)." op.separator "The abundance is placed at the end of the line following a ' #'," op.separator "with multiple abundances separated with a ','. Here are two examples:" op.separator "" op.separator "> SWISSAB|23B The anchor protein #23.2" op.separator "> SWISSSPECIAL|24B A green protein #23.2,29.4" op.separator "" op.separator "notes: Protein sequences are optional and files need not end in '.fasta'" op.separator "" op.separator "options (<default>):" op.on( "--num-control <#{defaults[:num_control]}>", Integer, "Number of *control* samples to generate." ) {|v| opts[:num_control] = v } op.on( "--num-case <#{defaults[:num_case]}>", Integer, "Number of *case* samples to generate." ) {|v| opts[:num_case] = v } op.on( "--pct-diff-express <#{defaults[:pct_diff_express]}>", Float, "Percentage of proteins to differentially ", " express between case and control." ) {|v| opts[:pct_diff_express] = v } op.on( "--control-variance <#{defaults[:control_variance]}>", Integer, "Variance for control samples (max lambda for", " Poisson distribution). The higher the value, ", " the more fold change will occur among healthy ", " populations. Used only when multiple ", " abundances are not provided in master fasta. ", " Not recommended to modify this parameter." ) {|v| opts[:control_variance] = v } op.on( "--case-variance <#{defaults[:case_variance]}>", Integer, "Variance increase for case samples (max lambda ", " for Poisson distribution). The higher the ", " value the more fold change will occur." ) {|v| opts[:case_variance] = v } op.on( "--downshift-min-threshold<#{defaults[:downshift_min_threshold]}>", Float, "Min threshold for downshifting some fold changes." ) {|v| opts[:downshift_min_threshold] = v } op.on( "--downshift-probability-threshold<#{defaults[:downshift_probability_threshold]}>", Float, "Min probability threshold for downshifting", "some fold changes." ) {|v| opts[:downshift_probability_threshold] = v } op.on("--verbose", "talk about it") {|v| $VERBOSE = 3 } end [parser, opts] end
format_and_emit_output(output)
click to toggle source
# File lib/ms_abundance_sim.rb, line 195 def format_and_emit_output(output) # the type keys are symbols--make them strings output_string_types = output.map {|key, value| [key, value.map {|k, v| [k.to_s, v] }.to_h] }.to_h # emit yaml without leading "---" puts output_string_types.to_yaml.gsub(/\A---\n/, '') end
run(argv)
click to toggle source
# File lib/ms_abundance_sim.rb, line 181 def run(argv) parser, opts = create_parser parser.parse!(argv) filenames = argv.to_a if filenames.size == 0 puts parser else output = MSAbundanceSim.process_files(filenames, opts) format_and_emit_output(output) end end