GraphMatcher#

class graph_matcher.GraphMatcher(processed_graph, coalescent_tree, initial_mapping, result_callback_function, logs_path=None, alignment_vertex_mode=AlignmentVertexMode.ALL_ALIGNMENTS, alignment_edge_mode=AlignmentEdgeMode.ALL_EDGE_ALIGNMENTS)#

This class runs the divide-and-conquer alignment algorithm on the given preprocessed pedigree and the coalescent tree.

class MatcherLogger(logs_directory_path='logs')#
__init__(logs_directory_path='logs')#

Initializes the logger and creates the log file.

Parameters:

logs_directory_path – The directory where the logs will be stored.

close()#

Closes the log file.

log(line)#

Logs the passed line and flushes the buffer.

Parameters:

line (str) – The line to log.

log_vertex_inference_time(coalescent_tree, spent_time, focal_vertex_coalescent_id, focal_vertex_children, child_candidates_map, inference_result)#

Logs the time spent on the coalescent vertex inference as well as the inference results themselves.

Parameters:
  • coalescent_tree (CoalescentTree) – The coalescent tree.

  • spent_time (float) – The time spent on the inference.

  • focal_vertex_coalescent_id (int) – The coalescent vertex id for which the inference has been done.

  • focal_vertex_children (list[int]) – The coalescent vertex children vertices.

  • child_candidates_map (dict[int, [int]]) – Dictionary mapping every focal’s child vertex to the list of its pedigree candidates.

  • inference_result – The list of candidates for the focal vertex.

section_delimiter = '####################################################################################################'#
subsection_delimiter = '----------------------------------------------------------------------------------------------------'#
__init__(processed_graph, coalescent_tree, initial_mapping, result_callback_function, logs_path=None, alignment_vertex_mode=AlignmentVertexMode.ALL_ALIGNMENTS, alignment_edge_mode=AlignmentEdgeMode.ALL_EDGE_ALIGNMENTS)#

Initializes the GraphMatcher object.

Parameters:
  • processed_graph (PotentialMrcaProcessedGraph) – The preprocessed pedigree graph that stores the “access vertices” through which a descendant vertex can reach the ancestor vertex.

  • coalescent_tree (CoalescentTree) – The coalescent tree with which the processed_graph is to be aligned.

  • initial_mapping (dict[int, [int]]) – The initial mapping between the proband vertices in the processed pedigree to the vertices in the coalescent tree.

  • logs_path (str | Path) – The path where the log file should be stored. None specifies that no logs should be stored.

  • alignment_vertex_mode (AlignmentVertexMode) – Specifies how extensive the search must be.

  • alignment_edge_mode (AlignmentEdgeMode) – Specifies whether edge alignments should be calculated.

find_alignments()#

This method finds all the valid mapping between the given processed pedigree and every sub-clade within the coalescent tree. Every valid vertex alignment is passed to the callback function provided in the constructor

log(string)#

Logs the given string if the logs are enabled. Does nothing otherwise.

Parameters:

string (str) – The string to log.

log_section_delimiter()#
log_subsection_delimiter()#
graph_matcher.get_initial_simulation_mapping_for_mode(coalescent_tree, mode=ProbandInitialAssignmentsMode.INDIVIDUAL)#
graph_matcher.get_pedigree_simulation_probands_for_alignment_mode(vertices, alignment_mode=ProbandInitialAssignmentsMode.INDIVIDUAL)#
graph_matcher.get_subtree_matcher_for_coalescent_tree_proband(proband, proband_pedigree_ids)#

Helper function returning the valid sub-alignments for a proband (which is simply one identity alignment).

Parameters:
  • proband (int) – The id of the proband in the coalescent tree

  • proband_pedigree_ids ([int]) – The ids of the corresponding vertices in the pedigree