Class: Coopy::IndexPair
- Inherits:
-
Object
- Object
- Coopy::IndexPair
- Defined in:
- lib/coopy/index_pair.rb
Instance Method Summary collapse
- #add_column(i) ⇒ Object
- #add_columns(ca, cb) ⇒ Object
- #get_quality ⇒ Object
- #get_top_freq ⇒ Object
- #index_tables(a, b) ⇒ Object
-
#initialize ⇒ IndexPair
constructor
A new instance of IndexPair.
- #query_by_content(row) ⇒ Object
- #query_by_key(ka) ⇒ Object
- #query_local(row) ⇒ Object
Constructor Details
Instance Method Details
#add_column(i) ⇒ Object
10 11 12 13 |
# File 'lib/coopy/index_pair.rb', line 10 def add_column(i) @ia.add_column i @ib.add_column i end |
#add_columns(ca, cb) ⇒ Object
15 16 17 18 |
# File 'lib/coopy/index_pair.rb', line 15 def add_columns(ca, cb) @ia.add_column ca @ib.add_column cb end |
#get_quality ⇒ Object
66 67 68 |
# File 'lib/coopy/index_pair.rb', line 66 def get_quality @quality end |
#get_top_freq ⇒ Object
62 63 64 |
# File 'lib/coopy/index_pair.rb', line 62 def get_top_freq [@ib.top_freq, @ia.top_freq].max end |
#index_tables(a, b) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/coopy/index_pair.rb', line 20 def index_tables(a, b) @ia.index_table a @ib.index_table b # calculate # P(present and unique within a AND present and unique with b) # for rows in a good = 0 @ia.items.keys.each do |key| item_a = @ia.items[key] spot_a = item_a.lst.length item_b = @ib.items[key] spot_b = 0; spot_b = item_b.lst.length if item_b if spot_a == 1 && spot_b == 1 good += 1 end end @quality = good / [1.0,a.height].max end |
#query_by_content(row) ⇒ Object
52 53 54 55 |
# File 'lib/coopy/index_pair.rb', line 52 def query_by_content(row) ka = @ia.to_key_by_content(row) query_by_key ka end |
#query_by_key(ka) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/coopy/index_pair.rb', line 40 def query_by_key(ka) result = CrossMatch.new result.item_a = @ia.items[ka] result.item_b = @ib.items[ka] result.spot_a = result.spot_b = 0 if ka != "" result.spot_a = result.item_a.lst.length if result.item_a result.spot_b = result.item_b.lst.length if result.item_b end result end |
#query_local(row) ⇒ Object
57 58 59 60 |
# File 'lib/coopy/index_pair.rb', line 57 def query_local(row) ka = @ia.to_key(@ia.get_table,row) query_by_key ka end |