ms-core 0.0.17 → 0.0.18

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,12 +1,4 @@
1
1
  require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
2
  require 'rake'
11
3
 
12
4
  require 'jeweler'
@@ -16,11 +8,13 @@ Jeweler::Tasks.new do |gem|
16
8
  gem.homepage = "http://github.com/jtprince/ms-core"
17
9
  gem.license = "MIT"
18
10
  gem.summary = %Q{basic, shared functionality for mspire libraries}
19
- gem.description = %Q{basic, shared functionality for mspire libraries}
11
+ gem.description = %Q{basic, shared functionality for mspire libraries.}
20
12
  gem.email = "jtprince@gmail.com"
21
13
  gem.authors = ["John T. Prince", "Simon Chiang"]
22
14
  gem.rubyforge_project = 'mspire'
23
- # Dependencies in Gemfile
15
+ gem.add_runtime_dependency 'bio', '>= 1.4.1'
16
+ gem.add_development_dependency "spec-more", ">= 0"
17
+ gem.add_development_dependency "jeweler", "~> 1.5.2"
24
18
  end
25
19
  Jeweler::RubygemsDotOrgTasks.new
26
20
 
@@ -31,12 +25,12 @@ Rake::TestTask.new(:spec) do |spec|
31
25
  spec.verbose = true
32
26
  end
33
27
 
34
- require 'rcov/rcovtask'
35
- Rcov::RcovTask.new do |spec|
36
- spec.libs << 'spec'
37
- spec.pattern = 'spec/**/*_spec.rb'
38
- spec.verbose = true
39
- end
28
+ #require 'rcov/rcovtask'
29
+ #Rcov::RcovTask.new do |spec|
30
+ # spec.libs << 'spec'
31
+ # spec.pattern = 'spec/**/*_spec.rb'
32
+ # spec.verbose = true
33
+ #end
40
34
 
41
35
  task :default => :spec
42
36
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.17
1
+ 0.0.18
data/lib/ms/fasta.rb CHANGED
@@ -55,5 +55,31 @@ module Ms
55
55
  Bio::FlatFile.new(Bio::FastaFormat, io)
56
56
  end
57
57
 
58
+ # returns two hashes [id_to_length, id_to_description]
59
+ # faster (~4x) than official route.
60
+ def self.protein_lengths_and_descriptions(file)
61
+ protid_to_description = {}
62
+ protid_to_length = {}
63
+ re = /^>([^\s]+) (.*)/
64
+ ids = []
65
+ lengths = []
66
+ current_length = nil
67
+ IO.foreach(file) do |line|
68
+ line.chomp!
69
+ if md=re.match(line)
70
+ lengths << current_length
71
+ current_id = md[1]
72
+ ids << current_id
73
+ current_length = 0
74
+ protid_to_description[current_id] = md[2]
75
+ else
76
+ current_length += line.size
77
+ end
78
+ end
79
+ lengths << current_length
80
+ lengths.shift # remove the first nil entry
81
+ [Hash[ids.zip(lengths).to_a], protid_to_description]
82
+ end
83
+
58
84
  end
59
85
  end
@@ -41,6 +41,10 @@ describe 'basic fasta operations' do
41
41
  end
42
42
  end
43
43
 
44
+ xit 'can deliver length and description hashes' do
45
+ # need to test
46
+ end
47
+
44
48
  it 'can read a file' do
45
49
  %w(newlines_file carriage_returns_and_newlines_file).each do |file|
46
50
  Ms::Fasta.open(@data[file]) do |fasta|
data/spec/spec_helper.rb CHANGED
@@ -1,13 +1,4 @@
1
1
  require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'benchmark'
11
2
  require 'spec/more'
12
3
 
13
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 17
9
- version: 0.0.17
8
+ - 18
9
+ version: 0.0.18
10
10
  platform: ruby
11
11
  authors:
12
12
  - John T. Prince
@@ -15,11 +15,12 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-09 00:00:00 -07:00
18
+ date: 2011-03-31 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: bio
23
+ prerelease: false
23
24
  requirement: &id001 !ruby/object:Gem::Requirement
24
25
  none: false
25
26
  requirements:
@@ -31,10 +32,10 @@ dependencies:
31
32
  - 1
32
33
  version: 1.4.1
33
34
  type: :runtime
34
- prerelease: false
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: spec-more
38
+ prerelease: false
38
39
  requirement: &id002 !ruby/object:Gem::Requirement
39
40
  none: false
40
41
  requirements:
@@ -44,26 +45,11 @@ dependencies:
44
45
  - 0
45
46
  version: "0"
46
47
  type: :development
47
- prerelease: false
48
48
  version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: bundler
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
54
- - - ~>
55
- - !ruby/object:Gem::Version
56
- segments:
57
- - 1
58
- - 0
59
- - 0
60
- version: 1.0.0
61
- type: :development
62
- prerelease: false
63
- version_requirements: *id003
64
49
  - !ruby/object:Gem::Dependency
65
50
  name: jeweler
66
- requirement: &id004 !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
67
53
  none: false
68
54
  requirements:
69
55
  - - ~>
@@ -74,22 +60,8 @@ dependencies:
74
60
  - 2
75
61
  version: 1.5.2
76
62
  type: :development
77
- prerelease: false
78
- version_requirements: *id004
79
- - !ruby/object:Gem::Dependency
80
- name: rcov
81
- requirement: &id005 !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- segments:
87
- - 0
88
- version: "0"
89
- type: :development
90
- prerelease: false
91
- version_requirements: *id005
92
- description: basic, shared functionality for mspire libraries
63
+ version_requirements: *id003
64
+ description: basic, shared functionality for mspire libraries.
93
65
  email: jtprince@gmail.com
94
66
  executables: []
95
67
 
@@ -98,8 +70,6 @@ extensions: []
98
70
  extra_rdoc_files:
99
71
  - README.rdoc
100
72
  files:
101
- - Gemfile
102
- - Gemfile.lock
103
73
  - History
104
74
  - MIT-LICENSE
105
75
  - README.rdoc
@@ -144,7 +114,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
114
  requirements:
145
115
  - - ">="
146
116
  - !ruby/object:Gem::Version
147
- hash: 268691801649348521
148
117
  segments:
149
118
  - 0
150
119
  version: "0"
data/Gemfile DELETED
@@ -1,14 +0,0 @@
1
- source "http://rubygems.org"
2
- # Add dependencies required to use your gem here.
3
- # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
- gem 'bio', '>= 1.4.1'
6
-
7
- # Add dependencies to develop your gem here.
8
- # Include everything needed to run rake, tests, features, etc.
9
- group :development do
10
- gem "spec-more", ">= 0"
11
- gem "bundler", "~> 1.0.0"
12
- gem "jeweler", "~> 1.5.2"
13
- gem "rcov", ">= 0"
14
- end
data/Gemfile.lock DELETED
@@ -1,24 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- bacon (1.1.0)
5
- bio (1.4.1)
6
- git (1.2.5)
7
- jeweler (1.5.2)
8
- bundler (~> 1.0.0)
9
- git (>= 1.2.5)
10
- rake
11
- rake (0.8.7)
12
- rcov (0.9.9)
13
- spec-more (0.0.4)
14
- bacon
15
-
16
- PLATFORMS
17
- ruby
18
-
19
- DEPENDENCIES
20
- bio (>= 1.4.1)
21
- bundler (~> 1.0.0)
22
- jeweler (~> 1.5.2)
23
- rcov
24
- spec-more