Exemplo n.º 1
0
def asa_xtra(entities, mode='internal', xtra_key=None, **asa_kwargs):
    """Calculates accessible surface areas (ASA) and puts the results into the
    xtra dictionaries of entities.
    
    Arguments:
    
        - entities: an entity or sequence of entities
        - mode(str): 'internal' for calculations using the built-in cython code 
          or 'stride' if the stride binary should be called to do the job.
        - xtra_key(str): Key in the xtra dictionary to hold the result for each
          entity
    
    Additional keyworded arguments are passed to the ``_prepare_asa`` and 
    ``_run_asa`` functions.
    """
    xtra_key = xtra_key or 'ASA'
    structures = einput(entities, 'S')
    if len(structures.values()) > 1:
        raise ValueError(
            'Entities from multiple structures are not supported.')
    if mode == 'internal':
        _prepare_entities(entities)  # mask waters
        result = _prepare_asa(entities, **asa_kwargs)  # calculate ASA
        _postpare_entities(entities)  # unmask waters
        result = dict([(id, {xtra_key: v}) for id, v in result.iteritems()])
        xtradata(result, structures)
    elif mode == 'stride':
        models = einput(entities, 'M')
        stride_app = Stride()
        result = stride_app(entities)['StdOut'].readlines()
        result = stride_parser(result)
        xtradata(result, structures.values()[0][(0, )])
    else:
        raise ValueError('Not a valid mode: "%s"' % mode)
    return result
Exemplo n.º 2
0
def asa_xtra(entities, mode='internal', xtra_key=None, **asa_kwargs):
    """Calculates accessible surface areas (ASA) and puts the results into the
    xtra dictionaries of entities.
    
    Arguments:
    
        - entities: an entity or sequence of entities
        - mode(str): 'internal' for calculations using the built-in cython code 
          or 'stride' if the stride binary should be called to do the job.
        - xtra_key(str): Key in the xtra dictionary to hold the result for each
          entity
    
    Additional keyworded arguments are passed to the ``_prepare_asa`` and 
    ``_run_asa`` functions.
    """
    xtra_key = xtra_key or 'ASA'
    structures = einput(entities, 'S')
    if len(structures.values()) > 1:
        raise ValueError('Entities from multiple structures are not supported.')
    if mode == 'internal':
        _prepare_entities(entities) # mask waters
        result = _prepare_asa(entities, **asa_kwargs) # calculate ASA
        _postpare_entities(entities) # unmask waters
        result = dict([(id, {xtra_key:v}) for id, v in result.iteritems()])
        xtradata(result, structures)
    elif mode == 'stride':
        models = einput(entities, 'M')
        stride_app = Stride()
        result = stride_app(entities)['StdOut'].readlines()
        result = stride_parser(result)
        xtradata(result, structures.values()[0][(0,)])
    else:
        raise ValueError('Not a valid mode: "%s"' % mode)
    return result
Exemplo n.º 3
0
    def test_stride_parser(self):
        """tests if output is parsed fully"""
        id_xtra = stride_parser(self.lines)

        assert len(id_xtra) < len(self.input_structure[(0,)][('A',)]) + \
                              len(self.input_structure[(0,)][('B',)])

        self.input_structure[(0, )][('A', )].remove_hetero()
        self.input_structure[(0, )][('B', )].remove_hetero()

        assert len(id_xtra) == len(self.input_structure[(0,)][('A',)]) + \
               len(self.input_structure[(0,)][('B',)])
Exemplo n.º 4
0
    def test_stride_parser(self):
        """tests if output is parsed fully"""
        id_xtra = stride_parser(self.lines)

        assert len(id_xtra) < len(self.input_structure[(0,)][('A',)]) + \
                              len(self.input_structure[(0,)][('B',)])

        self.input_structure[(0,)][('A',)].remove_hetero()
        self.input_structure[(0,)][('B',)].remove_hetero()

        assert len(id_xtra) == len(self.input_structure[(0,)][('A',)]) + \
               len(self.input_structure[(0,)][('B',)])
Exemplo n.º 5
0
def stride_xtra(entities, **kwargs):
    """Runs the stride application and maps the result on the residue xtra
    dictionaries.
    """
    structures = einput(entities, 'S')
    if len(structures.values()) > 1:
        raise ValueError('Entities from multiple structures are not supported.')
    stride_app = Stride(**kwargs)
    result = stride_app(entities)['StdOut'].readlines()
    result = stride_parser(result)
    xtradata(result, structures.values()[0][(0,)])
    return result
Exemplo n.º 6
0
def stride_xtra(entities, **kwargs):
    """Runs the stride application and maps the result on the residue xtra
    dictionaries.
    """
    structures = einput(entities, 'S')
    if len(structures.values()) > 1:
        raise ValueError('Entities from multiple structures are not supported.')
    stride_app = Stride(**kwargs)
    result = stride_app(entities)['StdOut'].readlines()
    result = stride_parser(result)
    xtradata(result, structures.values()[0][(0,)])
    return result