Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@mock_bel_resources
def test_namespace_name_persistience(self, mock_get):
"""Test that a namespace defined by a URL can't be overwritten by a definition by another URL."""
s = NAMESPACE_URL_FMT.format(HGNC_KEYWORD, HGNC_URL)
self.parser.parseString(s)
self.parser.ensure_resources()
help_check_hgnc(self, self.parser.namespace_to_term_to_encoding)
s = NAMESPACE_URL_FMT.format(HGNC_KEYWORD, 'XXXXX')
with self.assertRaises(RedefinedNamespaceError):
self.parser.parseString(s)
help_check_hgnc(self, self.parser.namespace_to_term_to_encoding)
@mock_bel_resources
def test_fragment_specified_end_only(self, mock):
dummy_namespace = n()
dummy_name = n()
node_data = Protein(namespace=dummy_namespace, name=dummy_name, variants=[Fragment(start='*', stop=1000)])
self._help_reconstitute(node_data, 2, 1)
@mock_bel_resources
def test_fragment_specified_start_only(self, mock):
dummy_namespace = n()
dummy_name = n()
node_data = Protein(namespace=dummy_namespace, name=dummy_name, variants=[Fragment(start=5, stop='*')])
self._help_reconstitute(node_data, 2, 1)
@mock_bel_resources
def test_translocation_default(self, mock):
"""This test checks that a translocation gets in the database properly"""
self.graph.add_increases(
Protein(name='F2', namespace='HGNC'),
Protein(name='EDN1', namespace='HGNC'),
evidence='In endothelial cells, ET-1 secretion is detectable under basal conditions, whereas thrombin '
'induces its secretion.',
citation='10473669',
source_modifier=secretion(),
)
make_dummy_namespaces(self.manager, self.graph)
network = self.manager.insert_graph(self.graph)
self.assertEqual(2, network.nodes.count(), msg='Missing one or both of the nodes.')
self.assertEqual(1, network.edges.count(), msg='Missing the edge')
@mock_bel_resources
def test_fragment_specified(self, mock):
dummy_namespace = n()
dummy_name = n()
node_data = Protein(namespace=dummy_namespace, name=dummy_name, variants=[Fragment(start=5, stop=8)])
self._help_reconstitute(node_data, 2, 1)
@mock_bel_resources
def test_pmod_custom_full(self, mock):
dummy_namespace = 'HGNC'
dummy_name = 'AKT1'
dummy_mod_namespace = 'GO'
dummy_mod_name = 'Protein phosphorylation'
node_data = Protein(
namespace=dummy_namespace,
name=dummy_name,
variants=[ProteinModification(name=dummy_mod_name, namespace=dummy_mod_namespace, code='Ser', position=5)]
)
self._help_reconstitute(node_data, 2, 1)
@mock_bel_resources
def test_Hgvs(self, mock):
node_data = Gene(namespace='HGNC', name='AKT1', variants=Hgvs('p.Phe508del'))
self._help_reconstitute(node_data, 2, 1)
@mock_bel_resources
def test_pmod_default_simple(self, mock):
dummy_namespace = n()
dummy_name = n()
node_data = Protein(namespace=dummy_namespace, name=dummy_name, variants=[ProteinModification('Me')])
self._help_reconstitute(node_data, 2, 1)
def setUpClass(cls):
"""Set up this class with several pre-loaded BEL graphs."""
super().setUpClass()
with mock_bel_resources:
cls.thorough_graph = from_bel_script(test_bel_thorough, manager=cls.manager, disallow_nested=False)
cls.slushy_graph = from_bel_script(
test_bel_slushy,
manager=cls.manager,
disallow_unqualified_translocations=True,
disallow_nested=True,
)
cls.simple_graph = from_bel_script_url(Path(test_bel_simple).as_uri(), manager=cls.manager)
cls.isolated_graph = from_bel_script(test_bel_isolated, manager=cls.manager)
cls.misordered_graph = from_bel_script(test_bel_misordered, manager=cls.manager, citation_clearing=False)
@mock_bel_resources
def test_gmod_custom(self, mock):
"""Tests a gene modification that uses a non-default namespace"""
dummy_namespace = 'HGNC'
dummy_name = 'AKT1'
dummy_mod_namespace = 'GO'
dummy_mod_name = 'DNA Methylation'
node_data = Gene(namespace=dummy_namespace, name=dummy_name,
variants=[GeneModification(name=dummy_mod_name, namespace=dummy_mod_namespace)])
self._help_reconstitute(node_data, 2, 1)