mspire 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -140,7 +140,7 @@ tm = Time.now
140
140
  spec = Gem::Specification.new do |s|
141
141
  s.platform = Gem::Platform::RUBY
142
142
  s.name = NAME
143
- s.version = "0.2.2"
143
+ s.version = "0.2.4"
144
144
  s.summary = "Mass Spectrometry Proteomics Objects, Scripts, and Executables"
145
145
  s.date = "#{tm.year}-#{tm.month}-#{tm.day}"
146
146
  s.email = "jprince@icmb.utexas.edu"
@@ -0,0 +1,225 @@
1
+ #!/usr/bin/ruby -w
2
+
3
+ tmp = $VERBOSE ; $VERBOSE = nil
4
+ require 'fox16'
5
+ $VERBOSE = tmp
6
+
7
+ include Fox
8
+
9
+
10
+ class Opt
11
+ attr_accessor :flag, :value
12
+ def initialize(flag, value=nil)
13
+ @flag = flag
14
+ @value = value
15
+ end
16
+
17
+ def self.[](flag, value=nil)
18
+ self.new(flag, value)
19
+ end
20
+
21
+ def to_s
22
+ st = @flag
23
+ if @value
24
+ st << " " << @value
25
+ end
26
+ st
27
+ end
28
+
29
+ end
30
+
31
+
32
+ NCOLS = 40
33
+
34
+ srf_dir = nil
35
+ output_dir = '.'
36
+ msdata_dir = '.'
37
+ $progname = 'bioworks_to_pepxml.rb'
38
+ $sequest_folder = '/project/marcotte/marcotte/ms/john/sequest'
39
+ $data_folder = '/project/marcotte/marcotte/ms/john/data'
40
+ $isb_folder = '/var/www/tpp'
41
+
42
+ # This is a directory selector consisting of: Label | FieldText | BrowseButton
43
+ # if you pass in patterns, then you can select multiple files!
44
+ class DirSelector
45
+ attr_writer :directory
46
+
47
+ def directory
48
+ @directory_data.to_s
49
+ end
50
+
51
+ # You should pass in the frame that you want filled up!
52
+ def initialize(parent, label='select directory', init_dir='.', text_field_width=30)
53
+ @directory_data = FXDataTarget.new(init_dir)
54
+
55
+ FXLabel.new(parent, label , nil, LAYOUT_CENTER_Y|LAYOUT_RIGHT|JUSTIFY_RIGHT)
56
+ srf_field = FXTextField.new(parent, text_field_width, @directory_data) do |tf|
57
+ tf.text = @directory_data.to_s
58
+ end
59
+ srf_field.connect(SEL_COMMAND) do |sender, sel, message|
60
+ @directory_data.value = message
61
+ end
62
+ but = FXButton.new(parent, "Browse")
63
+ but.connect(SEL_COMMAND) do |sender, sel, message|
64
+ @directory_data.value = FXFileDialog.getOpenDirectory(parent, "Open directory_data", @directory_data.to_s)
65
+ srf_field.text = @directory_data.value
66
+ end
67
+ end
68
+ end
69
+
70
+ # This is a directory selector consisting of: Label | FieldText | BrowseButton
71
+ # if you pass in patterns, then you can select multiple files!
72
+ class MultipleFilesSelector
73
+ # an array of filenames
74
+ attr_writer :files
75
+
76
+ # You should pass in the frame that you want filled up!
77
+ def initialize(parent, label='select multiple files', init_dir='.', text_field_width=30, patterns=["All Files (*)"])
78
+ @directory_data = FXDataTarget.new(init_dir)
79
+
80
+ FXLabel.new(parent, label , nil, LAYOUT_CENTER_Y|LAYOUT_RIGHT|JUSTIFY_RIGHT)
81
+ srf_field = FXTextField.new(parent, text_field_width, @directory_data) do |tf|
82
+ tf.text = @directory_data.to_s
83
+ end
84
+ srf_field.connect(SEL_COMMAND) do |sender, sel, message|
85
+ @directory_data.value = message
86
+ end
87
+ but = FXButton.new(parent, "Browse")
88
+ if patterns.is_a?(Array)
89
+ pattern_string = patterns.join("\n")
90
+ else
91
+ pattern_string = patterns
92
+ end
93
+ but.connect(SEL_COMMAND) do |sender, sel, message|
94
+ reply = FXFileDialog.getOpenFilenames(parent, "Open directory_data", @directory_data.to_s, pattern_string)
95
+ p reply
96
+ abort
97
+ srf_field.text = @directory_data.value
98
+ end
99
+ end
100
+ end
101
+
102
+
103
+ class MainWindow < FXMainWindow
104
+
105
+ def action(*args)
106
+ p args
107
+
108
+ cmd = []
109
+ cmd << $progname
110
+ #cmd << args
111
+ #cmd << Opt['-o', output_dir]
112
+
113
+ puts cmd.join(" ")
114
+ end
115
+
116
+ def initialize(anApp)
117
+ labels = ["&SRF files (select multiple)", "&Output Directory (ISB)", "&Directory with RAW files"]
118
+ super(anApp, "bioworks_to_pepxml", nil, nil, DECOR_ALL)
119
+
120
+ gb = FXGroupBox.new(self, "Specify input/output", FRAME_RIDGE)
121
+ mat = FXMatrix.new(gb, 3, MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP)
122
+
123
+ srf_files_selector = MultipleFilesSelector.new(mat, labels[0], $sequest_folder, NCOLS, ["SRF files (*.srf)"])
124
+
125
+ isb_files_selector = DirSelector.new(mat, labels[1], $isb_folder, NCOLS)
126
+
127
+ hf = FXHorizontalFrame.new(self)
128
+ create_mzxml = FXCheckButton.new(hf, 'create mzXML files')
129
+ copy_mzxml = FXCheckButton.new(hf, 'copy mzXML files to ISB dir') {|v| v.checkState = TRUE }
130
+ copy_mzxml.hide
131
+
132
+ @mat2 = FXMatrix.new(self, 3, MATRIX_BY_COLUMNS|LAYOUT_SIDE_TOP)
133
+ srf_dir_selector = DirSelector.new(@mat2, labels[2], $data_folder, NCOLS)
134
+
135
+ submit = FXButton.new(self, "Submit")
136
+ submit.connect(SEL_COMMAND) do |sender, sel, message|
137
+ action(srf_dir_selector.files)
138
+ end
139
+
140
+ create_mzxml.connect(SEL_COMMAND) do |button,b,checked|
141
+ if checked
142
+ copy_mzxml.show
143
+ @mat2.show
144
+ self.resize(self.width, @large_height)
145
+ else
146
+ copy_mzxml.hide
147
+ @mat2.hide
148
+ self.resize(self.width, @small_height)
149
+ end
150
+ end
151
+
152
+ end
153
+
154
+ def create
155
+ super
156
+ show(PLACEMENT_SCREEN)
157
+ @large_height = self.height
158
+
159
+ # setup hidden state
160
+ @mat2.hide
161
+ @small_height = @large_height - @mat2.height
162
+ self.resize(self.width, @small_height)
163
+ end
164
+
165
+ end
166
+
167
+
168
+ application = FXApp.new("Hello", "FXRuby") do |theApp|
169
+ MainWindow.new(theApp)
170
+ theApp.create
171
+ theApp.run
172
+ end
173
+
174
+
175
+ application.run()
176
+
177
+
178
+
179
+
180
+ =begin
181
+
182
+
183
+ ---------------------------------
184
+ class MyMainWindow < FXMainWindow
185
+
186
+ attr :advancedFrame
187
+
188
+ def initialize(app)
189
+ super(app, "MyMainWindow")
190
+
191
+ contents = FXVerticalFrame.new(self,
192
+ LAYOUT_FILL_X|LAYOUT_FILL_Y)
193
+
194
+ advancedButton = FXButton.new(contents, "Advanced >>",
195
+ nil, self, 0, FRAME_RAISED|FRAME_THICK)
196
+
197
+ advancedButton.connect(SEL_COMMAND) do
198
+ if @advancedFrame.shown?
199
+ self.height -= @advancedFrame.height
200
+ @advancedFrame.hide
201
+ advancedButton.text = "Advanced >>"
202
+ else
203
+ self.height += @advancedFrame.height
204
+ @advancedFrame.show
205
+ advancedButton.text = "<< Basic"
206
+ end
207
+
208
+ self.recalc
209
+ end
210
+ end
211
+ end
212
+ #---------------------------
213
+ app = FXApp.new
214
+
215
+ mainWindow = MyMainWindow.new(app)
216
+
217
+ app.create
218
+ mainWindow.advancedFrame.hide
219
+ mainWindow.height -= mainWindow.advancedFrame.height
220
+
221
+ mainWindow.show(PLACEMENT_SCREEN)
222
+
223
+ app.run
224
+
225
+ =end
data/changelog.txt CHANGED
@@ -49,3 +49,8 @@ minor bugfix
49
49
  made compatible with Bioworks fasta file reverser and updated tutorial.
50
50
  Killed classify_by_prefix routine in favor of classify_by_false_flag which has
51
51
  a prefix option
52
+
53
+ ## version 0.2.3
54
+
55
+ in protein_summary.rb added handling for proteins with no annotation. (either
56
+ dispaly NA or use gi2annnot to grab them from NCBI)
data/lib/gi.rb CHANGED
@@ -51,7 +51,12 @@ class GI
51
51
  #puts url
52
52
  begin
53
53
  open(url) do |handle|
54
- annots.push( *(parse_etool_output(handle)) )
54
+ if handle.is_a? StringIO
55
+ io_input = handle
56
+ else
57
+ io_input = handle.read
58
+ end
59
+ annots.push( *(parse_etool_output(io_input)) )
55
60
  end
56
61
  rescue SocketError
57
62
  return nil
@@ -6,6 +6,7 @@ require 'optparse'
6
6
  require 'ostruct'
7
7
  require 'spec_id'
8
8
  require 'spec_id/precision'
9
+ require 'gi'
9
10
 
10
11
  #############################################################
11
12
  # GLOBALS:
@@ -210,13 +211,26 @@ class ProteinSummary
210
211
  # returns a string of the table rows
211
212
  # false_positive_rate (give as a %) is the cutoff mark
212
213
  # returns the number of proteins at the desired_fppr (if given)
213
- def table_rows(uniq_prots, prefix, false_positive_rate_percent, num_cols, desired_fppr, actual_percent_fp, peptide_count_filename=nil)
214
+ def table_rows(uniq_prots, prefix, false_positive_rate_percent, num_cols, desired_fppr, actual_percent_fp, annotations=nil, peptide_count_filename=nil)
214
215
  prot_cnt = 0
216
+ an_cnt = 0
217
+
215
218
  uniq_prots.map do |prot|
216
219
  tr do
217
220
  prot_cnt += 1
218
221
  gi = accession(prot._protein_name)
219
- tds([prot_cnt, prot._probability, ref_html(gi, prot._protein_name), prot.annotation.first._protein_description, prot._percent_coverage, peptide_cell(prot_cnt, prot._unique_stripped_peptides.split('+')), prot._total_number_peptides, prot._pct_spectrum_ids])
222
+
223
+ if annotations
224
+ protein_description = annotations[an_cnt]
225
+ an_cnt += 1
226
+ else
227
+ if prot.annotation.size > 0
228
+ protein_description = prot.annotation.first._protein_description
229
+ else
230
+ protein_description = 'NA'
231
+ end
232
+ end
233
+ tds([prot_cnt, prot._probability, ref_html(gi, prot._protein_name), protein_description, prot._percent_coverage, peptide_cell(prot_cnt, prot._unique_stripped_peptides.split('+')), prot._total_number_peptides, prot._pct_spectrum_ids])
220
234
  end
221
235
  end.join
222
236
  end
@@ -310,8 +324,15 @@ class ProteinSummary
310
324
 
311
325
  output_peptide_counts_file(filtered_sorted_prots, opt.peptide_count) if opt.peptide_count
312
326
 
327
+ # get an array of annotations (or nil if no option)
328
+ annotations =
329
+ if opt.get_annotation
330
+ gis = filtered_sorted_prots.map {|prot| accession(prot._protein_name) }
331
+ GI.gi2annot(gis)
332
+ end
333
+
313
334
  table_string = table do
314
- tr{theaders} + table_rows(filtered_sorted_prots, opt.f, actual_percent_fp, num_cols, opt.c.to_f, actual_percent_fp, opt.peptide_count)
335
+ tr{theaders} + table_rows(filtered_sorted_prots, opt.f, actual_percent_fp, num_cols, opt.c.to_f, actual_percent_fp, annotations, opt.peptide_count)
315
336
  end
316
337
  er_info = opt.precision ? error_info(file) : ""
317
338
  html_pieces = [outfn, header, fppr_output_as_html, er_info, file_info(file), protproph_script_info, num_prots_html, table_string, trailer]
@@ -410,6 +431,8 @@ class ProteinSummary
410
431
  op.separator "Specific to ProteinProphet (with no concatenated DB):"
411
432
  op.on("-c", "--cutoff percent", "false positive predictive rate (FPPR)% for given cutoff") {|v| opt.c = v }
412
433
  op.on("--cut_at percent", "only reports proteins within FPPR %") {|v| opt.cut_at = v }
434
+ op.on("--get_annotation", "retrieves annotation by gi code") {|v| opt.get_annotation = v}
435
+ op.separator " (use if your proteins have gi's but no annotation) "
413
436
  end
414
437
 
415
438
  opts.parse!(argv)
data/test/tc_gi.rb CHANGED
@@ -7,9 +7,9 @@ class Gi2AnnotTest < Test::Unit::TestCase
7
7
  ROOT_DIR = File.join(File.dirname(__FILE__), '..')
8
8
 
9
9
  def test_single_query
10
- annot = GI.gi2annot([16130548])
10
+ annot = GI.gi2annot([836805])
11
11
  if annot
12
- assert_equal('CP4-57 prophage; RNase LS [Escherichia coli K12]', annot.first)
12
+ assert_equal('proteosome component PRE4 [Saccharomyces cerevisiae]', annot.first)
13
13
  else
14
14
  assert_nil( puts("SKIPPING gi test (no internet connection available)") )
15
15
  end
data/test/tc_spec_id.rb CHANGED
@@ -126,7 +126,6 @@ class TestOccamsRazor < Test::Unit::TestCase
126
126
  prots[1].peps = [peps[2]] ## should be missing
127
127
 
128
128
  test_prots = prots[0,2]
129
- require 'pp'
130
129
  answ = SpecID.occams_razor(test_prots)
131
130
  answ.each do |an|
132
131
  assert( an[0].is_a?(SpecID::Prot), "prots are there")
@@ -135,6 +134,16 @@ class TestOccamsRazor < Test::Unit::TestCase
135
134
  assert_equal( prots[0], first[0])
136
135
  assert_equal_array_content( prots[0].peps, first[1])
137
136
 
137
+ require 'pp'
138
+ #pp answ
139
+
140
+
141
+ prots[0].peps = peps[0,4]
142
+ prots[1].peps = [peps[2]] ## should be missing
143
+ prots[2].peps = [] ## should be missing
144
+
145
+ answ = SpecID.occams_razor(test_prots, true)
146
+ #pp answ
138
147
 
139
148
 
140
149
  #prots[2].peps = [peps[2]]
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: mspire
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.2
7
- date: 2007-05-08 00:00:00 -05:00
6
+ version: 0.2.4
7
+ date: 2007-05-17 00:00:00 -05:00
8
8
  summary: Mass Spectrometry Proteomics Objects, Scripts, and Executables
9
9
  require_paths:
10
10
  - lib
@@ -63,9 +63,9 @@ files:
63
63
  - LICENSE
64
64
  - changelog.txt
65
65
  - release_notes.txt
66
+ - bin/bioworks_to_pepxml_gui.rb
66
67
  - bin/gi2annot.rb
67
68
  - bin/protein_summary.rb
68
- - bin/bioworks2sequestXML_gui.rb
69
69
  - bin/bioworks2excel.rb
70
70
  - bin/pepproph_filter.rb
71
71
  - bin/fasta_shaker.rb
@@ -129,9 +129,9 @@ extra_rdoc_files:
129
129
  - INSTALL
130
130
  - LICENSE
131
131
  executables:
132
+ - bioworks_to_pepxml_gui.rb
132
133
  - gi2annot.rb
133
134
  - protein_summary.rb
134
- - bioworks2sequestXML_gui.rb
135
135
  - bioworks2excel.rb
136
136
  - pepproph_filter.rb
137
137
  - fasta_shaker.rb
@@ -1,67 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'fox14'
4
-
5
- include Fox
6
-
7
- class DirListWindow < FXMainWindow
8
-
9
- def initialize(app)
10
- # Invoke the base class initialize first
11
- super(app, "Directory List", nil, nil, DECOR_ALL, 0, 0, 800, 600)
12
-
13
- # Make menu bar
14
- menubar = FXMenuBar.new(self, LAYOUT_FILL_X)
15
- filemenu = FXMenuPane.new(self)
16
- FXMenuCommand.new(filemenu, "&Quit\tCtl-Q", nil, getApp(), FXApp::ID_QUIT)
17
- FXMenuTitle.new(menubar, "&File", nil, filemenu)
18
- helpmenu = FXMenuPane.new(self)
19
- FXMenuCommand.new(helpmenu, "&About FOX...").connect(SEL_COMMAND) {
20
- FXMessageBox.information(self, MBOX_OK, "About FOX",
21
- "FOX is a really, really cool C++ library...\n" +
22
- "and FXRuby is an even cooler GUI for Ruby!")
23
- }
24
- matrix = FXMatrix.new(menubar, 2, MATRIX_BY_COLUMNS|LAYOUT_FILL_X)
25
- FXLabel.new(matrix, "sequest.params:", nil,
26
- JUSTIFY_LEFT|LAYOUT_FILL_X|LAYOUT_CENTER_Y)
27
-
28
- FXMenuTitle.new(menubar, "&Help", nil, helpmenu, LAYOUT_RIGHT)
29
-
30
- # Text field at bottom
31
- text = FXTextField.new(self, 10, nil, 0,
32
- LAYOUT_SIDE_BOTTOM|LAYOUT_FILL_X|FRAME_SUNKEN|FRAME_THICK)
33
-
34
- # Make contents
35
- dirlist = FXDirList.new(self, nil, 0, (HSCROLLING_OFF|
36
- TREELIST_SHOWS_LINES|TREELIST_SHOWS_BOXES|FRAME_SUNKEN|FRAME_THICK|
37
- LAYOUT_FILL_X|LAYOUT_FILL_Y), 0, 0, 0, 0)
38
-
39
- # Now make the directory list widget (dirlist) the message target
40
- # for the text field. If you type a new directory name in the text
41
- # field the directory list should navigate to that directory.
42
- text.target = dirlist
43
- text.selector = FXWindow::ID_SETVALUE
44
- end
45
-
46
- # Create and show the main window
47
- def create
48
- super
49
- show(PLACEMENT_SCREEN)
50
- end
51
- end
52
-
53
- def run
54
- # Make application
55
- application = FXApp.new("DirList", "FoxTest")
56
-
57
- # Make window
58
- DirListWindow.new(application)
59
-
60
- # Create app
61
- application.create
62
-
63
- # Run
64
- application.run
65
- end
66
-
67
- run