/usr/share/xcrysden/Tcl/xyz.tcl is in xcrysden-data 1.5.53-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | #############################################################################
# Author: #
# ------ #
# Anton Kokalj Email: Tone.Kokalj@ijs.si #
# Department of Physical and Organic Chemistry Phone: x 386 1 477 3523 #
# Jozef Stefan Institute Fax: x 386 1 477 3811 #
# Jamova 39, SI-1000 Ljubljana #
# SLOVENIA #
# #
# Source: $XCRYSDEN_TOPDIR/Tcl/xyz.tcl
# ------ #
# Copyright (c) 1996-2003 by Anton Kokalj #
#############################################################################
proc xyzOpen {{file {}} {viewmol_exists {}}} {
global system
if { $file == {} } {
# get-file
set file [tk_getOpenFile -defaultextension .xyz \
-filetypes {
{{XYZ Files} {.xyz} }
{{All Files} {.*} }
} -initialdir $system(PWD) \
-title "Open XYZ File"]
if { $file == "" } {
return
}
} else {
if { ![file exists $file] } {
ErrorDialog "File \"$file\" does not exists !!!"
return
}
}
# uncompress the file is necessary
set file [gunzipFile $file]
set head [file rootname [file tail $file]]
set xsfFile $system(SCRDIR)/$head.xsf
# open the XYZ(read) and XSF(write) file
set xyzID [open $file r]
set xsfID [open $xsfFile w]
# --------------------------------------------------
# first-pass read (estimate number of animsteps)
# --------------------------------------------------
gets $xyzID line
set natoms [lindex $line 0]
if { ![string is integer $natoms] } {
ErrorDialog "error parsing XYZ file: \"$file\" !!!"
return
}
set nline 0
seek $xyzID 0 start
while {[gets $xyzID line] > -1} {
incr nline
}
# calculate number of animsteps
set animsteps [expr {int($nline / ($natoms + 2))}]
if { $animsteps > 1 } {
puts $xsfID "ANIMSTEPS $animsteps"
}
# --------------------------------------------------
# second-pass read: write XSF file
# --------------------------------------------------
seek $xyzID 0 start
set iframe 0
while {[gets $xyzID line] > -1} {
incr iframe
if { [llength $line] == 0 } {
# skip empty line
continue
}
set natoms [lindex $line 0]
if { ![string is integer $natoms] } {
ErrorDialog "error parsing XYZ file: \"$file\" !!!"
return
}
# read comment line
gets $xyzID lin
# read atoms
if { $animsteps > 1} {
puts $xsfID "ATOMS $iframe"
} else {
puts $xsfID "ATOMS"
}
for {set ia 0} {$ia < $natoms} {incr ia} {
if {[gets $xyzID line] < 0} {
ErrorDialog "error parsing XYZ file: \"$file\" !!!"
return
}
puts $xsfID $line
}
}
# close files
close $xyzID
close $xsfID
# load the structure ...
xsfOpen $xsfFile
}
|