bio-express_beta_diversity 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 15dff506cc2fe193776349c0e11f50141ef337a8
4
+ data.tar.gz: d9ca06baedd0dc7d991449d89c1925d57527f920
5
+ SHA512:
6
+ metadata.gz: 29b6931c8c18978fe5581aae21429ab2b77eccefea585aaf7c3adff91ad415ddcf0d1b96464ff5b5851308b12bf73d24882c4e4a9e86c83986a2537eff7072a8
7
+ data.tar.gz: 937c29d85243dfff76a3bb60e868ae80039f3d162321774996b77f7a5601f85ad13286bec0e7c4474e8ac535f46ce9a72de03d286375e5670f038e0228f8d895
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+
7
+ # - rbx-19mode
8
+ # - 1.8.7
9
+ # - jruby-18mode # JRuby in 1.8 mode
10
+ # - rbx-18mode
11
+
12
+ # uncomment this line if your project needs to run something other than `rake`:
13
+ # script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,15 @@
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-logger', '~>1.0'
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 "rspec", "~> 2.8"
11
+ gem "rdoc", "~> 3.12"
12
+ gem "jeweler", "~> 2.0"
13
+ gem "bundler", "~> 1.3"
14
+ gem "bio", "~> 1.4"
15
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Ben J. Woodcroft
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ # bio-express_beta_diversity
2
+
3
+ [![Build Status](https://secure.travis-ci.org/wwood/bioruby-express_beta_diversity.png)](http://travis-ci.org/wwood/bioruby-express_beta_diversity)
4
+
5
+ Ruby interface to [express beta diversity](https://github.com/dparks1134/ExpressBetaDiversity) things. Currently, functionality is limited to parsing the output distance matrices.
6
+
7
+ Note: this software is under active development!
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ gem install bio-express_beta_diversity
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ruby
18
+ require 'bio-express_beta_diversity'
19
+
20
+ dists = Bio::EBD::DistanceMatrix.parse_from_file 'Bray-Curtis.cluster.diss'
21
+ dists.sample_names #=> ["sample1", "sample2", ... ]
22
+ dists.distance('sample1','sample2') #=> 0.251761
23
+ dists.distance('sample2','sample1') #=> 0.251761
24
+
25
+ ```
26
+
27
+ The API doc is online. For more code examples see the test files in
28
+ the source tree.
29
+
30
+ ## Project home page
31
+
32
+ Information on the source tree, documentation, examples, issues and
33
+ how to contribute, see
34
+
35
+ http://github.com/wwood/bioruby-express_beta_diversity
36
+
37
+ ## Cite
38
+
39
+ If you use this software, please cite one of
40
+
41
+ * [BioRuby: bioinformatics software for the Ruby programming language](http://dx.doi.org/10.1093/bioinformatics/btq475)
42
+ * [Biogem: an effective tool-based approach for scaling up open source software development in bioinformatics](http://dx.doi.org/10.1093/bioinformatics/bts080)
43
+
44
+ ## Biogems.info
45
+
46
+ This Biogem is published at (http://biogems.info/index.html#bio-express_beta_diversity)
47
+
48
+ ## Copyright
49
+
50
+ Copyright (c) 2013 Ben J. Woodcroft. See LICENSE.txt for further details.
51
+
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "bio-express_beta_diversity"
18
+ gem.homepage = "http://github.com/wwood/bioruby-express_beta_diversity"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Interface for express beta diversity}
21
+ gem.description = %Q{Interface for express beta diversity file formats}
22
+ gem.email = "donttrustben near gmail.com"
23
+ gem.authors = ["Ben J. Woodcroft"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "bio-express_beta_diversity #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,14 @@
1
+
2
+ require 'bio-logger'
3
+ Bio::Log::LoggerPlus.new('bio-velvet')
4
+ module Bio::Velvet
5
+ module Logging
6
+ def log
7
+ Bio::Log::LoggerPlus['bio-velvet']
8
+ end
9
+ end
10
+ end
11
+
12
+
13
+ require 'bio-express_beta_diversity/distance_matrix.rb'
14
+
@@ -0,0 +1,60 @@
1
+ require 'pp'
2
+ require 'csv'
3
+
4
+ module Bio
5
+ class EBD
6
+ # Distance matrix output from express beta diversity (Donovan Parks et al).
7
+ # Similar to phylip distance format, but not quite the same.
8
+ class DistanceMatrix
9
+ attr_accessor :distance_matrix
10
+ attr_accessor :sample_names
11
+
12
+ def initialize
13
+ @distance_matrix = []
14
+ @sample_names = []
15
+ end
16
+
17
+ def self.parse_from_file(filename)
18
+ ebd = Bio::EBD::DistanceMatrix.new
19
+
20
+ line = 1
21
+ expected_number_of_samples = nil
22
+ CSV.foreach(filename, :col_sep => "\t") do |row|
23
+ if line == 1
24
+ # First line is the number of samples
25
+ raise "Parse exception at this row: #{row.inspect}, expected" unless row.length == 1
26
+ expected_number_of_samples = row[0].to_i
27
+ else
28
+ # all other lines are the sample names and then the lower
29
+ # triangular distance matrix
30
+ sample_index = line-2
31
+ raise "Parse exception at this row: #{row.inspect}" unless row.length == sample_index+1
32
+ ebd.sample_names.push row[0]
33
+
34
+ distances = row[1...row.length].collect{|d| d.to_f}
35
+ ebd.distance_matrix[sample_index] = distances
36
+ end
37
+ line += 1
38
+ end
39
+
40
+ return ebd
41
+ end
42
+
43
+ def number_of_samples
44
+ @sample_names.length
45
+ end
46
+
47
+ # Return the floating point distance between a pair of samples
48
+ def distance(sample1, sample2)
49
+ index1 = @sample_names.find_index{|n| n==sample1}
50
+ index2 = @sample_names.find_index{|n| n==sample2}
51
+ raise "error extracting the EBD distance between #{sample1.inspect} and #{sample2.inspect}" unless index1 and index2 and index2 != index1
52
+ if index1 > index2
53
+ return @distance_matrix[index1][index2]
54
+ else
55
+ return @distance_matrix[index2][index1]
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "BioExpressBetaDiversity" do
4
+ it "should parse a distance matrix" do
5
+ eg = File.expand_path(File.dirname(__FILE__) + '/data/eg.diss')
6
+ d = Bio::EBD::DistanceMatrix.parse_from_file(eg)
7
+
8
+ #3
9
+ #4459
10
+ #4446 0.255099
11
+ #4451 0.258384 0.364525
12
+ d.number_of_samples.should == 3
13
+ d.distance_matrix.length.should == 3
14
+ d.distance_matrix[0].should == []
15
+ d.distance_matrix[1].should == [0.255099]
16
+ d.distance_matrix[2].should == [0.258384, 0.364525]
17
+ d.sample_names.should == %w(4459 4446 4451)
18
+ d.distance('4446','4451').should == 0.364525
19
+ d.distance('4451','4446').should == 0.364525
20
+ end
21
+ end
@@ -0,0 +1,4 @@
1
+ 3
2
+ 4459
3
+ 4446 0.255099
4
+ 4451 0.258384 0.364525
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'bio-express_beta_diversity'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bio-express_beta_diversity
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ben J. Woodcroft
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bio-logger
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.8'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.8'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.12'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.12'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bio
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.4'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.4'
97
+ description: Interface for express beta diversity file formats
98
+ email: donttrustben near gmail.com
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files:
102
+ - LICENSE.txt
103
+ - README.md
104
+ files:
105
+ - ".document"
106
+ - ".rspec"
107
+ - ".travis.yml"
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - VERSION
113
+ - lib/bio-express_beta_diversity.rb
114
+ - lib/bio-express_beta_diversity/distance_matrix.rb
115
+ - spec/bio-express_beta_diversity_spec.rb
116
+ - spec/data/eg.diss
117
+ - spec/spec_helper.rb
118
+ homepage: http://github.com/wwood/bioruby-express_beta_diversity
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.2.0.rc.1
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Interface for express beta diversity
142
+ test_files: []