Module: BioChEMBL::REST::ChEMBL_URI

Defined in:
lib/bio-chembl/rest_client.rb

Overview

ChEMBL REST Web Service URI generator

[ChEMBL Web Services](www.ebi.ac.uk/chembldb/ws)

Class Method Summary collapse

Class Method Details

.address(path) ⇒ Object



45
46
47
# File 'lib/bio-chembl/rest_client.rb', line 45

def self.address(path)
  "#{BASE_URI}/#{path}"
end

.assays(chemblId, arg = nil) ⇒ Object

Get assay by ChEMBLID

BioChEMBL::REST::ChEMBL_URI.assays(chemblId)

Get individual assay bioactivities

BioChEMBL::REST::ChEMBL_URI.assays(chemblId, 'bioactivities')


148
149
150
151
152
153
154
155
156
157
158
# File 'lib/bio-chembl/rest_client.rb', line 148

def self.assays(chemblId, arg = nil)
  if chemblId and arg == nil
    # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/assays/CHEMBL1217643
    address("assays/#{chemblId}")
  elsif chemblId and arg == 'bioactivities' 
    # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/assays/CHEMBL1217643/bioactivities
    address("assays/#{chemblId}/bioactivities")
  else
    raise Exception, "Undefined. ChEMBL ID: #{chemblId}, arg: #{arg}"
  end
end

.compounds(chemblId = nil, arg = nil, params = nil) ⇒ Object

Get compound by ChEMBLID

BioChEMBL::REST::ChEMBL_URI.compounds("CHEMBL1")

Get image of a ChEMBL compound by ChEMBLID

BioChEMBL::REST::ChEMBL_URI.compounds("CHEMBL1", 'image')       
BioChEMBL::REST::ChEMBL_URI.compounds("CHEMBL1", 'image', {'dimensions' => 200})

Get individual compound bioactivities

BioChEMBL::REST::ChEMBL_URI.compounds("CHEMBL1", 'bioactivities')


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/bio-chembl/rest_client.rb', line 63

def self.compounds(chemblId = nil, arg = nil, params = nil)
  if chemblId and arg == nil and params == nil 
  # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/compounds/CHEMBL1
    address("compounds/#{chemblId}")
  elsif chemblId and arg == 'image' and params == nil
  # Example URL: http://www.ebi.ac.uk/chemblws/compounds/CHEMBL192/image
    address("compounds/#{chemblId}/#{arg}")
  elsif chemblId and arg == 'image' and params 
  # Example URL with dimensions parameter: http://www.ebi.ac.uk/chemblws/compounds/CHEMBL192/image?dimensions=200
    address("compounds/#{chemblId}/#{arg}?" + params.map {|k,v| "#{k}=#{v}"}.join("&"))
  elsif chemblId and arg == 'bioactivities' and params == nil
  # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/compounds/CHEMBL2/bioactivities
    address("compounds/#{chemblId}/#{arg}")
  else 
    raise Exception, "Undefined address. ID: #{chemblId}, arg: #{arg}, params: #{params.inspect}"
  end
end

.compounds_similarity(smiles) ⇒ Object

Get list of compounds similar to the one represented by a given Canonical SMILES, at a given cutoff percentage

BioChEMBL::REST::ChEMBL_URI.compounds_similarity(smiles + "/" + cutoff)


104
105
106
107
# File 'lib/bio-chembl/rest_client.rb', line 104

def self.compounds_similarity(smiles)
  # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/compounds/similarity/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/70
  address("compounds/similarity/#{smiles}")
end

.compounds_smiles(smiles) ⇒ Object

Get list of compounds matching Canonical SMILES

BioChEMBL::REST::ChEMBL_URI.compounds_smiles(smiles)


90
91
92
93
# File 'lib/bio-chembl/rest_client.rb', line 90

def self.compounds_smiles(smiles)
  # Example URL (XML Output): http://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
  address("compounds/smiles/#{smiles}")
end

.compounds_stdinchikey(stdinchikey) ⇒ Object

Get compound by Standard InChiKey

BioChEMBL::REST::ChEMBL_URI.compounds_stdinchikey(stdinchikey)


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

def self.compounds_stdinchikey(stdinchikey)
  # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/compounds/stdinchikey/QFFGVLORLPOAEC-SNVBAGLBSA-N
  address("compounds/stdinchikey/#{stdinchikey}")
end

.compounds_substructure(smiles) ⇒ Object

Get list of compounds containing the substructure represented by a given Canonical SMILES

BioChEMBL::REST::ChEMBL_URI.compounds_substructure(smiles)


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

def self.compounds_substructure(smiles)
  # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/compounds/substructure/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
  address("compounds/substructure/#{smiles}")
end

.statusObject

Check API status



51
52
53
54
# File 'lib/bio-chembl/rest_client.rb', line 51

def self.status
  # Example URL: http://www.ebi.ac.uk/chemblws/status/
  address("status/")
end

.targets(chemblId = nil, arg = nil) ⇒ Object

Get target by ChEMBLID

BioChEMBL::REST::ChEMBL_URI.targets(chemblId)

Get individual target bioactivities

BioChEMBL::REST::ChEMBL_URI.targets(chemblId, 'bioactivities')

Get all targets

BioChEMBL::REST::ChEMBL_URI.targets


115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/bio-chembl/rest_client.rb', line 115

def self.targets(chemblId = nil, arg = nil)
  if chemblId and arg == nil
    # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/targets/CHEMBL2477
    address("targets/#{chemblId}")
  elsif chemblId and arg == 'bioactivities' 
    # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/targets/CHEMBL240/bioactivities
    address("targets/#{chemblId}/bioactivities")
  elsif chemblId == nil and arg == nil 
    # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/targets
    address("targets")
  else
    raise Exception, "Undefined."
  end
end

.targets_refseq(refseq_id) ⇒ Object

Get target by RefSeq Accession Identifier

BioChEMBL::REST::ChEMBL_URI.targets_refseq(refseq_id)


139
140
141
142
# File 'lib/bio-chembl/rest_client.rb', line 139

def self.targets_refseq(refseq_id)
  # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/targets/refseq/NP_001128722
  address("targets/refseq/#{refseq_id}")
end

.targets_uniprot(uniprot_id) ⇒ Object

Get target by UniProt Accession Identifier

BioChEMBL::REST::ChEMBL_URI.targets_uniprot(uniprot_id)


132
133
134
135
# File 'lib/bio-chembl/rest_client.rb', line 132

def self.targets_uniprot(uniprot_id)
  # Example URL (XML Output): http://www.ebi.ac.uk/chemblws/targets/uniprot/Q13936
  address("targets/uniprot/#{uniprot_id}")
end