Skip to content

Commit

Permalink
Automatically add cif2cell
Browse files Browse the repository at this point in the history
  • Loading branch information
louisponet committed Mar 14, 2018
1 parent 2984282 commit 15b1b4b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ user_defaults/*
.DS_Store
docs/build/
docs/site/
deps/bin/
deps/lib/
1 change: 1 addition & 0 deletions REQUIRE
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
julia 0.6
RecipesBase
GeometryTypes
Conda
31 changes: 29 additions & 2 deletions deps/build.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,33 @@
try
if !isdir(joinpath(@__DIR__,"../user_defaults"))
mkdir(joinpath(@__DIR__,"../user_defaults"))
open(joinpath(@__DIR__,"../user_defaults/user_defaults.jl"),"w") do f
open(joinpath(@__DIR__,"../user_defaults/user_defaults.jl"), "w") do f
write(f,"#Generated by DFControl.")
end
end

using Conda
using BinDeps


# Conda.add("PyCifRW")
tarpath = joinpath(@__DIR__, "cif2cell.tar.gz")
tarpath2 = joinpath(@__DIR__, "pycifrw.tar.gz")
download("https://10gbps-io.dl.sourceforge.net/project/cif2cell/cif2cell-1.2.10.tar.gz", tarpath)
download("https://pypi.python.org/packages/f9/95/dd59d9c62c76f90110913d28910c81c563fb6db1e2c9fc668eac43c96a75/PyCifRW-4.1.1.tar.gz#md5=2435f47a1a7a935d43c8402d8f4339d5", tarpath2)
run(unpack_cmd("cif2cell.tar.gz", @__DIR__, ".gz",".tar"))
run(unpack_cmd("pycifrw.tar.gz", @__DIR__, ".gz",".tar"))
pythonpath = joinpath(Conda.PYTHONDIR, "python2")
cd(joinpath(@__DIR__, "cif2cell-1.2.10"))
run(`$pythonpath setup.py install --prefix=$(@__DIR__)`)
cd(joinpath(@__DIR__, "PyCifRW-4.1.1"))
run(`$pythonpath setup.py install`)

cp(joinpath(@__DIR__, "lib/python2.7/site-packages/elementdata.py"),joinpath(@__DIR__, "bin/elementdata.py"))
cp(joinpath(@__DIR__, "lib/python2.7/site-packages/ESPInterfaces.py"),joinpath(@__DIR__, "bin/ESPInterfaces.py"))
cp(joinpath(@__DIR__, "lib/python2.7/site-packages/spacegroupdata.py"),joinpath(@__DIR__, "bin/spacegroupdata.py"))
cp(joinpath(@__DIR__, "lib/python2.7/site-packages/uctools.py"),joinpath(@__DIR__, "bin/uctools.py"))
cp(joinpath(@__DIR__, "lib/python2.7/site-packages/utils.py"),joinpath(@__DIR__, "bin/utils.py"))
rm(tarpath)
rm(tarpath2)
rm(joinpath(@__DIR__,"PyCifRW-4.1.1"),recursive=true)
rm(joinpath(@__DIR__,"cif2cell-1.2.10"),recursive=true)
1 change: 1 addition & 0 deletions src/DFControl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,5 @@ module DFControl
export dfprintln
const UNDO_JOBS = DFJob[]

const cif2cellpath = joinpath(@__DIR__, "../deps/bin/cif2cell")
end
6 changes: 1 addition & 5 deletions src/structure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,7 @@ function cif2structure(cif_file::String; structure_name="NoName")
tmpdir = tempdir()
tmpfile = joinpath(tmpdir, "tmp.in")
@assert splitext(cif_file)[2] == ".cif" error("Please specify a valid cif input file")
try
run(`cif2cell $cif_file -p quantum-espresso -o $tmpfile`)
catch
error("Please install cif2cell to use this feature (https://sourceforge.net/projects/cif2cell/)")
end
run(`$cif2cellpath $cif_file -p quantum-espresso -o $tmpfile`)

bla, structure = read_qe_input(tmpfile, structure_name = structure_name)
rm(tmpfile)
Expand Down

0 comments on commit 15b1b4b

Please sign in to comment.