-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding the other polymorphs, /tmp modification and adding text files
- Loading branch information
1 parent
119ee92
commit b1c2c9e
Showing
13 changed files
with
547 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
""" | ||
transformingPBC(nfrag::Int64, xsize::Int64, ysize::Int64; phase="Iβ", pbc=nothing, xyzfile="file.xyz", vmd="vmd") | ||
This function applies the periodic boundary conditions on the cellulose fibrils over the axis `a`, `b`, and `both`. | ||
After this transformation, you export the cellulose fibril XYZ file with the cartesian coordinates. | ||
## Arguments | ||
- `nfrag::Int64`: is the number of fragments inside the XYZ file. | ||
- `xsize::Int64`: the number of unit cells along x axis (`a`). | ||
- `ysize::Int64`: the number of unit cells units along y axis (`b`). | ||
### Examples | ||
```jldoctest | ||
julia > transformingPBC(59, 5, 7) | ||
``` | ||
""" | ||
|
||
function transformingPBC(nfrag::Int64, xsize::Int64, ysize::Int64; phase="Iβ", pbc=nothing, xyzfile="file.xyz", vmd="vmd") | ||
|
||
forbbiden=Int64[]; remainder=Int64[]; | ||
|
||
if phase == "I-BETA" || phase == "Ib" || phase == "Iβ" | ||
|
||
a=nfrag; boundary=1; n_forbbiden=0; upper=nfrag-1; | ||
|
||
if pbc == :all || pbc == :ALL || pbc == :All | ||
for b in collect(boundary:1:ysize) | ||
n_forbbiden = (2*xsize-1)*b - 1 | ||
push!(forbbiden, convert(Int64, n_forbbiden)) | ||
end | ||
for b in collect(boundary:1:xsize) | ||
a = a - 1 | ||
push!(forbbiden, convert(Int64, a)) | ||
end | ||
elseif pbc == :a || pbc == :A | ||
for b in collect(boundary:1:ysize) | ||
n_forbbiden = (2*xsize-1)*b - 1 | ||
push!(forbbiden, convert(Int64, n_forbbiden)) | ||
end | ||
elseif pbc == :b || pbc == :B | ||
for b in collect(boundary:1:xsize) | ||
a = a - 1 | ||
push!(forbbiden, convert(Int64, a)) | ||
end | ||
end | ||
|
||
for num in 0:upper | ||
dummy_logical = 1 | ||
for ith_forbs in forbbiden | ||
if num == ith_forbs | ||
dummy_logical = 0 | ||
break | ||
end | ||
end | ||
if dummy_logical == 1 | ||
remainder = push!(remainder, convert(Int64, num)) | ||
end | ||
end | ||
|
||
sel_fragments = join(remainder, " "); n_fragments = length(remainder); | ||
|
||
new_xyzfile = "/tmp/cellulose" * ".xyz" | ||
vmdinput_file = tempname() * ".tcl" | ||
|
||
vmdinput = open(vmdinput_file, "w") | ||
Base.write(vmdinput, "mol new \"$xyzfile\" \n") | ||
Base.write(vmdinput, "set sel [ atomselect top \"fragment $sel_fragments\" ] \n") | ||
Base.write(vmdinput, "\$sel writexyz \"$new_xyzfile\" \n") | ||
Base.write(vmdinput, "exit \n") | ||
Base.close(vmdinput) | ||
vmdoutput = split(Base.read(`$vmd -dispdev text -e $vmdinput_file`, String), "\n") | ||
|
||
end | ||
|
||
return new_xyzfile, sel_fragments, n_fragments | ||
|
||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
cleaning_tmpfiles() | ||
Move the exported files to the work directory and clean all the *.pdb, *.tcl, and *xyz on temporary | ||
files inside the temp folder (it can be different on Linux, Windows and MacOS). | ||
### Arguments | ||
- `filename::String`: main name of the exported file. | ||
- `destination_path`: the default destination folder is the working directory. | ||
### Examples | ||
```jldoctest | ||
julia > cleaning_tmpfiles() | ||
``` | ||
""" | ||
|
||
function cleaning_tmpfiles(filename::String; destination_path=pwd()) | ||
|
||
tmp_path = tempdir() | ||
|
||
mv(joinpath(tmp_path, "$filename.xyz"), joinpath(destination_path, "$filename.xyz"), force=true) | ||
mv(joinpath(tmp_path, "$filename.psf"), joinpath(destination_path, "$filename.psf"), force=true) | ||
mv(joinpath(tmp_path, "$filename.pdb"), joinpath(destination_path, "$filename.pdb"), force=true) | ||
|
||
files = readdir(tmp) | ||
for file in files | ||
if occursin(".pdb", file) || occursin(".xyz", file) || occursin(".tcl", file) | ||
rm(joinpath(tmp_path, file)) | ||
end | ||
end | ||
|
||
return nothing | ||
|
||
end |
Oops, something went wrong.