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 +4 -4
- data/.travis.yml +2 -0
- data/lib/genome/version.rb +1 -1
- data/lib/genome.rb +29 -6
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5963b94eac35dc1945565026cacafd56ddc49f30a7c84d3651003927f9eaddb
|
4
|
+
data.tar.gz: 02d7cacbe02be0eabea105c8cd7d844d42a7f6e17975ecdbf992652b9614047d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6e9b2fdee73663e1d36640ee18710fa5fc69edd9d0b39026f4235ff5bd74a02a41d9fc652f829248838546e2cb31c0fdff304fa2ade552761568c9c58bb19ff
|
7
|
+
data.tar.gz: ae82cc8aa908e531d9c7ad7ad4e4581b7c79d8a0e4267a1ba0fe94ef06877e3c4a41a66ac8896bd0ce6bfa5b48f135d8052cc450c07ec8d7e4611d56c811819c
|
data/.travis.yml
CHANGED
data/lib/genome/version.rb
CHANGED
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
|
-
|
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.
|
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-
|
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.
|
99
|
+
rubygems_version: 3.0.4
|
100
100
|
signing_key:
|
101
101
|
specification_version: 4
|
102
102
|
summary: ruby library to read genome data
|