ms-xcalibur 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History +8 -0
- data/MIT-LICENSE +16 -18
- data/README +9 -1
- data/lib/ms/xcalibur/convert/dta_to_mgf.rb +26 -28
- data/lib/ms/xcalibur/convert/raw_to_dta.rb +81 -42
- data/lib/ms/xcalibur/peak_file.rb +1 -1
- data/lib/ms/xcalibur/peakify.rb +34 -34
- metadata +15 -4
- data/lib/ms/xcalibur/convert/raw_to_mgf.rb +0 -86
data/History
ADDED
data/MIT-LICENSE
CHANGED
@@ -1,21 +1,19 @@
|
|
1
|
-
Copyright (c)
|
2
|
-
Developer:: Simon Chiang, Biomolecular Structure Program, Hansen Lab
|
3
|
-
Support:: CU Denver School of Medicine Deans Academic Enrichment Fund
|
1
|
+
Copyright (c) 2009, Regents of the University of Colorado.
|
4
2
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
software and associated documentation files (the "Software"), to deal
|
7
|
-
without restriction, including without limitation the rights
|
8
|
-
publish, distribute, sublicense, and/or sell
|
9
|
-
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
10
9
|
|
11
|
-
The above copyright notice and this permission notice shall be included in all
|
12
|
-
substantial portions of the Software.
|
10
|
+
The above copyright notice and this permission notice shall be included in all
|
11
|
+
copies or substantial portions of the Software.
|
13
12
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
+
SOFTWARE.
|
data/README
CHANGED
@@ -8,6 +8,14 @@ An {Mspire}[http://mspire.rubyforge.org] library supporting {Xcalibur}[http://ww
|
|
8
8
|
* Github[http://github.com/bahuvrihi/ms-xcalibur/tree/master]
|
9
9
|
* {Google Group}[http://groups.google.com/group/mspire-forum]
|
10
10
|
|
11
|
+
== Usage
|
12
|
+
|
13
|
+
Currently the primary use of Ms-Xcalibur is to convert RAW files to dta files. Use this workflow to do so:
|
14
|
+
|
15
|
+
% tap run -- raw_to_dta RAW_FILE --:s dta_to_mgf > MGF_FILE
|
16
|
+
|
17
|
+
The extract_msn.exe tool provided by Xcalibur/BioWorks must already be installed.
|
18
|
+
|
11
19
|
== Installation
|
12
20
|
|
13
21
|
Ms-Xcalibur is available as a gem on RubyForge[http://rubyforge.org/projects/mspire]. Use:
|
@@ -16,7 +24,7 @@ Ms-Xcalibur is available as a gem on RubyForge[http://rubyforge.org/projects/msp
|
|
16
24
|
|
17
25
|
== Info
|
18
26
|
|
19
|
-
Copyright (c)
|
27
|
+
Copyright (c) 2009, Regents of the University of Colorado.
|
20
28
|
Developer:: {Simon Chiang}[http://bahuvrihi.wordpress.com], {Biomolecular Structure Program}[http://biomol.uchsc.edu/], {Hansen Lab}[http://hsc-proteomics.uchsc.edu/hansenlab/]
|
21
29
|
Support:: CU Denver School of Medicine Deans Academic Enrichment Fund
|
22
30
|
Licence:: {MIT-Style}[link:files/MIT-LICENSE.html]
|
@@ -3,9 +3,20 @@ require 'constants'
|
|
3
3
|
module Ms
|
4
4
|
module Xcalibur
|
5
5
|
module Convert
|
6
|
+
|
6
7
|
# :startdoc::manifest convert dta files to mgf format
|
7
|
-
#
|
8
|
-
#
|
8
|
+
#
|
9
|
+
# Converts a set of dta files (Sequest format) into an mgf (Mascot format)
|
10
|
+
# file. By default the mgf file is printed to $stdout, so redirection is
|
11
|
+
# a good way to save the results.
|
12
|
+
#
|
13
|
+
# % tap run -- dta_to_mgf ... > results.mgf
|
14
|
+
#
|
15
|
+
# Alternatively, specify the output file using the output configuration.
|
16
|
+
#
|
17
|
+
# === Conversion
|
18
|
+
#
|
19
|
+
# The dta -> mgf conversion is straightforward:
|
9
20
|
#
|
10
21
|
# dta format:
|
11
22
|
# [input_file.dta]
|
@@ -36,26 +47,17 @@ module Ms
|
|
36
47
|
|
37
48
|
# Returns the unrounded mass of a proton (H - e) as calculated
|
38
49
|
# from the {constants}[bioactive.rubyforge.org/constants] gem.
|
39
|
-
config :proton_mass, Element['H'].mass - Particle['Electron'].mass, &c.num_or_nil
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
prepare(output_file)
|
54
|
-
File.open(output_file, "wb") do |target|
|
55
|
-
h = proton_mass
|
56
|
-
|
57
|
-
dta_files.flatten.each do |file|
|
58
|
-
#log_basename(:merging, file)
|
50
|
+
config :proton_mass, Element['H'].mass - Particle['Electron'].mass, &c.num_or_nil # Specify the proton mass
|
51
|
+
config :output, $stdout, &c.io(:<<, :binmode) # The output file
|
52
|
+
|
53
|
+
def process(*dta_files)
|
54
|
+
prepare(output) if output.kind_of?(String)
|
55
|
+
open_io(output, 'w') do |target|
|
56
|
+
target.binmode
|
57
|
+
|
58
|
+
log :convert, "#{dta_files.length} dta files"
|
59
|
+
dta_files.each do |file|
|
60
|
+
check_terminate
|
59
61
|
lines = File.read(file).split(/\r?\n/)
|
60
62
|
|
61
63
|
# get the mh and z
|
@@ -70,19 +72,15 @@ module Ms
|
|
70
72
|
target << %Q{BEGIN IONS
|
71
73
|
TITLE=#{File.basename(file)}
|
72
74
|
CHARGE=#{z}+
|
73
|
-
PEPMASS=#{(mh + (z-1) *
|
75
|
+
PEPMASS=#{(mh + (z-1) * proton_mass)/ z}
|
74
76
|
#{lines.join("\n")}
|
75
77
|
END IONS
|
76
|
-
|
78
|
+
|
77
79
|
}
|
78
80
|
end
|
79
81
|
end
|
80
|
-
log(:made, output_file)
|
81
|
-
|
82
|
-
output_file
|
83
82
|
end
|
84
83
|
end
|
85
|
-
|
86
84
|
end
|
87
85
|
end
|
88
86
|
end
|
@@ -1,38 +1,54 @@
|
|
1
1
|
module Ms
|
2
2
|
module Xcalibur
|
3
3
|
module Convert
|
4
|
+
|
4
5
|
# :startdoc::manifest convert RAW files to dta format
|
5
|
-
# Converts a .RAW file to dta files using extract_msn.exe
|
6
6
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# version of your executable using:
|
7
|
+
# Converts a RAW file to dta files using extract_msn.exe. Returns an
|
8
|
+
# array of the output dta files. By default extracted files are put
|
9
|
+
# in a directory named after the RAW file, but an alternate extraction
|
10
|
+
# directory can be specified iwth the output-dir option.
|
12
11
|
#
|
13
|
-
#
|
12
|
+
# RawToDta will skip extraction of an 'lcq_dta.txt' file and all the dta
|
13
|
+
# files listed therein exist in the output directory. This is good in
|
14
|
+
# most cases; if you want to force execution set force true for the run:
|
15
|
+
#
|
16
|
+
# % tap run --force -- raw_to_dta ...
|
17
|
+
#
|
18
|
+
# === extract_msn
|
19
|
+
#
|
20
|
+
# extract_msn.exe is an Xcalibur/BioWorks tool that extracts spectra from
|
21
|
+
# RAW files into dta (Sequest) format and must be installed for RawToDta
|
22
|
+
# to work. At present this means that RawToDta can only work on Windows.
|
23
|
+
#
|
24
|
+
# RawToDta was developed against extract_msn version 4.0. You can check
|
25
|
+
# if extract_msn is installed at the default location, as well as
|
26
|
+
# determine the version of your executable using:
|
27
|
+
#
|
28
|
+
# % tap run -- raw_to_dta --extract_msn_help
|
14
29
|
#
|
15
30
|
class RawToDta < Tap::FileTask
|
16
|
-
config :extract_msn, 'C:\Xcalibur\System\Programs\extract_msn.exe' #
|
17
|
-
config :first_scan, nil, &c.integer_or_nil
|
18
|
-
config :last_scan, nil, &c.integer_or_nil
|
19
|
-
config :lower_MW, nil, &c.num_or_nil
|
20
|
-
config :upper_MW, nil, &c.num_or_nil
|
21
|
-
config :precursor_mass_tol, 1.4, &c.num
|
22
|
-
config :num_allowed_intermediate_scans_for_grouping, 1, &c.integer
|
23
|
-
config :charge_state, nil, &c.integer_or_nil
|
24
|
-
config :num_required_group_scans, 1, &c.integer_or_nil
|
25
|
-
config :num_ions_required, 0, &c.integer_or_nil
|
26
|
-
config :intensity_threshold, nil, &c.integer_or_nil
|
27
|
-
config :use_unified_search_file, nil, &c.flag
|
28
|
-
config :subsequence, nil
|
29
|
-
config :write_zta_files, nil, &c.flag
|
30
|
-
config :perform_charge_calculations, nil, &c.flag
|
31
|
-
config :template_file, nil
|
32
|
-
config :options_string, nil
|
33
|
-
config :minimum_signal_to_noise, 3, &c.num
|
34
|
-
config :minimum_number_of_peaks, 5, &c.integer
|
35
|
-
|
31
|
+
config :extract_msn, 'C:\Xcalibur\System\Programs\extract_msn.exe' # The full path to the extract_msn executable
|
32
|
+
config :first_scan, nil, :short => :F, &c.integer_or_nil
|
33
|
+
config :last_scan, nil, :short => :L, &c.integer_or_nil
|
34
|
+
config :lower_MW, nil, :short => :B, &c.num_or_nil
|
35
|
+
config :upper_MW, nil, :short => :T, &c.num_or_nil
|
36
|
+
config :precursor_mass_tol, 1.4, :short => :M, &c.num
|
37
|
+
config :num_allowed_intermediate_scans_for_grouping, 1, :short => :S, &c.integer
|
38
|
+
config :charge_state, nil, :short => :C, &c.integer_or_nil
|
39
|
+
config :num_required_group_scans, 1, :short => :G, &c.integer_or_nil
|
40
|
+
config :num_ions_required, 0, :short => :I, &c.integer_or_nil
|
41
|
+
config :intensity_threshold, nil, :short => :E, &c.integer_or_nil
|
42
|
+
config :use_unified_search_file, nil, :short => :U, &c.flag
|
43
|
+
config :subsequence, nil, :short => :Y
|
44
|
+
config :write_zta_files, nil, :short => :Z, &c.flag
|
45
|
+
config :perform_charge_calculations, nil, :short => :K, &c.flag
|
46
|
+
config :template_file, nil, :short => :O
|
47
|
+
config :options_string, nil, :short => :A
|
48
|
+
config :minimum_signal_to_noise, 3, :short => :R, &c.num
|
49
|
+
config :minimum_number_of_peaks, 5, :short => :r, &c.integer
|
50
|
+
|
51
|
+
config :output_dir, nil, &c.string_or_nil # The output directory
|
36
52
|
config_attr(:extract_msn_help, nil, :arg_type => :flag) do |value| # Print the extract_msn help
|
37
53
|
if value
|
38
54
|
sh(extract_msn)
|
@@ -114,29 +130,52 @@ module Ms
|
|
114
130
|
args.join(' ')
|
115
131
|
end
|
116
132
|
|
117
|
-
def process(input_file
|
133
|
+
def process(input_file)
|
118
134
|
extname = File.extname(input_file)
|
119
135
|
raise "Expected .RAW file: #{input_file}" unless extname =~ /\.RAW$/i
|
120
136
|
|
121
137
|
# Target the output to a directory with the same basename
|
122
138
|
# as the raw file, unless otherwise specified.
|
123
|
-
output_dir = input_file.chomp(File.extname(input_file))
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
log :sh, command
|
129
|
-
if app.quiet
|
130
|
-
capture_sh(command, true)
|
139
|
+
output_dir = self.output_dir || input_file.chomp(File.extname(input_file))
|
140
|
+
current_dta_files = dta_files(output_dir)
|
141
|
+
if !current_dta_files.empty? && uptodate?(current_dta_files, input_file)
|
142
|
+
log_basename :uptodate, input_file
|
143
|
+
current_dta_files
|
131
144
|
else
|
132
|
-
|
133
|
-
|
134
|
-
|
145
|
+
unless File.exists?(extract_msn)
|
146
|
+
raise "extract_msn does not exist at: #{extract_msn}"
|
147
|
+
end
|
148
|
+
|
149
|
+
mkdir(output_dir)
|
150
|
+
command = cmd(input_file, output_dir)
|
135
151
|
|
136
|
-
|
137
|
-
|
138
|
-
|
152
|
+
log :sh, command
|
153
|
+
if app.quiet
|
154
|
+
capture_sh(command, true)
|
155
|
+
else
|
156
|
+
sh(command)
|
157
|
+
puts "" # add extra line to make logging nice
|
158
|
+
end
|
159
|
+
|
160
|
+
dta_files(output_dir)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# Returns an array of dta_files specified in the lcq_dta.txt file under
|
165
|
+
# output_dir. A simple glob is less preferable than reading the list of
|
166
|
+
# files from lcq_dta because there is no guarantee all the .dta file in
|
167
|
+
# the output directory should be used for a particular file.
|
168
|
+
def dta_files(output_dir)
|
169
|
+
lcq_dta = File.join(output_dir, 'lcq_dta.txt')
|
170
|
+
|
171
|
+
dta_files = []
|
172
|
+
File.read(lcq_dta).scan(/Datafile:\s(.*?\.dta)\s/) do |dta_file|
|
173
|
+
dta_files << File.join(output_dir, dta_file)
|
174
|
+
end if File.exists?(lcq_dta)
|
175
|
+
|
176
|
+
dta_files
|
139
177
|
end
|
178
|
+
|
140
179
|
end
|
141
180
|
end
|
142
181
|
end
|
@@ -3,7 +3,7 @@ module Ms
|
|
3
3
|
# A simple representation of a peak file exported from Xcalibur Qual
|
4
4
|
# Browser (v 2.0). The expected format of a peak file is as shown below:
|
5
5
|
#
|
6
|
-
#
|
6
|
+
# [peak_file.txt]
|
7
7
|
# SPECTRUM - MS
|
8
8
|
# GSE_T29K_080703143635.raw
|
9
9
|
# ITMS + c ESI Full ms [300.00-2000.00]
|
data/lib/ms/xcalibur/peakify.rb
CHANGED
@@ -3,11 +3,12 @@ require 'ms/xcalibur/peak_file'
|
|
3
3
|
module Ms
|
4
4
|
module Xcalibur
|
5
5
|
# :startdoc::manifest adds graph data to an exported peak file
|
6
|
-
# Peakify adds points to signify the relative intensity
|
7
|
-
# (ie the rounded intensity/max_intensity) of peaks in
|
8
|
-
# an exported peak list. This can be useful as a visual aid.
|
9
6
|
#
|
10
|
-
#
|
7
|
+
# Peakify adds points to signify the relative intensity (ie the rounded
|
8
|
+
# intensity/max_intensity) of peaks to a peak list extracted from Xcalibur
|
9
|
+
# Qual Browser (v 2.0).. This can be useful as a visual aid.
|
10
|
+
#
|
11
|
+
# [peakfile.txt]
|
11
12
|
# SPECTRUM - MS
|
12
13
|
# GSE_T29K_080703143635.raw
|
13
14
|
# ITMS + c ESI Full ms [300.00-2000.00]
|
@@ -20,45 +21,44 @@ module Ms
|
|
20
21
|
# 302.465759 3000.0 ..................................................
|
21
22
|
# ...
|
22
23
|
#
|
23
|
-
# Options can be specified to filter out points within a
|
24
|
-
#
|
25
|
-
# peak lists from Xcalibur Qual Browser (v 2.0).
|
24
|
+
# Options can be specified to filter out points within a range of relative
|
25
|
+
# intensities.
|
26
26
|
#
|
27
27
|
class Peakify < Tap::FileTask
|
28
28
|
|
29
|
-
config :point_char, '.'
|
30
|
-
config :min, 0, &c.num
|
31
|
-
config :max, 100, &c.num
|
32
|
-
config :sort, false, &c.flag
|
29
|
+
config :point_char, '.' # A character used for each intensity point
|
30
|
+
config :min, 0, &c.num # Min relative intenisty
|
31
|
+
config :max, 100, &c.num # Max relative intenisty
|
32
|
+
config :sort, false, &c.flag # Sort by intensity
|
33
|
+
config :output, $stdout, &c.io(:<<, :binmode) # The output file
|
33
34
|
|
34
|
-
def process(source
|
35
|
-
prepare(
|
35
|
+
def process(source)
|
36
|
+
prepare(output) if output.kind_of?(String)
|
37
|
+
open_io(output, 'w') do |target|
|
38
|
+
target.binmode
|
39
|
+
|
40
|
+
# now perform the task...
|
41
|
+
peak_file = PeakFile.parse File.read(source)
|
42
|
+
max_intensity = peak_file.data.inject(0) do |max, (mz, intensity)|
|
43
|
+
intensity > max ? intensity : max
|
44
|
+
end
|
36
45
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
end
|
46
|
+
range = min..max
|
47
|
+
peak_file.data = peak_file.data.collect do |(mz, intensity)|
|
48
|
+
percent = (intensity / max_intensity * 100)
|
49
|
+
next unless range.include?(percent)
|
42
50
|
|
43
|
-
|
44
|
-
|
45
|
-
percent = (intensity / max_intensity * 100)
|
46
|
-
next unless range.include?(percent)
|
51
|
+
[mz, intensity, point_char * percent.round]
|
52
|
+
end.compact
|
47
53
|
|
48
|
-
|
49
|
-
|
54
|
+
if sort
|
55
|
+
peak_file.data = peak_file.data.sort_by do |(mz, intensity)|
|
56
|
+
intensity
|
57
|
+
end.reverse
|
58
|
+
end
|
50
59
|
|
51
|
-
|
52
|
-
peak_file.data = peak_file.data.sort_by do |(mz, intensity)|
|
53
|
-
intensity
|
54
|
-
end.reverse
|
60
|
+
target << peak_file.to_s
|
55
61
|
end
|
56
|
-
|
57
|
-
File.open(target, "wb") do |file|
|
58
|
-
file << peak_file.to_s
|
59
|
-
end
|
60
|
-
|
61
|
-
target
|
62
62
|
end
|
63
63
|
end
|
64
64
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ms-xcalibur
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Chiang
|
@@ -9,9 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date:
|
12
|
+
date: 2009-03-31 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: configurable
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.4.2
|
24
|
+
version:
|
15
25
|
- !ruby/object:Gem::Dependency
|
16
26
|
name: tap
|
17
27
|
type: :runtime
|
@@ -20,7 +30,7 @@ dependencies:
|
|
20
30
|
requirements:
|
21
31
|
- - ">="
|
22
32
|
- !ruby/object:Gem::Version
|
23
|
-
version:
|
33
|
+
version: 0.12.4
|
24
34
|
version:
|
25
35
|
- !ruby/object:Gem::Dependency
|
26
36
|
name: constants
|
@@ -39,15 +49,16 @@ executables: []
|
|
39
49
|
extensions: []
|
40
50
|
|
41
51
|
extra_rdoc_files:
|
52
|
+
- History
|
42
53
|
- README
|
43
54
|
- MIT-LICENSE
|
44
55
|
files:
|
45
56
|
- lib/ms/xcalibur/convert/dta_to_mgf.rb
|
46
57
|
- lib/ms/xcalibur/convert/raw_to_dta.rb
|
47
|
-
- lib/ms/xcalibur/convert/raw_to_mgf.rb
|
48
58
|
- lib/ms/xcalibur/peak_file.rb
|
49
59
|
- lib/ms/xcalibur/peakify.rb
|
50
60
|
- tap.yml
|
61
|
+
- History
|
51
62
|
- README
|
52
63
|
- MIT-LICENSE
|
53
64
|
has_rdoc: true
|
@@ -1,86 +0,0 @@
|
|
1
|
-
require 'ms/xcalibur/convert/raw_to_dta'
|
2
|
-
require 'ms/xcalibur/convert/dta_to_mgf'
|
3
|
-
|
4
|
-
module Ms
|
5
|
-
module Xcalibur
|
6
|
-
module Convert
|
7
|
-
# :startdoc::manifest convert RAW files to mgf format
|
8
|
-
# Extracts spectra from a .RAW file and formats them as mgf (Mascot
|
9
|
-
# Generic Format). RawToMgf is a workflow that uses the RawToDta
|
10
|
-
# and DtaToMgf tasks, and can be configured through these tasks
|
11
|
-
# using the following configuration files:
|
12
|
-
#
|
13
|
-
# config/xcalibur/convert
|
14
|
-
# |- raw_to_mgf.yml # configures RawToMgf
|
15
|
-
# `- raw_to_mgf
|
16
|
-
# |- raw_to_dta.yml # configures RawToDta
|
17
|
-
# `- dta_to_mgf.yml # configures DtaToMgf
|
18
|
-
#
|
19
|
-
# Mgf files are named after the RAW file they represent; the group
|
20
|
-
# merge file is named 'merge.mgf' although an alternate merge file
|
21
|
-
# name can be specified in the options.
|
22
|
-
#
|
23
|
-
class RawToMgf < Tap::Task
|
24
|
-
|
25
|
-
define :raw_to_dta, Xcalibur::Convert::RawToDta
|
26
|
-
define :dta_to_mgf, Xcalibur::Convert::DtaToMgf
|
27
|
-
define :cleanup do |raw_dir|
|
28
|
-
log :rm, raw_dir
|
29
|
-
|
30
|
-
# take this stepwise to be a little safer...
|
31
|
-
FileUtils.rm Dir.glob(raw_dir + "/*.dta")
|
32
|
-
FileUtils.rm ["#{raw_dir }/lcq_dta.txt", "#{raw_dir }/lcq_profile.txt"]
|
33
|
-
FileUtils.rmdir raw_dir
|
34
|
-
end
|
35
|
-
|
36
|
-
config :merge_file, 'merge.mgf' # the group merge file
|
37
|
-
config :merge_individual, true, &c.switch # merge the dta's for each RAW file
|
38
|
-
config :merge_group, true, &c.switch # merge the dta's for all RAW files
|
39
|
-
config :remove_dta_files, true, &c.switch # clean up dta files upon completion
|
40
|
-
|
41
|
-
def workflow
|
42
|
-
group_results = []
|
43
|
-
raw_to_dta.on_complete do |_result|
|
44
|
-
if merge_individual
|
45
|
-
input_file = _result._original[0]
|
46
|
-
output_file = File.join( File.dirname(merge_file), File.basename(input_file).chomp(File.extname(input_file)) + ".mgf")
|
47
|
-
dta_to_mgf.execute(output_file, *_result._iterate)
|
48
|
-
end
|
49
|
-
|
50
|
-
# collect _results to determine when all the input
|
51
|
-
# files have been processed by raw_to_dta
|
52
|
-
group_results << _result
|
53
|
-
|
54
|
-
# When all the input files have been converted, merge the
|
55
|
-
# group and enque a task to cleanup the dta files, as specified.
|
56
|
-
if group_results.length == @n_inputs
|
57
|
-
if merge_group
|
58
|
-
all_results = group_results.collect {|_result| _result._iterate }.flatten
|
59
|
-
dta_to_mgf.execute(merge_file, *all_results)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
def process(*input_files)
|
66
|
-
@n_inputs = input_files.length
|
67
|
-
|
68
|
-
dta_dirs = []
|
69
|
-
input_files.each do |input_file|
|
70
|
-
dta_dir = File.basename(input_file).chomp(File.extname(input_file))
|
71
|
-
dta_dirs << dta_dir
|
72
|
-
raw_to_dta.execute(input_file, dta_dir)
|
73
|
-
end
|
74
|
-
|
75
|
-
if remove_dta_files
|
76
|
-
dta_dirs.each {|dir| cleanup.process(dir) }
|
77
|
-
end
|
78
|
-
|
79
|
-
@n_inputs = nil
|
80
|
-
nil
|
81
|
-
end
|
82
|
-
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|