def test_convert_increases_abundance_then_phosphorylates(self):
        """Test the conversion of a bel graph containing one increases abundance and one phosphorylates relationship."""
        bel_graph = BELGraph()
        bel_graph.add_increases(
            oxaliplatin,
            reactive_o_species,
            evidence='10.1093/jnci/djv394',
            citation='26719345',
        )
        bel_graph.add_directly_increases(
            reactive_o_species,
            p_tau,
            evidence=n(),
            citation=n(),
        )

        re1, re2 = 1, 0
        expected_reified_graph = self.help_make_simple_expected_graph(
            oxaliplatin, reactive_o_species, INCREASES_ABUNDANCE, re1,
            self.help_causal_increases)

        expected_reified_graph.add_node(re2,
                                        label=PHOSPHORYLATES,
                                        causal=self.help_causal_increases)
        expected_reified_graph.add_edge(reactive_o_species,
                                        re2,
                                        label=REIF_SUBJECT)
        expected_reified_graph.add_edge(p_tau, re2, label=REIF_OBJECT)

        reified_graph = reify_bel_graph(bel_graph)
        self.help_test_graphs_equal(expected_reified_graph, reified_graph)
    def test_convert_activates(self):
        """Test the conversion of a bel statement like p(x) -> act(p(y))."""
        bel_graph = BELGraph()
        bel_graph.add_directly_activates(
            cdk5,
            casp8,
            evidence=n(),
            citation=n(),
        )

        expected_reified_graph = self.help_make_simple_expected_graph(
            cdk5, casp8, ACTIVATES, 0, self.help_causal_increases)

        reified_graph = reify_bel_graph(bel_graph)
        self.help_test_graphs_equal(expected_reified_graph, reified_graph)
    def test_convert_phosphorylates(self):
        """Test the conversion of a BEL statement like ``act(p(X)) -> p(Y, pmod(Ph))."""
        bel_graph = BELGraph()
        bel_graph.add_directly_increases(
            cdk5,
            p_tau,
            evidence=n(),
            citation=n(),
            subject_modifier=activity('kin'),
        )

        r_edge = 0
        expected_reified_graph = self.help_make_simple_expected_graph(
            cdk5, p_tau, PHOSPHORYLATES, r_edge, self.help_causal_increases)

        reified_graph = reify_bel_graph(bel_graph)
        self.help_test_graphs_equal(expected_reified_graph, reified_graph)
    def test_convert_fragments(self):
        """Test the conversion of a bel statement like A -> p(B, frag(?))."""

        casp3 = abundance('HGNC', 'CASP3', 'MeSH:D017628')
        tau = protein('HGNC', 'MAPT', 'HGNC:6893', variants=fragment())

        # act(p(HGNC:CASP3), ma(pep)) increases p(HGNC:MAPT, frag("?"))
        bel_graph = BELGraph()
        bel_graph.add_increases(casp3,
                                tau,
                                evidence='10.1038/s41586-018-0368-8',
                                citation='PubMed:30046111')

        expected_reified_graph = self.help_make_simple_expected_graph(
            casp3, tau, FRAGMENTS, 0, self.help_causal_increases)

        reified_graph = reify_bel_graph(bel_graph)
        self.help_test_graphs_equal(expected_reified_graph, reified_graph)
示例#5
0
def generate_bel_network(bel_graph_path: str,
                         dge_list: List[Gene],
                         max_adj_p: float,
                         max_log2_fold_change: float,
                         min_log2_fold_change: float,
                         current_disease_ids_path: Optional[str] = None,
                         disease_associations_path: Optional[str] = None,
                         collapse: str = None):
    """Generate the protein-protein interaction network.

    :param bel_graph_path:
    :param dge_list:
    :param max_adj_p:
    :param max_log2_fold_change:
    :param min_log2_fold_change:
    :param current_disease_ids_path:
    :param disease_associations_path:
    :param collapse:
    :return: Interaction network with information on differential expression.
    """
    # Load and reify the graph
    bel_graph = bel_graph_loader(bel_graph_path)
    reified = reify_bel_graph(bel_graph, collapse=collapse)

    if disease_associations_path is not None:
        if current_disease_ids_path:
            current_disease_ids = parse_disease_ids(current_disease_ids_path)
        else:
            current_disease_ids = set()
        disease_associations = parse_disease_associations(
            disease_associations_path, current_disease_ids)
    else:
        disease_associations = None

    # Build an undirected weighted graph with the remaining interactions based on Entrez gene IDs
    network = NetworkNx(
        reified,
        max_adj_p=max_adj_p,
        max_l2fc=max_log2_fold_change,
        min_l2fc=min_log2_fold_change,
    )
    network.set_up_network(dge_list, disease_associations=disease_associations)

    return network
    def test_convert_degradates(self):
        """Test the conversion of a bel statement like A -> deg(B)."""

        microglia = abundance('MeSH', 'Microglia', 'MeSH:D017628')
        abeta = abundance('CHEBI', 'amyloid-β', 'CHEBI:64645')

        # a(MESH:Microglia) reg deg(a(CHEBI:"amyloid-beta"))
        bel_graph = BELGraph()
        bel_graph.add_increases(microglia,
                                abeta,
                                evidence='10.1038/s41586-018-0368-8',
                                citation='PubMed:30046111',
                                object_modifier=degradation())

        expected_reified_graph = self.help_make_simple_expected_graph(
            microglia, abeta, DEGRADATES, 0, self.help_causal_increases)

        reified_graph = reify_bel_graph(bel_graph)
        self.help_test_graphs_equal(expected_reified_graph, reified_graph)
    def test_convert_promote_translation(self):
        """Test the conversion of a bel statement like A -> r(B)"""
        # example from Colorectal Cancer Model v2.0.6 @ scai
        # act(p(HGNC:CTNNB1), ma(tscript)) increases r(HGNC:BIRC5)
        ctnnb1 = protein('HGNC', name='CTNNB1')
        birc5 = rna('HGNC', name='BIRC5')

        # a(MESH:Microglia) reg deg(a(CHEBI:"amyloid-beta"))
        bel_graph = BELGraph()
        bel_graph.add_increases(ctnnb1,
                                birc5,
                                evidence='10.1038/s41586-018-0368-8',
                                citation='18075512',
                                subject_modifier=activity('tscript'))

        expected_reified_graph = self.help_make_simple_expected_graph(
            ctnnb1, birc5, PROMOTES_TRANSLATION, 0, self.help_causal_increases)
        reified_graph = reify_bel_graph(bel_graph)

        self.help_test_graphs_equal(expected_reified_graph, reified_graph)
    def test_convert_increases_abundance(self):
        """Test the conversion of a bel statement like A -> B, when A and B don't fall in any special case (activity, pmod, ...)."""
        bel_graph = BELGraph()
        bel_graph.add_increases(
            oxaliplatin,
            reactive_o_species,
            evidence='10.1093/jnci/djv394',
            citation='PubMed:26719345',
        )

        expected_reified_graph = self.help_make_simple_expected_graph(
            oxaliplatin,
            reactive_o_species,
            INCREASES_ABUNDANCE,
            0,
            self.help_causal_increases,
        )

        reified_graph = reify_bel_graph(bel_graph)
        self.help_test_graphs_equal(expected_reified_graph, reified_graph)
    def test_convert_two_phosphorylates(self):
        """Test that two phosphorylations of the same object get different reified nodes."""
        bel_graph = BELGraph()
        for kinase in (cdk5, gsk3b):
            bel_graph.add_directly_increases(
                kinase,
                p_tau,
                evidence=n(),
                citation=n(),
                subject_modifier=activity('kin'),
            )

        re1, re2 = 0, 1
        expected_reified_graph = self.help_make_simple_expected_graph(
            cdk5, p_tau, PHOSPHORYLATES, re1, self.help_causal_increases)
        expected_reified_graph.add_node(re2,
                                        label='phosphorylates',
                                        causal=self.help_causal_increases)
        expected_reified_graph.add_edge(gsk3b, re2, label=REIF_SUBJECT)
        expected_reified_graph.add_edge(p_tau, re2, label=REIF_OBJECT)

        reified_graph = reify_bel_graph(bel_graph)
        self.help_test_graphs_equal(expected_reified_graph, reified_graph)