Module: Sylfy::Service::ChEMBL::REST

Defined in:
lib/sylfy/service/chembl.rb

Constant Summary collapse

@@baseuri =
"https://www.ebi.ac.uk/chemblws"

Class Method Summary collapse

Class Method Details

.assays(id, bioactiv = false, json = true) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/sylfy/service/chembl.rb', line 87

def assays(id, bioactiv = false, json = true)
	input = "assays/#{id}"
	input += "/bioactivities" if bioactiv
	input += ".json" if json
	return perform(input)
	
end

.compounds(id, domain = '', target = '', json = true) ⇒ Object

Method for setting inchi data member

Parameters:

id

LipidMap id to search

:id, :dataPrimarySource, :xrefs, :relations :inchi, :formula, :smiles, :inchiKey :names



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/sylfy/service/chembl.rb', line 43

def compounds(id, domain = '', target = '', json = true)
	input = 'compounds'
	if [:stdinchikey, :smiles, :substructure].include?(domain.to_sym)
		input += "/#{domain}/#{id}"
		input += ".json" if json
	elsif domain.to_sym == :similaritiy 
		input += target.class == Integer ? "/#{domain}/#{id}/#{target}" : "/#{domain}/#{id}"
		input += ".json" if json
	elsif target.to_sym == :bioactivities
		input += "/#{id}/bioactivities"
		input += ".json" if json
	elsif target == :image || target =~ /^image?dimensions=(\d+)$/ || target =~ /^image=(\d+)$/
		if $1
			input += "/#{id}/image?dimensions=#{$1}"
		else
			input += "/#{id}/image?dimensions=300"
		end
	else
		input += "/#{id}"
		input += ".json" if json
	end
	
	return perform(input)
	
end

.perform(input) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/sylfy/service/chembl.rb', line 24

def perform(input)
	
	uri = "#{@@baseuri}/#{input}"
	p uri
	begin
		return URI.parse(uri).read().strip()
	rescue OpenURI::HTTPError => e
		raise ServiceException, e
	end
end

.targets(id, domain = '', bioactiv = false, json = true) ⇒ Object



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/sylfy/service/chembl.rb', line 69

def targets(id, domain = '', bioactiv = false, json = true)
	input = 'targets'
	if id == ''
		
	elsif [:uniprot, :refseq].include?(domain.to_sym)
		input += "/#{domain}/#{id}"
		
	elsif bioactiv
		input += "/#{id}/bioactivities"
	else
		input += "/#{id}"
	end
	
	input += ".json" if json
	return perform(input)
	
end