Repository: pybel/pybel
Pull request #455 (2020-07-06 21:54:36)

Remove the rest of the BEL default namespace
The final two things that needed auto-mapping to a high confidence controlled vocabulary were the protein and gene modifications. Luckily, I've already curated mappings to GO for both of them

- [x] Auto-mapping in DSL
- [x] Auto-mapping during parsing
- [x] Remove upload of BEL default namespace with insertion of graph


cthoyt: Now this is blocked by an issue with parsing pmods/gmods containing OBO-style identifiers
codecov[bot]: # [Codecov](https://codecov.io/gh/pybel/pybel/pull/455?src=pr&el=h1) Report
> Merging [#455](https://codecov.io/gh/pybel/pybel/pull/455?src=pr&el=desc) into [master](https://codecov.io/gh/pybel/pybel/commit/4ab0a6ad4183f960c42da2d443889ce540712d46&el=desc) will **decrease** coverage by `0.08%`.
> The diff coverage is `94.73%`.

[![Impacted file tree graph](https://codecov.io/gh/pybel/pybel/pull/455/graphs/tree.svg?width=650&height=150&src=pr&token=J7joRTRygG)](https://codecov.io/gh/pybel/pybel/pull/455?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master     #455      +/-   ##
==========================================
- Coverage   79.10%   79.01%   -0.09%     
==========================================
  Files         171      171              
  Lines        9039     9054      +15     
  Branches     1307     1311       +4     
==========================================
+ Hits         7150     7154       +4     
- Misses       1608     1619      +11     
  Partials      281      281              
```


| [Impacted Files](https://codecov.io/gh/pybel/pybel/pull/455?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/pybel/examples/ampk\_example.py](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree#diff-c3JjL3B5YmVsL2V4YW1wbGVzL2FtcGtfZXhhbXBsZS5weQ==) | `100.00% <ø> (ø)` | |
| [src/pybel/manager/cache\_manager.py](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree#diff-c3JjL3B5YmVsL21hbmFnZXIvY2FjaGVfbWFuYWdlci5weQ==) | `78.16% <ø> (-2.29%)` | :arrow_down: |
| [src/pybel/io/spia.py](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree#diff-c3JjL3B5YmVsL2lvL3NwaWEucHk=) | `72.82% <71.42%> (+0.91%)` | :arrow_up: |
| [src/pybel/canonicalize.py](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree#diff-c3JjL3B5YmVsL2Nhbm9uaWNhbGl6ZS5weQ==) | `87.68% <100.00%> (ø)` | |
| [src/pybel/dsl/node\_classes.py](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree#diff-c3JjL3B5YmVsL2RzbC9ub2RlX2NsYXNzZXMucHk=) | `92.63% <100.00%> (+1.65%)` | :arrow_up: |
| [src/pybel/parser/modifiers/gene\_modification.py](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree#diff-c3JjL3B5YmVsL3BhcnNlci9tb2RpZmllcnMvZ2VuZV9tb2RpZmljYXRpb24ucHk=) | `100.00% <100.00%> (ø)` | |
| [src/pybel/parser/modifiers/protein\_modification.py](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree#diff-c3JjL3B5YmVsL3BhcnNlci9tb2RpZmllcnMvcHJvdGVpbl9tb2RpZmljYXRpb24ucHk=) | `100.00% <100.00%> (ø)` | |
| [src/pybel/parser/parse\_bel.py](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree#diff-c3JjL3B5YmVsL3BhcnNlci9wYXJzZV9iZWwucHk=) | `93.40% <100.00%> (ø)` | |
| [src/pybel/testing/utils.py](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree#diff-c3JjL3B5YmVsL3Rlc3RpbmcvdXRpbHMucHk=) | `94.87% <0.00%> (-5.13%)` | :arrow_down: |
| [src/pybel/language.py](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree#diff-c3JjL3B5YmVsL2xhbmd1YWdlLnB5) | `91.54% <0.00%> (-2.82%)` | :arrow_down: |
| ... and [2 more](https://codecov.io/gh/pybel/pybel/pull/455/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pybel/pybel/pull/455?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pybel/pybel/pull/455?src=pr&el=footer). Last update [4ab0a6a...4546dd9](https://codecov.io/gh/pybel/pybel/pull/455?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/pybel/canonicalize.py b/src/pybel/canonicalize.py
index a9d339b7..5121e3f3 100644
--- a/src/pybel/canonicalize.py
+++ b/src/pybel/canonicalize.py
@@ -57,7 +57,7 @@ def to_bel_script_gz(graph, path, **kwargs) -> None:
         to_bel_script(graph, file, **kwargs)
 
 
-def to_bel_script_lines(graph, use_identifiers: bool = False) -> Iterable[str]:
+def to_bel_script_lines(graph, use_identifiers: bool = True) -> Iterable[str]:
     """Iterate over the lines of the BEL graph as a canonical BEL script.
 
     :param pybel.BELGraph graph: A BEL Graph
diff --git a/src/pybel/dsl/node_classes.py b/src/pybel/dsl/node_classes.py
index 80d84d7b..b302870d 100644
--- a/src/pybel/dsl/node_classes.py
+++ b/src/pybel/dsl/node_classes.py
@@ -9,13 +9,12 @@ from typing import Iterable, List, Optional, Set, Union
 
 from .exc import InferCentralDogmaException, ListAbundanceEmptyException, ReactionEmptyException
 from ..constants import (
-    ABUNDANCE, BEL_DEFAULT_NAMESPACE, BIOPROCESS, COMPLEX, COMPOSITE, CONCEPT, FRAGMENT, FRAGMENT_DESCRIPTION,
-    FRAGMENT_MISSING, FRAGMENT_START, FRAGMENT_STOP, FUNCTION, FUSION, FUSION_MISSING, FUSION_REFERENCE, FUSION_START,
-    FUSION_STOP, GENE, GMOD, HGVS, KIND, MEMBERS, MIRNA, PARTNER_3P, PARTNER_5P, PATHOLOGY, PMOD, PMOD_CODE, PMOD_ORDER,
-    PMOD_POSITION, POPULATION, PRODUCTS, PROTEIN, RANGE_3P, RANGE_5P, REACTANTS, REACTION, RNA, VARIANTS, XREFS,
-    rev_abundance_labels,
+    ABUNDANCE, BIOPROCESS, COMPLEX, COMPOSITE, CONCEPT, FRAGMENT, FRAGMENT_DESCRIPTION, FRAGMENT_MISSING,
+    FRAGMENT_START, FRAGMENT_STOP, FUNCTION, FUSION, FUSION_MISSING, FUSION_REFERENCE, FUSION_START, FUSION_STOP, GENE,
+    GMOD, HGVS, KIND, MEMBERS, MIRNA, PARTNER_3P, PARTNER_5P, PATHOLOGY, PMOD, PMOD_CODE, PMOD_ORDER, PMOD_POSITION,
+    POPULATION, PRODUCTS, PROTEIN, RANGE_3P, RANGE_5P, REACTANTS, REACTION, RNA, VARIANTS, XREFS, rev_abundance_labels,
 )
-from ..language import Entity
+from ..language import Entity, gmod_mappings, pmod_mappings
 
 __all__ = [
     # Base Classes
@@ -369,7 +368,7 @@ class EntityVariant(Variant, BaseConcept):
         super().__init__(kind=self.function)
 
         self[CONCEPT] = Entity(
-            namespace=(namespace or BEL_DEFAULT_NAMESPACE),
+            namespace=namespace,
             name=name,
             identifier=identifier,
         )
@@ -420,6 +419,10 @@ class ProteinModification(EntityVariant):
         >>>                     identifier='0006468', code='Thr', position=308)
 
         """
+        if name and not namespace and not identifier:
+            x = pmod_mappings[name]['xrefs'][0]
+            namespace, identifier, name = x.namespace, x.identifier, x.name
+
         super().__init__(
             name=name,
             namespace=namespace,
@@ -447,23 +450,48 @@ class ProteinModification(EntityVariant):
 
 
 class GeneModification(EntityVariant):
-    """Build a gene modification variant dictionary.
+    """Build a gene modification variant dictionary."""
+
+    function = GMOD
+
+    def __init__(
+        self,
+        name: str,
+        namespace: Optional[str] = None,
+        identifier: Optional[str] = None,
+        xrefs: Optional[List[Entity]] = None,
+    ) -> None:
+        """Build a protein modification variant data dictionary.
+
+        :param name: The name of the modification
+        :param namespace: The namespace to which the name of this modification belongs
+        :param identifier: The identifier of the name of the modification
+        :param xrefs: Alternative database xrefs
 
-    Either the name or the identifier must be used. If the namespace is omitted, it is assumed that a name is
-    specified from the BEL default namespace.
+        Either the name or the identifier must be used. If the namespace is omitted, it is assumed that a name is
+        specified from the BEL default namespace.
 
-    Example from BEL default namespace:
+        Example from BEL default namespace:
 
-    >>> from pybel.dsl import GeneModification
-    >>> GeneModification(name='Me')
+        >>> from pybel.dsl import GeneModification
+        >>> GeneModification(name='Me')
 
-    Example from custom namespace:
+        Example from custom namespace:
 
-    >>> from pybel.dsl import GeneModification
-    >>> GeneModification(name='DNA methylation', namespace='GO', identifier='0006306',)
-    """
+        >>> from pybel.dsl import GeneModification
+        >>> GeneModification(name='DNA methylation', namespace='GO', identifier='0006306')
 
-    function = GMOD
+        """
+        if name and not namespace and not identifier:
+            x = gmod_mappings[name]['xrefs'][0]
+            namespace, identifier, name = x.namespace, x.identifier, x.name
+
+        super().__init__(
+            name=name,
+            namespace=namespace,
+            identifier=identifier,
+            xrefs=xrefs,
+        )
 
     def as_bel(self, use_identifiers: bool = True) -> str:
         """Return this gene modification variant as a BEL string."""
diff --git a/src/pybel/examples/ampk_example.py b/src/pybel/examples/ampk_example.py
index 2616b731..4632a023 100644
--- a/src/pybel/examples/ampk_example.py
+++ b/src/pybel/examples/ampk_example.py
@@ -60,7 +60,7 @@ ampk_graph.add_directly_phosphorylates(
 )
 ampk_graph.add_binds(
     ComplexAbundance([
-        rptor.with_variants(ProteinModification('Ser')),
+        rptor.with_variants(ProteinModification('Ph')),
         mtor,
     ]),
     p14_3_3,
diff --git a/src/pybel/io/spia.py b/src/pybel/io/spia.py
index 09d8b174..ca8dbaf8 100644
--- a/src/pybel/io/spia.py
+++ b/src/pybel/io/spia.py
@@ -17,6 +17,7 @@ import pandas as pd
 
 from ..constants import ASSOCIATION, CAUSAL_DECREASE_RELATIONS, CAUSAL_INCREASE_RELATIONS, RELATION
 from ..dsl import CentralDogma, Gene, ListAbundance, ProteinModification, Rna
+from ..language import pmod_mappings
 from ..struct import BELGraph
 from ..typing import EdgeData
 
@@ -142,6 +143,10 @@ def build_spia_matrices(nodes: Set[str]) -> Dict[str, pd.DataFrame]:
     return matrices
 
 
+UB_NAMES = {"Ub"} | {e.name for e in pmod_mappings['Ub']['xrefs']}
+PH_NAMES = {"Ph"} | {e.name for e in pmod_mappings['Ph']['xrefs']}
+
+
 def update_spia_matrices(
     spia_matrices: Dict[str, pd.DataFrame],
     u: CentralDogma,
@@ -162,9 +167,9 @@ def update_spia_matrices(
             for variant in v.variants:
                 if not isinstance(variant, ProteinModification):
                     continue
-                elif variant.entity.name == "Ub":  # FIXME update with grounding
+                elif variant.entity.name in UB_NAMES:
                     spia_matrices["activation_ubiquination"][u_name][v_name] = 1
-                elif variant.entity.name == "Ph":
+                elif variant.entity.name in PH_NAMES:
                     spia_matrices["activation_phosphorylation"][u_name][v_name] = 1
         elif isinstance(v, (Gene, Rna)):  # Normal increase, add activation
             spia_matrices['expression'][u_name][v_name] = 1
@@ -177,9 +182,9 @@ def update_spia_matrices(
             for variant in v.variants:
                 if not isinstance(variant, ProteinModification):
                     continue
-                elif variant.entity.name == "Ub":
+                elif variant.entity.name in UB_NAMES:
                     spia_matrices['inhibition_ubiquination'][u_name][v_name] = 1
-                elif variant.entity.name == "Ph":
+                elif variant.entity.name in PH_NAMES:
                     spia_matrices["inhibition_phosphorylation"][u_name][v_name] = 1
         elif isinstance(v, (Gene, Rna)):  # Normal decrease, check which matrix
             spia_matrices["repression"][u_name][v_name] = 1
diff --git a/src/pybel/manager/cache_manager.py b/src/pybel/manager/cache_manager.py
index da3ea172..cb240c31 100644
--- a/src/pybel/manager/cache_manager.py
+++ b/src/pybel/manager/cache_manager.py
@@ -585,8 +585,6 @@ class InsertManager(NamespaceManager, LookupManager):
 
         t = time.time()
 
-        self.ensure_default_namespace()
-
         namespace_urls = graph.namespace_url.values()
         if use_tqdm:
             namespace_urls = tqdm(namespace_urls, **(tqdm_kwargs or {}))
diff --git a/src/pybel/parser/modifiers/gene_modification.py b/src/pybel/parser/modifiers/gene_modification.py
index 521b82f7..69690856 100644
--- a/src/pybel/parser/modifiers/gene_modification.py
+++ b/src/pybel/parser/modifiers/gene_modification.py
@@ -45,8 +45,8 @@ in the OpenBEL community.
 from pyparsing import Group, MatchFirst, ParserElement, oneOf
 
 from ..utils import nest, one_of_tags
-from ...constants import BEL_DEFAULT_NAMESPACE, CONCEPT, GMOD, KIND, NAME, NAMESPACE
-from ...language import gmod_namespace
+from ...constants import CONCEPT, GMOD, IDENTIFIER, KIND, NAME, NAMESPACE
+from ...language import gmod_mappings, gmod_namespace
 
 __all__ = [
     'get_gene_modification_language',
@@ -54,8 +54,10 @@ __all__ = [
 
 
 def _handle_gmod_default(_, __, tokens):
-    tokens[NAMESPACE] = BEL_DEFAULT_NAMESPACE
-    tokens[NAME] = gmod_namespace[tokens[0]]
+    e = gmod_mappings[gmod_namespace[tokens[0]]]['xrefs'][0]
+    tokens[NAMESPACE] = e.namespace
+    tokens[IDENTIFIER] = e.identifier
+    tokens[NAME] = e.name
     return tokens
 
 
@@ -63,9 +65,13 @@ gmod_tag = one_of_tags(tags=['gmod', 'geneModification'], canonical_tag=GMOD, na
 gmod_default_ns = oneOf(list(gmod_namespace)).setParseAction(_handle_gmod_default)
 
 
-def get_gene_modification_language(concept_qualified: ParserElement) -> ParserElement:
+def get_gene_modification_language(
+    concept_fqualified: ParserElement,
+    concept_qualified: ParserElement,
+) -> ParserElement:
     """Build a gene modification parser."""
     concept = MatchFirst([
+        concept_fqualified,
         concept_qualified,
         gmod_default_ns,
     ])
diff --git a/src/pybel/parser/modifiers/protein_modification.py b/src/pybel/parser/modifiers/protein_modification.py
index e31ef410..ece6ecb7 100644
--- a/src/pybel/parser/modifiers/protein_modification.py
+++ b/src/pybel/parser/modifiers/protein_modification.py
@@ -80,8 +80,8 @@ from pyparsing import Group, MatchFirst, Optional, ParseResults, ParserElement,
 
 from .constants import amino_acid
 from ..utils import WCW, nest, one_of_tags
-from ...constants import BEL_DEFAULT_NAMESPACE, CONCEPT, KIND, NAME, NAMESPACE, PMOD, PMOD_CODE, PMOD_POSITION
-from ...language import pmod_legacy_labels, pmod_namespace
+from ...constants import CONCEPT, IDENTIFIER, KIND, NAME, NAMESPACE, PMOD, PMOD_CODE, PMOD_POSITION
+from ...language import pmod_legacy_labels, pmod_mappings, pmod_namespace
 
 __all__ = [
     'get_protein_modification_language',
@@ -91,16 +91,21 @@ logger = logging.getLogger(__name__)
 
 
 def _handle_pmod_default_ns(_, __, tokens: ParseResults) -> ParseResults:
-    tokens[NAMESPACE] = BEL_DEFAULT_NAMESPACE
-    tokens[NAME] = pmod_namespace[tokens[0]]
-    return tokens
+    upgraded = pmod_namespace[tokens[0]]
+    return _r(upgraded, tokens)
 
 
 def _handle_pmod_legacy_ns(line, _, tokens: ParseResults) -> ParseResults:
     upgraded = pmod_legacy_labels[tokens[0]]
     logger.log(5, 'legacy pmod() value %s upgraded to %s', line, upgraded)
-    tokens[NAMESPACE] = BEL_DEFAULT_NAMESPACE
-    tokens[NAME] = upgraded
+    return _r(upgraded, tokens)
+
+
+def _r(upgraded, tokens):
+    e = pmod_mappings[upgraded]['xrefs'][0]
+    tokens[NAMESPACE] = e.namespace
+    tokens[IDENTIFIER] = e.identifier
+    tokens[NAME] = e.name
     return tokens
 
 
@@ -109,9 +114,13 @@ pmod_default_ns = oneOf(list(pmod_namespace)).setParseAction(_handle_pmod_defaul
 pmod_legacy_ns = oneOf(list(pmod_legacy_labels)).setParseAction(_handle_pmod_legacy_ns)
 
 
-def get_protein_modification_language(concept_qualified: ParserElement) -> ParserElement:
+def get_protein_modification_language(
+    concept_fqualified: ParserElement,
+    concept_qualified: ParserElement,
+) -> ParserElement:
     """Build a protein modification parser."""
     pmod_concept = MatchFirst([
+        concept_fqualified,
         concept_qualified,
         pmod_default_ns,
         pmod_legacy_ns,
diff --git a/src/pybel/parser/parse_bel.py b/src/pybel/parser/parse_bel.py
index 2c05eb27..5461ef44 100644
--- a/src/pybel/parser/parse_bel.py
+++ b/src/pybel/parser/parse_bel.py
@@ -316,14 +316,20 @@ class BELParser(BaseParser):
         # 2.2 Abundance Modifier Functions
 
         #: `2.2.1 <http://openbel.org/language/version_2.0/bel_specification_version_2.0.html#_protein_modifications>`_
-        self.pmod = get_protein_modification_language(self.concept_parser.identifier_qualified)
+        self.pmod = get_protein_modification_language(
+            concept_fqualified=self.concept_parser.identifier_fqualified,
+            concept_qualified=self.concept_parser.identifier_qualified,
+        )
 
         #: `2.2.4 <http://openbel.org/language/version_2.0/bel_specification_version_2.0.html#_cellular_location>`_
         self.location = get_location_language(self.concept_parser.language)
         opt_location = pyparsing.Optional(WCW + self.location)
 
         #: PyBEL BEL Specification variant
-        self.gmod = get_gene_modification_language(self.concept_parser.identifier_qualified)
+        self.gmod = get_gene_modification_language(
+            concept_fqualified=self.concept_parser.identifier_fqualified,
+            concept_qualified=self.concept_parser.identifier_qualified,
+        )
 
         # 2.6 Other Functions
 


Test patch:
diff --git a/tests/constants.py b/tests/constants.py
index 19ab7426..71e9326c 100644
--- a/tests/constants.py
+++ b/tests/constants.py
@@ -359,7 +359,7 @@ class BelReconstitutionMixin(TestGraphMixin):
         for node in graph:
             self.assertIsInstance(node, BaseEntity)
 
-        self.assertEqual(set(BEL_THOROUGH_NODES), set(graph), msg='Nodes not equal')
+        self.assertEqual(sorted(BEL_THOROUGH_NODES, key=str), sorted(graph, key=str), msg='Nodes not equal')
 
         # FIXME
         # self.assertEqual(set((u, v) for u, v, _ in e), set(g.edges()))
diff --git a/tests/test_canonicalization.py b/tests/test_canonicalization.py
index 888b43cd..b11b0451 100644
--- a/tests/test_canonicalization.py
+++ b/tests/test_canonicalization.py
@@ -28,7 +28,7 @@ class TestCanonicalize(unittest.TestCase):
         self.assertEqual('var("p.Val600Glu")', str(Hgvs('p.Val600Glu')))
         self.assertEqual('var("p.Val600Glu")', str(ProteinSubstitution('Val', 600, 'Glu')))
 
-        self.assertEqual('pmod(Ph)', str(ProteinModification('Ph')))
+        self.assertEqual('pmod(go:0006468 ! "protein phosphorylation")', str(ProteinModification('Ph')))
         self.assertEqual('pmod(TEST:Ph)', str(ProteinModification('Ph', namespace='TEST')))
         self.assertEqual('pmod(TEST:Ph, Ser)', str(ProteinModification('Ph', namespace='TEST', code='Ser')))
         self.assertEqual('pmod(TEST:Ph, Ser, 5)',
@@ -42,7 +42,7 @@ class TestCanonicalize(unittest.TestCase):
         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(GeneModification('Me')))
+        self.assertEqual('gmod(go:0006306 ! "DNA methylation")', str(GeneModification('Me')))
         self.assertEqual('gmod(TEST:Me)', str(GeneModification('Me', namespace='TEST')))
         self.assertEqual('gmod(GO:"DNA Methylation")', str(GeneModification('DNA Methylation', namespace='GO')))
 
@@ -68,7 +68,7 @@ class TestCanonicalize(unittest.TestCase):
 
     def test_protein_pmod(self):
         node = Protein(name='PLCG1', namespace='HGNC', variants=[ProteinModification(name='Ph', code='Tyr')])
-        self.assertEqual('p(HGNC:PLCG1, pmod(Ph, Tyr))', str(node))
+        self.assertEqual('p(HGNC:PLCG1, pmod(go:0006468 ! "protein phosphorylation", Tyr))', str(node))
 
     def test_protein_fragment(self):
         node = Protein(name='APP', namespace='HGNC', variants=[Fragment(start=672, stop=713)])
diff --git a/tests/test_io/test_import.py b/tests/test_io/test_import.py
index 1b66eca2..d85ce783 100644
--- a/tests/test_io/test_import.py
+++ b/tests/test_io/test_import.py
@@ -207,7 +207,7 @@ class TestInterchange(TemporaryCacheClsMixin, BelReconstitutionMixin):
         os.remove(path)
 
     def test_thorough_upgrade(self):
-        lines = to_bel_script_lines(self.thorough_graph)
+        lines = to_bel_script_lines(self.thorough_graph, use_identifiers=True)
         reconstituted = BELGraph()
         parse_lines(reconstituted, lines, manager=self.manager)
         self.bel_thorough_reconstituted(reconstituted, check_citation_name=False, check_path=False)
diff --git a/tests/test_io/test_umbrella_nodelink.py b/tests/test_io/test_umbrella_nodelink.py
index 195bbeca..4d43b3b8 100644
--- a/tests/test_io/test_umbrella_nodelink.py
+++ b/tests/test_io/test_umbrella_nodelink.py
@@ -27,7 +27,7 @@ class TestUmbrellaNodeLinkExporter(unittest.TestCase):
             custom_json_dict['nodes'],
         )
         self.assertIn(
-            'act(p(hgnc:PTK2, pmod(Ph, Tyr, 925)), ma(go:0016301 ! "kinase activity"))',
+            'act(p(hgnc:PTK2, pmod(go:0006468 ! "protein phosphorylation", Tyr, 925)), ma(go:0016301 ! "kinase activity"))',
             custom_json_dict['nodes'])
         self.assertIn(
             'act(p(fus(hgnc:BCR, "?", hgnc:ABL1, "?")), ma(go:0016301 ! "kinase activity"))',
diff --git a/tests/test_manager/test_manager_graph.py b/tests/test_manager/test_manager_graph.py
index a1427cf6..716597f1 100644
--- a/tests/test_manager/test_manager_graph.py
+++ b/tests/test_manager/test_manager_graph.py
@@ -848,11 +848,11 @@ class TestReconstituteEdges(TemporaryCacheMixin):
         self.assertEqual(2, network.nodes.count(), msg='number of nodes')
         self.assertEqual(1, network.edges.count(), msg='number of edges')
 
-        kin_list = self.manager.session.query(NamespaceEntry).filter(NamespaceEntry.name == 'kin').all()
+        kin_list = self.manager.session.query(NamespaceEntry).filter(NamespaceEntry.name == 'kinase activity').all()
         self.assertEqual(1, len(kin_list), msg='number of kinase NamespaceEntrys')
 
         kin = list(kin_list)[0]
-        self.assertEqual('kin', kin.name)
+        self.assertEqual('kinase activity', kin.name)
 
     @mock_bel_resources
     def test_subject_activity_custom(self, mock):
@@ -900,11 +900,11 @@ class TestReconstituteEdges(TemporaryCacheMixin):
         self.assertEqual(2, network.nodes.count())
         self.assertEqual(1, network.edges.count())
 
-        kin_list = self.manager.session.query(NamespaceEntry).filter(NamespaceEntry.name == 'kin').all()
+        kin_list = self.manager.session.query(NamespaceEntry).filter(NamespaceEntry.name == 'kinase activity').all()
         self.assertEqual(1, len(kin_list))
 
         kin = list(kin_list)[0]
-        self.assertEqual('kin', kin.name)
+        self.assertEqual('kinase activity', kin.name)
 
     @mock_bel_resources
     def test_object_activity_custom(self, mock):
diff --git a/tests/test_parse/test_parse_bel.py b/tests/test_parse/test_parse_bel.py
index bc8db812..b246fc20 100644
--- a/tests/test_parse/test_parse_bel.py
+++ b/tests/test_parse/test_parse_bel.py
@@ -11,10 +11,8 @@ from pybel.constants import (
     ABUNDANCE, ACTIVITY, BIOPROCESS, CELL_SECRETION, CELL_SURFACE_EXPRESSION, COMPLEX, COMPOSITE, CONCEPT, DEGRADATION,
     DIRECTLY_INCREASES, DIRTY, EFFECT, FRAGMENT, FROM_LOC, FUNCTION, FUSION, FUSION_MISSING, FUSION_REFERENCE,
     FUSION_START, FUSION_STOP, GENE, HAS_VARIANT, HGVS, IDENTIFIER, KIND, LOCATION, MEMBERS, MIRNA, MODIFIER, NAME,
-    NAMESPACE, SOURCE, TARGET, TARGET_MODIFIER, PARTNER_3P, PARTNER_5P, PART_OF, PATHOLOGY, POPULATION, PRODUCTS,
-    PROTEIN,
-    RANGE_3P, RANGE_5P,
-    REACTANTS, REACTION, RELATION, RNA, SOURCE_MODIFIER, TO_LOC, TRANSLOCATION, VARIANTS,
+    NAMESPACE, PARTNER_3P, PARTNER_5P, PART_OF, PATHOLOGY, POPULATION, PRODUCTS, PROTEIN, RANGE_3P, RANGE_5P, REACTANTS,
+    REACTION, RELATION, RNA, SOURCE, TARGET, TARGET_MODIFIER, TO_LOC, TRANSLOCATION, VARIANTS,
 )
 from pybel.dsl import (
     Fragment, Population, abundance, bioprocess, cell_surface_expression, complex_abundance, composite_abundance,
@@ -252,7 +250,7 @@ class TestGene(TestTokenParserBase):
 
         expected_node = gene('HGNC', 'AKT1', variants=gmod('Me'))
         self.assert_has_node(expected_node)
-        self.assertEqual('g(HGNC:AKT1, gmod(Me))', self.graph.node_to_bel(expected_node))
+        self.assertEqual('g(HGNC:AKT1, gmod(go:0006306 ! "DNA methylation"))', self.graph.node_to_bel(expected_node))
 
         parent = gene('HGNC', 'AKT1')
         self.assert_has_node(parent)
@@ -750,7 +748,10 @@ class TestProtein(TestTokenParserBase):
         parent = protein('HGNC', 'AKT1')
         node = parent.with_variants([hgvs('p.Ala127Tyr'), pmod('Ph', code='Ser')])
         self.assert_has_node(node)
-        self.assertEqual('p(HGNC:AKT1, pmod(Ph, Ser), var("p.Ala127Tyr"))', self.graph.node_to_bel(node))
+        self.assertEqual(
+            'p(HGNC:AKT1, pmod(go:0006468 ! "protein phosphorylation", Ser), var("p.Ala127Tyr"))',
+            self.graph.node_to_bel(node),
+        )
 
         self.assert_has_node(parent)
         self.assert_has_edge(parent, node, relation=HAS_VARIANT)
@@ -927,7 +928,10 @@ class TestProtein(TestTokenParserBase):
         parent = protein('HGNC', 'AKT1')
         expected_node = parent.with_variants(pmod('Ph', code='Ser', position=473))
         self.assert_has_node(expected_node)
-        self.assertEqual('p(HGNC:AKT1, pmod(Ph, Ser, 473))', self.graph.node_to_bel(expected_node))
+        self.assertEqual(
+            'p(HGNC:AKT1, pmod(go:0006468 ! "protein phosphorylation", Ser, 473))',
+            self.graph.node_to_bel(expected_node),
+        )
 
         self.assert_has_node(parent)
         self.assert_has_edge(parent, expected_node, relation=HAS_VARIANT)
@@ -940,7 +944,10 @@ class TestProtein(TestTokenParserBase):
         parent = protein('HGNC', 'AKT1')
         expected_node = parent.with_variants(pmod('Ph', code='Ser', position=473))
         self.assert_has_node(expected_node)
-        self.assertEqual('p(HGNC:AKT1, pmod(Ph, Ser, 473))', self.graph.node_to_bel(expected_node))
+        self.assertEqual(
+            'p(HGNC:AKT1, pmod(go:0006468 ! "protein phosphorylation", Ser, 473))',
+            self.graph.node_to_bel(expected_node),
+        )
 
         self.assert_has_node(parent)
         self.assert_has_edge(parent, expected_node, relation=HAS_VARIANT)
@@ -966,7 +973,10 @@ class TestProtein(TestTokenParserBase):
         parent = protein('HGNC', 'HRAS')
         expected_node = parent.with_variants(pmod('Palm'))
         self.assert_has_node(expected_node)
-        self.assertEqual('p(HGNC:HRAS, pmod(Palm))', self.graph.node_to_bel(expected_node))
+        self.assertEqual(
+            'p(HGNC:HRAS, pmod(go:0018345 ! "protein palmitoylation"))',
+            self.graph.node_to_bel(expected_node),
+        )
 
         self.assert_has_node(parent)
         self.assert_has_edge(parent, expected_node, relation=HAS_VARIANT)
diff --git a/tests/test_parse/test_parse_bel_relations.py b/tests/test_parse/test_parse_bel_relations.py
index 3ddbd9b5..92792ed5 100644
--- a/tests/test_parse/test_parse_bel_relations.py
+++ b/tests/test_parse/test_parse_bel_relations.py
@@ -10,13 +10,12 @@ from pyparsing import ParseException
 from pybel import BELGraph
 from pybel.canonicalize import edge_to_bel
 from pybel.constants import (
-    ABUNDANCE, ACTIVITY, ANNOTATIONS, BEL_DEFAULT_NAMESPACE, BIOPROCESS, CAUSES_NO_CHANGE, CITATION, COMPLEX, COMPOSITE,
-    CONCEPT, CORRELATION, DECREASES, DIRECTLY_DECREASES, DIRECTLY_INCREASES, EFFECT, EQUIVALENT_TO, EVIDENCE, FROM_LOC,
-    FUNCTION, GENE, GMOD, HAS_PRODUCT, HAS_REACTANT, HAS_VARIANT, HGVS, INCREASES, IS_A, KIND, LOCATION, MEMBERS,
-    MODIFIER, NAME, NAMESPACE, NEGATIVE_CORRELATION, NO_CORRELATION, ORTHOLOGOUS, PART_OF, PATHOLOGY,
-    POSITIVE_CORRELATION, PRODUCTS, PROTEIN, RATE_LIMITING_STEP_OF, REACTANTS, REACTION, REGULATES, RELATION, RNA,
-    SOURCE, SOURCE_MODIFIER, SUBPROCESS_OF, TARGET, TARGET_MODIFIER, TO_LOC, TRANSCRIBED_TO, TRANSLATED_TO,
-    TRANSLOCATION, VARIANTS,
+    ABUNDANCE, ACTIVITY, ANNOTATIONS, BIOPROCESS, CAUSES_NO_CHANGE, CITATION, COMPLEX, COMPOSITE, CONCEPT, CORRELATION,
+    DECREASES, DIRECTLY_DECREASES, DIRECTLY_INCREASES, EFFECT, EQUIVALENT_TO, EVIDENCE, FROM_LOC, FUNCTION, GENE, GMOD,
+    HAS_PRODUCT, HAS_REACTANT, HAS_VARIANT, HGVS, IDENTIFIER, INCREASES, IS_A, KIND, LOCATION, MEMBERS, MODIFIER, NAME,
+    NAMESPACE, NEGATIVE_CORRELATION, NO_CORRELATION, ORTHOLOGOUS, PART_OF, PATHOLOGY, POSITIVE_CORRELATION, PRODUCTS,
+    PROTEIN, RATE_LIMITING_STEP_OF, REACTANTS, REACTION, REGULATES, RELATION, RNA, SOURCE, SOURCE_MODIFIER,
+    SUBPROCESS_OF, TARGET, TARGET_MODIFIER, TO_LOC, TRANSCRIBED_TO, TRANSLATED_TO, TRANSLOCATION, VARIANTS,
 )
 from pybel.dsl import (
     ComplexAbundance, Pathology, Protein, Rna, abundance, activity, bioprocess, complex_abundance, composite_abundance,
@@ -137,7 +136,12 @@ class TestRelations(TestTokenParserBase):
 
     def test_increases_methylation(self):
         """Test a causal statement with a gene modification."""
-        statement = 'a(CHEBI:"lead atom") -> g(HGNC:APP, gmod(Me))'
+        for gmod in ['Me', 'go:0006306 ! "DNA methylation"']:
+            with self.subTest(gmod=gmod):
+                self._help_test_increases_methylation(gmod)
+
+    def _help_test_increases_methylation(self, x):
+        statement = f'a(CHEBI:"lead atom") -> g(HGNC:APP, gmod({x}))'
         result = self.parser.relation.parseString(statement)
         expected_dict = {
             TARGET: {
@@ -150,9 +154,10 @@ class TestRelations(TestTokenParserBase):
                     {
                         KIND: GMOD,
                         CONCEPT: {
-                            NAMESPACE: BEL_DEFAULT_NAMESPACE,
-                            NAME: 'Me',
-                        }
+                            NAMESPACE: 'go',
+                            IDENTIFIER: '0006306',
+                            NAME: 'DNA methylation',
+                        },
                     },
                 ],
             },
@@ -559,7 +564,12 @@ class TestRelations(TestTokenParserBase):
         """
         3.2.1 http://openbel.org/language/web/version_2.0/bel_specification_version_2.0.html#XnegCor
         Test phosphoralation tag"""
-        statement = 'kin(p(FPLX:GSK3)) neg p(HGNC:MAPT,pmod(P))'
+        for pmod in ['P', 'Ph', 'go:0006468 ! "protein phosphorylation"']:
+            with self.subTest(pmod=pmod):
+                self._help_test_negative_correlation_with_object_variant(pmod)
+
+    def _help_test_negative_correlation_with_object_variant(self, x):
+        statement = f'kin(p(FPLX:GSK3)) neg p(HGNC:MAPT,pmod({x}))'
         result = self.parser.relation.parseString(statement)
 
         expected_dict = {
@@ -934,7 +944,7 @@ class TestRelations(TestTokenParserBase):
         self.assert_has_node(expected_child)
 
         self.assertEqual('g(HGNC:AKT1)', self.graph.node_to_bel(expected_parent))
-        self.assertEqual('g(HGNC:AKT1, gmod(Me))', self.graph.node_to_bel(expected_child))
+        self.assertEqual('g(HGNC:AKT1, gmod(go:0006306 ! "DNA methylation"))', self.graph.node_to_bel(expected_child))
 
         self.assert_has_edge(expected_parent, expected_child, **{RELATION: HAS_VARIANT})
 
diff --git a/tests/test_parse/test_parse_bel_variants.py b/tests/test_parse/test_parse_bel_variants.py
index eedcf2f9..acd672e7 100644
--- a/tests/test_parse/test_parse_bel_variants.py
+++ b/tests/test_parse/test_parse_bel_variants.py
@@ -7,9 +7,9 @@ import re
 import unittest
 
 from pybel.constants import (
-    BEL_DEFAULT_NAMESPACE, CONCEPT, FRAGMENT, FRAGMENT_DESCRIPTION, FRAGMENT_MISSING, FRAGMENT_START, FRAGMENT_STOP,
-    FUSION_MISSING, FUSION_REFERENCE, FUSION_START, FUSION_STOP, GMOD, KIND, LOCATION, NAME, NAMESPACE,
-    PARTNER_3P, PARTNER_5P, PMOD, PMOD_CODE, PMOD_POSITION, RANGE_3P, RANGE_5P,
+    CONCEPT, FRAGMENT, FRAGMENT_DESCRIPTION, FRAGMENT_MISSING, FRAGMENT_START, FRAGMENT_STOP, FUSION_MISSING,
+    FUSION_REFERENCE, FUSION_START, FUSION_STOP, GMOD, IDENTIFIER, KIND, LOCATION, NAME, NAMESPACE, PARTNER_3P,
+    PARTNER_5P, PMOD, PMOD_CODE, PMOD_POSITION, RANGE_3P, RANGE_5P,
 )
 from pybel.dsl import GeneModification, Hgvs, ProteinModification
 from pybel.language import Entity
@@ -100,8 +100,10 @@ class TestPmod(unittest.TestCase):
             'MOD': re.compile('.*'),
             'HGNC': re.compile('.*'),
         })
-        identifier_qualified = identifier_parser.identifier_qualified
-        self.parser = get_protein_modification_language(identifier_qualified)
+        self.parser = get_protein_modification_language(
+            concept_qualified=identifier_parser.identifier_qualified,
+            concept_fqualified=identifier_parser.identifier_fqualified,
+        )
 
     def _help_test_pmod_simple(self, statement):
         result = self.parser.parseString(statement)
@@ -109,8 +111,9 @@ class TestPmod(unittest.TestCase):
         expected = {
             KIND: PMOD,
             CONCEPT: {
-                NAMESPACE: BEL_DEFAULT_NAMESPACE,
-                NAME: 'Ph',
+                NAMESPACE: 'go',
+                NAME: 'protein phosphorylation',
+                IDENTIFIER: '0006468',
             },
         }
         self.assertEqual(expected, ProteinModification('Ph'))
@@ -133,8 +136,9 @@ class TestPmod(unittest.TestCase):
         expected = {
             KIND: PMOD,
             CONCEPT: {
-                NAMESPACE: BEL_DEFAULT_NAMESPACE,
-                NAME: 'Ph',
+                NAMESPACE: 'go',
+                NAME: 'protein phosphorylation',
+                IDENTIFIER: '0006468',
             },
             PMOD_CODE: 'Ser',
         }
@@ -153,8 +157,9 @@ class TestPmod(unittest.TestCase):
         expected = {
             KIND: PMOD,
             CONCEPT: {
-                NAMESPACE: BEL_DEFAULT_NAMESPACE,
-                NAME: 'Ph',
+                NAMESPACE: 'go',
+                NAME: 'protein phosphorylation',
+                IDENTIFIER: '0006468',
             },
             PMOD_CODE: 'Ser',
             PMOD_POSITION: 473,
@@ -196,8 +201,10 @@ class TestPmod(unittest.TestCase):
 class TestGeneModification(unittest.TestCase):
     def setUp(self):
         identifier_parser = ConceptParser()
-        identifier_qualified = identifier_parser.identifier_qualified
-        self.parser = get_gene_modification_language(identifier_qualified)
+        self.parser = get_gene_modification_language(
+            concept_fqualified=identifier_parser.identifier_fqualified,
+            concept_qualified=identifier_parser.identifier_qualified,
+        )
 
         self.expected = GeneModification('Me')
 
@@ -205,8 +212,9 @@ class TestGeneModification(unittest.TestCase):
         self.assertEqual({
             KIND: GMOD,
             CONCEPT: {
-                NAME: 'Me',
-                NAMESPACE: BEL_DEFAULT_NAMESPACE,
+                NAME: 'DNA methylation',
+                IDENTIFIER: '0006306',
+                NAMESPACE: 'go',
             }
         }, self.expected)
 
diff --git a/tests/test_struct/test_struct_graph.py b/tests/test_struct/test_struct_graph.py
index d9860541..0f589969 100644
--- a/tests/test_struct/test_struct_graph.py
+++ b/tests/test_struct/test_struct_graph.py
@@ -101,7 +101,7 @@ class TestStruct(unittest.TestCase):
 Name                   Sialic Acid Graph
 Version                1.0.0
 Number of Nodes        9
-Number of Namespaces   4
+Number of Namespaces   3
 Number of Edges        11
 Number of Annotations  2
 Number of Citations    1
@@ -117,12 +117,11 @@ Protein           7
 Complex           1
 Abundance         1
 
-Namespace (4)      Count
+Namespace (3)      Count
 ---------------  -------
 hgnc                   8
+go                     3
 chebi                  2
-go                     2
-bel                    1
 
 Edge Type (7)                        Count
 ---------------------------------  -------
diff --git a/tests/test_struct/test_summary/test_summary_nodes.py b/tests/test_struct/test_summary/test_summary_nodes.py
index 0fdde437..2a52a3d8 100644
--- a/tests/test_struct/test_summary/test_summary_nodes.py
+++ b/tests/test_struct/test_summary/test_summary_nodes.py
@@ -46,8 +46,7 @@ class TestSummary(unittest.TestCase):
         namespace_result = {
             'hgnc': 8,
             'chebi': 2,
-            BEL_DEFAULT_NAMESPACE: 1,
-            'go': 2
+            'go': 3,
         }
         self.assertEqual(set(namespace_result), get_namespaces(sialic_acid_graph))
         self.assertEqual(Counter(namespace_result), count_namespaces(sialic_acid_graph))