<< Masa.20120228-check-accessor-Package-Registration-check-parallel-runs-oddb_org | Index | Masa.20120224-fix-migel-view-atc-overview-oddb_org-drop-crawler-request-sbsm >>
Error
error in SBSM::Session#to_html: /de/gcc/search/search_query/Mezereum-Homaccord/search_type/st_sequence/code/D11AX/currency/USD NoMethodError undefined method `[]' for nil:NilClass /home/masa/ywesee/oddb.org/src/view/drugs/resultlist.rb:296:in `compose_list' /usr/local/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.5/lib/htmlgrid/list.rb:54:in `compose' /usr/local/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.5/lib/htmlgrid/composite.rb:56:in `init' /usr/local/lib/ruby/gems/1.9.1/gems/htmlgrid-1.0.5/lib/htmlgrid/list.rb:129:in `init'
Commit
Experiment
class PackageCommon .... def define_check_class_method(accessor, klass) define_method("#{accessor.to_s}=") do |arg| #if arg.is_a?(ODDB::Sequence) if arg.class.to_s == klass.to_s @sequence = arg else arg_class = arg.class arg = if arg.respond_to?(:to_s) arg.to_s[0,10] end raise TypeError.new("'#{arg.to_s}'(#{arg_class}) should be #{klass}") end end end end ... check_classes = {:sequence => 'ODDB::Sequence'} check_classes.each do |accessor, klass| define_check_class_method accessor, klass end
Run
ch.oddb> update(ODDB::Package.find_by_pharmacode('223332').pointer, {:sequence => 'utf-8'}, :admin) -> 'utf-8'(String) should be a ODDB::Sequence
ch.oddb> registration('31706').sequence('02').odba_id -> 73749 ch.oddb> registration('31706').sequence('01').odba_id -> 73748 ch.oddb> ODDB::Package.find_by_pharmacode('223332').sequence.odba_id -> 73748 ch.oddb> seq = registration('31706').sequence('02'); update(ODDB::Package.find_by_pharmacode('223332').pointer, {:sequence => seq}, :admin) -> #<ODDB::Package:0x00000001bcbbe0> ch.oddb> ODDB::Package.find_by_pharmacode('223332').sequence.odba_id -> 73749
Next
ActiveAgent class
Check all accessor class
attr_accessor :substance attr_accessor :chemical_substance, :equivalent_substance attr_accessor :dose, :chemical_dose, :equivalent_dose, :sequence attr_accessor :spagyric_dose, :spagyric_type, :composition
Experiment
ch.oddb> registrations.values.map{|reg| reg.sequences.values.map{|seq| seq.active_agents.map{|aa| aa.substance.class}}}.flatten.uniq -> [ODDB::Substance]
def check_active_agent_class methods = [:substance, :chemical_substance, :equivalent_substance, :dose, :chemical_dose, :equivalent_dose, :sequence] open("/home/masa/work/active_agent_class.dat","w") do |out| methods.each do |method| classes = registrations.values.map do |reg| reg.sequences.values.map do |seq| seq.active_agents.map do |aa| aa.send(method).class end end end.flatten.uniq out.print method, ": ", classes.join(","), "\n" end end end
Result
:substance => ODDB::Substance :chemical_substance => NilClass,ODDB::Substance :equivalent_substance => NilClass,ODDB::Substance :dose => ODDB::Dose,NilClass :chemical_dose => NilClass,ODDB::Dose :equivalent_dose => NilClass,ODDB::Dose :sequence => ODDB::Sequence
Commit
Next
AtcClass
masa@masa ~/ywesee/oddb.org $ ruby -I . -rcheck_accessor bin/oddbd
ch.oddb> ODDB::AtcClass.attr_writers -> [:code, :sequences, :descriptions]
Check accessor classes
masa@masa ~/ywesee/oddb.org $ ruby -I . -rcheck_class bin/oddbd
ch.oddb> check_atcclass_accessor_class
Result
:code => "String", :sequences => "Array", :descriptions => "ODDB::SimpleLanguage::Descriptions",
Commit
Note (for development)
Sequence
masa@masa ~/ywesee/oddb.org $ ruby -I . -rcheck_accessor bin/oddbd
ch.oddb> ODDB::SequenceCommon.attr_writers -> [:registration, :atc_class, :export_flag, :patinfo, :pdf_patinfo, :atc_request_time, :deactivate_patinfo, :sequence_date, :activate_patinfo, :composition_text, :dose, :inactive_date]
masa@masa ~/ywesee/oddb.org $ ruby -I . -rcheck_class bin/oddbd
ch.oddb> check_sequence_accessor_class
Result
:registration => "ODDB::Registration", :atc_class => "ODDB::AtcClass,NilClass", :export_flag => "FalseClass,TrueClass,NilClass", :patinfo => "NilClass,ODDB::Patinfo", :pdf_patinfo => "NilClass,String", :atc_request_time => "NilClass,Time", :deactivate_patinfo => "NilClass,Date", :sequence_date => "NilClass,Date", :activate_patinfo => "NilClass,Date", :composition_text => "NilClass,String", :dose => "ODDB::Dose,NilClass", :inactive_date => "NilClass",
Commit
Check Array and Hash element class
Note
Temporary conclusion
Test
$ sh batch.sh
Result
Note