Class: BioChEMBL::Assay
- Inherits:
-
Object
- Object
- BioChEMBL::Assay
- Extended by:
- DataModel
- Defined in:
- lib/bio-chembl/assay.rb
Overview
ChEMBL Assay
Data XML <assay>
<chemblId>CHEMBL1217643</chemblId>
<assayType>B</assayType>
<journal>Bioorg. Med. Chem. Lett.</journal>
<assayOrganism>Homo sapiens</assayOrganism>
<assayStrain>Unspecified</assayStrain>
<assayDescription>Inhibition of human hERG</assayDescription>
<numBioactivities>1</numBioactivities>
</assay>
Constant Summary collapse
- ATTRIBUTES =
[ :chemblId, :assayType, :journal, :assayOrganism, :assayStrain, :assayDescription, :numBioactivities ]
Class Method Summary collapse
- .find(chemblId) ⇒ Object
- .parse(str) ⇒ Object
- .parse_json(str) ⇒ Object
- .parse_rdf(str) ⇒ Object
- .parse_xml(str) ⇒ Object
Instance Method Summary collapse
-
#bioactivities ⇒ Object
ChEMBL Bioactivity.
-
#initialize(chemblId = nil) ⇒ Assay
constructor
new.
-
#resolve ⇒ Object
Resolve the compound data by given ChEMBL ID.
Methods included from DataModel
set_attr_accessors, set_attr_values
Constructor Details
#initialize(chemblId = nil) ⇒ Assay
new
77 78 79 |
# File 'lib/bio-chembl/assay.rb', line 77 def initialize(chemblId = nil) @chemblId = chemblId end |
Class Method Details
.find(chemblId) ⇒ Object
71 72 73 |
# File 'lib/bio-chembl/assay.rb', line 71 def self.find(chemblId) self.parse_xml(REST.new.assays(chemblId)) end |
.parse(str) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bio-chembl/assay.rb', line 40 def self.parse(str) case str when /^</ format = 'xml' when /^\{/ format = 'json' else raise ArgumentError, "Unexpected file format: #{str.inspect}" end begin eval "self.parse_#{format}(str)" rescue raise NoMethodError end end |
.parse_json(str) ⇒ Object
63 64 65 |
# File 'lib/bio-chembl/assay.rb', line 63 def self.parse_json(str) raise NotImplementedError end |
.parse_rdf(str) ⇒ Object
67 68 69 |
# File 'lib/bio-chembl/assay.rb', line 67 def self.parse_rdf(str) raise NotImplementedError end |
.parse_xml(str) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/bio-chembl/assay.rb', line 56 def self.parse_xml(str) xml = Nokogiri::XML(str) this = new eval set_attr_values(ATTRIBUTES) this end |
Instance Method Details
#bioactivities ⇒ Object
ChEMBL Bioactivity
90 91 92 |
# File 'lib/bio-chembl/assay.rb', line 90 def bioactivities BioChEMBL::Bioactivity.parse_list_xml(REST.new.assays(@chemblId, 'bioactivities')) end |
#resolve ⇒ Object
Resolve the compound data by given ChEMBL ID
82 83 84 85 86 87 |
# File 'lib/bio-chembl/assay.rb', line 82 def resolve resolved = self.class.find(@chemblId) ATTRIBUTES.each do |attr| eval "@#{attr} = resolved.#{attr}" end end |