Skip to content

Commit f5568c8

Browse files
authored
Merge pull request #6 from cclib/dev/bindings
Dev/bindings
2 parents 8737740 + 2d1b969 commit f5568c8

11 files changed

+7680
-1930
lines changed

CondaPkg.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
[pip.deps]
3+
cclib = ""

Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ authors = ["Felipe S. S. Schneider <[email protected]> and contri
44
version = "0.1.0"
55

66
[deps]
7+
CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
78
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
9+
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"
810

911
[compat]
1012
PyCall = "1"

src/Cclib.jl

Lines changed: 6 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,77 +1,14 @@
1-
# Basically an exact application of
2-
# <https://github.com/JuliaPy/PyCall.jl#using-pycall-from-julia-modules>.
3-
#
4-
# The initialization strategy is similar to the one employed by SymPy.jl, see
5-
# <https://github.com/JuliaPy/SymPy.jl/blob/aea9fb5568022bbd68fe4b69d670ce2a22413a7c/src/SymPy.jl#L124>.
6-
7-
__precompile__()
8-
91
module Cclib
2+
using PythonCall
3+
using CondaPkg
104

11-
using PyCall
12-
13-
14-
export bridge
15-
export io
16-
export method
17-
export parser
18-
19-
export ccopen, ccwrite
20-
21-
22-
"""
23-
bridge
24-
25-
Facilities for moving parsed data to other cheminformatic libraries.
26-
"""
27-
const bridge = PyCall.PyNULL()
28-
29-
"""
30-
io
31-
32-
Available writers for standard chemical representations.
33-
"""
34-
const io = PyCall.PyNULL()
35-
36-
"""
37-
method
38-
39-
Analyses and calculations based on data parsed by cclib.
40-
"""
41-
const method = PyCall.PyNULL()
42-
43-
"""
44-
parser
45-
46-
Parsers for all supported programs.
47-
"""
48-
const parser = PyCall.PyNULL()
49-
50-
51-
"""
52-
Guess the identity of a particular log file and return an instance of it.
53-
"""
54-
const ccopen = PyCall.PyNULL()
55-
56-
"""
57-
Write the parsed data from an outputfile to a standard chemical representation.
58-
"""
59-
const ccwrite = PyCall.PyNULL()
5+
include("functions.jl")
6+
include("config.jl")
607

8+
const cclib = Ref{Py}()
619

6210
function __init__()
63-
cclib = PyCall.pyimport_conda("cclib", "cclib")
64-
65-
# Version of the underlying cclib Python package.
66-
global __version__ = cclib.__version__
67-
68-
copy!(bridge, PyCall.pyimport_conda("cclib.bridge", "cclib"))
69-
copy!(io, PyCall.pyimport_conda("cclib.io", "cclib"))
70-
copy!(method, PyCall.pyimport_conda("cclib.method", "cclib"))
71-
copy!(parser, PyCall.pyimport_conda("cclib.parser", "cclib"))
72-
73-
copy!(ccopen, io.ccopen)
74-
copy!(ccwrite, io.ccwrite)
11+
cclib[] = pyimport("cclib")
7512
end
7613

7714
end

src/config.jl

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
export cclibtypes
2+
3+
cclibtypes = Dict(
4+
"aonames" => Array{String},
5+
"aooverlaps" => Array{Float64, 2},
6+
"atombasis" => Array{Array{Int64}},
7+
"atomcharges" => Dict{String, Array{Float64}},
8+
"atomcoords" => Array{Float64, 3},
9+
"atommasses" => Array{Float64},
10+
"atomnos" => Array{Int64},
11+
"atomspins" => Dict{Array},
12+
"ccenergies" => Array{Float64, 2},
13+
"charge" => Int64,
14+
"coreelectrons" => Array{}, # specify subytpe?
15+
"dispersionenergies" => Array{Float64},
16+
"enthalpy" => Float64,
17+
"entropy" => Float64,
18+
"etenergies" => Array{Float64},
19+
20+
# # subtypes for these?
21+
"etoscs" => Array{},
22+
"etdips" => Array{},
23+
"etveldips" => Array{},
24+
"etmagdips" => Array{},
25+
"etrotats" => Array{},
26+
27+
"etsecs" => Array{Array},
28+
"etsyms" => Array{String},
29+
"freeenergy" => Float64,
30+
"fonames" => Array{String},
31+
"fooverlaps" => Array{}, # subtype ?
32+
"fragnames" => Array{String},
33+
"frags" => Array{Array},
34+
"gbasis" => Any, # PyQuante format
35+
"geotargets" => Array{},
36+
"geovalues" => Array{},
37+
"grads" => Array{},
38+
"hessian" => Array{},
39+
"homos" => Array{},
40+
"metadata" => Dict{Any, Any},
41+
"mocoeffs" => Array{Array{Float64}},
42+
"moenergies" => Array{Array{Float64}},
43+
"moments" => Array{Array},
44+
"mosyms" => Array{Array},
45+
"mpenergies" => Array{Array{Float64}},
46+
"mult" => Int64,
47+
"natom" => Int64,
48+
"nbasis" => Int64,
49+
"nmo" => Int64,
50+
"nmrtensors" => Any, # Find the right one for this one
51+
"nocoeffs" => Array{Array},
52+
"nooccnos" => Array{Array},
53+
"optdone" => Bool,
54+
"optstatus" => Array{},
55+
"polarizabilities" => Array{Array{Float64, 2}},
56+
"pressure" => Float64,
57+
"scancoords" => Array{},
58+
"scanenergies" => Array{},
59+
"scannames" => Array{String},
60+
"scanparm" => Array{Tuple},
61+
"scfenergies" => Array{Float64},
62+
"scftargets" => Array{Float64, 2},
63+
"scfvalues" => Array{Array{Float64, 2}},
64+
"temperature" => Float64,
65+
"time" => Array{},
66+
"transprop" => Dict{Any, Any},
67+
"vibanharms" => Array{},
68+
"vibdisps" => Array{},
69+
"vibfreqs" => Array{},
70+
"vibfconsts" => Array{},
71+
"vibirs" => Array{},
72+
"vibanharms" => Array{},
73+
"vibrmasses" => Array{},
74+
"vibsyms" => Array{String},
75+
"zpve" => Float64
76+
)

src/functions.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
export ccread
2+
3+
4+
function pyccread(file)
5+
data = cclib[].io.ccread(file)
6+
keys = pyconvert(Array, data.__dict__.keys())
7+
values = pyconvert(Array, data.__dict__.values())
8+
return Dict(zip(keys, values))
9+
end
10+
11+
function ccread(pydict)
12+
datadict = pyccread(pydict)
13+
for (key, value) in datadict
14+
type = cclibtypes[key]
15+
datadict[key] = pyconvert(type, value)
16+
end
17+
return datadict
18+
end

0 commit comments

Comments
 (0)