ms-quant 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/bin/peptide_hit_qvalues_to_spectral_counts_table.rb +6 -3
- data/lib/ms/quant/qspec.rb +14 -1
- data/lib/ms/quant/spectral_counts.rb +7 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
@@ -92,6 +92,7 @@ psq is really .psq.tsv file
|
|
92
92
|
opt :verbose, "speak up", :default => false
|
93
93
|
opt :count_type, "type of spectral counts (<spectral|aaseqcharge|aaseq>)", :default => 'spectral'
|
94
94
|
opt :qspec_normalize, "normalize spectral counts per run", :default => false
|
95
|
+
opt :qspec_keep_files, "keep a copy of the files submitted and returned from Qspec", :default => false
|
95
96
|
opt :write_subset, "(dev use only) write subset db", :default => false
|
96
97
|
end
|
97
98
|
|
@@ -201,13 +202,15 @@ counts_table = Ruport::Data::Table.new(:data => counts_data, :column_names => sa
|
|
201
202
|
if opt[:qspec]
|
202
203
|
|
203
204
|
# prepare data for qspec
|
204
|
-
condition_to_count_array = counts_table.column_names.map
|
205
|
+
condition_to_count_array = counts_table.column_names.map do |name|
|
206
|
+
[samplename_to_condition[name], counts_table.column(name)]
|
207
|
+
end
|
205
208
|
# average length of the proteins in the group
|
206
209
|
name_length_pairs = protein_groups.map do |pg|
|
207
|
-
[pg.join(":"), pg.map(&:length).reduce(:+)./(pg.size).round]
|
210
|
+
[pg.map(&:id).join(":"), pg.map(&:length).reduce(:+)./(pg.size).round]
|
208
211
|
end
|
209
212
|
|
210
|
-
qspec_results = Ms::Quant::Qspec.new(name_length_pairs, condition_to_count_array).run(opt[:qspec_normalize])
|
213
|
+
qspec_results = Ms::Quant::Qspec.new(name_length_pairs, condition_to_count_array).run(opt[:qspec_normalize], :keep => opt[:qspec_keep_files])
|
211
214
|
|
212
215
|
cols_to_add = [:bayes_factor, :fold_change, :fdr]
|
213
216
|
counts_table.add_columns cols_to_add
|
data/lib/ms/quant/qspec.rb
CHANGED
@@ -8,6 +8,8 @@ class Ms::Quant::Qspec
|
|
8
8
|
INIT_HEADER = %w(protid protLen)
|
9
9
|
DELIMITER = "\t"
|
10
10
|
|
11
|
+
SUBMITTED_TO_QSPEC = 'submitted_to_qspec.txt'
|
12
|
+
|
11
13
|
# takes an ordered list of conditions ['cond1', 'cond1', 'cond2', 'cond2'] and
|
12
14
|
# returns an array of ints [0,0,0,1,1,1...]
|
13
15
|
def self.conditions_to_ints(conditions)
|
@@ -75,6 +77,11 @@ class Ms::Quant::Qspec
|
|
75
77
|
puts "normalize: #{normalize}" if $VERBOSE
|
76
78
|
tfile = Tempfile.new("qspec")
|
77
79
|
write(tfile.path)
|
80
|
+
if opts[:keep]
|
81
|
+
local_file = File.join(Dir.pwd,File.basename(tfile.path))
|
82
|
+
FileUtils.cp(tfile.path, local_file, :verbose => $VERBOSE)
|
83
|
+
puts "(copy of) file submitted to qspec: #{local_file}" if $VERBOSE
|
84
|
+
end
|
78
85
|
qspec_exe = self.class.executable(conditions)
|
79
86
|
cmd = [qspec_exe, tfile.path, NBURNIN, NITER, (normalize ? 1 : 0)].join(' ')
|
80
87
|
if $VERBOSE
|
@@ -84,7 +91,13 @@ class Ms::Quant::Qspec
|
|
84
91
|
end
|
85
92
|
reply = `#{cmd}`
|
86
93
|
puts reply if $VERBOSE
|
87
|
-
|
94
|
+
outfile = tfile.path + '_' + qspec_exe
|
95
|
+
results = self.class.results_array(outfile)
|
96
|
+
if opts[:keep]
|
97
|
+
local_outfile = File.join(Dir.pwd, File.basename(outfile))
|
98
|
+
FileUtils.cp(outfile, local_outfile, :verbose => $VERBOSE)
|
99
|
+
puts "(copy of) file returned from qspec: #{outfile}"
|
100
|
+
end
|
88
101
|
tfile.unlink
|
89
102
|
results
|
90
103
|
end
|
@@ -5,6 +5,13 @@ module Ms
|
|
5
5
|
module Quant
|
6
6
|
module SpectralCounts
|
7
7
|
Counts = Struct.new(:spectral, :aaseqcharge, :aaseq)
|
8
|
+
class Counts
|
9
|
+
def initialize(*args)
|
10
|
+
super(*args)
|
11
|
+
# default is zero counts
|
12
|
+
self[0] ||= 0.0 ; self[1] ||= 0.0 ; self[2] ||= 0.0
|
13
|
+
end
|
14
|
+
end
|
8
15
|
|
9
16
|
# returns a parallel array of Count objects. If split_hits then counts
|
10
17
|
# are split between groups sharing the hit. peptide_hits must respond
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ms-quant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- John T. Prince
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-05 00:00:00 -06:00
|
14
14
|
default_executable: peptide_hit_qvalues_to_spectral_counts_table.rb
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|