mspire-simulator 0.1.2 → 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/lib/progress.rb CHANGED
@@ -1,24 +1,25 @@
1
1
 
2
- module Progress
3
- module_function
4
- def progress(message, num, time = '')
5
- # move cursor to beginning of line
6
- cr = "\r"
7
-
8
- # ANSI escape code to clear line from cursor to end of line
9
- # "\e" is an alternative to "\033"
10
- # cf. http://en.wikipedia.org/wiki/ANSI_escape_code
11
- clear = "\e[0K"
12
-
2
+ class Progress
3
+ # ANSI escape code to clear line from cursor to end of line
4
+ # "\e" is an alternative to "\033"
5
+ # cf. http://en.wikipedia.org/wiki/ANSI_escape_code
6
+ def initialize(message, time = nil)
7
+ @message = message
8
+ @time = time ? time : Time.now
9
+ @reset = "\r\e[0K"
10
+ end
11
+ def progress(num, message_addition = "")
12
+ message = @message+message_addition
13
13
  # reset lines
14
- reset = cr + clear
15
- if time == ''
16
- print "#{reset} #{message}" + "#{num}%".rjust(60-message.length)
17
- $stdout.flush
18
- else
19
- str = "#{reset} #{message}" + "#{num}%".rjust(60-message.length)
20
- print str + "Took: #{"%.2f" % time} sec.".rjust(100-str.length)
21
- $stdout.flush
22
- end
14
+ print "#{@reset} #{message}" + "#{num}%".rjust(60-message.length)
15
+ $stdout.flush
16
+ end
17
+ def finish!(message_addition = "")
18
+ time = Time.now - @time
19
+ message = @message + message_addition
20
+ str = "#{@reset} #{message}" + "100%".rjust(60-message.length)
21
+ print str + "Took: #{"%.2f" % time} sec.\n".rjust(100-str.length)
22
+ $stdout.flush
23
23
  end
24
+ alias :update :progress
24
25
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "mspire-simulator"
8
- s.version = "0.1.2"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["anoyce"]
12
- s.date = "2012-08-10"
12
+ s.date = "2012-12-13"
13
13
  s.description = "Simulates MS1 runs given amino acid FASTA files. Outputs an MZML file.\n\t\t\tCan simulate specific data if given an MZML file containing a single isolated peptide peak."
14
14
  s.email = "andrewbnoyce@gmail.com"
15
15
  s.executables = ["mspire-simulator", "sim_mail"]
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
  "VERSION",
25
25
  "bin/mspire-simulator",
26
26
  "bin/sim_mail",
27
+ "lib/cv_parser.rb",
27
28
  "lib/ms/curvefit.rb",
28
29
  "lib/ms/curvefit/curve_fit_helper.rb",
29
30
  "lib/ms/curvefit/fit_graph.rb",
@@ -49,14 +50,13 @@ Gem::Specification.new do |s|
49
50
  "spec/merger_spec.rb",
50
51
  "spec/ms-simulate_spec.rb",
51
52
  "spec/peptide_spec.rb",
52
- "spec/progress_spec.rb",
53
53
  "spec/spec_helper.rb",
54
54
  "spec/spectra_spec.rb"
55
55
  ]
56
- s.homepage = "http://dl.dropbox.com/u/42836826/Ms_Sim_Homepage.html"
56
+ s.homepage = "https://github.com/princelab/mspire-simulator"
57
57
  s.licenses = ["MIT"]
58
58
  s.require_paths = ["lib"]
59
- s.rubygems_version = "1.8.21"
59
+ s.rubygems_version = "1.8.24"
60
60
  s.summary = "Simulates MS1 runs given amino acid FASTA files. Outputs an MZML file."
61
61
 
62
62
  if s.respond_to? :specification_version then
@@ -1,4 +1,5 @@
1
-
1
+ $LOAD_PATH << './lib'
2
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
3
  require 'time'
3
4
  require 'mspire'
4
5
  require 'ms/sim_spectra'
data/spec/merger_spec.rb CHANGED
@@ -1,4 +1,5 @@
1
-
1
+ $LOAD_PATH << './lib'
2
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
3
  require 'ms/merger'
3
4
 
4
5
  describe Merger do
@@ -3,7 +3,7 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
 
4
4
  describe "MSsimulate" do
5
5
  it "Gathers parameters from the cmd line and runs the simulator; If no params are given or --help a help message is displayed" do
6
- output = `ruby bin/ms-simulate.rb --help`
6
+ output = `ruby bin/mspire-simulator --help`
7
7
  output.should =~ /where/
8
8
  end
9
9
  end
data/spec/peptide_spec.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  #peptide_spec.rb
2
-
2
+ $LOAD_PATH << './lib'
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
4
  require 'mspire'
4
5
  require 'ms/sim_peptide'
5
6
 
data/spec/spec_helper.rb CHANGED
@@ -2,10 +2,15 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
2
  $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
4
 
5
- # Requires supporting files with custom matchers and macros, etc,
6
- # in ./support/ and its subdirectories.
7
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
5
+ Dir["#{File.dirname(__FILE__)}/lib/**/*.rb"].each {|f| require f}
8
6
 
9
7
  RSpec.configure do |config|
8
+
9
+ config.before(:all) do
10
+ system("mkdir .m .i")
11
+ system("mkdir .m/A .m/R .m/N .m/D .m/C .m/E .m/Q .m/G .m/H .m/I .m/L .m/K .m/M .m/F .m/P .m/S .m/T .m/W .m/Y .m/V .m/U .m/O")
12
+ system("mkdir .i/A .i/R .i/N .i/D .i/C .i/E .i/Q .i/G .i/H .i/I .i/L .i/K .i/M .i/F .i/P .i/S .i/T .i/W .i/Y .i/V .i/U .i/O")
13
+ end
10
14
 
15
+ config.after(:all) {system("rm -r -f .m .i")}
11
16
  end
data/spec/spectra_spec.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  #spectra_spec.rb
2
-
2
+ $LOAD_PATH << './lib'
3
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
4
  require 'mspire'
4
5
  require 'ms/sim_spectra'
5
6
  require 'ms/sim_peptide'
@@ -91,8 +92,8 @@ describe MS::Sim_Spectra do
91
92
  end
92
93
 
93
94
  it "Each feature should have a predicted retention time and intensity" do
94
- p_rts = [(2079..2082),(1774..1777),(1400..1402)]
95
- p_ints = [2.325,2.927,3.559]
95
+ p_rts = [(823..826),(769..772),(1485..1490)]
96
+ p_ints = [2.058,2.095,2.219]
96
97
  @spectra.features.each_with_index do |fe,i|
97
98
  p_rts[i].should cover(fe.p_rt)
98
99
  fe.p_int.should == p_ints[i]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mspire-simulator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-10 00:00:00.000000000 Z
12
+ date: 2012-12-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mspire
@@ -189,6 +189,7 @@ files:
189
189
  - VERSION
190
190
  - bin/mspire-simulator
191
191
  - bin/sim_mail
192
+ - lib/cv_parser.rb
192
193
  - lib/ms/curvefit.rb
193
194
  - lib/ms/curvefit/curve_fit_helper.rb
194
195
  - lib/ms/curvefit/fit_graph.rb
@@ -214,10 +215,9 @@ files:
214
215
  - spec/merger_spec.rb
215
216
  - spec/ms-simulate_spec.rb
216
217
  - spec/peptide_spec.rb
217
- - spec/progress_spec.rb
218
218
  - spec/spec_helper.rb
219
219
  - spec/spectra_spec.rb
220
- homepage: http://dl.dropbox.com/u/42836826/Ms_Sim_Homepage.html
220
+ homepage: https://github.com/princelab/mspire-simulator
221
221
  licenses:
222
222
  - MIT
223
223
  post_install_message:
@@ -238,7 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
238
238
  version: '0'
239
239
  requirements: []
240
240
  rubyforge_project:
241
- rubygems_version: 1.8.21
241
+ rubygems_version: 1.8.24
242
242
  signing_key:
243
243
  specification_version: 3
244
244
  summary: Simulates MS1 runs given amino acid FASTA files. Outputs an MZML file.
@@ -1,22 +0,0 @@
1
- #progress_spec.rb
2
-
3
- require 'progress'
4
- require 'time'
5
-
6
- describe Progress, "#progress" do
7
- it "Prints out a given message and percentage, refreshing the current line with each call." do
8
- 101.times do |i|
9
- Progress.progress("Message:",i)
10
- sleep 0.01
11
- end
12
- end
13
-
14
- it "Also can take a final time to show how long a process took." do
15
- start = Time.now
16
- 101.times do |i|
17
- Progress.progress("Message:",i)
18
- sleep 0.01
19
- end
20
- Progress.progress("Message:",100,Time.now - start)
21
- end
22
- end