updated the classyfire api. you can get query or entity in the sdf format now.
This commit is contained in:
parent
68c662759a
commit
f6165c61c3
|
@ -11,28 +11,51 @@ module ClassyFireAPI
|
||||||
e.response
|
e.response
|
||||||
rescue RestClient::InternalServerError => e
|
rescue RestClient::InternalServerError => e
|
||||||
e.response
|
e.response
|
||||||
|
rescue RestClient::GatewayTimeout => e
|
||||||
|
e.response
|
||||||
|
rescue RestClient::RequestTimeout => e
|
||||||
|
e.response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def ClassyFireAPI.get_query(query_id)
|
def ClassyFireAPI.get_query(query_id,format="json")
|
||||||
|
# format can be either 'json' or 'sdf'
|
||||||
begin
|
begin
|
||||||
|
if format == "json"
|
||||||
puts "#{URL}/queries/#{query_id}.json"
|
puts "#{URL}/queries/#{query_id}.json"
|
||||||
RestClient.get "#{URL}/queries/#{query_id}.json", :accept => :json
|
RestClient.get "#{URL}/queries/#{query_id}.json", :accept => :json
|
||||||
|
elsif format == "sdf"
|
||||||
|
puts "#{URL}/queries/#{query_id}.sdf"
|
||||||
|
RestClient.get "#{URL}/queries/#{query_id}.sdf", :accept => :sdf
|
||||||
|
end
|
||||||
rescue RestClient::ResourceNotFound => e
|
rescue RestClient::ResourceNotFound => e
|
||||||
e.response
|
e.response
|
||||||
rescue RestClient::InternalServerError => e
|
rescue RestClient::InternalServerError => e
|
||||||
e.response
|
e.response
|
||||||
|
rescue RestClient::GatewayTimeout => e
|
||||||
|
e.response
|
||||||
|
rescue RestClient::RequestTimeout => e
|
||||||
|
e.response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def ClassyFireAPI.get_entity_classification(inchikey)
|
def ClassyFireAPI.get_entity_classification(inchikey,format="json")
|
||||||
|
# format can be either 'json' or 'sdf'
|
||||||
inchikey_id = inchikey.to_s.gsub('InChIKey=','')
|
inchikey_id = inchikey.to_s.gsub('InChIKey=','')
|
||||||
begin
|
begin
|
||||||
RestClient.get "#{URL}/entities/#{inchikey_id}.json", :accept => :json
|
if format == "json"
|
||||||
|
RestClient.get "#{URL}/entities/#{inchikey_id}.#{format}", :accept => :json
|
||||||
|
elsif format == "sdf"
|
||||||
|
RestClient.get "#{URL}/entities/#{inchikey_id}.#{format}", :accept => :sdf
|
||||||
|
end
|
||||||
rescue RestClient::ResourceNotFound => e
|
rescue RestClient::ResourceNotFound => e
|
||||||
e.response
|
e.response
|
||||||
rescue RestClient::InternalServerError => e
|
rescue RestClient::InternalServerError => e
|
||||||
e.response
|
e.response
|
||||||
|
rescue RestClient::GatewayTimeout => e
|
||||||
|
e.response
|
||||||
|
rescue RestClient::RequestTimeout => e
|
||||||
|
e.response
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -40,9 +63,8 @@ module ClassyFireAPI
|
||||||
s = JSON.parse(get_query(query_id))
|
s = JSON.parse(get_query(query_id))
|
||||||
if s['error']
|
if s['error']
|
||||||
s
|
s
|
||||||
elsif s['state']
|
elsif s['classification_status:']
|
||||||
|
s['classification_status']
|
||||||
s['state']
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
Loading…
Reference in New Issue