def test_rcr_pipeline_with_errors(self): """Test rcr pipeline with error allowed.""" drug_dict = {'b': 1, 'd': 1, 'c': -1} disease_dict = {'b': -1, 'd': 1, 'c': -1} paths = [['a', 'b', 'd', 'e'], ['a', 'c', 'e']] directed_graph = self.create_graph() filtered_paths = rcr_all_paths( graph=directed_graph, all_paths=paths, drug_dict=drug_dict, errors_allowed=1 ) valid_paths = validate_paths_with_disease_data( paths=filtered_paths, drug_dict=drug_dict, disease_dict=disease_dict, errors_allowed=1 ) self.assertEqual( valid_paths, [['a', 'b', 'd'], ['a', 'c']] )
def _validation_helper( graph: str, fmt: str, source: str, target: str, lmax: int, simple_paths: bool, output: str, drug_data: str, disease_data: str, log: bool, name: str, ) -> None: """Wrap explore command in cli. :param graph: path to the graph :param fmt: graph format :param source: path to the source nodes :param target: path to the target nodes :param lmax: max length of path :param simple_paths: use simple paths or cycles :param output: output folder :param drug_data: drug experimental data :param disease_data: disease experimental data :param log: debug mode :param output: output directory :param name: name of the graph for output purposes """ _setup_logging(log) # Load graph directed_graph: DiGraph = load_graph(graph, fmt) drug_dict = ... disease_dict = ... # Check what's the overlap between each dataset and the nodes in the network evaluate_data_network_overlap(directed_graph, drug_dict) evaluate_data_network_overlap(directed_graph, disease_dict) # Get all paths between source and targets all_paths = get_all_paths_validation(directed_graph, source, target, lmax, simple_paths) # Get paths which paths are concordant with the drug_dict through all the length filtered_paths = rcr_all_paths(directed_graph, all_paths, drug_dict) # for each path, check that the values for each node in both dictionaries are the opposite validate_paths = validate_paths_with_disease_data( paths=filtered_paths, drug_dict=drug_dict, disease_dict=disease_dict) # Using the paths and the original network we induce the subgraph to visualize it later mechanism_of_action_subgraph = directed_graph.subgraph( [node for path in validate_paths for node in path])
def test_rcr_paths_with_errors(self): """Test rcr method with error allowed.""" drug_dict = {'b': 1, 'd': 1, 'c': -1} paths = [['a', 'b', 'd', 'e'], ['a', 'c', 'e']] directed_graph = self.create_graph() filtered_paths = rcr_all_paths( graph=directed_graph, all_paths=paths, drug_dict=drug_dict, errors_allowed=1 ) self.assertEqual( filtered_paths, [['a', 'b', 'd'], ['a', 'c']] )
def test_rcr_paths(self): """Test rcr method.""" ''' |--> B --> D --| | A - | | - E | --> C --> | ''' drug_dict = {'b': 1, 'd': 1, 'c': 1} paths = [['a', 'b', 'd', 'e'], ['a', 'c', 'e']] directed_graph = self.create_graph() filtered_paths = rcr_all_paths( graph=directed_graph, all_paths=paths, drug_dict=drug_dict ) self.assertEqual( filtered_paths, [['a', 'b', 'd'], ['a', 'c']] )