gene-matcher 0.1.4 → 0.1.6

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: 3d31a639b4faa8f8c6b0625564377d8e43e2acd18e5aba9de696e04dd2c6de60
4
- data.tar.gz: cea3e517c62db70b871dca04869622a3a5d89abaf618e0d3b36851a57ecb82fd
3
+ metadata.gz: 16d36396bec9b08dc0cd41f911274feef3b444c7c5408e406b528d627f74e92b
4
+ data.tar.gz: 71f75988056e3de2a0e022ed7b501e88209866f373e753e471298462ff7f428e
5
5
  SHA512:
6
- metadata.gz: ad793ca6d4bb5e5b01bbf019e47d0835dbdbb02327683ffa68d82e10101bfb0b0b3c8202a8d0050b56cce0d9d209e03b5d045ec218b57e12fcc222f716697665
7
- data.tar.gz: 87c261393441dbe6ac39ff701b2c73201beddddad184c6e0379a53aa9d25ee05609ec95a03ca7576b4c03aaf66ca0e282fedb34d5bb4a8478b1e615d9c91a128
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"]
@@ -39,6 +36,21 @@ class Alignment
39
36
  @source = h["source"]
40
37
  end
41
38
 
39
+ def to_h
40
+ # ハッシュに変換
41
+ h = {}
42
+ h["alignmentI"] = @alignmentI
43
+ h["alignmentJ"] = @alignmentJ
44
+ h["startI"] = @startI
45
+ h["startJ"] = @startJ
46
+ h["endI"] = @endI
47
+ h["endJ"] = @endJ
48
+ h["reversed"] = @reversed
49
+ h["aside"] = @aside
50
+ h["source"] = @source
51
+ return h
52
+ end
53
+
42
54
  # 二つの配列の一致部分と不一致部分を表した文字列を返す。
43
55
  # ex. AGTCAAAAAAAAA- :...:::::::::. AT-TAAAAAAAAAG
44
56
  #
@@ -71,7 +83,17 @@ class Alignment
71
83
  def number_of_blank
72
84
  end
73
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
+
74
96
  def to_s
75
- "score=#{@score} I=" + @alignmentI + " J=" + @alignmentJ;
97
+ "score=#{score} I=" + @alignmentI + " J=" + @alignmentJ;
76
98
  end
77
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.4
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