Exemplo n.º 1
0
    def inner(*args, **kwd):
        args = list(args)
        traj = kwd.get('traj', args[0])
        frame_indices = kwd.get('frame_indices')
        ref = kwd.get('ref')
        top = kwd.get('top')

        if 'mask' in kwd.keys():
            mask = kwd.get('mask')
        else:
            mask = args[1]

        # overwrite
        kwd['top'] = get_topology(traj, top)
        if ref is not None:
            kwd['ref'] = get_reference(traj, ref)
        if 'traj' in kwd.keys():
            kwd['traj'] = get_fiterator(traj, frame_indices)
        else:
            args[0] = get_fiterator(traj, frame_indices)
        if not isinstance(mask, string_types):
            mask = array_to_cpptraj_atommask(mask)
        if 'mask' in kwd.keys():
            kwd['mask'] = mask
        else:
            args[1] = mask
        return f(*args, **kwd)
Exemplo n.º 2
0
    def inner(*args, **kwd):
        args = list(args)
        traj = kwd.get('traj', args[0])
        frame_indices = kwd.get('frame_indices')
        ref = kwd.get('ref')
        top = kwd.get('top')

        if 'mask' in kwd.keys():
            mask = kwd.get('mask')
        else:
            mask = args[1]

        # overwrite
        kwd['top'] = get_topology(traj, top)
        if ref is not None:
            kwd['ref'] = get_reference(traj, ref)
        if 'traj' in kwd.keys():
            kwd['traj'] = get_fiterator(traj, frame_indices)
        else:
            args[0] = get_fiterator(traj, frame_indices)
        if not isinstance(mask, string_types):
            mask = array_to_cpptraj_atommask(mask)
        if 'mask' in kwd.keys():
            kwd['mask'] = mask
        else:
            args[1] = mask
        return f(*args, **kwd)
Exemplo n.º 3
0
        def inner(*args, **kwargs):
            args = list(args)
            # traj is always 1st argument
            if 'traj' in kwargs:
                traj = kwargs.get('traj')
                has_traj_arg = True
            else:
                traj = args[0]
                has_traj_arg = False

            mask = kwargs.get('mask', kwargs_spec.get('mask'))
            ref = kwargs.get('ref', kwargs_spec.get('ref'))
            frame_indices = kwargs.get('frame_indices')
            top = kwargs.get('top')

            if has_mask_arg and mask == '':
                if has_traj_arg:
                    try:
                        mask = args[0]
                    except IndexError:
                        mask = ''
                else:
                    try:
                        mask = args[1]
                    except IndexError:
                        mask = ''

            if has_ref_arg:
                if ref is None:
                    try:
                        ref = args[
                            self.
                            refindex] if self.refindex is not None else args[2]
                    except IndexError:
                        ref = 0
                ref = get_reference(traj, ref)

            # update traj to args or kwargs
            if 'traj' in kwargs:
                kwargs['traj'] = get_fiterator(traj, frame_indices)
            else:
                args[0] = get_fiterator(traj, frame_indices)

            # update topology to kwargs
            kwargs['top'] = get_topology(traj, top)

            # update reference to args or kwargs
            if has_ref_arg:
                kwargs['ref'] = get_reference(traj, ref)

            # update mask to args or kwargs
            if has_mask_arg and not isinstance(mask, string_types):
                mask = array_to_cpptraj_atommask(mask)
            if 'mask' in kwargs:
                kwargs['mask'] = mask
            else:
                if has_mask_arg:
                    if 'traj' not in kwargs:
                        try:
                            args[1] = mask
                        except IndexError:
                            args.append(mask)
            return f(*args, **kwargs)