Esempio n. 1
0
    def residues(self, **kwargs):
        """Get residues from this structure. The keyword arguments work as
        described by EntitySelector.

        :kwargs: Keywords for filtering and ordering
        :returns: The requested residues.
        """
        if 'polymeric' not in kwargs:
            kwargs['polymeric'] = True
        if kwargs.get('polymeric', False) is None:
            kwargs.pop('polymeric')

        return EntitySelector(self._residues, **kwargs)
Esempio n. 2
0
    def atoms(self, **kwargs):
        """Get, filter and sort the atoms in this component. Access is as
        described by EntitySelector.

        :kwargs: The keyword arguments to filter and sort by.
        :returns: A list of the requested atoms.
        """

        name = kwargs.get('name')
        if isinstance(name, basestring):
            definition = self.centers.definition(name)
            if definition:
                kwargs['name'] = definition

        return EntitySelector(self._atoms, **kwargs)
Esempio n. 3
0
 def test_can_filter_by_method_to_find_several(self):
     ids = ['1S72|1|A|C|1', '1S72|1|A|C|3']
     val = sorted(EntitySelector(self.atoms, component_unit_id=ids),
                  key=lambda a: a.name)
     self.assertEquals([self.atoms[0], self.atoms[2]], val)
Esempio n. 4
0
 def test_can_filter_by_method_to_find_one(self):
     comp_id = '1S72|1|A|C|1'
     val = list(EntitySelector(self.atoms, component_unit_id=comp_id))
     self.assertEquals([self.atoms[2]], val)
Esempio n. 5
0
 def test_it_does_not_fail_if_missing_attribute_used(self):
     val = sorted(EntitySelector(self.atoms, name3=('a1', 'c2'), type='N'),
                  key=lambda a: a.name)
     self.assertEquals([], val)
Esempio n. 6
0
 def test_can_filter_by_several(self):
     val = sorted(EntitySelector(self.atoms, name=('a1', 'c2'), type='N'),
                  key=lambda a: a.name)
     self.assertEquals([self.atoms[3]], val)
Esempio n. 7
0
 def test_can_filter_by_function_using_object(self):
     val = sorted(EntitySelector(self.atoms, _=lambda a: a.x >= 2),
                  key=lambda a: a.name)
     self.assertEquals([self.atoms[1], self.atoms[2]], val)
Esempio n. 8
0
 def test_can_select_with_set_of_names(self):
     val = sorted(EntitySelector(self.atoms, name=set(['a1', 'c2'])),
                  key=lambda a: a.name)
     self.assertEquals([self.atoms[0], self.atoms[3]], val)
Esempio n. 9
0
 def test_can_select_by_one_name(self):
     val = list(EntitySelector(self.atoms, name='a1'))
     self.assertEquals([self.atoms[0]], val)
Esempio n. 10
0
 def test_gives_nothing_if_no_match(self):
     val = list(EntitySelector(self.atoms, name='bob'))
     self.assertEquals([], val)
Esempio n. 11
0
 def test_matches_everything_with_empty_filter(self):
     filter = {}
     val = len(list(EntitySelector(self.atoms), **filter))
     self.assertEquals(4, val)
Esempio n. 12
0
 def test_can_iterate_over_all(self):
     val = len(list(EntitySelector(self.atoms)))
     self.assertEquals(4, val)
 def test_can_filter_using_method_and_lambda(self):
     comp_id = '1S72|1|A|C|1'
     val = list(
         EntitySelector(self.atoms,
                        component_unit_id=lambda t: t == comp_id))
     assert [self.atoms[2]] == val
 def test_can_filter_using_op(self):
     val = list(EntitySelector(self.atoms, type=ft.partial(op.eq, 'C')))
     assert [self.atoms[0], self.atoms[1]] == val