Skip to content

Commit e47a087

Browse files
committed
v0.20.0
1 parent ad4a99e commit e47a087

File tree

11 files changed

+72
-61
lines changed

11 files changed

+72
-61
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@ clean:
1212
build: clean
1313
$(JULIA) --project=. $(JULIAC) --output-lib $(OUTPUT) --compile-ccallable src/MolecularGraph.jl
1414

15+
# Does not work for now
1516
build-trim: clean
1617
$(JULIA) --project=. $(JULIAC) --experimental --output-lib $(OUTPUT) --trim=safe --compile-ccallable src/MolecularGraph.jl

Project.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "MolecularGraph"
22
uuid = "6c89ec66-9cd8-5372-9f91-fabc50dd27fd"
3-
version = "0.19.1"
3+
version = "0.20.0"
44
authors = ["Seiji Matsuoka <[email protected]"]
55

66
[deps]
@@ -48,8 +48,7 @@ libinchi_jll = "1.5"
4848

4949
[extras]
5050
Logging = "56ddb016-857b-54e1-b83d-db4d58db5568"
51-
RDKitMinimalLib = "44044271-7623-48dc-8250-42433c44e4b7"
5251
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
5352

5453
[targets]
55-
test = ["Test", "Logging", "RDKitMinimalLib"]
54+
test = ["Test", "Logging"]

hoge.png

-23.1 KB
Binary file not shown.

scripts/python_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def tdmces_size(jl, mol1: bytes, mol2: bytes, options: bytes) -> int:
162162
print(has_substruct_match(jl, mol1, mol2, json.dumps({}).encode()))
163163
print(tdmces_size(jl, mol1, mol2, json.dumps({}).encode()))
164164
print(len(mol_to_svg(jl, mol1, json.dumps({}).encode())))
165-
print(len(mol_to_png(jl, mol1, 100, 100, json.dumps({}).encode())))
165+
# print(len(mol_to_png(jl, mol1, 100, 100, json.dumps({}).encode())))
166166
print(len(mol_to_molblock(jl, mol1)))
167167
print(len(mol_to_sdfblock(jl, mol1)))
168168
jl_exit(jl)

src/draw/svg.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ Generate fixed-size HTML wrapper for the SVG element.
128128
129129
The width and height args can be numeric values (converted to `px`) or CSS strings like `100%`.
130130
"""
131-
function html_fixed_size(mol, width, height; kwargs...)
131+
function html_fixed_size(mol::SimpleMolGraph, width, height; kwargs...)
132132
wstr = width isa Real ? "$(convert(Int, round(width)))px" : width
133133
hstr = height isa Real ? "$(convert(Int, round(height)))px" : height
134134
svg = drawsvg(mol; kwargs...)
@@ -137,14 +137,14 @@ end
137137

138138

139139
"""
140-
html_grid(mols, cols, rowheight) -> HTML{String}
140+
html_grid(mols, cols::Int, rowheight) -> HTML{String}
141141
142142
Generate grid layout HTML wrapper for the SVG elements.
143143
144144
`cols` - number of columns in the grid.
145145
`rowheight` - numeric value (converted to `px`) or CSS string like `100%`.
146146
"""
147-
function html_grid(mols, cols, rowheight; kwargs...)
147+
function html_grid(mols, cols::Int, rowheight; kwargs...)
148148
htmls = String[]
149149
hstr = rowheight isa Real ? "$(convert(Int, round(rowheight)))px" : rowheight
150150
for row in Iterators.partition(mols, cols)

src/preprocess.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ function kekulize(mol::SimpleMolGraph{T}) where T
8080
return bondorder, pyrrole_like
8181
end
8282

83-
function kekulize!(mol::ReactiveMolGraph)
83+
function kekulize!(mol::SimpleMolGraph)
8484
bondorder, pyrrole_like = kekulize(mol)
8585
mol.gprops.descriptors.bond_order = bondorder
8686
mol.gprops.pyrrole_like = pyrrole_like
@@ -216,7 +216,7 @@ function protonate_acids(mol::SimpleMolGraph)
216216
return arr
217217
end
218218

219-
function protonate_acids!(mol::ReactiveMolGraph)
219+
function protonate_acids!(mol::SimpleMolGraph)
220220
has_descriptor(mol, :atom_charge) || error("Descriptor :atom_charge not available")
221221
set_descriptor!(mol, :atom_charge, protonate_acids(mol))
222222
return
@@ -238,7 +238,7 @@ function deprotonate_oniums(mol::SimpleMolGraph)
238238
return arr
239239
end
240240

241-
function deprotonate_oniums!(mol::ReactiveMolGraph)
241+
function deprotonate_oniums!(mol::SimpleMolGraph)
242242
has_descriptor(mol, :atom_charge) || error("Descriptor :atom_charge not available")
243243
set_descriptor!(mol, :atom_charge, deprotonate_oniums(mol))
244244
return
@@ -271,7 +271,7 @@ function depolarize(mol::SimpleMolGraph; negative=:O, positive=[:C, :P])
271271
return carr, oarr
272272
end
273273

274-
function depolarize!(mol::ReactiveMolGraph)
274+
function depolarize!(mol::SimpleMolGraph)
275275
has_descriptor(mol, :atom_charge) || error("Descriptor :atom_charge not available")
276276
has_descriptor(mol, :bond_order) || error("Descriptor :bond_order not available")
277277
carr, oarr = depolarize(mol)
@@ -307,7 +307,7 @@ function polarize(mol::SimpleMolGraph; negative=:O, positive=[:N, :S])
307307
return carr, oarr
308308
end
309309

310-
function polarize!(mol::ReactiveMolGraph)
310+
function polarize!(mol::SimpleMolGraph)
311311
has_descriptor(mol, :atom_charge) || error("Descriptor :atom_charge not available")
312312
has_descriptor(mol, :bond_order) || error("Descriptor :bond_order not available")
313313
carr, oarr = polarize(mol)
@@ -352,7 +352,7 @@ function to_triple_bond(mol::SimpleMolGraph)
352352
return carr, oarr
353353
end
354354

355-
function to_triple_bond!(mol::ReactiveMolGraph)
355+
function to_triple_bond!(mol::SimpleMolGraph)
356356
has_descriptor(mol, :atom_charge) || error("Descriptor :atom_charge not available")
357357
has_descriptor(mol, :bond_order) || error("Descriptor :bond_order not available")
358358
carr, oarr = to_triple_bond(mol)
@@ -379,7 +379,7 @@ function to_allene_like(mol::SimpleMolGraph)
379379
return carr, oarr
380380
end
381381

382-
function to_allene_like!(mol::ReactiveMolGraph)
382+
function to_allene_like!(mol::SimpleMolGraph)
383383
has_descriptor(mol, :atom_charge) || error("Descriptor :atom_charge not available")
384384
has_descriptor(mol, :bond_order) || error("Descriptor :bond_order not available")
385385
carr, oarr = to_allene_like(mol)

src/property/interface.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,16 @@ to_dict(::Val{:metadata}, ::Val{:default}, gprop::AbstractProperty
7777

7878
# Metadata specific shorthands (e.g. mol["compound_id"] = "CP000001")
7979

80-
function set_prop!(mol::ReactiveMolGraph, prop::String, value::String)
80+
function set_prop!(mol::SimpleMolGraph, prop::String, value::String)
8181
# Metadata update would not affect graph state
8282
mol.gprops.metadata[prop] = value
8383
end
8484

85-
get_prop(mol::ReactiveMolGraph, prop::String) = mol.gprops.metadata[prop]
86-
has_prop(mol::ReactiveMolGraph, prop::String) = haskey(mol.gprops.metadata, prop)
85+
get_prop(mol::SimpleMolGraph, prop::String) = mol.gprops.metadata[prop]
86+
has_prop(mol::SimpleMolGraph, prop::String) = haskey(mol.gprops.metadata, prop)
8787

88-
Base.getindex(mol::ReactiveMolGraph, key::String) = get_prop(mol, key)
89-
Base.setindex!(mol::ReactiveMolGraph, value::String, key::String) = set_prop!(mol, key, value)
88+
Base.getindex(mol::SimpleMolGraph, key::String) = get_prop(mol, key)
89+
Base.setindex!(mol::SimpleMolGraph, value::String, key::String) = set_prop!(mol, key, value)
9090

9191

9292
# Descriptors
@@ -186,16 +186,16 @@ function remap_gprops!(mol::ReactiveMolGraph, vmap::Vector{T},
186186
end
187187

188188

189-
get_prop(mol::ReactiveMolGraph, prop::Symbol) = getproperty(mol.gprops, prop)
190-
has_prop(mol::ReactiveMolGraph, prop::Symbol) = hasproperty(mol.gprops, prop)
189+
get_prop(mol::SimpleMolGraph, prop::Symbol) = getproperty(mol.gprops, prop)
190+
has_prop(mol::SimpleMolGraph, prop::Symbol) = hasproperty(mol.gprops, prop)
191191
# Note: editing graph-level properties may break consistency.
192-
set_prop!(mol::ReactiveMolGraph, prop::Symbol, value
192+
set_prop!(mol::SimpleMolGraph, prop::Symbol, value
193193
) = setproperty!(mol.gprops, prop, value)
194194

195-
get_descriptor(mol::ReactiveMolGraph, field::Symbol
195+
get_descriptor(mol::SimpleMolGraph, field::Symbol
196196
) = getproperty(mol.gprops.descriptors, field)
197-
has_descriptor(mol::ReactiveMolGraph, field::Symbol
197+
has_descriptor(mol::SimpleMolGraph, field::Symbol
198198
) = hasproperty(mol.gprops.descriptors, field)
199-
set_descriptor!(mol::ReactiveMolGraph, field::Symbol, value
199+
set_descriptor!(mol::SimpleMolGraph, field::Symbol, value
200200
) = setproperty!(mol.gprops.descriptors, field, value)
201201

src/sdfilereader.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function sympair(s)::Pair{Symbol, Union{String, Int}}
1616
end
1717

1818

19-
function ctab_atom_v2(::Type{T}, line::AbstractString) where T
19+
function ctab_atom_v2(::Type{T}, line::AbstractString) where T <: AbstractElement
2020
d = Dict{String,Any}()
2121
xpos = parse(Float64, line[1:10])
2222
ypos = parse(Float64, line[11:20])
@@ -33,7 +33,7 @@ function ctab_atom_v2(::Type{T}, line::AbstractString) where T
3333
return T(d)
3434
end
3535

36-
function ctab_atom_v3(::Type{T}, line::AbstractString) where T
36+
function ctab_atom_v3(::Type{T}, line::AbstractString) where T <: AbstractElement
3737
d = Dict{String,Any}()
3838
ss = split(line)
3939
d["coords"] = parse.(Float64, ss[5:7])
@@ -45,7 +45,8 @@ function ctab_atom_v3(::Type{T}, line::AbstractString) where T
4545
return T(d)
4646
end
4747

48-
function ctab_bond_v2(::Type{T}, ::Type{E}, line::AbstractString) where {T<:Integer,E}
48+
function ctab_bond_v2(
49+
::Type{T}, ::Type{E}, line::AbstractString) where {T<:Integer,E<:AbstractElement}
4950
d = Dict{String,Any}()
5051
u = parse(T, line[1:3])
5152
v = parse(T, line[4:6])
@@ -56,7 +57,8 @@ function ctab_bond_v2(::Type{T}, ::Type{E}, line::AbstractString) where {T<:Inte
5657
return (u_edge(T, u, v), E(d))
5758
end
5859

59-
function ctab_bond_v3(::Type{T}, ::Type{E}, line::AbstractString) where {T<:Integer,E}
60+
function ctab_bond_v3(
61+
::Type{T}, ::Type{E}, line::AbstractString) where {T<:Integer,E<:AbstractElement}
6062
d = Dict{String,Any}()
6163
ss = split(line)
6264
d["order"], u, v = parse.(T, ss[4:6])
@@ -363,7 +365,7 @@ rdfilereader(::Type{T}, path::AbstractString; kwargs...
363365
rdfilereader(path::AbstractString; kwargs...) = rdfilereader(Reaction{SDFMolGraph}, open(path); kwargs...)
364366

365367

366-
struct SDFileScanner{T}
368+
struct SDFileScanner{T<:AbstractMolGraph}
367369
io::IO
368370
end
369371

0 commit comments

Comments
 (0)