Class: BioChEMBL::Target
- Inherits:
-
Object
- Object
- BioChEMBL::Target
- Extended by:
- DataModel
- Defined in:
- lib/bio-chembl/target.rb
Overview
ChEMBL Target
Data XML <target>
<chemblId>CHEMBL1785</chemblId>
<targetType>PROTEIN</targetType>
<preferredName>Endothelin receptor ET-B</preferredName>
<proteinAccession>P24530</proteinAccession>
<synonyms>Endothelin B receptor; Endothelin receptor non-selective type; ET-B; ET-BR</synonyms>
<organism>Homo sapiens</organism>
<description>Endothelin B receptor</description>
<geneNames>EDNRB; ETRB</geneNames>
</target>
Constant Summary collapse
- ATTRIBUTES =
[ :chemblId, :targetType, :preferredName, :proteinAccession, :synonyms, :organism, :description, :geneNames ]
Class Method Summary collapse
- .find(chemblId) ⇒ Object
- .find_by_refseq(refseq_id) ⇒ Object
- .find_by_uniprot(uniprot_id) ⇒ Object
- .parse(str) ⇒ Object
- .parse_json(str) ⇒ Object
-
.parse_list_xml(str) ⇒ Object
XML <list><target> …
- .parse_rdf(str) ⇒ Object
- .parse_xml(str) ⇒ Object
Instance Method Summary collapse
-
#bioactivities ⇒ Object
bioactivities => [aBioactivity, …].
-
#resolve ⇒ Object
Resolve the target data by given ChEMBL ID => aTarget.
Methods included from DataModel
set_attr_accessors, set_attr_values
Class Method Details
.find(chemblId) ⇒ Object
77 78 79 |
# File 'lib/bio-chembl/target.rb', line 77 def self.find(chemblId) self.parse_xml(REST.new.targets(chemblId)) end |
.find_by_refseq(refseq_id) ⇒ Object
85 86 87 |
# File 'lib/bio-chembl/target.rb', line 85 def self.find_by_refseq(refseq_id) self.parse_xml(REST.new.targets_refseq(refseq_id)) end |
.find_by_uniprot(uniprot_id) ⇒ Object
81 82 83 |
# File 'lib/bio-chembl/target.rb', line 81 def self.find_by_uniprot(uniprot_id) self.parse_xml(REST.new.targets_uniprot(uniprot_id)) end |
.parse(str) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bio-chembl/target.rb', line 37 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
69 70 71 |
# File 'lib/bio-chembl/target.rb', line 69 def self.parse_json(str) raise NotImplementedError end |
.parse_list_xml(str) ⇒ Object
XML <list><target> …
62 63 64 65 66 67 |
# File 'lib/bio-chembl/target.rb', line 62 def self.parse_list_xml(str) xmls = Nokogiri::XML(str) xmls.xpath("/list/target").map do |cpd| self.parse_xml(cpd.to_s) end end |
.parse_rdf(str) ⇒ Object
73 74 75 |
# File 'lib/bio-chembl/target.rb', line 73 def self.parse_rdf(str) raise NotImplementedError end |
.parse_xml(str) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/bio-chembl/target.rb', line 53 def self.parse_xml(str) xml = Nokogiri::XML(str) this = new eval set_attr_values(ATTRIBUTES) this end |
Instance Method Details
#bioactivities ⇒ Object
bioactivities => [aBioactivity, …]
90 91 92 |
# File 'lib/bio-chembl/target.rb', line 90 def bioactivities BioChEMBL::Bioactivity.parse_list_xml(REST.new.targets(chemblId, 'bioactivities')) end |
#resolve ⇒ Object
Resolve the target data by given ChEMBL ID => aTarget
95 96 97 98 99 100 |
# File 'lib/bio-chembl/target.rb', line 95 def resolve resolved = self.class.find(@chemblId) ATTRIBUTES.each do |attr| eval "@#{attr} = resolved.#{attr}" end end |