@@ -23,23 +23,23 @@ Base.@ccallable function smilestomol(smiles::Cstring, options::Cstring)::Cstring
2323 if haskey(op, " remove_all_hydrogens" ) && op[" remove_all_hydrogens" ]
2424 remove_all_hydrogens!(mol) # default remove_all_hydrogens=false
2525 end
26- unsafe_convert(Cstring, JSON. json(to_dict( mol) ))
26+ unsafe_convert(Cstring, JSON. json(mol))
2727 catch e
2828 mol = SMILESMolGraph()
2929 mol[:logs][" error_smiles" ] = e. msg
30- unsafe_convert(Cstring, JSON. json(to_dict( mol) ))
30+ unsafe_convert(Cstring, JSON. json(mol))
3131 end
3232end
3333
3434
3535Base. @ccallable function smartstomol(smarts:: Cstring ):: Cstring
3636 try
3737 mol = MolecularGraph. smartstomol(unsafe_string(smarts))
38- unsafe_convert(Cstring, JSON. json(to_dict( mol) ))
38+ unsafe_convert(Cstring, JSON. json(mol))
3939 catch e
4040 mol = SMARTSMolGraph()
4141 mol[:logs][" error_smarts" ] = e. msg
42- unsafe_convert(Cstring, JSON. json(to_dict( mol) ))
42+ unsafe_convert(Cstring, JSON. json(mol))
4343 end
4444end
4545
@@ -55,18 +55,18 @@ Base.@ccallable function sdftomol(sdf::Cstring, options::Cstring)::Cstring
5555 if haskey(op, " remove_all_hydrogens" ) && op[" remove_all_hydrogens" ]
5656 remove_all_hydrogens!(mol) # default remove_all_hydrogens=false
5757 end
58- unsafe_convert(Cstring, JSON. json(to_dict( mol) ))
58+ unsafe_convert(Cstring, JSON. json(mol))
5959 catch e
6060 mol = SDFMolGraph()
6161 mol[:logs][" error_sdfile" ] = e. msg
62- unsafe_convert(Cstring, JSON. json(to_dict( mol) ))
62+ unsafe_convert(Cstring, JSON. json(mol))
6363 end
6464end
6565
6666
6767Base. @ccallable function vertex_count(mol:: Cstring ):: Cint
6868 try
69- molobj = MolGraph(JSON . parse( unsafe_string(mol) ))
69+ molobj = mol_from_json( unsafe_string(mol))
7070 nv(molobj)
7171 catch
7272 Base. invokelatest(Base. display_error, Base. catch_stack())
7676
7777Base. @ccallable function edge_count(mol:: Cstring ):: Cint
7878 try
79- molobj = MolGraph(JSON . parse( unsafe_string(mol) ))
79+ molobj = mol_from_json( unsafe_string(mol))
8080 ne(molobj)
8181 catch
8282 Base. invokelatest(Base. display_error, Base. catch_stack())
8686
8787Base. @ccallable function inchikey(mol:: Cstring ):: Cstring
8888 try
89- molobj = MolGraph(JSON . parse( unsafe_string(mol) ))
89+ molobj = mol_from_json( unsafe_string(mol))
9090 ikey = MolecularGraph. inchikey(molobj)
9191 unsafe_convert(Cstring, something(ikey, " " ))
9292 catch
9797
9898Base. @ccallable function standard_weight(mol:: Cstring ):: Cdouble
9999 try
100- molobj = MolGraph(JSON . parse( unsafe_string(mol) ))
100+ molobj = mol_from_json( unsafe_string(mol))
101101 MolecularGraph. standard_weight(molobj, 2 )
102102 catch
103103 Base. invokelatest(Base. display_error, Base. catch_stack())
107107
108108Base. @ccallable function molblock(mol:: Cstring ):: Cstring
109109 try
110- molobj = MolGraph(JSON . parse( unsafe_string(mol) ))
110+ molobj = mol_from_json( unsafe_string(mol))
111111 unsafe_convert(Cstring, printv2mol(molobj; givebackhydrogen= false ))
112112 catch
113113 Base. invokelatest(Base. display_error, Base. catch_stack())
117117
118118Base. @ccallable function sdfmolblock(mol:: Cstring ):: Cstring
119119 try
120- molobj = MolGraph(JSON . parse( unsafe_string(mol) ))
120+ molobj = mol_from_json( unsafe_string(mol))
121121 buf = IOBuffer(write= true )
122122 printv2sdf(buf, molobj; givebackhydrogen= false )
123123 res = String(take!(buf))
131131
132132Base. @ccallable function drawsvg(mol:: Cstring , options:: Cstring ):: Cstring
133133 try
134- molobj = MolGraph(JSON . parse( unsafe_string(mol) ))
134+ molobj = mol_from_json( unsafe_string(mol))
135135 op = JSON. parse(unsafe_string(options))
136136 kwgs = Pair{Symbol,Any}[]
137137 haskey(op, " viewbox" ) && push!(kwgs, :viewbox => op[" viewbox" ])
149149Base. @ccallable function drawpng(
150150 mol:: Cstring , width:: UInt32 , height:: UInt32 , options:: Cstring ):: Cstring
151151 try
152- molobj = MolGraph(JSON . parse( unsafe_string(mol) ))
152+ molobj = mol_from_json( unsafe_string(mol))
153153 op = JSON. parse(unsafe_string(options))
154154 kwgs = Pair{Symbol,Any}[]
155155 haskey(op, " show_carbon" ) && push!(kwgs, :show_carbon => Symbol(op[" show_carbon" ]))
171171Base. @ccallable function has_exact_match(
172172 mol1:: Cstring , mol2:: Cstring , kwargs:: Cstring ):: Cint
173173 try
174- mol1 = mol_from_dict(JSON . parse( unsafe_string(mol1) ))
175- mol2 = mol_from_dict(JSON . parse( unsafe_string(mol2) ))
174+ mol1 = mol_from_json( unsafe_string(mol1))
175+ mol2 = mol_from_json( unsafe_string(mol2))
176176 kwargs = JSON. parse(unsafe_string(kwargs))
177177 MolecularGraph. has_exact_match(mol1, mol2; kwargs... )
178178 catch
184184Base. @ccallable function has_substruct_match(
185185 mol1:: Cstring , mol2:: Cstring , kwargs:: Cstring ):: Cint
186186 try
187- mol1 = mol_from_dict(JSON . parse( unsafe_string(mol1) ))
188- mol2 = mol_from_dict(JSON . parse( unsafe_string(mol2) ))
187+ mol1 = mol_from_json( unsafe_string(mol1))
188+ mol2 = mol_from_json( unsafe_string(mol2))
189189 kwargs = JSON. parse(unsafe_string(kwargs))
190190 MolecularGraph. has_substruct_match(mol1, mol2; kwargs... )
191191 catch
197197Base. @ccallable function tdmcis_size(
198198 mol1:: Cstring , mol2:: Cstring , kwargs:: Cstring ):: Cint
199199 try
200- mol1 = MolGraph(JSON . parse( unsafe_string(mol1) ))
201- mol2 = MolGraph(JSON . parse( unsafe_string(mol2) ))
200+ mol1 = mol_from_json( unsafe_string(mol1))
201+ mol2 = mol_from_json( unsafe_string(mol2))
202202 kwargs = Dict(Symbol(k) => v for (k, v) in JSON. parse(unsafe_string(kwargs)))
203203 length(tdmcis(mol1, mol2; kwargs... )[1 ])
204204 catch
210210Base. @ccallable function tdmces_size(
211211 mol1:: Cstring , mol2:: Cstring , kwargs:: Cstring ):: Cint
212212 try
213- mol1 = MolGraph(JSON . parse( unsafe_string(mol1) ))
214- mol2 = MolGraph(JSON . parse( unsafe_string(mol2) ))
213+ mol1 = mol_from_json( unsafe_string(mol1))
214+ mol2 = mol_from_json( unsafe_string(mol2))
215215 kwargs = Dict(Symbol(k) => v for (k, v) in JSON. parse(unsafe_string(kwargs)))
216216 length(tdmces(mol1, mol2; kwargs... )[1 ])
217217 catch
223223Base. @ccallable function tdmcis_gls(
224224 mol1:: Cstring , mol2:: Cstring , kwargs:: Cstring ):: Cdouble
225225 try
226- mol1 = MolGraph(JSON . parse( unsafe_string(mol1) ))
227- mol2 = MolGraph(JSON . parse( unsafe_string(mol2) ))
226+ mol1 = mol_from_json( unsafe_string(mol1))
227+ mol2 = mol_from_json( unsafe_string(mol2))
228228 if nv(mol1) == 0 || nv(mol2) == 0
229229 return 0.0
230230 end
244244Base. @ccallable function tdmces_gls(
245245 mol1:: Cstring , mol2:: Cstring , kwargs:: Cstring ):: Cdouble
246246 try
247- mol1 = MolGraph(JSON . parse( unsafe_string(mol1) ))
248- mol2 = MolGraph(JSON . parse( unsafe_string(mol2) ))
247+ mol1 = mol_from_json( unsafe_string(mol1))
248+ mol2 = mol_from_json( unsafe_string(mol2))
249249 if ne(mol1) == 0 || ne(mol2) == 0
250250 return 0.0
251251 end
0 commit comments