Changeset 1830 for trunk


Ignore:
Timestamp:
Jul 17, 2010, 1:54:59 PM (14 years ago)
Author:
gah
Message:
 
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/analyzer.tcl

    r1797 r1830  
    2424option add *Analyzer.simControlActiveBackground #ffffcc widgetDefault
    2525option add *Analyzer.simControlActiveOutline black widgetDefault
     26option add *Analyzer.notebookpage "about" widgetDefault
    2627
    2728option add *Analyzer.font \
     
    4647    itk_option define -simcontrolactivebackground simControlActiveBackground Background ""
    4748    itk_option define -holdwindow holdWindow HoldWindow ""
    48     itk_option define -notebookpage notebookPage NotebookPage "about"
     49    itk_option define -notebookpage notebookPage NotebookPage ""
    4950
    5051    constructor {tool args} { # defined below }
     
    505506        foreach c [$inclobj children output] {
    506507            switch -glob -- $c {
    507                 # we don't want to include these tags
     508                # We don't want to include these tags.
    508509                include* - time* - status* - user* {
    509510                    continue
     
    521522    lappend _runs $xmlobj
    522523
    523     # detect molecule elements that contain trajectory data and convert
     524    # Detect molecule elements that contain trajectory data and convert
    524525    # to sequences.
    525526    _trajToSequence $xmlobj output
    526527
    527     # go through the analysis and find all result sets
     528    # Go through the analysis and find all result sets.
    528529    set haveresults 0
    529530    foreach item [_reorder [$xmlobj children output]] {
     
    11971198
    11981199# ----------------------------------------------------------------------
    1199 # USAGE: _trajtosequence <xmlobj> ?<path>?
    1200 #
    1201     # If the molecule element is a trajectory, delete the original
    1202     # and create a sequence of individual molecules.
     1200# USAGE: _pdbToSequence <xmlobj> ?<path>?
     1201#
     1202# If the molecule element is a trajectory, delete the original
     1203# and create a sequence of individual molecules.
    12031204# Used internally to detect any molecule output elements that contain
    12041205# trajectory data.  Trajectories will be converted into sequences of
     
    12131214    $xmlobj remove $child
    12141215
    1215     set seqPath  $path.sequence($id)
    1216     $xmlobj put ${seqPath}.about.label $seqLabel
    1217     $xmlobj put ${seqPath}.about.description $descr
    1218     $xmlobj put ${seqPath}.index.label "Frame"
     1216    set sequence  $path.sequence($id)
     1217    $xmlobj put ${sequence}.about.label $seqLabel
     1218    $xmlobj put ${sequence}.about.description $descr
     1219    $xmlobj put ${sequence}.index.label "Frame"
    12191220
    12201221    set frameNum 0
    1221     set frameContents ""
    1222     set inModel 0
    1223     foreach line $data {
     1222    set numLines [llength $data]
     1223    for { set i 0 } { $i < $numLines } { incr i } {
     1224        set line [lindex $data $i]
    12241225        set line [string trim $line]
    1225         if { $line == "" } {
    1226             continue;                   # Skip blank lines
     1226        set contents {}
     1227        if { [string match "MODEL*" $line] } {
     1228            # Save the contents until we get an ENDMDL record.
     1229            for {} { $i < $numLines } { incr i } {
     1230                set line [lindex $data $i]
     1231                set line [string trim $line]
     1232                if { $line == "" } {
     1233                    continue;           # Skip blank lines.
     1234                }
     1235                if { [string match "ENDMDL*" $line] } {
     1236                    break;
     1237                }
     1238                append contents $line\n
     1239            }
     1240            set frame ${sequence}.element($frameNum)
     1241            $xmlobj put ${frame}.index $frameNum
     1242           
     1243            set molecule ${frame}.structure.components.molecule
     1244            $xmlobj put ${molecule}.pdb $contents
     1245            $xmlobj put ${molecule}.formula $formula
     1246            incr frameNum
    12271247        }
    1228         if { [string match "MODEL*" $line] } {
    1229             if { $inModel && $frameContents != "" } {
    1230                 # Dump the current contents into the last model
    1231 
    1232                 set framePath ${seqPath}.element($frameNum)
    1233                 $xmlobj put ${framePath}.index $frameNum
    1234                
    1235                 set molPath ${framePath}.structure.components.molecule
    1236                 $xmlobj put ${molPath}.pdb $frameContents
    1237                 $xmlobj put ${molPath}.formula $formula
    1238                
    1239                 incr frameNum
    1240                 set frameContents ""
    1241             }
    1242             set inModel 1
    1243         } elseif {[string match "ATOM*" $line] } {
    1244             if { !$inModel } {
    1245                 puts stderr "found \"$line\" without previous MODEL line"
    1246                 set inModel 1
    1247             }
    1248             append frameContents $line\n
    1249         }
    1250     }
    1251     if { $frameContents != "" } {
    1252         # Dump the current contents into the last model
    1253 
    1254         set framePath ${seqPath}.element($frameNum)
    1255         $xmlobj put ${framePath}.index $frameNum
    1256        
    1257         set molPath ${framePath}.structure.components.molecule
    1258         $xmlobj put ${molPath}.pdb $frameContents
    1259         $xmlobj put ${molPath}.formula $formula
    1260     }
    1261 }
    1262 
     1248    }
     1249}
     1250
     1251# ----------------------------------------------------------------------
     1252# USAGE: _lammpsToSequence <xmlobj> ?<path>?
     1253#
     1254# If the molecule element is a trajectory, delete the original
     1255# and create a sequence of individual molecules.
     1256# Used internally to detect any molecule output elements that contain
     1257# trajectory data.  Trajectories will be converted into sequences of
     1258# individual molecules.  All other elements will be unaffected. Scans
     1259# the entire xml tree if a starting path is not specified.
     1260# ----------------------------------------------------------------------
    12631261itcl::body Rappture::Analyzer::_lammpsToSequence {xmlobj path id child data} {
    12641262
     
    12681266    $xmlobj remove $child
    12691267
    1270     set seqPath ${path}.sequence($id)
    1271     $xmlobj put ${seqPath}.about.label $seqLabel
    1272     $xmlobj put ${seqPath}.about.description $descr
    1273     $xmlobj put ${seqPath}.index.label "Frame"
     1268    set sequence ${path}.sequence($id)
     1269    $xmlobj put ${sequence}.about.label $seqLabel
     1270    $xmlobj put ${sequence}.about.description $descr
     1271    $xmlobj put ${sequence}.index.label "Frame"
    12741272
    12751273    set frameNum 0
     
    12831281        if {[regexp {^[\t ]*ITEM:[ \t]+ATOMS} $line] } {
    12841282            if { $inModel && $frameContents != "" } {
    1285                 set framePath ${seqPath}.element($frameNum)
    1286                 $xmlobj put ${framePath}.index $frameNum
     1283                set frame ${sequence}.element($frameNum)
     1284                $xmlobj put ${frame}.index $frameNum
    12871285               
    1288                 set molPath ${framePath}.structure.components.molecule
    1289                 $xmlobj put ${molPath}.lammps $frameContents
    1290                 $xmlobj put ${molPath}.lammpstypemap $typemap
     1286                set molecule ${frame}.structure.components.molecule
     1287                $xmlobj put ${molecule}.lammps $frameContents
     1288                $xmlobj put ${molecule}.lammpstypemap $typemap
    12911289               
    12921290                incr frameNum
     
    13031301    }
    13041302    if { $frameContents != "" } {
    1305         set framePath ${seqPath}.element($frameNum)
    1306         $xmlobj put ${framePath}.index $frameNum
     1303        set frame ${sequence}.element($frameNum)
     1304        $xmlobj put ${frame}.index $frameNum
    13071305       
    1308         set molPath ${framePath}.structure.components.molecule
    1309         $xmlobj put ${molPath}.lammps $frameContents
    1310         $xmlobj put ${molPath}.lammpstypemap $typemap
    1311     }
    1312 }
    1313 
    1314 # ----------------------------------------------------------------------
    1315 # USAGE: _trajtosequence <xmlobj> ?<path>?
     1306        set molecule ${frame}.structure.components.molecule
     1307        $xmlobj put ${molecule}.lammps $frameContents
     1308        $xmlobj put ${molecule}.lammpstypemap $typemap
     1309    }
     1310}
     1311
     1312# ----------------------------------------------------------------------
     1313# USAGE: _trajToSequence <xmlobj> ?<path>?
    13161314#
    13171315#       Check for PDB and LAMMPS trajectories in molecule data and rewrite
     
    13331331        set current ${path}.${child}
    13341332        if { [string match "structure*" $child] } {
     1333            set isTraj [$xmlobj get ${current}.components.molecule.trajectory]
     1334            if { !$isTraj } {
     1335                continue;               # Not a trajectory.
     1336            }
    13351337            # Look for trajectory if molecule element found.  Check both pdb
    13361338            # data and lammps data.
     
    13521354            continue
    13531355        }
     1356        if 0 {
    13541357        # Recurse over all child nodes.
    13551358        _trajToSequence $xmlobj $current
     1359        }
    13561360    }
    13571361}
  • trunk/packages/vizservers/pymolproxy/pymolproxy.c

    r1814 r1830  
    5757#include <fcntl.h>
    5858#include <getopt.h>
    59 #include <net/if.h>
    60 #include <netinet/in.h>
    6159#include <poll.h>
    62 #include <signal.h>
    6360#include <stdio.h>
    6461#include <stdlib.h>
    6562#include <string.h>
    66 #include <sys/ioctl.h>
    67 #include <sys/select.h>
    68 #include <sys/socket.h>
    6963#include <sys/stat.h>
    7064#include <sys/time.h>
     
    10296
    10397static FILE *flog;
    104 static int debug = 0;
     98static int debug = FALSE;
    10599static FILE *scriptFile;
    106 static int savescript = 0;
     100static int savescript = FALSE;
    107101
    108102typedef struct Image {
     
    10251019           const char *argv[])
    10261020{
    1027     const char *pdbdata, *name;
    1028     PymolProxy *proxyPtr = clientData;
    1029     int state = 1;
    1030     int i, defer = 0, push = 0, varg = 1;
     1021    const char *data, *name;
     1022    char *allocated;
     1023    PymolProxy *proxyPtr = clientData;
     1024    int state, defer, push;
    10311025    int nBytes;
    1032 
    1033     if (proxyPtr == NULL)
     1026    int i, j;
     1027
     1028    if (proxyPtr == NULL){
    10341029        return TCL_ERROR;
    1035     clear_error(proxyPtr);
    1036     pdbdata = name = NULL;              /* Suppress compiler warning. */
    1037     nBytes = 0;                         /* Suppress compiler warning. */
    1038     for(i = 1; i < argc; i++) {
    1039         if ( strcmp(argv[i],"-defer") == 0 )
    1040             defer = 1;
    1041         else if (strcmp(argv[i],"-push") == 0)
    1042             push = 1;
    1043         else if (varg == 1) {
    1044             nBytes = atoi(argv[i]);
    1045             varg++;
    1046         } else if (varg == 2) {
    1047             name = argv[i];
    1048             varg++;
    1049         } else if (varg == 3) {
    1050             state = atoi( argv[i] );
    1051             varg++;
     1030    }
     1031    clear_error(proxyPtr);
     1032    defer = push = FALSE;
     1033    for(i = j = 1; i < argc; i++) {
     1034        if (strcmp(argv[i],"-defer") == 0) {
     1035            defer = TRUE;
     1036        } else if (strcmp(argv[i],"-push") == 0) {
     1037            push = TRUE;
     1038        } else {
     1039            if (j < i) {
     1040                argv[j] = argv[i];
     1041            }
     1042            j++;
     1043        }
     1044    }
     1045    argc = j;
     1046    if (argc < 4) {
     1047        Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
     1048                         " <data>|follows <model> <state> ?<nBytes>?\"",
     1049                         (char *)NULL);
     1050        return TCL_ERROR;
     1051    }
     1052    data = argv[1];
     1053    name = argv[2];
     1054    if (Tcl_GetInt(interp, argv[3], &state) != TCL_OK) {
     1055        return TCL_ERROR;
     1056    }
     1057    nBytes = -1;
     1058    if (strcmp(data, "follows") == 0) {
     1059        if (argc != 5) {
     1060            Tcl_AppendResult(interp, "wrong # arguments: should be \"", argv[0],
     1061                         " follows <model> <state> <nBytes>\"", (char *)NULL);
     1062            return TCL_ERROR;
     1063        }
     1064        if (Tcl_GetInt(interp, argv[4], &nBytes) != TCL_OK) {
     1065            return TCL_ERROR;
     1066        }
     1067        if (nBytes < 0) {
     1068            Tcl_AppendResult(interp, "bad value for # bytes \"", argv[4],
     1069                         "\"", (char *)NULL);
     1070            return TCL_ERROR;
    10521071        }
    10531072    }
     
    10611080    /* Does not invalidate cache? */
    10621081
     1082    allocated = NULL;
     1083    if (nBytes >= 0) {
     1084        allocated = malloc(sizeof(char) * nBytes);
     1085        if (allocated == NULL) {
     1086            Tcl_AppendResult(interp, "can't allocate buffer for pdbdata.",
     1087                             (char *)NULL);
     1088            return TCL_ERROR;
     1089        }
     1090        if (GetBytes(&proxyPtr->client, allocated, nBytes) != BUFFER_OK) {
     1091            Tcl_AppendResult(interp, "can't read pdbdata from client.",
     1092                             (char *)NULL);
     1093            free(allocated);
     1094            return TCL_ERROR;
     1095        }
     1096        data = allocated;
     1097    } else {
     1098        nBytes = strlen(data);
     1099    }
    10631100    {
    10641101        char fileName[200];
    10651102        FILE *f;
    1066         char *data;
    10671103        ssize_t nWritten;
    10681104
    1069         data = malloc(sizeof(char) * nBytes);
    1070         if (data == NULL) {
    1071             trace("can't allocate %d bytes for \"pdbdata\" buffer", nBytes);
    1072             return  TCL_ERROR;
    1073         }
    1074         if (GetBytes(&proxyPtr->client, data, nBytes) != BUFFER_OK) {
    1075             trace("can't read %d bytes for \"pdbdata\" buffer", nBytes);
    1076             free(data);
    1077             return  TCL_ERROR;
    1078         }
     1105        proxyPtr->status = TCL_ERROR;
    10791106        sprintf(fileName, "/tmp/pymol%d.pdb", getpid());
    10801107        f = fopen(fileName, "w");
    10811108        if (f == NULL) {
    1082             trace("can't open `%s': %s", fileName, strerror(errno));
    1083             perror("pymolproxy");
    1084             free(data);
    1085             return TCL_ERROR;
     1109            Tcl_AppendResult(interp, "can't create temporary file \"",
     1110                             fileName, "\": ", Tcl_PosixError(interp),
     1111                             (char *)NULL);
     1112            goto error;
    10861113        }
    10871114        nWritten = fwrite(data, sizeof(char), nBytes, f);
    10881115        if (nBytes != nWritten) {
    1089             trace("short write %d wanted %d bytes", nWritten, nBytes);
    1090             perror("pymolproxy");
     1116            Tcl_AppendResult(interp, "can't write PDB data to \"",
     1117                             fileName, "\": ", Tcl_PosixError(interp),
     1118                             (char *)NULL);
     1119            fclose(f);
     1120            goto error;
    10911121        }
    10921122        fclose(f);
    1093         free(data);
    10941123        Pymol(proxyPtr, "load %s,%s,%d\n", fileName, name, state);
     1124        proxyPtr->status = TCL_OK;
     1125    }
     1126 error:
     1127    if (allocated != NULL) {
     1128        free(allocated);
    10951129    }
    10961130    return proxyPtr->status;
Note: See TracChangeset for help on using the changeset viewer.