view · edit · sidebar · attach · print · history

20120625-anwendung-search-update-drugbank-link

<< | Index | >>


Summary

  • Updated Drugbank link
    • added support for Markenname search.
    • updated link page for multi drugbank records (to search result).
    • added plugin test.
  • Fixed Data-Corruption probelm by Updater.

Commits

Index


Added support drugbank lik for Markenname search

Problem

ATC class has DrugBank ID data, But some search results don't have a link in Markenname search. (Currently, If a ATC code has multi related records in drugbank.ca, then ATC class of oddb.org has first one only.)

z.B.

(drugbank.ca => http://www.drugbank.ca/search?utf8=✓&query=C03DA01&commit=Search)

ch.oddb> registration('27257').sequence('01').atc_class
-> Spironolacton
ch.oddb> registration('27257').sequence('01').atc_class.code
-> C03DA01
ch.oddb> registration('27257').sequence('01').atc_class.ni_id
-> NI_11110
ch.oddb> registration('27257').sequence('01').atc_class.db_id
-> DB00421

ATC class has correct ID.
SearchResult(ATCFacade) has strange value.

in src/mode/search_result.rb

module ODDB
  class SearchResult
    ...
    def db_id
      p @atc.class
      p @atc.code
      p @atc.odba_id
      p @atc.db_id
      @atc.db_id
    end
# =>
ODDB::AtcClass
"C03DA01"
28759059
nil

ATCFacade is not persistable Object.

ch.oddb> ODBA.cache.fetch('28759059')
-> Unknown odba_id 28759059

found where is prbolem comes form.

in src/util/oddbapp.rb

  def _search_exact_classified_result(sequences, type=:unknown, result=nil)
    atc_classes = {} 
    sequences.each { |seq|
      code = (atc = seq.atc_class) ? atc.code : 'n.n'
      new_atc = atc_classes.fetch(code) {
        atc_class = ODDB::AtcClass.new(code)
        unless(atc.nil?)
          atc_class.descriptions = atc.descriptions
->        atc_class.db_id = atc.db_id
          atc_class.ni_id = atc.ni_id
        end  
       ...
  end

added drugbank link support to markenname search.

commit

Update drugbank link

Currently, If multi records are found in result of drugbank.ca, ATC has only id of first one.
I updated Updater-Job that ATC has ids as Array in this case.

And created simple testcase for this plugin.

commit
test result
$ ruby test/test_plugin/drugbank.rb
# =>
Loaded suite test/test_plugin/drugbank
Started
......

Finished in 15.004181795 seconds.

6 tests, 22 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

0.40 tests/s, 1.47 assertions/s

Anwendung search

  • replace Indikation(search type is :st_indication.) with Anwendung
  • :search_type_selection of lookandfeel.

in src/view/searchbar.rb

module SearchBarMethods
  def search_type(model, session=@session)
    select = HtmlGrid::Select.new(:search_type, model, @session, self)
    if(@lookandfeel.respond_to?(:search_type_selection))
      select.valid_values = @lookandfeel.search_type_selection
    end 
    select.set_attribute('onChange', 'this.form.onsubmit();')
    select.selected = @session.persistent_user_input(:search_type)
    select
  end 
end
NOTE (search of st_indication)
  • st_indication (src/state/global.rb)
    • search_exact_indication(query, lang) (src/util/oddbapp.rb)
      • search_by_indication(query, lang, result) (src/util/oddbapp.rb)
Anwendung target
ch.oddb> registration('31706').indication
-> Beta-Rezeptorenblocker
ch.oddb> registration('31706').indication.class
-> ODDB::Indication

It seems that ODDB::Indication has invalid data....
We could not get atc class from indication objects.

ch.oddb> indications.select {|i| i.respond_to?(:atc_classes) }.length
-> 3432
ch.oddb> indications.select {|i| i.atc_classes }
-> undefined method `values' for nil:NilClass

I found a strange Indication record.
ODDB::Interaction#registrations is expected Array. But.

ch.oddb> indications.select {|i| i.registrations.is_a? ODDB::Migel::Item }.length
-> 1
ch.oddb> indications.select {|i| i.registrations.is_a? ODDB::Migel::Item }.first.class
-> ODDB::Indication

continue tomorrow.


problem Data-Corruption

Problem

In-crawler process(10001 is crawler server), I found strange error.

sorted_fachinfo
[Mon Jun 25 14:57:41 2012] [error] access to /de/gcc/fachinfo/reg/56480/chapter/iksnrs failed for (null), reason: (druby://localhost:10001) /usr/local/lib/ruby/gems/1.9.1/gems/odba-1.0.8/lib/odba/stub.rb:112:in `method_missing'
[Mon Jun 25 14:57:41 2012] [error] access to /de/gcc/fachinfo/reg/56480/chapter/iksnrs failed for (null), reason: (druby://localhost:10001) /var/www/oddb.org/src/util/oddbapp.rb:1179:in `block in sorted_fachinfos'
[Mon Jun 25 14:57:41 2012] [error] access to /de/gcc/fachinfo/reg/56480/chapter/iksnrs failed for (null), reason: (druby://localhost:10001) /var/www/oddb.org/src/util/oddbapp.rb:1178:in `select'
[Mon Jun 25 14:57:41 2012] [error] access to /de/gcc/fachinfo/reg/56480/chapter/iksnrs failed for (null), reason: (druby://localhost:10001) /var/www/oddb.org/src/util/oddbapp.rb:1178:in `sorted_fachinfos'

There were 2 invalid record as Fachinfo.
These Array are Drugbank data of ATC-Class Object.

odba_id
  • 28767755
  • 28767153
ch.oddb> sorted_fachinfos.length
-> undefined method `revision' for ["DB00722", "DB00455"]:Array
ch.oddb> fachinfos.length
-> 4797
ch.oddb> fachinfos.values.first
-> #<ODDB::FachinfoDocument:0x000000070e6788>
ch.oddb> fachinfos.values.select {|f| f.is_a? Array}.length
-> 2
ch.oddb> fachinfos.values.select {|f| f.is_a? Array}.first.odba_id
-> 28767755
ch.oddb> fachinfos.values.select {|f| f.is_a? Array}.first.odba_delete
-> ["DB00722", "DB00455"]
ch.oddb> fachinfos.values.select {|f| f.is_a? Array}.first.odba_id
-> 28767153
ch.oddb> fachinfos.values.select {|f| f.is_a? Array}.first.odba_delete
-> ["DB00627", "DB00184"]
ch.oddb> fachinfos.values.select {|f| f.is_a? Array}                  
-> []

I have deleted theses invalid data via bin/admin.
It seems that this problem is caused by Data-Corruption.

NOTE

don't run over 2 updater-jobs at same time.
If same odba_id(s) are used in multi(each) processes, then Data-corruption is caused.

view · edit · sidebar · attach · print · history
Page last modified on June 26, 2012, at 03:29 AM