CAS Common Chemistry

Is there a Julia package for accessing the CAS Common Chemistry database?

2 Likes

You might not need a package depending on how much processing you require?
For example, I found this tutorial โ€ฆin Python โ€” Scholarly API Cookbook
It is reasonably direct to adapt it to Julia:

using HTTP
using JSON

detail_base_url = "https://commonchemistry.cas.org/api/detail?"
casrn1 = "10094-36-7" # ethyl cyclohexanepropionate

data = HTTP.request("GET", detail_base_url*"cas_rn="*casrn1)
body = String(data.body)

casrn1_data = JSON.parse(body)

# We can then use the data: for example, get an SVG of the format
write(casrn1*".svg", casrn1_data["image"])
# or continue with the tutorial example:
casrn1_data["experimentalProperties"][1]

If youโ€™re interested in writing this into a package, happy to help.

2 Likes

Thanks for the link and suggestions @jd-foster .

Could be fun to write a package like that together.

1 Like

Now there is a package for accessing the CAS Common Chemistry API: GitHub - tp2750/CasCommonChemistry.jl

It only exports two functions: cas, cas_search.
For interactive use, the cas function should all that is needed.

It takes a query string as input, and returns a DataFrame of matching records:

julia> using CasCommonChemistry

julia> cas("water")
# [ Info: Found 1 results from query 'water'. Fetching 1..1
# 1ร—15 DataFrame
#  Row โ”‚ hasMolfile  rn         name    inchi              replacedRns                        smile   experimentalProperties             โ‹ฏ
#      โ”‚ Bool        String     String  String             Vector{Any}                        String  Vector{Any}                        โ‹ฏ
# โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
#    1 โ”‚       true  7732-18-5  Water   InChI=1S/H2O/h1H2  Any["558440-22-5", "558440-53-2"โ€ฆ  O       Any[Dict{String, Any}("name"=>"Bโ€ฆ  โ‹ฏ

It is not registered yet.

Comments are welcome.

4 Likes