gene-matcher 0.1.5 → 0.1.7

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: f451b24184e517be0bfdf398c1ad227be0c956a7e3173f7a31a45530af64291d
4
- data.tar.gz: ee44f41ce12e8ac4a311c58a59339621230513bbe6202083bae3f044f830f4c6
3
+ metadata.gz: b8157bdd5dae107a5180e78d51de4a146b0768b4d8d8b8e638e61ec23ad8d6c6
4
+ data.tar.gz: 4dc38fa6ecccd8a31f77e96a672ee76d047f55af4957a28bf931c75a8483d45d
5
5
  SHA512:
6
- metadata.gz: 7237131d90e3fed9a1f935c818bd75c8179a3de6a0bbcf4b7073cced5c3bc314a769680e73cfe46f3f228328427e447e0ee7fb22ec632920eea0b14c29510c98
7
- data.tar.gz: 27614deb05f5649814174f3c5e4f8b771d3610c4dd9d8034409326f7dff77a32140e1fd038e6f055b1aa1661f0d3ea7ffe18cd0856617bd30c524ef5a28ee9b2
6
+ metadata.gz: 5333cfbcc037c18bb67cb140d49018af1e696260ff6268e4c1f5a968e4753fc138425bba5fd96f1928ef9cece8200a957a4f1607ec99ed792f64dff0ea0f77e4
7
+ data.tar.gz: fc5ff17d69865a118262ec29da7127bf2eae5e7aadad22697bc5c606e668acbccbd848b6caa470be9eafac04dd2dcc5e364a7cb876eab95f659d6d73d2931056
data/lib/alignment.rb CHANGED
@@ -1,12 +1,10 @@
1
1
  class Alignment
2
- attr_accessor :score, :alignmentI, :alignmentJ, :startI, :startJ, :endI, :endJ, :reversed, :aside, :source
2
+ attr_accessor :alignmentI, :alignmentJ, :startI, :startJ, :endI, :endJ, :reversed, :aside, :source
3
3
 
4
4
  BLANK = "-"
5
5
 
6
6
  def initialize(h=nil)
7
7
  return init_from_hash(h) if h
8
- # スコア
9
- @score = 0
10
8
  # 検索対象(データベースに入っていた)配列
11
9
  @alignmentI = ""
12
10
  # 検索した(クエリ=入力された)配列
@@ -27,7 +25,6 @@ class Alignment
27
25
 
28
26
  def init_from_hash(h)
29
27
  # 引数のハッシュから初期化
30
- @score = h["score"]
31
28
  @alignmentI = h["alignmentI"]
32
29
  @alignmentJ = h["alignmentJ"]
33
30
  @startI = h["startI"]
@@ -42,7 +39,6 @@ class Alignment
42
39
  def to_h
43
40
  # ハッシュに変換
44
41
  h = {}
45
- h["score"] = @score
46
42
  h["alignmentI"] = @alignmentI
47
43
  h["alignmentJ"] = @alignmentJ
48
44
  h["startI"] = @startI
@@ -87,7 +83,18 @@ class Alignment
87
83
  def number_of_blank
88
84
  end
89
85
 
86
+ def score_a
87
+ return 0 if @alignmentI.length == 0
88
+ return alignment_count / @alignmentI.length.to_f
89
+ end
90
+
91
+ def score(thresh=20)
92
+ # 長さがthresh以下なら0を返す
93
+ return 0 if @alignmentI.length < thresh
94
+ return alignment_count * score_a
95
+ end
96
+
90
97
  def to_s
91
- "score=#{@score} I=" + @alignmentI + " J=" + @alignmentJ;
98
+ "score=#{score} I=" + @alignmentI + " J=" + @alignmentJ;
92
99
  end
93
100
  end
data/lib/gene-matcher.rb CHANGED
@@ -14,8 +14,9 @@ class Matcher
14
14
  def scan(target_sequence,source = {})
15
15
  sw = SmithWaterman.instance
16
16
  a = sw.alignment(target_sequence, @input_sequence)
17
- a.source = source
18
- @alignments += [a] if a.score >= @limit
17
+ a.source = {target_sequence: target_sequence}.merge(source)
18
+ puts "#{a.score} / #{a.alignment_count} = #{a.score / a.alignment_count}" if ENV["DEBUG"]
19
+ @alignments += [a] if a.score / a.alignment_count >= @limit
19
20
  end
20
21
  end
21
22
 
@@ -88,11 +88,7 @@ class SmithWaterman
88
88
  a.startI = i
89
89
  a.startJ = j
90
90
 
91
- if a.alignmentI.length <= 20
92
- a.score = 0
93
- else
94
- a.score = a.alignment_count ** 2 / a.alignmentI.length.to_f
95
- end
91
+ # スコアはここでは求めない(Java版ではここで決定していた)
96
92
  return a
97
93
  end
98
94
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gene-matcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITO Yosei
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-31 00:00:00.000000000 Z
11
+ date: 2023-09-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Algorithm for determining similar regions between nucleic acid sequences.
14
14
  email: y-itou@lumber-mill.co.jp