Subtree Search Algorithms¶
Stuff about this module
-
class
glypy.algorithms.subtree_search.MaximumCommonSubtreeResults(score, tree, similarity_matrix)¶ Bases:
objectResults Container for
maximum_common_subgraph()
-
glypy.algorithms.subtree_search._extract_maximum_common_subgraph(node_a, node_b, exact=False)[source]¶ Given a pair of matched starting nodes from two separate glycan structures, traverse them together, copying the best matching branches into a new
Glycanobject.Parameters: node_a: Monosaccharide
node_b: Monosaccharide
exact: bool
Whether or not to take exact matches, or just take the best pairing. If
exact=Trueand there is no exact match, the branch will terminate.
-
glypy.algorithms.subtree_search._find_max_of_matrix(solution_matrix)[source]¶ Given the
solution_matrix, find the coordinates of the maximum scoreReturns: float:
The maximum similarity score
int:
The index of the maximum similarity in
seq_aint:
The index of the maximum similarity in
seq_b
-
glypy.algorithms.subtree_search.compare_nodes(node_a, node_b, include_substituents=True, exact=False, visited=None)[source]¶ Score the pair of
node_aandnode_band all pairings of their children.Returns: float:
The similarity score between the input nodes
-
glypy.algorithms.subtree_search.distinct_fragments(self, other, fragmentation_parameters=None)[source]¶ Compute the set of distinct masses observed between two structures
Parameters: self: Glycan or list
other : Glycan or list
Glycan objects whose fragments will be compared or lists of Fragment to compare.
fragmentation_parameters : dict, optional
If
selfandotherareGlycanobjects, these parameters will be used to callGlycan.fragments().Returns: set: The distinct fragment masses of
selfset: The distinct fragment masses of
other
-
glypy.algorithms.subtree_search.exact_ordering_inclusion(self, other, substituents=True, tolerance=0, visited=None)[source]¶ A generalization of
exact_ordering_equality()which allows forselfto be matched toother, but forotherto include more. Consequently, this method is not commutative.
-
glypy.algorithms.subtree_search.maximum_common_subgraph(seq_a, seq_b, exact=True)[source]¶ Find the maximum common subgraph between
seq_aandseq_b.Parameters: seq_a: Glycan
seq_b: Glycan
exact: bool
Whether to use exact equality or fuzzy equality
Returns: MaximumCommonSubtreeResults
-
glypy.algorithms.subtree_search.n_saccharide_similarity(self, other, n=2, exact=False)[source]¶ Calculate n-saccharide similarity between two structures
Parameters: self: Glycan
other: Glycan
n: int
Size of the fragment saccharide to consider. Defaults to 2
exact: bool
Whether to use
Glycan.exact_ordering_equality()orGlycan.topological_equality(). Defaults toexact_ordering_equalityReturns: score: float
How similar these structures are at the n-saccharide level. Ranges between 0 and 1.0 where 1.0 is exactly the same, while 0.0 means no shared n-saccharides.
-
glypy.algorithms.subtree_search.subtree_of(subtree, tree, exact=False, tolerance=0)[source]¶ Test to see if
subtreeis included intreeanywhere. Returns the node id number of the first occurence ofsubtreeincluded intreeorNoneif it is not found.Parameters: subtree: Glycan
The structure to search for. The search attempts to match the complete structure of subtree.
tree: Glycan
The sturcture to search in. The search iterates over each residue in
treeand calls a comparator function, comparing thesubtreeto the substructure rooted at that residue.exact: bool
If
True, useexact_ordering_inclusion()to compare nodes. Otherwise usetopological_inclusion(). Defaults toFalse.Returns: intorNoneif no match
-
glypy.algorithms.subtree_search.topological_inclusion(self, other, substituents=True, tolerance=0, visited=None)[source]¶ Performs equality testing between two monosaccharides where the exact ordering of child links does not have match between the input
Monosaccharide, so long as anais included inbEquality testing is done by
similarity.monosaccharide_similarity().Parameters: self: Glycan
The
Glycanto test inclusion ofother: Glycan
The
Glycanto test inclusion insubstituents: bool
Consider substituents when comparing
Monosaccharides. Defaults toTruetolerance: int
The amount of error allowed when checking for flat similarity.
Returns: bool
See also
similarity.monosaccharide_similarity()