def test_get_tf_pairs(self): """Test iterating over transcription factor pairs.""" graph = BELGraph() p1, p2, p3 = (Protein('test', str(i)) for i in range(1, 4)) r4, r5, r6 = (Rna('test', str(j)) for j in range(4, 7)) g4 = r4.get_gene() self.assertIsNotNone(g4) g5 = r5.get_gene() self.assertIsNotNone(g5) c14, c25 = ComplexAbundance([p1, g4]), ComplexAbundance([p2, g5]) _tf_up(graph, p1, r4) _tf_down(graph, p2, r5) graph.add_correlation(p3, r6, citation=n(), evidence=n()) self.assertEqual({p1, p2, p3, r4, r5, r6, g4, g5, c14, c25}, set(graph)) expected_edges = [ (c14, r4), (p1, c14), (g4, c14), (c25, r5), (p2, c25), (g5, c25), (p3, r6), (r6, p3), ] sorted_expected_edges = sorted(expected_edges, key=_bel_pair_key) sorted_actual_edges = sorted(graph.edges(), key=_bel_pair_key) self.assertEqual(sorted_expected_edges, sorted_actual_edges) pairs = set(get_tf_pairs(graph)) expected_pairs = {(p1, r4, +1), (p2, r5, -1)} self.assertEqual(expected_pairs, pairs)
def _add_my_row(graph: BELGraph, row) -> None: relation = row['relation'] source_uniprot_id = row['source'] target_uniprot_id = row['target'] pubmed_ids = row['pubmed_ids'] pubmed_ids = pubmed_ids.split('|') source = pybel.dsl.Protein( namespace='uniprot', identifier=source_uniprot_id, name=get_mnemonic(source_uniprot_id), ) target = pybel.dsl.Protein( namespace='uniprot', identifier=target_uniprot_id, name=get_mnemonic(target_uniprot_id), ) for pubmed_id in pubmed_ids: if relation == 'deubiquitination': target_ub = target.with_variants( pybel.dsl.ProteinModification('Ub')) graph.add_decreases( source, target_ub, citation=pubmed_id, evidence='From intact', ) elif relation == 'ubiqutination': target_ub = target.with_variants( pybel.dsl.ProteinModification('Ub')) graph.add_increases( source, target_ub, citation=..., evidence='From intact', ) elif relation == 'degratation': graph.add_decreases( source, target, citation=..., evidence='From intact', ) elif relation == 'activates': graph.add_increases( source, target, ..., object_modifier=pybel.dsl.activity(), ) elif relation == 'co-expressed': graph.add_correlation( pybel.dsl.Rna( namespace='uniprot', identifier=source_uniprot_id, name=get_mnemonic(source_uniprot_id), ), pybel.dsl.Rna( namespace='uniprot', identifier=target_uniprot_id, name=get_mnemonic(target_uniprot_id), ), annotations=dict(cell_line={'HEK2': True}), )