bio-chembl 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.project +11 -0
- data/.travis.yml +12 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +33 -0
- data/LICENSE.txt +20 -0
- data/README.md +79 -0
- data/Rakefile +45 -0
- data/VERSION +1 -0
- data/bio-chembl.gemspec +94 -0
- data/lib/bio-chembl.rb +12 -0
- data/lib/bio-chembl/assay.rb +96 -0
- data/lib/bio-chembl/bioactivity.rb +113 -0
- data/lib/bio-chembl/chembl.rb +30 -0
- data/lib/bio-chembl/chemblid.rb +102 -0
- data/lib/bio-chembl/compound.rb +157 -0
- data/lib/bio-chembl/datamodel.rb +25 -0
- data/lib/bio-chembl/rest_api_server.rb +40 -0
- data/lib/bio-chembl/rest_client.rb +264 -0
- data/lib/bio-chembl/target.rb +103 -0
- data/test/helper.rb +18 -0
- data/test/test_bio-chembl-assay.rb +152 -0
- data/test/test_bio-chembl-assay.sh +3 -0
- data/test/test_bio-chembl-chemblid.rb +36 -0
- data/test/test_bio-chembl-chemblid.sh +3 -0
- data/test/test_bio-chembl-compound.rb +125 -0
- data/test/test_bio-chembl-compound.sh +3 -0
- data/test/test_bio-chembl-rest-client.rb +188 -0
- data/test/test_bio-chembl-rest-client.sh +3 -0
- data/test/test_bio-chembl-target.rb +114 -0
- data/test/test_bio-chembl-target.sh +3 -0
- data/test/test_bio-chembl.rb +9 -0
- data/test/test_bio-chembl.sh +3 -0
- metadata +210 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'bio-chembl/datamodel.rb'
|
3
|
+
require 'bio-chembl/bioactivity.rb'
|
4
|
+
|
5
|
+
module BioChEMBL
|
6
|
+
|
7
|
+
# ChEMBL Target
|
8
|
+
#
|
9
|
+
# Data XML
|
10
|
+
# <target>
|
11
|
+
# <chemblId>CHEMBL1785</chemblId>
|
12
|
+
# <targetType>PROTEIN</targetType>
|
13
|
+
# <preferredName>Endothelin receptor ET-B</preferredName>
|
14
|
+
# <proteinAccession>P24530</proteinAccession>
|
15
|
+
# <synonyms>Endothelin B receptor; Endothelin receptor non-selective type; ET-B; ET-BR</synonyms>
|
16
|
+
# <organism>Homo sapiens</organism>
|
17
|
+
# <description>Endothelin B receptor</description>
|
18
|
+
# <geneNames>EDNRB; ETRB</geneNames>
|
19
|
+
# </target>
|
20
|
+
#
|
21
|
+
class Target
|
22
|
+
extend BioChEMBL::DataModel
|
23
|
+
|
24
|
+
ATTRIBUTES = [
|
25
|
+
:chemblId,
|
26
|
+
:targetType,
|
27
|
+
:preferredName,
|
28
|
+
:proteinAccession,
|
29
|
+
:synonyms,
|
30
|
+
:organism,
|
31
|
+
:description,
|
32
|
+
:geneNames
|
33
|
+
]
|
34
|
+
|
35
|
+
set_attr_accessors(ATTRIBUTES)
|
36
|
+
|
37
|
+
def self.parse(str)
|
38
|
+
case str
|
39
|
+
when /^</
|
40
|
+
format = 'xml'
|
41
|
+
when /^\{/
|
42
|
+
format = 'json'
|
43
|
+
else
|
44
|
+
raise ArgumentError, "Unexpected file format: #{str.inspect}"
|
45
|
+
end
|
46
|
+
begin
|
47
|
+
eval "self.parse_#{format}(str)"
|
48
|
+
rescue
|
49
|
+
raise NoMethodError
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.parse_xml(str)
|
54
|
+
xml = Nokogiri::XML(str)
|
55
|
+
this = new
|
56
|
+
eval set_attr_values(ATTRIBUTES)
|
57
|
+
this
|
58
|
+
end
|
59
|
+
|
60
|
+
# XML
|
61
|
+
# <list><target> ...
|
62
|
+
def self.parse_list_xml(str)
|
63
|
+
xmls = Nokogiri::XML(str)
|
64
|
+
xmls.xpath("/list/target").map do |cpd|
|
65
|
+
self.parse_xml(cpd.to_s)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.parse_json(str)
|
70
|
+
raise NotImplementedError
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.parse_rdf(str)
|
74
|
+
raise NotImplementedError
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.find(chemblId)
|
78
|
+
self.parse_xml(REST.new.targets(chemblId))
|
79
|
+
end
|
80
|
+
|
81
|
+
def self.find_by_uniprot(uniprot_id)
|
82
|
+
self.parse_xml(REST.new.targets_uniprot(uniprot_id))
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.find_by_refseq(refseq_id)
|
86
|
+
self.parse_xml(REST.new.targets_refseq(refseq_id))
|
87
|
+
end
|
88
|
+
|
89
|
+
# bioactivities => [aBioactivity, ...]
|
90
|
+
def bioactivities
|
91
|
+
BioChEMBL::Bioactivity.parse_list_xml(REST.new.targets(chemblId, 'bioactivities'))
|
92
|
+
end
|
93
|
+
|
94
|
+
# Resolve the target data by given ChEMBL ID => aTarget
|
95
|
+
def resolve
|
96
|
+
resolved = self.class.find(@chemblId)
|
97
|
+
ATTRIBUTES.each do |attr|
|
98
|
+
eval "@#{attr} = resolved.#{attr}"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'bio-chembl'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'bio-chembl/chembl.rb'
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
class TestBioChemblAssay < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@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>"
|
9
|
+
@chemblId = "CHEMBL1217643"
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_assay_parser_xml
|
13
|
+
doc = BioChEMBL::Assay.parse_xml(@xml)
|
14
|
+
assert_equal("CHEMBL1217643", doc.chemblId)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_assay_attributes
|
18
|
+
doc = BioChEMBL::Assay.parse_xml(@xml)
|
19
|
+
assert_equal(doc.class, BioChEMBL::Assay)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_assay_attributes
|
23
|
+
doc = BioChEMBL::Assay.parse_xml(@xml)
|
24
|
+
assert_equal("CHEMBL1217643", doc.chemblId)
|
25
|
+
assert_equal("B", doc.assayType)
|
26
|
+
assert_equal("Bioorg. Med. Chem. Lett.", doc.journal)
|
27
|
+
assert_equal("Homo sapiens", doc.assayOrganism)
|
28
|
+
assert_equal("Unspecified", doc.assayStrain)
|
29
|
+
assert_equal("Inhibition of human hERG", doc.assayDescription)
|
30
|
+
assert_equal("1", doc.numBioactivities)
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
def test_assay_parse_json
|
35
|
+
assert_raise(NotImplementedError) {
|
36
|
+
BioChEMBL::Assay.parse_json("")
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
def test_assay_parse_rdf
|
42
|
+
assert_raise(NotImplementedError) {
|
43
|
+
BioChEMBL::Assay.parse_rdf("")
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def test_assay_parse
|
49
|
+
doc = BioChEMBL::Assay.parse(@xml)
|
50
|
+
assert_equal("CHEMBL1217643", doc.chemblId)
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def test_assay_resolve
|
55
|
+
doc = BioChEMBL::Assay.new
|
56
|
+
doc.chemblId = @chemblId
|
57
|
+
assert_equal(nil, doc.assayType)
|
58
|
+
doc.resolve
|
59
|
+
assert_equal("B", doc.assayType)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class TestBioChemblAssayClassMethods < Test::Unit::TestCase
|
64
|
+
def setup
|
65
|
+
@chemblId = "CHEMBL1217643"
|
66
|
+
@assay = BioChEMBL::Assay.find(@chemblId)
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_find
|
70
|
+
assert_equal("CHEMBL1217643", @assay.chemblId)
|
71
|
+
assert_equal("B", @assay.assayType)
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_bioactivities
|
75
|
+
docs = @assay.bioactivities
|
76
|
+
assert_equal(Array, docs.class)
|
77
|
+
assert_equal(BioChEMBL::Bioactivity, docs.first.class)
|
78
|
+
assert_equal("Homo sapiens", docs.first.organism)
|
79
|
+
assert_equal("Bioorg. Med. Chem. Lett., (2010) 20:15:4359", docs.first.reference)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
class TestBioChemblBioactivity < Test::Unit::TestCase
|
85
|
+
def setup
|
86
|
+
@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>"
|
87
|
+
@chemblId = "CHEMBL1214402"
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_bioactivity_new
|
91
|
+
ba = BioChEMBL::Bioactivity.new
|
92
|
+
assert_equal(BioChEMBL::Bioactivity, ba.class)
|
93
|
+
ba.reference = '11'
|
94
|
+
assert_equal('11', ba.reference)
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_bioactivities_parser_list_xml
|
98
|
+
docs = BioChEMBL::Bioactivity.parse_list_xml(@xml)
|
99
|
+
assert_equal("CHEMBL1214402", docs.first.parent__cmpd__chemblid)
|
100
|
+
end
|
101
|
+
|
102
|
+
def test_bioactivity_attributes
|
103
|
+
docs = BioChEMBL::Bioactivity.parse_list_xml(@xml)
|
104
|
+
assert_equal(docs.first.class, BioChEMBL::Bioactivity)
|
105
|
+
end
|
106
|
+
|
107
|
+
def test_bioactivity_attributes
|
108
|
+
docs = BioChEMBL::Bioactivity.parse_list_xml(@xml)
|
109
|
+
doc = docs.first
|
110
|
+
assert_equal("CHEMBL1214402", doc.parent__cmpd__chemblid)
|
111
|
+
assert_equal("CHEMBL1214402", doc.ingredient__cmpd__chemblid)
|
112
|
+
assert_equal("CHEMBL240", doc.target__chemblid)
|
113
|
+
assert_equal("9", doc.target__confidence)
|
114
|
+
assert_equal("HERG", doc.target__name)
|
115
|
+
assert_equal("Bioorg. Med. Chem. Lett., (2010) 20:15:4359", doc.reference)
|
116
|
+
assert_equal("26", doc.name__in__reference)
|
117
|
+
assert_equal("Homo sapiens", doc.organism)
|
118
|
+
assert_equal("IC50", doc.bioactivity__type)
|
119
|
+
assert_equal("Unspecified", doc.activity__comment)
|
120
|
+
assert_equal("=", doc.operator)
|
121
|
+
assert_equal("nM", doc.units)
|
122
|
+
assert_equal("CHEMBL1217643", doc.assay__chemblid)
|
123
|
+
assert_equal("B", doc.assay__type)
|
124
|
+
assert_equal("Inhibition of human hERG", doc.assay__description)
|
125
|
+
assert_equal("5900", doc.value)
|
126
|
+
end
|
127
|
+
|
128
|
+
|
129
|
+
def test_bioactivity_parse_json
|
130
|
+
assert_raise(NotImplementedError) {
|
131
|
+
BioChEMBL::Bioactivity.parse_json("")
|
132
|
+
}
|
133
|
+
end
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
def test_bioactivity_parse_rdf
|
138
|
+
assert_raise(NotImplementedError) {
|
139
|
+
BioChEMBL::Bioactivity.parse_rdf("")
|
140
|
+
}
|
141
|
+
end
|
142
|
+
|
143
|
+
|
144
|
+
def test_bioactivity_parse_xml
|
145
|
+
docs = BioChEMBL::Bioactivity.parse_list_xml(@xml)
|
146
|
+
assert_equal(Array, docs.class)
|
147
|
+
assert_equal(BioChEMBL::Bioactivity, docs.first.class)
|
148
|
+
assert_equal("CHEMBL1214402", docs.first.parent__cmpd__chemblid)
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'bio-chembl/chembl.rb'
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
class TestBioChemblChembId < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@str = "CHEMBL1"
|
9
|
+
@chemblid = BioChEMBL::ChEMBLID.new(@str)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_chemblid
|
13
|
+
assert_equal(@chemblid.class, BioChEMBL::ChEMBLID)
|
14
|
+
assert_equal(@chemblid, "CHEMBL1")
|
15
|
+
assert_equal(@chemblid.data_type, nil)
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_invalid_chembl_id
|
19
|
+
assert_raise(Exception) {
|
20
|
+
BioChEMBL::CHEMBLID.new("CHEMBLCHEMBL1")
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_chemblid_is_compound?
|
25
|
+
assert_equal(@chemblid.is_compound?, true)
|
26
|
+
assert_equal(@chemblid.data_type, Compound)
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_chemblid_is_target?
|
30
|
+
assert_equal(@chemblid.is_target?, false)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_chemblid_is_assay?
|
34
|
+
assert_equal(@chemblid.is_assay?, false)
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'bio-chembl/chembl.rb'
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
class TestBioChemblCompound < Test::Unit::TestCase
|
7
|
+
def setup
|
8
|
+
@xml = "<compound><chemblId>CHEMBL1</chemblId><knownDrug>No</knownDrug><medChemFriendly>Yes</medChemFriendly><passesRuleOfThree>No</passesRuleOfThree><molecularFormula>C32H32O8</molecularFormula><smiles>COc1ccc2[C@@H]3[C@H](COc2c1)C(C)(C)OC4=C3C(=O)C(=O)C5=C4OC(C)(C)[C@@H]6COc7cc(OC)ccc7[C@H]56</smiles><stdInChiKey>GHBOEFUAGSHXPO-XZOTUCIWSA-N</stdInChiKey><numRo5Violations>1</numRo5Violations><rotatableBonds>2</rotatableBonds><molecularWeight>544.59167</molecularWeight><alogp>3.627</alogp><acdLogp>7.669</acdLogp><acdLogd>7.669</acdLogd></compound>"
|
9
|
+
@chemblId = "CHEMBL1"
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_compound_parser_xml
|
13
|
+
doc = BioChEMBL::Compound.parse_xml(@xml)
|
14
|
+
assert_equal(doc.chemblId, "CHEMBL1")
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_compound_attributes
|
18
|
+
doc = BioChEMBL::Compound.parse_xml(@xml)
|
19
|
+
assert_equal(doc.class, BioChEMBL::Compound)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_compound_attributes
|
23
|
+
doc = BioChEMBL::Compound.parse_xml(@xml)
|
24
|
+
assert_equal(doc.chemblId, "CHEMBL1")
|
25
|
+
assert_equal(doc.knownDrug, "No")
|
26
|
+
assert_equal(doc.medChemFriendly, "Yes")
|
27
|
+
assert_equal(doc.passesRuleOfThree, "No")
|
28
|
+
assert_equal(doc.molecularFormula, "C32H32O8")
|
29
|
+
assert_equal(doc.smiles, "COc1ccc2[C@@H]3[C@H](COc2c1)C(C)(C)OC4=C3C(=O)C(=O)C5=C4OC(C)(C)[C@@H]6COc7cc(OC)ccc7[C@H]56")
|
30
|
+
assert_equal(doc.stdInChiKey, "GHBOEFUAGSHXPO-XZOTUCIWSA-N")
|
31
|
+
assert_equal(doc.numRo5Violations, "1")
|
32
|
+
assert_equal(doc.rotatableBonds, "2")
|
33
|
+
assert_equal(doc.molecularWeight, "544.59167")
|
34
|
+
assert_equal(doc.alogp, "3.627")
|
35
|
+
assert_equal(doc.acdLogp, "7.669")
|
36
|
+
assert_equal(doc.acdLogd, "7.669")
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
def test_compound_parse_json
|
41
|
+
assert_raise(NotImplementedError) {
|
42
|
+
BioChEMBL::Compound.parse_json("")
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
def test_compound_parse_rdf
|
48
|
+
assert_raise(NotImplementedError) {
|
49
|
+
BioChEMBL::Compound.parse_rdf("")
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def test_compound_parse
|
55
|
+
doc = BioChEMBL::Compound.parse(@xml)
|
56
|
+
assert_equal("CHEMBL1", doc.chemblId)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
def test_compound_resolve
|
61
|
+
doc = BioChEMBL::Compound.new
|
62
|
+
doc.chemblId = @chemblId
|
63
|
+
assert_equal(doc.knownDrug, nil)
|
64
|
+
doc.resolve
|
65
|
+
assert_equal(doc.knownDrug, "No")
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class TestBioChemblCompoundClassMethods < Test::Unit::TestCase
|
70
|
+
def setup
|
71
|
+
@chemblId = "CHEMBL1"
|
72
|
+
@smiles = "COc1ccc2[C@@H]3[C@H](COc2c1)C(C)(C)OC4=C3C(=O)C(=O)C5=C4OC(C)(C)[C@@H]6COc7cc(OC)ccc7[C@H]56"
|
73
|
+
@stdinchikey = "QFFGVLORLPOAEC-SNVBAGLBSA-N"
|
74
|
+
@warfarine = "CC(=O)CC(C1=C(O)c2ccccc2OC1=O)c3ccccc3"
|
75
|
+
@warfarine70 = "CC(=O)CC(C1=C(O)c2ccccc2OC1=O)c3ccccc3/70"
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_find
|
79
|
+
doc = BioChEMBL::Compound.find(@chemblId)
|
80
|
+
assert_equal(doc.chemblId, "CHEMBL1")
|
81
|
+
assert_equal(doc.knownDrug, "No")
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_find_by_smiles
|
85
|
+
uri = BioChEMBL::REST::ChEMBL_URI.compounds_smiles(@smiles)
|
86
|
+
assert_equal(uri, "https://www.ebi.ac.uk/chemblws/compounds/smiles/COc1ccc2[C@@H]3[C@H](COc2c1)C(C)(C)OC4=C3C(=O)C(=O)C5=C4OC(C)(C)[C@@H]6COc7cc(OC)ccc7[C@H]56")
|
87
|
+
xml = BioChEMBL::REST.new.compounds_smiles(@smiles)
|
88
|
+
assert_equal(xml, "<list><compound><chemblId>CHEMBL1</chemblId><knownDrug>No</knownDrug><medChemFriendly>Yes</medChemFriendly><passesRuleOfThree>No</passesRuleOfThree><molecularFormula>C32H32O8</molecularFormula><smiles>COc1ccc2[C@@H]3[C@H](COc2c1)C(C)(C)OC4=C3C(=O)C(=O)C5=C4OC(C)(C)[C@@H]6COc7cc(OC)ccc7[C@H]56</smiles><stdInChiKey>GHBOEFUAGSHXPO-XZOTUCIWSA-N</stdInChiKey><numRo5Violations>1</numRo5Violations><rotatableBonds>2</rotatableBonds><molecularWeight>544.59167</molecularWeight><alogp>3.627</alogp><acdLogp>7.669</acdLogp><acdLogd>7.669</acdLogd></compound></list>")
|
89
|
+
doc = BioChEMBL::Compound.find_by_smiles(@smiles)
|
90
|
+
assert_equal(doc.class, BioChEMBL::Compound)
|
91
|
+
assert_equal("CHEMBL1", doc.chemblId)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_find_all_by_smiles
|
95
|
+
uri = BioChEMBL::REST::ChEMBL_URI.compounds_smiles(@smiles)
|
96
|
+
assert_equal(uri, "https://www.ebi.ac.uk/chemblws/compounds/smiles/COc1ccc2[C@@H]3[C@H](COc2c1)C(C)(C)OC4=C3C(=O)C(=O)C5=C4OC(C)(C)[C@@H]6COc7cc(OC)ccc7[C@H]56")
|
97
|
+
xml = BioChEMBL::REST.new.compounds_smiles(@smiles)
|
98
|
+
assert_equal(xml, "<list><compound><chemblId>CHEMBL1</chemblId><knownDrug>No</knownDrug><medChemFriendly>Yes</medChemFriendly><passesRuleOfThree>No</passesRuleOfThree><molecularFormula>C32H32O8</molecularFormula><smiles>COc1ccc2[C@@H]3[C@H](COc2c1)C(C)(C)OC4=C3C(=O)C(=O)C5=C4OC(C)(C)[C@@H]6COc7cc(OC)ccc7[C@H]56</smiles><stdInChiKey>GHBOEFUAGSHXPO-XZOTUCIWSA-N</stdInChiKey><numRo5Violations>1</numRo5Violations><rotatableBonds>2</rotatableBonds><molecularWeight>544.59167</molecularWeight><alogp>3.627</alogp><acdLogp>7.669</acdLogp><acdLogd>7.669</acdLogd></compound></list>")
|
99
|
+
docs = BioChEMBL::Compound.find_all_by_smiles(@smiles)
|
100
|
+
assert_equal(docs.class, Array)
|
101
|
+
assert_equal(docs.first.class, BioChEMBL::Compound)
|
102
|
+
assert_equal("CHEMBL1", docs.first.chemblId)
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_find_by_stdinchikey
|
106
|
+
doc = BioChEMBL::Compound.find_by_stdinchikey(@stdinchikey)
|
107
|
+
assert_equal(doc.class, BioChEMBL::Compound)
|
108
|
+
assert_equal("CHEMBL1201760", doc.chemblId)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_find_all_by_substructure
|
112
|
+
docs = BioChEMBL::Compound.find_all_by_substructure(@warfarine)
|
113
|
+
assert_equal(docs.class, Array)
|
114
|
+
assert_equal(docs.first.class, BioChEMBL::Compound)
|
115
|
+
assert_equal("CHEMBL149194", docs.first.chemblId)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_find_all_by_similarity
|
119
|
+
docs = BioChEMBL::Compound.find_all_by_similarity(@warfarine70)
|
120
|
+
assert_equal(docs.class, Array)
|
121
|
+
assert_equal(docs.first.class, BioChEMBL::Compound)
|
122
|
+
assert_equal("CHEMBL313331", docs.first.chemblId)
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|