genome-rb 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 720d3f90b716800b67257c44ccacec7d8e2f06d79c19047a2d0a0df51c68c97c
4
- data.tar.gz: 03bb58c453382af625ed4e85bbd11efcfbec4e7c4f36ff5c1e47e64cb41408cb
3
+ metadata.gz: f5963b94eac35dc1945565026cacafd56ddc49f30a7c84d3651003927f9eaddb
4
+ data.tar.gz: 02d7cacbe02be0eabea105c8cd7d844d42a7f6e17975ecdbf992652b9614047d
5
5
  SHA512:
6
- metadata.gz: 59e51076ee77934ffe20cb6a5d5b0a78eef008c5d64a3126880716821ef6397ac4020a974470fade6abf128fe3003e480ffaff1800e60bfc4f4a69e8190e68b0
7
- data.tar.gz: 6841cfc17e64cf6ecf671b68d07a5c892cf962dba3a77f59f3f04ef2138838a1503a887e94eded214e0aae6465f1d5560e1ba9297e5f1ed1ac4f20d52af7a273
6
+ metadata.gz: e6e9b2fdee73663e1d36640ee18710fa5fc69edd9d0b39026f4235ff5bd74a02a41d9fc652f829248838546e2cb31c0fdff304fa2ade552761568c9c58bb19ff
7
+ data.tar.gz: ae82cc8aa908e531d9c7ad7ad4e4581b7c79d8a0e4267a1ba0fe94ef06877e3c4a41a66ac8896bd0ce6bfa5b48f135d8052cc450c07ec8d7e4611d56c811819c
data/.travis.yml CHANGED
@@ -14,3 +14,5 @@ deploy:
14
14
  gem: genome-rb
15
15
  on:
16
16
  repo: marigenhq/genome-rb
17
+ ruby: 2.5.5
18
+ branch: master
@@ -1,3 +1,3 @@
1
1
  module GENOME
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
data/lib/genome.rb CHANGED
@@ -1,7 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'genome/version'
2
4
 
5
+ class ProviderError < StandardError
6
+ def initialize(message = 'ProviderError')
7
+ super(message)
8
+ end
9
+ end
10
+
11
+ class FileTypeError < StandardError
12
+ def initialize(message = 'FileTypeError')
13
+ super(message)
14
+ end
15
+ end
16
+
3
17
  module GENOME
4
- class Error < StandardError; end
5
18
  # Your code goes here...
6
19
  autoload :Genome, 'genome/genome'
7
20
  autoload :SNP, 'genome/snp'
@@ -25,15 +38,25 @@ module GENOME
25
38
  end
26
39
 
27
40
  def self.load(_filename, _provider = '23andme')
41
+ raise ProviderError, "#{_provider} is not supported." unless %w[23andme ancestry].include? _provider
42
+
43
+ first_line = File.open(_filename, &:readline)
44
+ if _provider == '23andme'
45
+ raise FileTypeError, "#{_filename} is not in a correct #{_provider} format" unless first_line.downcase.include? '23'.downcase
46
+ elsif _provider == 'ancestry'
47
+ raise FileTypeError, "#{_filename} is not in a correct #{_provider} format" unless first_line.downcase.include? 'ancestry'.downcase
48
+ end
49
+
28
50
  genome = Genome.new(name = _filename)
51
+ reader = if _provider == '23andme'
52
+ :ttandme_reader
53
+ elsif _provider == 'ancestry'
54
+ :ancestry_reader
55
+ end
29
56
  File.open(_filename).each do |line|
30
57
  next if line.start_with?('#') || line.start_with?('rsid')
31
58
 
32
- if _provider.casecmp? '23andme'
33
- rsid, snp = ttandme_reader line
34
- else
35
- rsid, snp = ancestry_reader line
36
- end
59
+ rsid, snp = send reader, line
37
60
  genome[rsid] = snp
38
61
  end
39
62
  genome
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genome-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gary Lai
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-05-27 00:00:00.000000000 Z
11
+ date: 2019-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -96,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  requirements: []
99
- rubygems_version: 3.0.3
99
+ rubygems_version: 3.0.4
100
100
  signing_key:
101
101
  specification_version: 4
102
102
  summary: ruby library to read genome data