Class: BioChEMBL::Bioactivity

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

Overview

ChEMBL Bioactivity data parser and container.

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

bioactivties = BioChEMBL::Compound(chemlbId).bioactivities  
bioactivties = BioChEMBL::Target(chemlbId).bioactivities  
bioactivties = BioChEMBL::Assay(chemlbId).bioactivities  

bioactivities.find_all {|x| x.bioactivity__type =~ /IC50/ and x.value.to_i < 100 }.each do |ba|
  assay = ba.assay
  puts "Assay CHEMBLID:  #{assay.chemblId},  #{assay.assayDescription}"
end

bioactivity = bioactivities[0]
compound = bioactivity.parent_compound
compound = bioactivity.compound
assay = bioactivity.assay
target = bioactivity.target

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

Parse the Bioactivity data.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/bio-chembl/bioactivity.rb', line 74

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 Bioactivity data in JSON format.

Raises:

  • (NotImplementedError)


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

def self.parse_json(str)
  raise NotImplementedError
end

.parse_list_xml(str) ⇒ Object

Parse the Bioactivity data list in XML format. data list: <list><bioactivity/></list>



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

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

Parse the Bioactivity data in RDF format.

Raises:

  • (NotImplementedError)


113
114
115
# File 'lib/bio-chembl/bioactivity.rb', line 113

def self.parse_rdf(str)
  raise NotImplementedError
end

.parse_xml(str) ⇒ Object

Parse the Bioactivity data in XML format.



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

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

Instance Method Details

#assayObject

Link to the Assay



136
137
138
139
# File 'lib/bio-chembl/bioactivity.rb', line 136

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

#compoundObject

Link to the Compound



124
125
126
127
# File 'lib/bio-chembl/bioactivity.rb', line 124

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

#parent_compoundObject

Link to the parent Compound



118
119
120
121
# File 'lib/bio-chembl/bioactivity.rb', line 118

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

#targetObject

Link to the Target



130
131
132
133
# File 'lib/bio-chembl/bioactivity.rb', line 130

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