Skip to content

Commit

Permalink
add inorganic database, support passing other types of strings
Browse files Browse the repository at this point in the history
  • Loading branch information
longemen3000 committed Nov 22, 2024
1 parent 49c8630 commit 30f9020
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ChemicalIdentifiers"
uuid = "fa4ea961-1416-484e-bda2-883ee1634ba5"
authors = ["Andrés Riedemann <[email protected]> and contributors"]
version = "0.1.9"
version = "0.1.10"

[deps]
Arrow = "69666777-d1a9-59fb-9406-91d4454c9d45"
Expand All @@ -15,7 +15,7 @@ Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
Arrow = "^1.5, 2"
Preferences = "^1.2"
Scratch = "^1.1"
julia = "^1.6"
julia = "^1.6"D

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
7 changes: 5 additions & 2 deletions src/ChemicalIdentifiers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,14 @@ If you don't want to store the query, you could use `search_chemical(query,nothi
end
global download_cache = Scratch.@get_scratch!("databases")

url_short = "https://github.com/CalebBell/chemicals/raw/master/chemicals/Identifiers/chemical%20identifiers%20pubchem%20small.tsv"
url_long = "https://github.com/CalebBell/chemicals/raw/master/chemicals/Identifiers/chemical%20identifiers%20pubchem%20large.tsv"
url_short = "https://raw.githubusercontent.com/CalebBell/chemicals/refs/heads/master/chemicals/Identifiers/chemical%20identifiers%20pubchem%20small.tsv"
url_inorganic = "https://raw.githubusercontent.com/CalebBell/chemicals/refs/heads/master/chemicals/Identifiers/Inorganic%20db.tsv"
url_long = "https://raw.githubusercontent.com/CalebBell/chemicals/refs/heads/master/chemicals/Identifiers/chemical%20identifiers%20pubchem%20large.tsv"
load_data!(:short,url= url_short)
load_data!(:inorganic,url = url_inorganic)
load_data!(:long,url = url_long)
load_db!(:short)
load_db!(:inorganic)
load_db!(:long)
return nothing
end
Expand Down
6 changes: 4 additions & 2 deletions src/search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ function detect_query(id::String)
end
end

detect_query(id::AbstractString) = detect_query(String(id))

function detect_query(id::Int)
return PubChemIDQuery(id)
end
Expand All @@ -67,9 +69,9 @@ end

function db_iteration_order(DB)
#generating keys iteration order: user, short database, long database
dbnames = [:short,:long]
dbnames = [:short,:inorganic,:long]
for k in keys(DATA_DB)
if !(k in (:short,:long))
if !(k in (:short,:inorganic,:long))
push!(dbnames,k)
end
end
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ using Test
res1 = search_chemical("water",nothing)
res2 = search_chemical("SMILES=O",nothing)
res3 = search_chemical("water (H2O)", nothing)
res4 = search_chemical(lstrip(" water"),nothing)
@test res1.formula == res2.formula
@test res1.formula == res3.formula
@test res1.formula == res4.formula
@test ismissing(search_chemical("[3-(2,3-EPOXYPROXY)PROPYL]TRIMETHOXYSILANE",nothing))
@test ismissing(search_chemical(missing))
end
Expand Down

0 comments on commit 30f9020

Please sign in to comment.