1010from pybel import BELGraph , to_pickle
1111from pybel .dsl .edges import activity
1212from pybel .dsl .node_classes import CentralDogma
13- from pybel .dsl .nodes import abundance , bioprocess , complex_abundance , composite_abundance , pmod , protein , reaction
13+ from pybel .dsl .nodes import abundance , bioprocess , complex_abundance , composite_abundance , pmod , protein , reaction , rna
1414from pybel .struct .summary import count_functions , edge_summary
1515
1616from pathme .constants import *
@@ -171,7 +171,8 @@ def gene_to_bel_node(graph, node):
171171 return protein_node
172172
173173 elif UNIPROT in attribute :
174- protein_node = protein (namespace = UNIPROT .upper (), name = attribute [UNIPROT ], identifier = attribute [UNIPROT ])
174+ protein_node = protein (namespace = UNIPROT .upper (), name = attribute [UNIPROT ],
175+ identifier = attribute [UNIPROT ])
175176 graph .add_node_from_data (protein_node )
176177 return protein_node
177178
@@ -505,13 +506,23 @@ def add_simple_edge(graph, u, v, relation_type):
505506
506507 # Add increases edge if pmod subtype is coupled with activation subtype
507508 if relation_type [0 ] == 'activation' :
508- graph .add_increases (u , v_modified , citation = '' , evidence = '' , subject_modifier = activity (),
509- annotations = {})
509+ graph .add_increases (
510+ u , v_modified ,
511+ citation = KEGG_CITATION , evidence = 'Extracted from KEGG' ,
512+ subject_modifier = activity () if u in {protein , complex_abundance , rna } else None ,
513+ # Add the activity function if subject is one of the following nodes (BEL 2.0 specifications)
514+ annotations = {},
515+ )
510516
511517 # Add decreases edge if pmod subtype is coupled with inhibition subtype
512518 elif relation_type [0 ] == 'inhibition' :
513- graph .add_decreases (u , v_modified , citation = '' , evidence = '' , subject_modifier = activity (),
514- annotations = {})
519+ graph .add_decreases (
520+ u , v_modified ,
521+ citation = KEGG_CITATION , evidence = 'Extracted from KEGG' ,
522+ subject_modifier = activity () if u in {protein , complex_abundance , rna } else None ,
523+ # Add the activity function if subject is one of the following nodes (BEL 2.0 specifications)
524+ annotations = {},
525+ )
515526
516527 # TODO: add pmod of v activates v
517528 # TODO: how to represent abundance modification in BEL?
@@ -522,48 +533,72 @@ def add_simple_edge(graph, u, v, relation_type):
522533 # If the object is a gene, miRNA, RNA, or protein, add protein modification
523534 if isinstance (v , CentralDogma ):
524535 v_modified = v .with_variants (pmod (KEGG_MODIFICATIONS [relation_type ]))
525- graph .add_increases (u , v_modified , citation = '' , evidence = '' , subject_modifier = activity (),
526- annotations = {})
536+ graph .add_increases (
537+ u , v_modified ,
538+ citation = KEGG_CITATION , evidence = 'Extracted from KEGG' ,
539+ subject_modifier = activity () if u in {protein , complex_abundance , rna } else None ,
540+ annotations = {},
541+ )
527542
528543 # Subject activity decreases protein modification (i.e. dephosphorylation) of object
529544 elif relation_type == 'dephosphorylation' :
530545
531546 # If the object is a gene, miRNA, RNA, or protein, add protein modification
532547 if isinstance (v , CentralDogma ):
533548 v = v .with_variants (pmod ('Ph' ))
534- graph .add_decreases (u , v , citation = KEGG_CITATION , evidence = '' , subject_modifier = activity (), annotations = {})
549+ graph .add_decreases (
550+ u , v ,
551+ citation = KEGG_CITATION , evidence = 'Extracted from KEGG' ,
552+ subject_modifier = activity () if u in {protein , complex_abundance , rna } else None ,
553+ annotations = {},
554+ )
535555
536556 # Subject increases activity of object
537557 elif relation_type == 'activation' :
538- graph .add_increases (u , v , citation = KEGG_CITATION , evidence = '' , object_modifier = activity (), annotations = {})
558+ graph .add_increases (
559+ u , v ,
560+ citation = KEGG_CITATION , evidence = 'Extracted from KEGG' ,
561+ object_modifier = activity () if v in {protein , complex_abundance , rna } else None ,
562+ annotations = {},
563+ )
539564
540565 # Catalytic activity of subject increases transformation of reactant(s) to product(s)
541566 elif relation_type in {'reversible' , 'irreversible' }:
542- graph .add_increases (u , v , citation = KEGG_CITATION , evidence = '' , subject_modifier = activity ('cat' ), annotations = {})
567+ graph .add_increases (
568+ u , v ,
569+ citation = KEGG_CITATION , evidence = 'Extracted from KEGG' ,
570+ subject_modifier = activity ('cat' ) if u in {protein , complex_abundance , rna } else None ,
571+ annotations = {},
572+ )
543573
544574 # Subject decreases activity of object
545575 elif relation_type == 'inhibition' :
546- graph .add_decreases (u , v , citation = KEGG_CITATION , evidence = '' , object_modifier = activity (), annotations = {})
576+ graph .add_decreases (
577+ u , v ,
578+ citation = KEGG_CITATION , evidence = 'Extracted from KEGG' ,
579+ object_modifier = activity () if v in {protein , complex_abundance , rna } else None ,
580+ annotations = {},
581+ )
547582
548583 # Indirect effect and binding/association are noted to be equivalent relation types
549584 elif relation_type in {'indirect effect' , 'binding/association' }:
550- graph .add_association (u , v , citation = KEGG_CITATION , evidence = '' , annotations = {})
585+ graph .add_association (u , v , citation = KEGG_CITATION , evidence = 'Extracted from KEGG ' , annotations = {})
551586
552587 # Subject increases expression of object
553588 elif relation_type == 'expression' :
554589
555590 # Expression object is converted to RNA abundance
556591 if isinstance (v , CentralDogma ):
557592 v = v .get_rna ()
558- graph .add_increases (u , v , citation = KEGG_CITATION , evidence = '' , annotations = {})
593+ graph .add_increases (u , v , citation = KEGG_CITATION , evidence = 'Extracted from KEGG ' , annotations = {})
559594
560595 # Subject decreases expression of object
561596 elif relation_type == 'repression' :
562597
563598 # Repression object is converted to RNA abundance
564599 if isinstance (v , CentralDogma ):
565600 v = v .get_rna ()
566- graph .add_decreases (u , v , citation = KEGG_CITATION , evidence = '' , annotations = {})
601+ graph .add_decreases (u , v , citation = KEGG_CITATION , evidence = 'Extracted from KEGG ' , annotations = {})
567602
568603 elif relation_type in {'dissociation' , 'hidden compound' , 'missing interaction' , 'state change' }:
569604 pass
0 commit comments