Skip to content

Commit

Permalink
Add abundance with ACTIVITY_ALLOWED_MODIFIERS
Browse files Browse the repository at this point in the history
  • Loading branch information
ddomingof committed Jul 1, 2019
1 parent 522d212 commit a7ea5db
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
11 changes: 10 additions & 1 deletion src/pathme/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import os

from bio2bel.utils import get_connection
from pybel.dsl.nodes import abundance, complex_abundance, protein, rna

MODULE_NAME = 'pathme'
DEFAULT_PATHME_DIR = os.path.join(os.path.expanduser('~'), '.pathme')
Expand Down Expand Up @@ -40,7 +41,7 @@ def get_data_dir() -> str:
UNIVERSE_DIR = os.path.join(DATA_DIR, 'universe')


def ensure_pathme_folders(): # TODO why is this a function?
def ensure_pathme_folders(): # TODO why is this a function?
"""Ensure data folders are created."""
os.makedirs(KEGG_DIR, exist_ok=True)
os.makedirs(REACTOME_DIR, exist_ok=True)
Expand Down Expand Up @@ -89,6 +90,14 @@ def ensure_pathme_folders(): # TODO why is this a function?
'ubiquitination': 'Ub',
'methylation': 'Me',
}

ACTIVITY_ALLOWED_MODIFIERS = {
abundance,
protein,
complex_abundance,
rna
}

KEGG_CITATION = '10592173'
REACTOME_CITATION = '29145629'

Expand Down
16 changes: 8 additions & 8 deletions src/pathme/kegg/convert_to_bel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pybel import BELGraph, to_pickle
from pybel.dsl.edges import activity
from pybel.dsl.node_classes import CentralDogma
from pybel.dsl.nodes import abundance, bioprocess, complex_abundance, composite_abundance, pmod, protein, reaction, rna
from pybel.dsl.nodes import bioprocess, composite_abundance, pmod, reaction
from pybel.struct.summary import count_functions, edge_summary

from pathme.constants import *
Expand Down Expand Up @@ -512,7 +512,7 @@ def add_simple_edge(graph, u, v, relation_type):
graph.add_increases(
u, v_modified,
citation=KEGG_CITATION, evidence='Extracted from KEGG',
subject_modifier=activity() if u in {protein, complex_abundance, rna} else None,
subject_modifier=activity() if u in ACTIVITY_ALLOWED_MODIFIERS else None,
# Add the activity function if subject is one of the following nodes (BEL 2.0 specifications)
annotations={},
)
Expand All @@ -522,7 +522,7 @@ def add_simple_edge(graph, u, v, relation_type):
graph.add_decreases(
u, v_modified,
citation=KEGG_CITATION, evidence='Extracted from KEGG',
subject_modifier=activity() if u in {protein, complex_abundance, rna} else None,
subject_modifier=activity() if u in ACTIVITY_ALLOWED_MODIFIERS else None,
# Add the activity function if subject is one of the following nodes (BEL 2.0 specifications)
annotations={},
)
Expand All @@ -539,7 +539,7 @@ def add_simple_edge(graph, u, v, relation_type):
graph.add_increases(
u, v_modified,
citation=KEGG_CITATION, evidence='Extracted from KEGG',
subject_modifier=activity() if u in {protein, complex_abundance, rna} else None,
subject_modifier=activity() if u in ACTIVITY_ALLOWED_MODIFIERS else None,
annotations={},
)

Expand All @@ -552,7 +552,7 @@ def add_simple_edge(graph, u, v, relation_type):
graph.add_decreases(
u, v,
citation=KEGG_CITATION, evidence='Extracted from KEGG',
subject_modifier=activity() if u in {protein, complex_abundance, rna} else None,
subject_modifier=activity() if u in ACTIVITY_ALLOWED_MODIFIERS else None,
annotations={},
)

Expand All @@ -561,7 +561,7 @@ def add_simple_edge(graph, u, v, relation_type):
graph.add_increases(
u, v,
citation=KEGG_CITATION, evidence='Extracted from KEGG',
object_modifier=activity() if v in {protein, complex_abundance, rna} else None,
object_modifier=activity() if v in ACTIVITY_ALLOWED_MODIFIERS else None,
annotations={},
)

Expand All @@ -570,7 +570,7 @@ def add_simple_edge(graph, u, v, relation_type):
graph.add_increases(
u, v,
citation=KEGG_CITATION, evidence='Extracted from KEGG',
subject_modifier=activity('cat') if u in {protein, complex_abundance, rna} else None,
subject_modifier=activity('cat') if u in ACTIVITY_ALLOWED_MODIFIERS else None,
annotations={},
)

Expand All @@ -579,7 +579,7 @@ def add_simple_edge(graph, u, v, relation_type):
graph.add_decreases(
u, v,
citation=KEGG_CITATION, evidence='Extracted from KEGG',
object_modifier=activity() if v in {protein, complex_abundance, rna} else None,
object_modifier=activity() if v in ACTIVITY_ALLOWED_MODIFIERS else None,
annotations={},
)

Expand Down
6 changes: 3 additions & 3 deletions src/pathme/reactome/convert_to_bel.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
NamedComplexAbundance
)

from pathme.constants import UNKNOWN, REACTOME_CITATION
from pathme.constants import ACTIVITY_ALLOWED_MODIFIERS, UNKNOWN, REACTOME_CITATION
from pathme.reactome.utils import get_valid_node_parameters, process_multiple_proteins
from pathme.utils import add_bel_metadata, parse_id_uri

Expand Down Expand Up @@ -167,15 +167,15 @@ def add_simple_edge(graph: BELGraph, u, v, edge_types):
graph.add_increases(
u, v,
citation=REACTOME_CITATION, evidence='Extracted from Reactome',
object_modifier=activity() if v in {protein, complex_abundance, rna} else None,
object_modifier=activity() if v in ACTIVITY_ALLOWED_MODIFIERS else None,
annotations={},
)

elif 'INHIBITION' in edge_types:
graph.add_decreases(
u, v,
citation=REACTOME_CITATION, evidence='Extracted from Reactome',
object_modifier=activity() if v in {protein, complex_abundance, rna} else None,
object_modifier=activity() if v in ACTIVITY_ALLOWED_MODIFIERS else None,
annotations={},
)
else:
Expand Down
8 changes: 4 additions & 4 deletions src/pathme/wikipathways/convert_to_bel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pybel.dsl import BaseEntity, abundance, activity, bioprocess, complex_abundance, gene, protein, reaction, rna

from .utils import check_multiple, evaluate_wikipathways_metadata, get_valid_gene_identifier
from ..constants import HGNC
from ..constants import HGNC, ACTIVITY_ALLOWED_MODIFIERS
from ..utils import add_bel_metadata, parse_id_uri

log = logging.getLogger(__name__)
Expand Down Expand Up @@ -205,23 +205,23 @@ def add_simple_edge(graph: BELGraph, u, v, edge_types, uri_id):
graph.add_increases(
u, v,
citation=uri_id, evidence='Extracted from WikiPathways',
object_modifier=activity() if v in {protein, complex_abundance, rna} else None,
object_modifier=activity() if v in ACTIVITY_ALLOWED_MODIFIERS else None,
annotations={},
)

elif 'Inhibition' in edge_types:
graph.add_decreases(
u, v,
citation=uri_id, evidence='Extracted from WikiPathways',
object_modifier=activity() if v in {protein, complex_abundance, rna} else None,
object_modifier=activity() if v in ACTIVITY_ALLOWED_MODIFIERS else None,
annotations={},
)

elif 'Catalysis' in edge_types:
graph.add_increases(
u, v,
citation=uri_id, evidence='Extracted from WikiPathways',
object_modifier=activity() if v in {protein, complex_abundance, rna} else None,
object_modifier=activity() if v in ACTIVITY_ALLOWED_MODIFIERS else None,
annotations={},
)

Expand Down

0 comments on commit a7ea5db

Please sign in to comment.