Class: BioChEMBL::Assay
- Inherits:
-
Object
- Object
- BioChEMBL::Assay
- Extended by:
- DataModel
- Defined in:
- lib/bio-chembl/assay.rb
Overview
ChEMBL Assay Data parser and container.
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>
Usage
assay = BioChEMBL::Assay.find("CHEMBL1217643")
assay.assayType
assay.assayOrganism
ba = assay.bioactivities
assay = BioChEMBL::Assay.new("CHEMBL1217643")
assay.assayType #=> nil
assay.resolve
assay.assayType #=> "B"
xml = BioChEMBL::REST.new.assays("CHEMBL1217643")
assay = BioChEMBL::Assay.parse_xml(xml)
Constant Summary collapse
- ATTRIBUTES =
[ :chemblId, :assayType, :journal, :assayOrganism, :assayStrain, :assayDescription, :numBioactivities ]
Class Method Summary collapse
-
.find(chemblId) ⇒ Object
Find the assay data by ChEMBL ID via the web service.
-
.parse(str) ⇒ Object
Parse the assay data.
-
.parse_json(str) ⇒ Object
Parse the assay data in JSON format.
-
.parse_rdf(str) ⇒ Object
Parse the assay data in RDF format.
-
.parse_xml(str) ⇒ Object
Parse the assay data in XML format.
Instance Method Summary collapse
-
#bioactivities ⇒ Object
Find the Bioactivity data by the assay.
-
#initialize(chemblId = nil) ⇒ Assay
constructor
Create a blank Assay instance.
-
#resolve ⇒ Object
Resolve the assay data by given ChEMBL ID.
Methods included from DataModel
set_attr_accessors, set_attr_values
Constructor Details
#initialize(chemblId = nil) ⇒ Assay
Create a blank Assay instance.
94 95 96 |
# File 'lib/bio-chembl/assay.rb', line 94 def initialize(chemblId = nil) @chemblId = chemblId end |
Class Method Details
.find(chemblId) ⇒ Object
Find the assay data by ChEMBL ID via the web service.
88 89 90 |
# File 'lib/bio-chembl/assay.rb', line 88 def self.find(chemblId) self.parse_xml(REST.new.assays(chemblId)) end |
.parse(str) ⇒ Object
Parse the assay data.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/bio-chembl/assay.rb', line 53 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
Parse the assay data in JSON format.
78 79 80 |
# File 'lib/bio-chembl/assay.rb', line 78 def self.parse_json(str) raise NotImplementedError end |
.parse_rdf(str) ⇒ Object
Parse the assay data in RDF format.
83 84 85 |
# File 'lib/bio-chembl/assay.rb', line 83 def self.parse_rdf(str) raise NotImplementedError end |
.parse_xml(str) ⇒ Object
Parse the assay data in XML format.
70 71 72 73 74 75 |
# File 'lib/bio-chembl/assay.rb', line 70 def self.parse_xml(str) xml = Nokogiri::XML(str) this = new eval set_attr_values(ATTRIBUTES) this end |
Instance Method Details
#bioactivities ⇒ Object
Find the Bioactivity data by the assay.
107 108 109 |
# File 'lib/bio-chembl/assay.rb', line 107 def bioactivities BioChEMBL::Bioactivity.parse_list_xml(REST.new.assays(@chemblId, 'bioactivities')) end |
#resolve ⇒ Object
Resolve the assay data by given ChEMBL ID
99 100 101 102 103 104 |
# File 'lib/bio-chembl/assay.rb', line 99 def resolve resolved = self.class.find(@chemblId) ATTRIBUTES.each do |attr| eval "@#{attr} = resolved.#{attr}" end end |