Class: BioChEMBL::Target
- Inherits:
-
Object
- Object
- BioChEMBL::Target
- Extended by:
- DataModel
- Defined in:
- lib/bio-chembl/target.rb
Overview
ChEMBL Target parser and container.
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>
Usage
target = BioChEMBL::Target.find("CHEMBL1785")
target.geneNames
BioChEMBL.to_array(target.geneNames)[0] #=> "EDNRB"
bioactivities = target.bioactivities
target = BioChEMBL::Target.find_by_uniprot("P24530")
Constant Summary collapse
- ATTRIBUTES =
[ :chemblId, :targetType, :preferredName, :proteinAccession, :synonyms, :organism, :description, :geneNames ]
Class Method Summary collapse
-
.find(chemblId) ⇒ Object
Find the Target data by the ChEMBL ID.
-
.find_by_refseq(refseq_id) ⇒ Object
Find the Target data by the RefSeq ID.
-
.find_by_uniprot(uniprot_id) ⇒ Object
Find the Target data by the UniProt ID.
-
.parse(str) ⇒ Object
Parse the Target data.
-
.parse_json(str) ⇒ Object
Parse the Target data in JSON format.
-
.parse_list_xml(str) ⇒ Object
Parse the Target data list in XML format.
-
.parse_rdf(str) ⇒ Object
Parse the Target data in RDF format.
-
.parse_xml(str) ⇒ Object
Parse the Target data in XML format.
Instance Method Summary collapse
-
#bioactivities ⇒ Object
Get the bioactivity data list.
-
#resolve ⇒ Object
Resolve the Target data by the ChEMBL ID.
Methods included from DataModel
set_attr_accessors, set_attr_values
Class Method Details
.find(chemblId) ⇒ Object
Find the Target data by the ChEMBL ID.
93 94 95 |
# File 'lib/bio-chembl/target.rb', line 93 def self.find(chemblId) self.parse_xml(REST.new.targets(chemblId)) end |
.find_by_refseq(refseq_id) ⇒ Object
Find the Target data by the RefSeq ID.
103 104 105 |
# File 'lib/bio-chembl/target.rb', line 103 def self.find_by_refseq(refseq_id) self.parse_xml(REST.new.targets_refseq(refseq_id)) end |
.find_by_uniprot(uniprot_id) ⇒ Object
Find the Target data by the UniProt ID.
98 99 100 |
# File 'lib/bio-chembl/target.rb', line 98 def self.find_by_uniprot(uniprot_id) self.parse_xml(REST.new.targets_uniprot(uniprot_id)) end |
.parse(str) ⇒ Object
Parse the Target data.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/bio-chembl/target.rb', line 49 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 Target data in JSON format.
83 84 85 |
# File 'lib/bio-chembl/target.rb', line 83 def self.parse_json(str) raise NotImplementedError end |
.parse_list_xml(str) ⇒ Object
Parse the Target data list in XML format. data lsit: <list><target/></list>
75 76 77 78 79 80 |
# File 'lib/bio-chembl/target.rb', line 75 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
Parse the Target data in RDF format.
88 89 90 |
# File 'lib/bio-chembl/target.rb', line 88 def self.parse_rdf(str) raise NotImplementedError end |
.parse_xml(str) ⇒ Object
Parse the Target data in XML format.
66 67 68 69 70 71 |
# File 'lib/bio-chembl/target.rb', line 66 def self.parse_xml(str) xml = Nokogiri::XML(str) this = new eval set_attr_values(ATTRIBUTES) this end |
Instance Method Details
#bioactivities ⇒ Object
Get the bioactivity data list.
108 109 110 |
# File 'lib/bio-chembl/target.rb', line 108 def bioactivities BioChEMBL::Bioactivity.parse_list_xml(REST.new.targets(chemblId, 'bioactivities')) end |
#resolve ⇒ Object
Resolve the Target data by the ChEMBL ID
113 114 115 116 117 118 |
# File 'lib/bio-chembl/target.rb', line 113 def resolve resolved = self.class.find(@chemblId) ATTRIBUTES.each do |attr| eval "@#{attr} = resolved.#{attr}" end end |