Class: BioChEMBL::Bioactivity

Inherits:
Object
  • Object
show all
Extended by:
DataModel
Defined in:
lib/bio-chembl/bioactivity.rb

Overview

BioChEMBL::Bioactivity

Data XML <list>

<bioactivity>
  <parent__cmpd__chemblid>CHEMBL1214402</parent__cmpd__chemblid>
  <ingredient__cmpd__chemblid>CHEMBL1214402</ingredient__cmpd__chemblid>
  <target__chemblid>CHEMBL240</target__chemblid>
  <target__confidence>9</target__confidence>
  <target__name>HERG</target__name>
  <reference>Bioorg. Med. Chem. Lett., (2010) 20:15:4359</reference>
  <name__in__reference>26</name__in__reference>
  <organism>Homo sapiens</organism>
  <bioactivity__type>IC50</bioactivity__type>
  <activity__comment>Unspecified</activity__comment>
  <operator>=</operator>
  <units>nM</units>
  <assay__chemblid>CHEMBL1217643</assay__chemblid>
  <assay__type>B</assay__type>
  <assay__description>Inhibition of human hERG</assay__description>
  <value>5900</value>
</bioactivity>

</list>

Usage

Constant Summary collapse

ATTRIBUTES =
[
  :parent__cmpd__chemblid,
  :ingredient__cmpd__chemblid,
  :target__chemblid,
  :target__confidence,
  :target__name,
  :reference,
  :name__in__reference,
  :organism,
  :bioactivity__type,
  :activity__comment,
  :operator,
  :units,
  :assay__chemblid,
  :assay__type,
  :assay__description,
  :value
]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DataModel

set_attr_accessors, set_attr_values

Class Method Details

.parse(str) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/bio-chembl/bioactivity.rb', line 57

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

Raises:

  • (NotImplementedError)


89
90
91
# File 'lib/bio-chembl/bioactivity.rb', line 89

def self.parse_json(str)
  raise NotImplementedError
end

.parse_list_xml(str) ⇒ Object

XML <list><bioactivity> …



82
83
84
85
86
87
# File 'lib/bio-chembl/bioactivity.rb', line 82

def self.parse_list_xml(str)
  xmls = Nokogiri::XML(str)
  xmls.xpath("/list/bioactivity").map do |cpd|
    self.parse_xml(cpd.to_s)
  end
end

.parse_rdf(str) ⇒ Object

Raises:

  • (NotImplementedError)


93
94
95
# File 'lib/bio-chembl/bioactivity.rb', line 93

def self.parse_rdf(str)
  raise NotImplementedError
end

.parse_xml(str) ⇒ Object



73
74
75
76
77
78
# File 'lib/bio-chembl/bioactivity.rb', line 73

def self.parse_xml(str)
  xml = Nokogiri::XML(str)
  this = new
  eval set_attr_values(ATTRIBUTES)
  this
end

Instance Method Details

#assayObject



107
108
109
110
# File 'lib/bio-chembl/bioactivity.rb', line 107

def assay
  require 'bio-chembl/assay.rb'
  BioChEMBL::Assay.find(@assay__chemblid)
end

#parent_compoundObject



97
98
99
100
# File 'lib/bio-chembl/bioactivity.rb', line 97

def parent_compound
  require 'bio-chembl/compound.rb'
  BioChEMBL::Compound.find(@parent__cmpd__chemblid)
end

#targetObject



102
103
104
105
# File 'lib/bio-chembl/bioactivity.rb', line 102

def target
  require 'bio-chembl/target.rb'
  BioChEMBL::Target.find(@target__chemblid)
end