Class: MiGA::Cli::Action::Add
- Inherits:
-
MiGA::Cli::Action
- Object
- MiGA
- MiGA::Cli::Action
- MiGA::Cli::Action::Add
- Defined in:
- lib/miga/cli/action/add.rb
Constant Summary collapse
- @@INPUT_TYPES =
{ raw_reads_single: ['Single raw reads in a single FastQ file', :raw_reads, %w[.1.fastq]], raw_reads_paired: ['Paired raw reads in two FastQ files', :raw_reads, %w[.1.fastq .2.fastq]], trimmed_reads_single: ['Single trimmed reads in a single FastA file', :trimmed_fasta, %w[.SingleReads.fa]], trimmed_reads_paired: ['Paired trimmed reads in two FastA files', :trimmed_fasta, %w[.1.fasta .2.fasta]], trimmed_reads_interleaved: ['Paired trimmed reads in a single FastA file', :trimmed_fasta, %w[.CoupledReads.fa]], assembly: ['Assembled contigs or scaffolds in FastA format', :assembly, %w[.LargeContigs.fna]] }
Constants included from MiGA
MiGA::CITATION, VERSION, VERSION_DATE, VERSION_NAME
Instance Attribute Summary
Attributes inherited from MiGA::Cli::Action
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from MiGA::Cli::Action
#complete, #empty_action, #initialize, #launch, load, #name
Methods inherited from MiGA
CITATION, CITATION_ARRAY, DEBUG, DEBUG_OFF, DEBUG_ON, DEBUG_TRACE_OFF, DEBUG_TRACE_ON, FULL_VERSION, LONG_VERSION, VERSION, VERSION_DATE, #advance, debug?, debug_trace?, initialized?, #like_io?, #num_suffix, rc_path, #result_files_exist?, #say
Methods included from MiGA::Common::Path
Methods included from MiGA::Common::Format
#clean_fasta_file, #seqs_length, #tabulate
Methods included from MiGA::Common::Net
#download_file_ftp, #known_hosts, #remote_connection
Methods included from MiGA::Common::SystemCall
Constructor Details
This class inherits a constructor from MiGA::Cli::Action
Class Method Details
.INPUT_TYPES ⇒ Object
101 102 103 |
# File 'lib/miga/cli/action/add.rb', line 101 def INPUT_TYPES @@INPUT_TYPES end |
Instance Method Details
#parse_cli ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 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 |
# File 'lib/miga/cli/action/add.rb', line 7 def parse_cli cli.expect_files = true cli.defaults = { ref: true, ignore_dups: false } cli.parse do |opt| opt.separator 'You can create multiple datasets with a single command; ' \ 'simply pass all the files at the end: {FILES...}' opt.separator 'If -D is passed, only one dataset will be added. ' \ 'Otherwise, dataset names will be determined by the file paths (see -R)' opt.separator '' cli.opt_object(opt, [:project, :dataset_opt, :dataset_type_req]) opt.on( '-q', '--query', 'Register the dataset as a query, not a reference dataset' ) { |v| cli[:ref] = !v } opt.on( '-d', '--description STRING', 'Description of the dataset' ) { |v| cli[:description] = v } opt.on( '-c', '--comments STRING', 'Comments on the dataset' ) { |v| cli[:comments] = v } opt.on( '-m', '--metadata STRING', 'Metadata as key-value pairs separated by = and delimited by comma', 'Values are saved as strings except for booleans (true / false) or nil' ) { |v| cli[:metadata] = v } opt.on( '-R', '--name-regexp REGEXP', Regexp, 'Regular expression indicating how to extract the name from the path', 'By default for paired files:', "'#{MiGA::Cli.FILE_REGEXP(true)}'", 'By default for other files:', "'#{MiGA::Cli.FILE_REGEXP}'" ) { |v| cli[:regexp] = v } opt.on( '--prefix STRING', 'Prefix to all the dataset names' ) { |v| cli[:prefix] = v } opt.on( '-i', '--input-type STRING', 'Type of input data, one of the following:', *self.class.INPUT_TYPES.map { |k, v| "~ #{k}: #{v[0]}" } ) { |v| cli[:input_type] = v.downcase.to_sym } opt.on( '--ignore-dups', 'Continue with a warning if a dataset already exists' ) { |v| cli[:ignore_dups] = v } end end |
#perform ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/miga/cli/action/add.rb', line 58 def perform p = cli.load_project cli.ensure_par(type: '-t') files, file_type = get_files_and_type paired = cli[:input_type].to_s.include?('_paired') cli[:regexp] ||= MiGA::Cli.FILE_REGEXP(paired) cli.say 'Creating datasets:' files.each do |file| d = create_dataset(file, p) next if d.nil? copy_file_to_project(file, file_type, d, p) cli.(d) p.add_dataset(d.name) res = d.first_preprocessing(true) cli.say " result: #{res}" end end |