def test_is_n_glycan(self): core = glycans['N-Linked Core'] tree = glycoct.loads(broad_n_glycan) result = (subtree_search.subtree_of(core, tree)) self.assertTrue(result == 1) tree = glycoct.loads(complex_glycan) result = (subtree_search.subtree_of(core, tree, exact=False)) self.assertTrue(result == 1) result = (subtree_search.subtree_of(core, tree, exact=True)) self.assertTrue(result == 1) tree = glycoct.loads(branchy_glycan) result = (subtree_search.subtree_of(core, tree, exact=False)) self.assertTrue(result is None)
def matches(self, other): motif = self.structure() target = other.structure() ix = subtree_search.subtree_of(motif, target, exact=True) if self.is_core_motif: return ix == 1 else: return ix is not None
def is_n_glycan(record): ''' A predicate testing if the :title:`N-linked Glycan` core motif is present in `record.structure`. Returns ------- int: 0 if |False|, 1 if |True|. Sqlite doesn't have a dedicated |bool| data type. See Also -------- :func:`glypy.algorithms.subtree_search.subtree_of` ''' return int(subtree_search.subtree_of( n_glycan_core, record.structure, exact=False) == 1)
def test_subtree_inclusion(self): core = glycans['N-Linked Core'] tree = glycoct.loads(broad_n_glycan) self.assertTrue(subtree_search.subtree_of(core, tree)) self.assertTrue(subtree_search.subtree_of(tree, core) is None)