gene-matcher 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f451b24184e517be0bfdf398c1ad227be0c956a7e3173f7a31a45530af64291d
4
- data.tar.gz: ee44f41ce12e8ac4a311c58a59339621230513bbe6202083bae3f044f830f4c6
3
+ metadata.gz: 16d36396bec9b08dc0cd41f911274feef3b444c7c5408e406b528d627f74e92b
4
+ data.tar.gz: 71f75988056e3de2a0e022ed7b501e88209866f373e753e471298462ff7f428e
5
5
  SHA512:
6
- metadata.gz: 7237131d90e3fed9a1f935c818bd75c8179a3de6a0bbcf4b7073cced5c3bc314a769680e73cfe46f3f228328427e447e0ee7fb22ec632920eea0b14c29510c98
7
- data.tar.gz: 27614deb05f5649814174f3c5e4f8b771d3610c4dd9d8034409326f7dff77a32140e1fd038e6f055b1aa1661f0d3ea7ffe18cd0856617bd30c524ef5a28ee9b2
6
+ metadata.gz: 47f79bf0bf8be63ada87103503d2ec0ef7717cf2d008ff836dbf9d5582c035f082e6049bb3add93c6130c15024a015bb7f52aa8f04300963cafed1119a0f1d4c
7
+ data.tar.gz: 38e05772aacdd96a57d43ff0cb16f19c00adf300c083d85b6fbb93cbb0449ab51212981d94ef1cbe5a38c542fa707d9bd9cb39dc0b58b3a3782ed9f5ab5eeda5
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,17 @@ class Alignment
87
83
  def number_of_blank
88
84
  end
89
85
 
86
+ def score_a
87
+ return alignment_count / @alignmentI.length.to_f
88
+ end
89
+
90
+ def score(thresh=20)
91
+ # 長さがthresh以下なら0を返す
92
+ return 0 if @alignmentI.length < thresh
93
+ return alignment_count * score_a
94
+ end
95
+
90
96
  def to_s
91
- "score=#{@score} I=" + @alignmentI + " J=" + @alignmentJ;
97
+ "score=#{score} I=" + @alignmentI + " J=" + @alignmentJ;
92
98
  end
93
99
  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.6
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