Changeset 1801 for branches/blt4/gui


Ignore:
Timestamp:
Jul 12, 2010, 8:03:19 PM (14 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/gui/scripts/analyzer.tcl

    r1795 r1801  
    12051205
    12061206# ----------------------------------------------------------------------
    1207 # USAGE: _trajtosequence <xmlobj> ?<path>?
    1208 #
    1209     # If the molecule element is a trajectory, delete the original
    1210     # and create a sequence of individual molecules.
     1207# USAGE: _pdbToSequence <xmlobj> ?<path>?
     1208#
     1209# If the molecule element is a trajectory, delete the original
     1210# and create a sequence of individual molecules.
    12111211# Used internally to detect any molecule output elements that contain
    12121212# trajectory data.  Trajectories will be converted into sequences of
     
    12211221    $xmlobj remove $child
    12221222
    1223     set seqPath  $path.sequence($id)
    1224     $xmlobj put ${seqPath}.about.label $seqLabel
    1225     $xmlobj put ${seqPath}.about.description $descr
    1226     $xmlobj put ${seqPath}.index.label "Frame"
     1223    set sequence  $path.sequence($id)
     1224    $xmlobj put ${sequence}.about.label $seqLabel
     1225    $xmlobj put ${sequence}.about.description $descr
     1226    $xmlobj put ${sequence}.index.label "Frame"
     1227
     1228    set frameNum 0
     1229    set numLines [llength $data]
     1230    for { set i 0 } { $i < $numLines } { incr i } {
     1231        set line [lindex $data $i]
     1232        set line [string trim $line]
     1233        set contents {}
     1234        if { [string match "MODEL*" $line] } {
     1235            # Save the contents until we get an ENDMDL record.
     1236            for {} { $i < $numLines } { incr i } {
     1237                set line [lindex $data $i]
     1238                set line [string trim $line]
     1239                if { $line == "" } {
     1240                    continue;           # Skip blank lines.
     1241                }
     1242                if { [string match "ENDMDL*" $line] } {
     1243                    break;
     1244                }
     1245                append contents $line\n
     1246            }
     1247            set frame ${sequence}.element($frameNum)
     1248            $xmlobj put ${frame}.index $frameNum
     1249           
     1250            set molecule ${frame}.structure.components.molecule
     1251            $xmlobj put ${molecule}.pdb $contents
     1252            $xmlobj put ${molecule}.formula $formula
     1253            incr frameNum
     1254        }
     1255    }
     1256}
     1257
     1258itcl::body Rappture::Analyzer::_lammpsToSequence {xmlobj path id child data} {
     1259
     1260    set seqLabel [$xmlobj get ${child}.about.label]
     1261    set descr    [$xmlobj get ${child}.about.description]
     1262    set typemap  [$xmlobj get ${child}.components.molecule.lammpstypemap]
     1263    $xmlobj remove $child
     1264
     1265    set sequence ${path}.sequence($id)
     1266    $xmlobj put ${sequence}.about.label $seqLabel
     1267    $xmlobj put ${sequence}.about.description $descr
     1268    $xmlobj put ${sequence}.index.label "Frame"
    12271269
    12281270    set frameNum 0
     
    12341276            continue;                   # Skip blank lines
    12351277        }
    1236         if { [string match "MODEL*" $line] } {
    1237             if { $inModel && $frameContents != "" } {
    1238                 # Dump the current contents into the last model
    1239 
    1240                 set framePath ${seqPath}.element($frameNum)
    1241                 $xmlobj put ${framePath}.index $frameNum
    1242                
    1243                 set molPath ${framePath}.structure.components.molecule
    1244                 $xmlobj put ${molPath}.pdb $frameContents
    1245                 $xmlobj put ${molPath}.formula $formula
    1246                
    1247                 incr frameNum
    1248                 set frameContents ""
    1249             }
    1250             set inModel 1
    1251         } elseif {[string match "ATOM*" $line] } {
    1252             if { !$inModel } {
    1253                 puts stderr "found \"$line\" without previous MODEL line"
    1254                 set inModel 1
    1255             }
    1256             append frameContents $line\n
    1257         }
    1258     }
    1259     if { $frameContents != "" } {
    1260         # Dump the current contents into the last model
    1261 
    1262         set framePath ${seqPath}.element($frameNum)
    1263         $xmlobj put ${framePath}.index $frameNum
    1264        
    1265         set molPath ${framePath}.structure.components.molecule
    1266         $xmlobj put ${molPath}.pdb $frameContents
    1267         $xmlobj put ${molPath}.formula $formula
    1268     }
    1269 }
    1270 
    1271 itcl::body Rappture::Analyzer::_lammpsToSequence {xmlobj path id child data} {
    1272 
    1273     set seqLabel [$xmlobj get ${child}.about.label]
    1274     set descr    [$xmlobj get ${child}.about.description]
    1275     set typemap  [$xmlobj get ${child}.components.molecule.lammpstypemap]
    1276     $xmlobj remove $child
    1277 
    1278     set seqPath ${path}.sequence($id)
    1279     $xmlobj put ${seqPath}.about.label $seqLabel
    1280     $xmlobj put ${seqPath}.about.description $descr
    1281     $xmlobj put ${seqPath}.index.label "Frame"
    1282 
    1283     set frameNum 0
    1284     set frameContents ""
    1285     set inModel 0
    1286     foreach line $data {
    1287         set line [string trim $line]
    1288         if { $line == "" } {
    1289             continue;                   # Skip blank lines
    1290         }
    12911278        if {[regexp {^[\t ]*ITEM:[ \t]+ATOMS} $line] } {
    12921279            if { $inModel && $frameContents != "" } {
    1293                 set framePath ${seqPath}.element($frameNum)
    1294                 $xmlobj put ${framePath}.index $frameNum
     1280                set frame ${sequence}.element($frameNum)
     1281                $xmlobj put ${frame}.index $frameNum
    12951282               
    1296                 set molPath ${framePath}.structure.components.molecule
    1297                 $xmlobj put ${molPath}.lammps $frameContents
    1298                 $xmlobj put ${molPath}.lammpstypemap $typemap
     1283                set molecule ${frame}.structure.components.molecule
     1284                $xmlobj put ${molecule}.lammps $frameContents
     1285                $xmlobj put ${molecule}.lammpstypemap $typemap
    12991286               
    13001287                incr frameNum
     
    13111298    }
    13121299    if { $frameContents != "" } {
    1313         set framePath ${seqPath}.element($frameNum)
    1314         $xmlobj put ${framePath}.index $frameNum
     1300        set frame ${sequence}.element($frameNum)
     1301        $xmlobj put ${frame}.index $frameNum
    13151302       
    1316         set molPath ${framePath}.structure.components.molecule
    1317         $xmlobj put ${molPath}.lammps $frameContents
    1318         $xmlobj put ${molPath}.lammpstypemap $typemap
     1303        set molecule ${frame}.structure.components.molecule
     1304        $xmlobj put ${molecule}.lammps $frameContents
     1305        $xmlobj put ${molecule}.lammpstypemap $typemap
    13191306    }
    13201307}
Note: See TracChangeset for help on using the changeset viewer.