def test_canonicalize_variant_dsl(self): """Use the __str__ functions in the DSL to create BEL instead of external pybel.canonicalize.""" self.assertEqual('var("p.Val600Glu")', str(hgvs('p.Val600Glu'))) self.assertEqual('var("p.Val600Glu")', str(protein_substitution('Val', 600, 'Glu'))) self.assertEqual('pmod(Ph)', str(pmod('Ph'))) self.assertEqual('pmod(TEST:Ph)', str(pmod('Ph', namespace='TEST'))) self.assertEqual('pmod(TEST:Ph, Ser)', str(pmod('Ph', namespace='TEST', code='Ser'))) self.assertEqual( 'pmod(TEST:Ph, Ser, 5)', str(pmod('Ph', namespace='TEST', code='Ser', position=5))) self.assertEqual( 'pmod(GO:"protein phosphorylation", Thr, 308)', str( pmod(name='protein phosphorylation', namespace='GO', code='Thr', position=308))) self.assertEqual('frag("?")', str(fragment())) self.assertEqual('frag("672_713")', str(fragment(start=672, stop=713))) self.assertEqual('frag("?", "descr")', str(fragment(description='descr'))) self.assertEqual( 'frag("672_713", "descr")', str(fragment(start=672, stop=713, description='descr'))) self.assertEqual('gmod(Me)', str(gmod('Me'))) self.assertEqual('gmod(TEST:Me)', str(gmod('Me', namespace='TEST'))) self.assertEqual('gmod(GO:"DNA Methylation")', str(gmod('DNA Methylation', namespace='GO')))
def test_fragments(self): self.assertTrue( has_fragment( protein(name='APP', namespace='HGNC', variants=[ fragment(start=672, stop=713, description='random text') ]))) self.assertTrue( has_fragment( protein(name='APP', namespace='HGNC', variants=[fragment()])))
def test_get_parent(self): """Test the get_parent function in :class:`CentralDogmaAbundance`s.""" ab42 = protein(name='APP', namespace='HGNC', variants=[fragment(start=672, stop=713)]) app = ab42.get_parent() self.assertEqual('p(HGNC:APP)', app.as_bel()) self.assertEqual('p(HGNC:APP, frag("672_713"))', ab42.as_bel())
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)
def test_with_variants_list(self): """Test the `with_variant` function in :class:`CentralDogmaAbundance`s.""" app = protein(name='APP', namespace='HGNC') ab42 = app.with_variants([fragment(start=672, stop=713)]) self.assertEqual('p(HGNC:APP)', app.as_bel()) self.assertEqual('p(HGNC:APP, frag("672_713"))', ab42.as_bel())
is_protein, is_translocated, keep_node_permissive, node_exclusion_predicate_builder, node_inclusion_predicate_builder, not_pathology, ) from pybel.testing.utils import n p1 = protein(name='BRAF', namespace='HGNC') p2 = protein(name='BRAF', namespace='HGNC', variants=[hgvs('p.Val600Glu'), pmod('Ph')]) p3 = protein(name='APP', namespace='HGNC', variants=fragment(start=672, stop=713)) p4 = protein(name='2', namespace='HGNC') g1 = gene(name='BRAF', namespace='HGNC', variants=gmod('Me')) class TestNodePredicates(unittest.TestCase): """Tests for node predicates.""" def test_none_data(self): """Test permissive node predicate with a node data dictionary.""" self.assertTrue(keep_node_permissive(p1)) def test_none(self): """Test permissive node predicate with graph and tuple.""" g = BELGraph() p1_tuple = g.add_node_from_data(p1)
def test_protein_fragment(self): node = protein(name='APP', namespace='HGNC', variants=[fragment(start=672, stop=713)]) self.assertEqual('p(HGNC:APP, frag("672_713"))', str(node))
from pybel.struct.filters.edge_predicate_builders import build_relation_predicate from pybel.struct.filters.edge_predicates import ( edge_has_activity, edge_has_annotation, edge_has_degradation, edge_has_translocation, has_authors, has_polarity, has_provenance, has_pubmed, is_associative_relation, is_causal_relation, is_direct_causal_relation, ) from pybel.struct.filters.node_predicates import ( has_activity, has_causal_in_edges, has_causal_out_edges, has_fragment, has_gene_modification, has_hgvs, has_protein_modification, has_variant, is_abundance, is_causal_central, is_causal_sink, is_causal_source, is_degraded, is_gene, is_pathology, is_protein, is_translocated, none_of, not_pathology, one_of, ) from pybel.testing.utils import n p1 = protein(name='BRAF', namespace='HGNC') p2 = protein(name='BRAF', namespace='HGNC', variants=[hgvs('p.Val600Glu'), pmod('Ph')]) p3 = protein(name='APP', namespace='HGNC', variants=fragment(start=672, stop=713)) p4 = protein(name='2', namespace='HGNC') g1 = gene(name='BRAF', namespace='HGNC', variants=gmod('Me')) class TestNodePredicates(unittest.TestCase): """Tests for node predicates.""" def test_none_data(self): """Test permissive node predicate with a node data dictionary.""" self.assertTrue(true_node_predicate(p1)) self.assertFalse(false_node_predicate(p1)) def test_none(self): """Test permissive node predicate with graph and tuple."""