# Similar to the previous script. This script finds all the files fitting into the filemask, e.g. "*.vel *.coor *.pdb" (search may be recursive into subfolders). Then it converts them individually into DCD format (one single-frame DCD per one file). It can (optionally) delete originals. Useful when you want in one step to free up some space, since DCD takes 2 time less space than the *coor or *.vel, and about 6 times less that PDB. Be careful with PDBs since DCD will retain only coordinates and will discard all other information (atom names, beta and occupancy fields etc.). # Andriy Anishkin (anishkin@icqmail.com) UMCP # Procedure to make a recursive list of files of current type. Both forward and back slaches can be used (for backslash put space between it and closing bracket). The last slash can be omitted. List of folders can be processed. List of filemasks may be supplied. One single filelist will be the output in any case. set recursive 0; # Flag to make <1> or not <0> recursive search into subfolders set fileMask {*.vel *.coor *.pdb}; # FileMask for files to search # set fileMask {*.coor}; # FileMask for files to search # set fileMask {*.vel}; # FileMask for files to search # set fileMask {*.vel *.coor}; # FileMask for files to search # set fileMask {*.vel *.coor *.pdb}; # FileMask for files to search # set fileMask {minall*.coor}; # FileMask for files to search set dir [subst -nobackslashes { {c:\simulations\mscs-cry_symmetrization\n-term_fully-open_straight\ } }]; # List of the folders to search set fileType {}; # Autodetect file type, if empty. Otherwise it can be pdb, namdbin... set deleteOriginals 1; # # ______________________________ Procedures declaration proc fileList {dirList recursive patternsList} { set files {} regsub -all {\\} $dirList {/} dirList foreach dir $dirList { foreach pattern $patternsList { # Reverse slashes if necessary set dir [string trim $dir] # Check if the directory name includes slash at the end if {[string compare [string index $dir end] {/}]!=0} { set dir "[set dir]/" } # Look for files in the $dir folder foreach file [eval "glob -nocomplain -path \{$dir\} -type f $pattern"] { lappend files $file } if {$recursive == 1} {; # Recursive search # Search for subfolders set subfolders [glob -nocomplain -path $dir -type d *] if {[llength $subfolders]>0} {; # There are some subfolders # Look for files in the subfolders foreach subfolder $subfolders { set subFileList [fileList $subfolder $recursive $pattern] set files [concat $files $subFileList] } } } } } set filesClean {} foreach file $files { if {[llength $file]>0} { lappend filesClean $file } } set filesClean "\{[join $filesClean "\}\n\{"]\}" return $filesClean } proc coor2dcd {filePath {fileType ""} {outFrames ""}} { # ____ Load the file if {[llength $fileType]>0} { mol new $filePath type $fileType waitfor all } else { if {[catch {mol new $filePath waitfor all}]!=0} { if {[catch {mol new $filePath type namdbin waitfor all}]!=0} { mol new $filePath type pdb waitfor all } } } animate write dcd "$filePath.dcd" waitfor all mol delete top } # ______________________________ Computational part set fileList [fileList $dir $recursive $fileMask] # puts "________________________________ " # puts $list set errorsCount 0 foreach file $fileList { if {[catch {coor2dcd $file $fileType}]!=0} { puts "Conversion of '$file' unsuccessful" incr errorsCount } else { if {$deleteOriginals==1} { if {[catch {file delete -force $file}]!=0} { puts "Finished '$file'. Original file not deleted" } else { puts "Finished '$file'. Original file deleted" } } else { puts "Finished '$file'" } } } puts " Finished !!! $errorsCount errors." # exit