def correlation(operation, map1, map2, aboveThreshold = True,
                rotationAxis = None, angleRange = (0,360,2),
                plot = True):

    from VolumeViewer import Volume
    map1 = [m for m in map1 if isinstance(m, Volume)]
    map2 = [m for m in map2 if isinstance(m, Volume)]
    if len(map1) == 0 or len(map2) == 0:
        raise CommandError, 'Must specify 2 maps'

    if rotationAxis:
        # Rotate map1 in steps and report correlations.
        from Commands import parse_axis
        axis, center, csys = parse_axis(rotationAxis, 'measure')
        if center is None:
            raise CommandError, 'Rotation axis must be atom/bond spec'
        axis = csys.xform.apply(axis).data()
        center = csys.xform.apply(center).data()
        if isinstance(angleRange, str):
            try:
                angleRange = [float(x) for x in angleRange.split(',')]
            except:
                angleRange = []
            if len(angleRange) != 3:
                raise CommandError, 'Angle range must be 3 comma-separated values, got "%s"' % angleRange

        for v1 in map1:
            for v2 in map2:
                report_correlations_with_rotation(v1, v2, aboveThreshold,
                                                  axis, center, angleRange,
                                                  plot)
    else:
        for v1 in map1:
            for v2 in map2:
                report_correlation(v1, v2, aboveThreshold)
Exemple #2
0
def parse_vector(varg, cmdname):

    from Commands import parse_axis
    v, axis_point, csys = parse_axis(varg, cmdname)
    if csys:
        v = csys.xform.apply(v)
    vc = v.data()
    return vc
Exemple #3
0
def parse_center_axis(center, axis, csys, cmdname):

    from Commands import parseCenterArg, parse_axis

    if isinstance(center, (tuple, list)):
        from chimera import Point
        center = Point(*center)
        ccs = csys
    elif center:
        center, ccs = parseCenterArg(center, cmdname)
    else:
        ccs = None

    if isinstance(axis, (tuple, list)):
        from chimera import Vector
        axis = Vector(*axis)
        axis_point = None
        acs = csys
    elif axis:
        axis, axis_point, acs = parse_axis(axis, cmdname)
    else:
        axis_point = None
        acs = None

    if not center and axis_point:
        # Use axis point if no center specified.
        center = axis_point
        ccs = acs

    # If no coordinate system specified use axis or center coord system.
    cs = (ccs or acs)
    if csys is None and cs:
        csys = cs
        xf = cs.xform.inverse()
        if center and not ccs:
            center = xf.apply(center)
        if axis and not acs:
            axis = xf.apply(axis)

    # Convert axis and center to requested coordinate system.
    if csys:
        xf = csys.xform.inverse()
        if center and ccs:
            center = xf.apply(ccs.xform.apply(center))
        if axis and acs:
            axis = xf.apply(acs.xform.apply(axis))

    return center, axis, csys
Exemple #4
0
def parse_center_axis(center, axis, csys, cmdname):

    from Commands import parseCenterArg, parse_axis

    if isinstance(center, (tuple, list)):
        from chimera import Point
        center = Point(*center)
        ccs = csys
    elif center:
        center, ccs = parseCenterArg(center, cmdname)
    else:
        ccs = None

    if isinstance(axis, (tuple, list)):
        from chimera import Vector
        axis = Vector(*axis)
        acs = csys
    elif axis:
        axis, axis_point, acs = parse_axis(axis, cmdname)
    else:
        axis_point = None
        acs = None

    if not center and axis_point:
        # Use axis point if no center specified.
        center = axis_point
        ccs = acs

    # If no coordinate system specified use axis or center coord system.
    cs = (ccs or acs)
    if csys is None and cs:
        csys = cs
        xf = cs.xform.inverse()
        if center and not ccs:
            center = xf.apply(center)
        if axis and not acs:
            axis = xf.apply(axis)

    # Convert axis and center to requested coordinate system.
    if csys:
        xf = csys.xform.inverse()
        if center and ccs:
            center = xf.apply(ccs.xform.apply(center))
        if axis and acs:
            axis = xf.apply(acs.xform.apply(axis))

    return center, axis, csys
Exemple #5
0
def correlation(operation,
                map1,
                map2,
                aboveThreshold=True,
                rotationAxis=None,
                angleRange=(0, 360, 2),
                plot=True):

    from VolumeViewer import Volume
    map1 = [m for m in map1 if isinstance(m, Volume)]
    map2 = [m for m in map2 if isinstance(m, Volume)]
    if len(map1) == 0 or len(map2) == 0:
        raise CommandError('Must specify 2 maps')

    if rotationAxis:
        # Rotate map1 in steps and report correlations.
        from Commands import parse_axis
        axis, center, csys = parse_axis(rotationAxis, 'measure')
        if center is None:
            raise CommandError('Rotation axis must be atom/bond spec')
        axis = csys.xform.apply(axis).data()
        center = csys.xform.apply(center).data()
        if isinstance(angleRange, str):
            try:
                angleRange = [float(x) for x in angleRange.split(',')]
            except:
                angleRange = []
            if len(angleRange) != 3:
                raise CommandError(
                    'Angle range must be 3 comma-separated values, got "%s"' %
                    angleRange)

        for v1 in map1:
            for v2 in map2:
                report_correlations_with_rotation(v1, v2, aboveThreshold, axis,
                                                  center, angleRange, plot)
    else:
        for v1 in map1:
            for v2 in map2:
                report_correlation(v1, v2, aboveThreshold)