Commit 0ba9f83e authored by Martina Locatelli's avatar Martina Locatelli 🍁
Browse files

Correcting None node error in networkX

parent d95a4654
Pipeline #2489 failed with stages
in 2 minutes and 54 seconds
......@@ -239,7 +239,8 @@ def create_class_prot():
G = nx.DiGraph()
for r in R:
G.add_edge(r[1], r[0]) # The tree
if r[1] is not None:
G.add_edge(r[1], r[0]) # The tree
R = psql.qstring("SELECT cs.accession, cc.protein_class_id FROM component_sequences cs, component_class cc WHERE cs.component_id = cc.component_id AND cs.accession IS NOT NULL", chembl_dbname)
......
......@@ -174,7 +174,8 @@ def create_class_prot():
G = nx.DiGraph()
for r in R:
G.add_edge(r[1], r[0]) # The tree
if r[1] is not None:
G.add_edge(r[1], r[0]) # The tree
R = psql.qstring("SELECT cs.accession, cc.protein_class_id FROM component_sequences cs, component_class cc WHERE cs.component_id = cc.component_id AND cs.accession IS NOT NULL", chembl_dbname)
......
......@@ -197,7 +197,8 @@ def create_class_prot():
G = nx.DiGraph()
for r in R:
G.add_edge(r[1], r[0]) # The tree
if r[1] is not None:
G.add_edge(r[1], r[0]) # The tree
kinase_idx = set([x for w in kinase_idx for k, v in nx.dfs_successors(
G, w).items() for x in v] + kinase_idx)
......@@ -241,7 +242,8 @@ def create_class_prot():
G = nx.DiGraph()
for r in R:
G.add_edge(r[1], r[0]) # The tree
if r[1] is not None:
G.add_edge(r[1], r[0]) # The tree
R = psql.qstring("SELECT cs.accession, cc.protein_class_id FROM component_sequences cs, component_class cc WHERE cs.component_id = cc.component_id AND cs.accession IS NOT NULL", chembl_dbname)
......
......@@ -76,7 +76,8 @@ def parse_chembl():
G = nx.DiGraph()
for s in S:
G.add_edge(s[1], s[0]) # The tree
if s[1] is not None:
G.add_edge(s[1], s[0]) # The tree
S = psql.qstring("SELECT cs.accession, cc.protein_class_id FROM component_sequences cs, component_class cc WHERE cs.component_id = cc.component_id AND cs.accession IS NOT NULL", chembl_dbname)
......
......@@ -42,7 +42,8 @@ def prepare_hotnet_input(outdir, all_binary_sif):
if l[0] in chebi_inchikey and l[2] in chebi_inchikey:
ik1 = chebi_inchikey[l[0]]
ik2 = chebi_inchikey[l[2]]
G.add_edge(ik1, ik2)
if ik1 is not None:
G.add_edge(ik1, ik2)
with open(os.path.join(outdir, pcomms_file), "w") as f:
for e in G.edges():
......
......@@ -183,7 +183,8 @@ def process_activity_according_to_pharos(ACTS):
G = nx.DiGraph()
for r in R:
G.add_edge(r[1], r[0]) # The tree
if r[1] is not None:
G.add_edge(r[1], r[0]) # The tree
kinase_idx = set([x for w in kinase_idx for k, v in nx.dfs_successors(
G, w).items() for x in v] + kinase_idx)
......@@ -237,7 +238,8 @@ def process_activity_according_to_pharos(ACTS):
G = nx.DiGraph()
for r in R:
G.add_edge(r[1], r[0]) # The tree
if r[1] is not None:
G.add_edge(r[1], r[0]) # The tree
R = psql.qstring("SELECT cs.accession, cc.protein_class_id FROM component_sequences cs, component_class cc WHERE cs.component_id = cc.component_id AND cs.accession IS NOT NULL", chembl_dbname)
......
......@@ -17,7 +17,8 @@ G = nx.DiGraph()
f = open(myfold + "/bp.tsv", "r")
for l in f:
l = l.rstrip("\n").split("\t")
G.add_edge(l[0], l[1])
if l[0] is not None:
G.add_edge(l[0], l[1])
f.close()
# Read Uniprot GOA
......
......@@ -184,7 +184,8 @@ def process_activity_according_to_pharos(ACTS):
G = nx.DiGraph()
for r in R:
G.add_edge(r[1], r[0]) # The tree
if r[1] is not None:
G.add_edge(r[1], r[0]) # The tree
kinase_idx = set([x for w in kinase_idx for k, v in nx.dfs_successors(
G, w).items() for x in v] + kinase_idx)
......@@ -238,7 +239,8 @@ def process_activity_according_to_pharos(ACTS):
G = nx.DiGraph()
for r in R:
G.add_edge(r[1], r[0]) # The tree
if r[1] is not None:
G.add_edge(r[1], r[0]) # The tree
R = psql.qstring("SELECT cs.accession, cc.protein_class_id FROM component_sequences cs, component_class cc WHERE cs.component_id = cc.component_id AND cs.accession IS NOT NULL", chembl_dbname)
......@@ -449,7 +451,8 @@ def main(args):
parent = l.split("is_a: ")[1].split(" !")[0]
if parent == "regulates":
continue
G.add_edge(parent, child)
if parent is not None:
G.add_edge(parent, child)
f = open(os.path.join(args.models_path, "bp.tsv"), "w")
for e in G.edges():
......
......@@ -217,7 +217,8 @@ def process_activity_according_to_pharos(ACTS):
G = nx.DiGraph()
for r in R:
G.add_edge(r[1], r[0]) # The tree
if r[1] is not None:
G.add_edge(r[1], r[0]) # The tree
kinase_idx = set([x for w in kinase_idx for k, v in nx.dfs_successors(
G, w).items() for x in v] + kinase_idx)
......@@ -271,7 +272,8 @@ def process_activity_according_to_pharos(ACTS):
G = nx.DiGraph()
for r in R:
G.add_edge(r[1], r[0]) # The tree
if r[1] is not None:
G.add_edge(r[1], r[0]) # The tree
R = psql.qstring("SELECT cs.accession, cc.protein_class_id FROM component_sequences cs, component_class cc WHERE cs.component_id = cc.component_id AND cs.accession IS NOT NULL", chembl_dbname)
......
......@@ -91,7 +91,8 @@ def parse_cellosaurus(R, cellosaurus_obo):
G.add_node(child)
if "relationship: derived_from " in l:
parent = l.split("derived_from ")[1].split(" !")[0]
G.add_edge(parent, child)
if parent is not None:
G.add_edge(parent, child)
# if "relationship: originate_from_same_individual_as" in l:
# parent = l.split("originate_from_same_individual_as ")[1].split(" !")[0]
# G.add_edge(parent, child)
......@@ -100,7 +101,8 @@ def parse_cellosaurus(R, cellosaurus_obo):
for n in list(G.nodes()):
if not nx.ancestors(G, n):
G.add_edge(n, "*")
if n is not None:
G.add_edge(n, "*")
# Cell hierarchy
......
......@@ -130,6 +130,7 @@ def include_mesh(ctd_diseases, IND):
if pardisids == [""]:
pardisids = ["ROOT"]
for pardisid in pardisids:
if pardisid is not None:
G.add_edge(pardisid, disid)
classIND = collections.defaultdict(list)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment