Skip to content

Commit

Permalink
Better parsing of colvar.traj files in VMD
Browse files Browse the repository at this point in the history
  • Loading branch information
jhenin committed Jun 26, 2024
1 parent 17f7f54 commit 0f2d682
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions vmd/cv_dashboard/cv_dashboard.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,7 @@ proc ::cv_dashboard::load_cv_traj { filenames } {
}

set steps [list]
set step -1 ;# MD step read from first column
set file_num 0
set title ""

Expand All @@ -851,7 +852,6 @@ proc ::cv_dashboard::load_cv_traj { filenames } {
puts "Opening $n ..."
set fd [open $n "r"]
set line_in_file 0
set step -1 ;# MD step read from first column
incr file_num

while { [gets $fd line] >= 0 } {
Expand All @@ -871,12 +871,16 @@ proc ::cv_dashboard::load_cv_traj { filenames } {
}
}
# This is a data line
incr line_in_file
set prev_step $step
set step [lindex $line 0]
if { $step == $prev_step } { continue }
incr line_in_file
if { $line_in_file == 1 && $file_num > 1 } {
# Skip redundant first data line in subsequent files
if { $step == $prev_step } {
puts "Skipping second copy of step $step"
continue
}
if { $line_in_file == 1 && $file_num > 1 && $step <= $prev_step } {
# Step number may reset between files and take a lower value
puts "Skipping redundant first step $step"
continue
}
# Convert vector quantities to Tcl lists: ( 1.0 , 2.3 ) -> { 1.0 2.3 }
Expand Down Expand Up @@ -913,7 +917,8 @@ proc ::cv_dashboard::load_cv_traj { filenames } {
puts "Error: cannot match $nsteps steps with $nf frames."
tk_messageBox -icon error -title "Colvars Dashboard Error"\
-message "Could not match $nsteps steps with $nf frames. Check that the selected colvars.traj files ($filenames) correspond to \
the loaded trajectory of molecule $molid, and that the molecular trajectory frequency is a multiple of the colvars.traj frequency."
the loaded trajectory of molecule $molid, and that the molecular trajectory frequency is a multiple of the colvars.traj frequency. \
Read the standard output (terminal) for details."
return
}

Expand Down
2 changes: 1 addition & 1 deletion vmd/cv_dashboard/cv_dashboard_main.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ proc ::cv_dashboard::createWindow {} {
incr gridrow
grid [ttk::button $main.cvfromprotein -text "Protein/NA auto-colvars" -command ::cv_dashboard::auto_cv -padding "2 0 2 0"] -row $gridrow -column 0 -pady 2 -padx 2 -sticky nsew
grid [ttk::button $main.cvfromlabels -text "Colvars from VMD labels" -command ::cv_dashboard::cvs_from_labels -padding "2 0 2 0"] -row $gridrow -column 1 -pady 2 -padx 2 -sticky nsew
grid [ttk::button $main.cvfromtraj -text "Colvars from traj file" -command ::cv_dashboard::cvs_from_traj -padding "2 0 2 0"] -row $gridrow -column 2 -pady 2 -padx 2 -sticky nsew
grid [ttk::button $main.cvfromtraj -text "Colvars from traj files" -command ::cv_dashboard::cvs_from_traj -padding "2 0 2 0"] -row $gridrow -column 2 -pady 2 -padx 2 -sticky nsew

# General options
incr gridrow
Expand Down

0 comments on commit 0f2d682

Please sign in to comment.