Class: Ms::Xcalibur::Convert::RawToMgf

Inherits:
Tap::Task
  • Object
show all
Defined in:
lib/ms/xcalibur/convert/raw_to_mgf.rb

Overview

:startdoc::manifest convert RAW files to mgf format Extracts spectra from a .RAW file and formats them as mgf (Mascot Generic Format). RawToMgf is a workflow that uses the RawToDta and DtaToMgf tasks, and can be configured through these tasks using the following configuration files:

config/xcalibur/convert
|- raw_to_mgf.yml               # configures RawToMgf
`- raw_to_mgf
 |- raw_to_dta.yml              # configures RawToDta
 `- dta_to_mgf.yml              # configures DtaToMgf

Mgf files are named after the RAW file they represent; the group merge file is named ‘merge.mgf’ although an alternate merge file name can be specified in the options.

Instance Method Summary collapse

Instance Method Details

#process(*input_files) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ms/xcalibur/convert/raw_to_mgf.rb', line 65

def process(*input_files)
  @n_inputs = input_files.length
  
  dta_dirs = []
  input_files.each do |input_file|
    dta_dir = File.basename(input_file).chomp(File.extname(input_file))
    dta_dirs << dta_dir
    raw_to_dta.execute(input_file, dta_dir)
  end
  
  if remove_dta_files
    dta_dirs.each {|dir| cleanup.process(dir) }
  end
      
  @n_inputs = nil
  nil
end

#workflowObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ms/xcalibur/convert/raw_to_mgf.rb', line 41

def workflow
  group_results = []
  raw_to_dta.on_complete do |_result|
    if merge_individual
      input_file = _result._original[0]
      output_file = File.join( File.dirname(merge_file), File.basename(input_file).chomp(File.extname(input_file)) + ".mgf")
      dta_to_mgf.execute(output_file, *_result._iterate)
    end

    # collect _results to determine when all the input
    # files have been processed by raw_to_dta
    group_results << _result

    # When all the input files have been converted, merge the
    # group and enque a task to cleanup the dta files, as specified.
    if group_results.length == @n_inputs
      if merge_group
        all_results = group_results.collect {|_result| _result._iterate }.flatten
        dta_to_mgf.execute(merge_file, *all_results)
      end
    end
  end
end