Skip to content

Commit

Permalink
Standardize TSV header casing; handle new DIRECT values; model_title …
Browse files Browse the repository at this point in the history
…param
  • Loading branch information
dustine32 committed Apr 9, 2020
1 parent debc45e commit 6862ceb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
23 changes: 15 additions & 8 deletions pathway_connections.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import csv
import itertools
from ontobio.vocabulary.relations import OboRO
from rdflib.term import URIRef
from prefixcommons.curie_util import expand_uri
Expand Down Expand Up @@ -72,7 +73,7 @@ def __init__(self, id_a, id_b, mechanism, effect, direct, relation, pmid, linenu
self.complex_b = COMPLEXES[self.id_b]
# by default mechanism = molecular function
mechanism_term = "GO:0003674"
if self.direct == "YES":
if self.direct in ["YES", "t"]:
if(mechanism):
mechanism_term = MECHANISM_GO_MAPPING[mechanism]
self.mechanism = { "name" : mechanism, "uri" : None, "term" : mechanism_term }
Expand Down Expand Up @@ -191,33 +192,39 @@ def full_statement_bnode_in_model(self, model):
if candidate_reg_triple in graph:
return candidate_reg_triple


def upper_first(iterator):
return itertools.chain([next(iterator).upper()], iterator)


class PathwayConnectionSet():
def __init__(self, filename=None):
self.connections = []
linenum = 0

if filename:
with open(filename, "r") as f:
data = list(csv.DictReader(f, delimiter="\t"))

data = list(csv.DictReader(upper_first(f), delimiter="\t"))
for line in data:
linenum += 1
print(line)
# print(line)

# If up-regulates (including any variants of this), use RO:0002629 if DIRECT, and use RO:0002213 if not DIRECT or UNKNOWN
relation = None
if line["EFFECT"].startswith("up-regulates"):
if line["DIRECT"] == "YES":
if line["DIRECT"] in ["YES", "t"]:
relation = "RO:0002629"
elif line["DIRECT"] == "NO":
elif line["DIRECT"] in ["NO", "f"]:
relation = "RO:0002213"
# If down-regulates (including any variants of this), use RO:0002630 if DIRECT, and use RO:0002212 if not DIRECT or UNKNOWN
elif line["EFFECT"].startswith("down-regulates"):
if line["DIRECT"] == "YES":
if line["DIRECT"] in ["YES", "t"]:
relation = "RO:0002630"
elif line["DIRECT"] == "NO":
elif line["DIRECT"] in ["NO", "f"]:
relation = "RO:0002212"
# If unknown, use RO:0002211
elif line["EFFECT"] == "unknown":
elif line["EFFECT"] in ["unknown", ""]:
relation = "RO:0002211"
# If 'form complex', ignore these lines for now
elif line["EFFECT"] == "form complex":
Expand Down
8 changes: 7 additions & 1 deletion pathway_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
parser = argparse.ArgumentParser()
parser.add_argument('-f', "--filename", type=str, required=True,
help="Input filename of SIGNOR pathway data")
parser.add_argument('-t', "--model_title",
help="Model title. Defaults to --outfile value.")
parser.add_argument('-o', "--outfile", type=str, required=True,
help="Output filename of generated model")

Expand Down Expand Up @@ -56,7 +58,11 @@ def main():

args = parser.parse_args()

model = GoCamModel(args.outfile)
if args.model_title:
model_title = args.model_title
else:
model_title = args.outfile
model = GoCamModel(model_title)
# p_connections = PathwayConnectionSet("SIGNOR-G2-M_trans_02_03_18.tsv")
p_connections = PathwayConnectionSet(args.filename)
linenum = 1
Expand Down
2 changes: 2 additions & 0 deletions signor_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def __init__(self, filename):
self.families = self.grouping

def main():
# TODO: parameterize SIGNOR_complexes.csv path
complex_list = SignorComplexFactory("SIGNOR_complexes.csv")
complex = complex_list.complexes["SIGNOR-C87"]
complex_cc = "GO:0032991"
Expand All @@ -101,6 +102,7 @@ def main():
pathway_line_mech_or_reg_activity = "pc.whatevs"
# state "pathway_line_mech_or_reg_activity ENABLED_BY complex_cc"

# TODO: parameterize SIGNOR_PF.csv path
pf_list = SignorProteinFamilyFactory("SIGNOR_PF.csv")
pf = pf_list.families["SIGNOR-PF11"]
print("PF list for " + pf.name + ":")
Expand Down

0 comments on commit 6862ceb

Please sign in to comment.