Ejemplo n.º 1
0
def scolor_command(cmdname, args):

    from Commands import doExtensionFunc, parse_enumeration
    if cmdname.startswith('un'):
        if len(args) == 0:
            args = '#'
        doExtensionFunc(unscolor,
                        args,
                        specInfo=[
                            ('surfaceSpec', 'surfaces', 'models'),
                        ])
    else:
        sa = args.split(None, 2)
        if len(sa) < 2:
            raise CommandError, 'scolor requires at least 2 arguments: scolor <surf> <method>'
        sspec = ('surfaceSpec', 'surfaces', 'models')
        vspec = ('volumeSpec', 'volume', 'models')
        gspec = ('gradientSpec', 'gradient', 'models')
        cspec = ('coordinateSystemSpec', 'coordinateSystem', 'models')
        methods = {
            'color': (color_op, [sspec]),
            'geometry': (geometry_op, [sspec, cspec]),
            'gradient': (gradient_op, [sspec, gspec]),
            'volume': (volume_op, [sspec, vspec]),
        }
        method = parse_enumeration(sa[1], methods.keys())
        if method is None:
            raise CommandError, 'Unknown scolor method: %s' % sa[1]
        func, spec = methods[method]
        doExtensionFunc(func, args, specInfo=spec)
def measure_command(cmdname, args):

    operations = {
        'rotation': (rotation_axis, [('model1Spec', 'model1', 'models'),
                                     ('model2Spec', 'model2', 'models')]),
        'volume': (volume_area, [('surfaceSpec', 'surface', 'models')]),
        'area': (volume_area, [('surfaceSpec', 'surface', 'models')]),
        'correlation': (correlation, [('map1Spec', 'map1', 'models'),
                                      ('map2Spec', 'map2', 'models')]),
        'buriedArea': (buried_area, [('a1Spec', 'atoms1', 'atoms'),
                                     ('a2Spec', 'atoms2', 'atoms')]),
        'inertia': (inertia, []),
    }
    from Commands import abbreviation_table
    aop = abbreviation_table(operations.keys())

    fields = args.split(' ', 1)
    if len(fields) == 0:
        ops = ', '.join(operations.keys())
        raise CommandError, 'Missing required argument: "operation" (%s)' % ops
    op = aop.get(fields[0].lower())
    if op is None:
        ops = ', '.join(operations)
        raise CommandError, 'Unknown operation "%s" (use %s)' % (fields[0],
                                                                 ops)

    from Commands import doExtensionFunc
    f, specInfo = operations[op]
    doExtensionFunc(f, args, specInfo=specInfo)
Ejemplo n.º 3
0
def scolor_command(cmdname, args):
    
    from Commands import doExtensionFunc, parse_enumeration
    if cmdname.startswith('un'):
        if len(args) == 0:
            args = '#'
        doExtensionFunc(unscolor, args,
                        specInfo = [('surfaceSpec','surfaces','models'),])
    else:
        sa = args.split(None, 2)
        if len(sa) < 2:
            raise CommandError, 'scolor requires at least 2 arguments: scolor <surf> <method>'
        sspec = ('surfaceSpec','surfaces','models')
        vspec = ('volumeSpec','volume','models')
        gspec = ('gradientSpec', 'gradient', 'models')
        cspec = ('coordinateSystemSpec','coordinateSystem','models')
        methods = {
        'color': (color_op, [sspec]),
        'geometry': (geometry_op, [sspec, cspec]),
        'gradient': (gradient_op, [sspec, gspec]),
        'volume': (volume_op, [sspec, vspec]),
        }
        method = parse_enumeration(sa[1], methods.keys())
        if method is None:
            raise CommandError, 'Unknown scolor method: %s' % sa[1]
        func, spec = methods[method]
        doExtensionFunc(func, args, specInfo = spec)
Ejemplo n.º 4
0
def measure_command(cmdname, args):

    operations = {'rotation': (rotation_axis, [('model1Spec','model1','models'),
                                             ('model2Spec','model2','models')]),
                  'volume': (volume_area, [('surfaceSpec','surface','models')]),
                  'area': (volume_area, [('surfaceSpec','surface','models')]),
                  'correlation': (correlation, [('map1Spec','map1','models'),
                                                ('map2Spec','map2','models')]),
                  'buriedArea': (buried_area, [('a1Spec','atoms1','atoms'),
                                                ('a2Spec','atoms2','atoms')]),
                  'inertia': (inertia, []),
                  }
    from Commands import abbreviation_table
    aop = abbreviation_table(operations.keys())

    fields = args.split(' ', 1)
    if len(fields) == 0:
        ops = ', '.join(operations.keys())
        raise CommandError, 'Missing required argument: "operation" (%s)' % ops
    op = aop.get(fields[0].lower())
    if op is None:
        ops = ', '.join(operations)
        raise CommandError, 'Unknown operation "%s" (use %s)' % (fields[0], ops)
        
    from Commands import doExtensionFunc
    f, specInfo = operations[op]
    doExtensionFunc(f, args, specInfo = specInfo)
Ejemplo n.º 5
0
def shape_command(cmdname, args):

    vspec = ('atomSpec','atoms','atoms')
    shapes = {
        'cylinder': (cylinder_shape, []),
        'ellipsoid': (sphere_shape, []),
        'icosahedron': (icosahedron_shape, []),
        'sphere': (sphere_shape, []),
        'tube': (tube_shape, [vspec]),
        }
    snames = shapes.keys()

    sa = args.split(None, 1)
    if len(sa) < 1:
        raise CommandError, 'shape requires at least 1 argument: shape <name>'

    from Commands import parse_enumeration
    shape = parse_enumeration(sa[0], snames)
    if shape is None:
        raise CommandError, 'Unknown shape: %s' % sa[0]

    func, specs = shapes[shape]
    from Commands import doExtensionFunc
    fargs = ' '.join(sa[1:])
    doExtensionFunc(func, fargs, specInfo = specs)
def shape_command(cmdname, args):

    vspec = ('atomSpec', 'atoms', 'atoms')
    shapes = {
        'cylinder': (cylinder_shape, []),
        'ellipsoid': (sphere_shape, []),
        'icosahedron': (icosahedron_shape, []),
        'sphere': (sphere_shape, []),
        'tube': (tube_shape, [vspec]),
    }
    snames = shapes.keys()

    sa = args.split(None, 1)
    if len(sa) < 1:
        raise CommandError, 'shape requires at least 1 argument: shape <name>'

    from Commands import parse_enumeration
    shape = parse_enumeration(sa[0], snames)
    if shape is None:
        raise CommandError, 'Unknown shape: %s' % sa[0]

    func, specs = shapes[shape]
    from Commands import doExtensionFunc
    fargs = ' '.join(sa[1:])
    doExtensionFunc(func, fargs, specInfo=specs)
Ejemplo n.º 7
0
def tile_command(cmdname, args):

  if len(args) == 0:
    args = '#'
  from Commands import doExtensionFunc
  if cmdname.startswith('un'):
    f = untile
  else:
    f = tile
  doExtensionFunc(f, args, specInfo = [('modelSpec','models','models'),])
Ejemplo n.º 8
0
def tile_command(cmdname, args):

    if len(args) == 0:
        args = '#'
    from Commands import doExtensionFunc
    if cmdname.startswith('un'):
        f = untile
    else:
        f = tile
    doExtensionFunc(f, args, specInfo=[
        ('modelSpec', 'models', 'models'),
    ])
Ejemplo n.º 9
0
def vop_command(cmdname, args):

    vspec = ('volumeSpec','volumes','models')
    gspec = ('onGridSpec', 'onGrid', 'models')
    operations = {
        'add': (add_op, [vspec, gspec]),
        'bin': (bin_op, [vspec]),
        'boxes': (boxes_op, [vspec, ('markersSpec', 'markers', 'atoms')]),
        'cover': (cover_op, [vspec, ('atomBoxSpec', 'atomBox', 'atoms')]),
        'fourier': (fourier_op, [vspec]),
        'gaussian': (gaussian_op, [vspec]),
        'laplacian': (laplacian_op, [vspec]),
        'median': (median_op, [vspec]),
        'morph': (morph_op, [vspec]),
        'octant': (octant_op, [vspec]),
        '~octant': (octant_complement_op, [vspec]),
        'permuteAxes': (permute_axes_op, [vspec]),
        'resample': (resample_op, [vspec, gspec]),
        'scale': (scale_op, [vspec]),
        'subtract': (subtract_op, [('volume1Spec','vol1','models'),
                                   ('volume2Spec','vol2','models')]),
        'zFlip': (z_flip_op, [vspec]),
        }
    ops = operations.keys()

    sa = args.split(None, 2)
    if len(sa) < 2:
        raise CommandError, 'vop requires at least 2 arguments: vop <operation> <args...>'

    from Commands import parse_enumeration
    op = parse_enumeration(sa[0], ops)
    if op is None:
        # Handle old syntax where operation argument followed volume spec
        op = parse_enumeration(sa[1], ops)
        if op:
            sa = [sa[1], sa[0]] + sa[2:]
        else:
            raise CommandError, 'Unknown vop operation: %s' % sa[0]

    func, spec = operations[op]
    from Commands import doExtensionFunc
    fargs = ' '.join(sa[1:])
    doExtensionFunc(func, fargs, specInfo = spec)
Ejemplo n.º 10
0
def vop_command(cmdname, args):

    vspec = ('volumeSpec', 'volumes', 'models')
    gspec = ('onGridSpec', 'onGrid', 'models')
    operations = {
        'add': (add_op, [vspec, gspec]),
        'bin': (bin_op, [vspec]),
        'boxes': (boxes_op, [vspec, ('markersSpec', 'markers', 'atoms')]),
        'cover': (cover_op, [vspec, ('atomBoxSpec', 'atomBox', 'atoms')]),
        'fourier': (fourier_op, [vspec]),
        'gaussian': (gaussian_op, [vspec]),
        'laplacian': (laplacian_op, [vspec]),
        'median': (median_op, [vspec]),
        'morph': (morph_op, [vspec]),
        'octant': (octant_op, [vspec]),
        '~octant': (octant_complement_op, [vspec]),
        'permuteAxes': (permute_axes_op, [vspec]),
        'resample': (resample_op, [vspec, gspec]),
        'scale': (scale_op, [vspec]),
        'subtract': (subtract_op, [('volume1Spec', 'vol1', 'models'),
                                   ('volume2Spec', 'vol2', 'models')]),
        'zFlip': (z_flip_op, [vspec]),
    }
    ops = operations.keys()

    sa = args.split(None, 2)
    if len(sa) < 2:
        raise CommandError, 'vop requires at least 2 arguments: vop <operation> <args...>'

    from Commands import parse_enumeration
    op = parse_enumeration(sa[0], ops)
    if op is None:
        # Handle old syntax where operation argument followed volume spec
        op = parse_enumeration(sa[1], ops)
        if op:
            sa = [sa[1], sa[0]] + sa[2:]
        else:
            raise CommandError, 'Unknown vop operation: %s' % sa[0]

    func, spec = operations[op]
    from Commands import doExtensionFunc
    fargs = ' '.join(sa[1:])
    doExtensionFunc(func, fargs, specInfo=spec)
Ejemplo n.º 11
0
def old_measure_command(cmdname, args):
    from Commands import CommandError

    operations = {
        'rotation': (rotation_axis, [('model1Spec', 'model1', 'models'),
                                     ('model2Spec', 'model2', 'models')]),
        'volume': (volume_area, [('surfaceSpec', 'surface', 'vertices')]),
        'area': (volume_area, [('surfaceSpec', 'surface', 'vertices')]),
        'correlation': (correlation, [('map1Spec', 'map1', 'models'),
                                      ('map2Spec', 'map2', 'models')]),
        'buriedArea': (buried_area, [('a1Spec', 'atoms1', 'atoms'),
                                     ('a2Spec', 'atoms2', 'atoms')]),
        'contactArea': (contact_area, []),
        'inertia': (inertia, []),
        'spine': (spine, []),
        'distance': (distance, [('object1Spec', 'object1', None),
                                ('object2Spec', 'object2', None)]),
        'mapValues': (map_values, [('mapSpec', 'volume', 'models'),
                                   ('atomSpec', 'atoms', 'atoms')]),
        'pathLength': (path_length, [('pathSpec', 'path', None)]),
        'symmetry': (symmetry, [('volumeSpec', 'volume', 'models')]),
        'center': (center, [('objectSpec', 'objects', None)]),
        'fieldLines': (field_lines, [('volumeSpec', 'volume', 'models')]),
        'mapStats': (map_statistics, [('volumeSpec', 'volume', 'models')]),
        'mapSum': (map_sum, [('volumeSpec', 'volume', 'models')]),
    }
    from Commands import abbreviation_table
    aop = abbreviation_table(operations.keys())

    fields = args.split(' ', 1)
    if len(fields) == 0:
        ops = ', '.join(operations.keys())
        raise CommandError('Missing required argument: "operation" (%s)' % ops)
    op = aop.get(fields[0].lower())
    if op is None:
        ops = ', '.join(operations)
        raise CommandError('Unknown operation "%s" (use %s)' %
                           (fields[0], ops))

    from Commands import doExtensionFunc
    f, specInfo = operations[op]
    doExtensionFunc(f, args, specInfo=specInfo)
def sop_command(cmdname, args):

    operations = {
        'finerMesh': (subdivide_op, []),
        }
    ops = operations.keys()

    sa = args.split(None, 2)
    if len(sa) < 2:
        raise CommandError, 'sop requires at least 2 arguments: sop <operation> <args...>'

    from Commands import parse_enumeration
    op = parse_enumeration(sa[0], ops)
    if op is None:
        raise CommandError, 'Unknown sop operation: %s' % sa[0]

    func, spec = operations[op]
    from Commands import doExtensionFunc
    fargs = ' '.join(sa[1:])
    doExtensionFunc(func, fargs, specInfo = spec)
Ejemplo n.º 13
0
def molmap_command(cmdname, args):

    from Commands import doExtensionFunc
    doExtensionFunc(molecule_map, args,
                    specInfo = [('atomSpec','atoms','atoms')])
Ejemplo n.º 14
0
def mask_command(cmdname, args):

    from Commands import doExtensionFunc
    doExtensionFunc(mask, args,
                    specInfo = [('volumeSpec','volumes','models'),
                                ('surfaceSpec','surfaces',None)])
Ejemplo n.º 15
0
def molmap_command(cmdname, args):

    from Commands import doExtensionFunc
    doExtensionFunc(molecule_map,
                    args,
                    specInfo=[('atomSpec', 'atoms', 'atoms')])