From b458fc8c6267d391e4664f87d796c998212dbe32 Mon Sep 17 00:00:00 2001 From: Marcello Sega Date: Tue, 29 Apr 2014 17:26:39 +0200 Subject: [PATCH] fixes VMD crash with long lines in vtf files --- scripts/vtf.tcl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/scripts/vtf.tcl b/scripts/vtf.tcl index 2030da82e1..870fae0c94 100644 --- a/scripts/vtf.tcl +++ b/scripts/vtf.tcl @@ -195,8 +195,20 @@ proc writevsf { file args } { lappend aids "$from:$to" } unset from - - puts $file "atom [join $aids ,] $desc" + # let's group atom ranges, so that there are no more than 8 per line + # This fixes a problem with the vmd plugin, and makes the vtf more + # readable anyway. + set start 0 + set maxlen 8 + set ll [llength [lrange $aids $start end ]] + while { $ll >= $maxlen } { + puts $file "atom [join [lrange $aids $start [expr $start + $maxlen -1]] ,] $desc" + incr start $maxlen + set ll [llength [lrange $aids $start end ]] + } + if { $start < [llength $aids ] } { + puts $file "atom [join [lrange $aids $start end] ,] $desc" + } } # Print bond data