diff --git a/graphs/ccf_Brain_graph.pdf b/graphs/ccf_Brain_graph.pdf index 5b12cea09..c1dfff86a 100644 Binary files a/graphs/ccf_Brain_graph.pdf and b/graphs/ccf_Brain_graph.pdf differ diff --git a/graphs/ccf_Brain_graph.png b/graphs/ccf_Brain_graph.png index 5a89511e7..21cb22156 100644 Binary files a/graphs/ccf_Brain_graph.png and b/graphs/ccf_Brain_graph.png differ diff --git a/src/ccf_tools.py b/src/ccf_tools.py index c7aa08f32..c55e6f69b 100644 --- a/src/ccf_tools.py +++ b/src/ccf_tools.py @@ -34,13 +34,13 @@ def parse_asctb(path): where each pair of adjacent columns => a subject-object pair for testing""" def is_valid_id(content): - if re.match("(CL|UBERON)\:[0-9]+", content['id']): + if re.match("(CL|UBERON|PCL)\:[0-9]+", content['id']): return content else: logger.warning(f"No valid ID provided for '{content['id']}', label: {content['name']}, user_label: {content['rdfs_label']}") return False def check_id(id): - return re.match("(CL|UBERON)\:[0-9]+", id) + return re.match("(CL|UBERON|PCL)\:[0-9]+", id) asct_b_tab = json.load(open(path)) as_invalid_terms = set() diff --git a/src/template_generation_tools.py b/src/template_generation_tools.py index 6d07fd6bc..2058111f5 100644 --- a/src/template_generation_tools.py +++ b/src/template_generation_tools.py @@ -94,7 +94,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): del_index = [] for t in no_valid_class: - logger.warning(f"Unrecognised UBERON/CL entity '{t}'") + logger.warning(f"Unrecognised UBERON/CL/PCL entity '{t}'") del_index.extend(ccf_tools_df[(ccf_tools_df['s'] == t) | (ccf_tools_df['o'] == t)].index) # Drop rows with unrecognized UBERON/CL terms @@ -116,7 +116,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): if 'CL' in r['o']: records_cl_sub.append({'ID': r['o'], 'present_in_taxon': 'NCBITaxon:9606', 'in_subset': 'human_reference_atlas'}) - if 'CL' in r['s'] and 'UBERON' in r['o']: + if ('CL' in r['s'] or 'PCL' in r['s']) and 'UBERON' in r['o']: terms_ct_as.add(f"({r['s']} {r['o']})") all_ct.add(r['s']) all_as.add(r['o']) @@ -125,7 +125,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): terms_pairs.add(f"({r['s']} {r['o']})") all_as.add(r['s']) all_as.add(r['o']) - elif 'CL' in r['s'] and 'CL' in r['o']: + elif ('CL' in r['s'] or 'PCL' in r['s']) and ('CL' in r['o'] or 'PCL' in r['o']): relation_ct.add(f"({r['s']} {r['o']})") terms_pairs.add(f"({r['s']} {r['o']})") all_ct.add(r['s']) @@ -192,7 +192,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): if 'UBERON' in s and 'UBERON' in o: valid_as.add((s,o)) - elif 'CL' in s and 'CL' in o: + elif ('CL' in s or 'PCL' in s) and ('CL' in o or 'PCL' in o): valid_ct.add((s,o)) @@ -210,7 +210,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): for _, r in rows_nvso.iterrows(): if 'UBERON' in r['s'] and 'UBERON' in r['o']: indirect_as.add((r['s'], r['o'])) - elif 'CL' in r['s'] and 'CL' in r['o']: + elif ('CL' in r['s'] or 'PCL' in r['s']) and ('CL' in r['o'] or 'PCL' in r['o']): indirect_ct.add((r['s'], r['o'])) terms_pairs = terms_pairs - terms_valid_subclass @@ -241,7 +241,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): if 'UBERON' in s and 'UBERON' in o: valid_as.add((s,o)) - elif 'CL' in s and 'CL' in o: + elif ('CL' in s or 'PCL' in s) and ('CL' in o or 'PCL' in o): valid_ct.add((s,o)) # INDIRECT PART OF CHECK @@ -263,7 +263,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): for _, r in rows_nvponr.iterrows(): if 'UBERON' in r['s'] and 'UBERON' in r['o']: indirect_as.add((r['s'], r['o'])) - elif 'CL' in r['s'] and 'CL' in r['o']: + elif ('CL' in r['s'] or 'PCL' in r['s']) and ('CL' in r['o'] or 'PCL' in r['o']): indirect_ct.add((r['s'], r['o'])) terms_pairs = terms_pairs - terms_valid_po @@ -296,7 +296,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): if 'UBERON' in s and 'UBERON' in o: valid_as.add((s,o)) - elif 'CL' in s and 'CL' in o: + elif ('CL' in s or 'PCL' in s) and ('CL' in o or 'PCL' in o): valid_ct.add((s,o)) # INDIRECT OVERLAPS CHECK @@ -313,7 +313,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): for _, r in rows_nvonr.iterrows(): if 'UBERON' in r['s'] and 'UBERON' in r['o']: indirect_as.add((r['s'], r['o'])) - elif 'CL' in r['s'] and 'CL' in r['o']: + elif ('CL' in r['s'] or 'PCL' in r['s']) and ('CL' in r['o'] or 'PCL' in r['o']): indirect_ct.add((r['s'], r['o'])) terms_pairs = terms_pairs - transform_to_str(valid_overlaps) @@ -338,7 +338,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): if 'UBERON' in s and 'UBERON' in o: valid_as.add((s,o)) - elif 'CL' in s and 'CL' in o: + elif ('CL' in s or 'PCL' in s) and ('CL' in o or 'PCL' in o): valid_ct.add((s,o)) terms_ct_as = terms_ct_as - transform_to_str(valid_ct_as_locatedin) @@ -368,7 +368,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): if 'UBERON' in s and 'UBERON' in o: valid_as.add((s,o)) - elif 'CL' in s and 'CL' in o: + elif ('CL' in s or 'PCL' in s) and ('CL' in o or 'PCL' in o): valid_ct.add((s,o)) terms_pairs = terms_pairs - transform_to_str(valid_conn_to) @@ -399,7 +399,7 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): if 'UBERON' in s and 'UBERON' in o: valid_as.add((s,o)) - elif 'CL' in s and 'CL' in o: + elif ('CL' in s or 'PCL' in s) and ('CL' in o or 'PCL' in o): valid_ct.add((s,o)) # AS-CT HAS PART @@ -508,13 +508,13 @@ def generate_class_graph_template(ccf_tools_df :pd.DataFrame): no_v_rec['ID'] = r['s'] no_v_rec['ccf_part_of'] = r['o'] no_valid_records.append(no_v_rec) - elif 'CL' in r['s'] and 'CL' in r['o']: + elif ('CL' in r['s'] or 'PCL' in r['s']) and ('CL' in r['o'] or 'PCL' in r['o']): invalid_ct.add((r['s'], r['o'])) no_v_rec = dict() no_v_rec['ID'] = r['s'] no_v_rec['ccf_part_of'] = r['o'] no_valid_records.append(no_v_rec) - elif 'CL' in r['s'] and 'UBERON' in r['o']: + elif ('CL' in r['s'] or 'PCL' in r['s']) and 'UBERON' in r['o']: invalid_ct_as.add((r['s'], r['o'])) no_v_rec = dict() no_v_rec['ID'] = r['s'] diff --git a/src/uberongraph_tools.py b/src/uberongraph_tools.py index 6517089df..41d07fb7b 100644 --- a/src/uberongraph_tools.py +++ b/src/uberongraph_tools.py @@ -8,6 +8,7 @@ def __init__(self): PREFIX part_of: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object FROM FROM @@ -23,6 +24,7 @@ def __init__(self): PREFIX overlaps: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object FROM FROM @@ -37,6 +39,7 @@ def __init__(self): PREFIX rdfs: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object FROM { @@ -51,6 +54,7 @@ def __init__(self): PREFIX owl: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject FROM { @@ -64,6 +68,7 @@ def __init__(self): PREFIX connected_to: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object FROM FROM @@ -79,6 +84,7 @@ def __init__(self): PREFIX owl: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object { VALUES ?subject { @@ -93,6 +99,7 @@ def __init__(self): PREFIX owl: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object FROM { @@ -107,6 +114,7 @@ def __init__(self): PREFIX part_of: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object FROM { @@ -121,6 +129,7 @@ def __init__(self): PREFIX overlaps: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object FROM { @@ -135,6 +144,7 @@ def __init__(self): PREFIX rdfs: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object FROM { @@ -150,6 +160,7 @@ def __init__(self): PREFIX rdfs: PREFIX UBERON: PREFIX CL: + PREFIX PCL: PREFIX part_of: SELECT ?subject ?object FROM @@ -167,6 +178,7 @@ def __init__(self): PREFIX rdfs: PREFIX UBERON: PREFIX CL: + PREFIX PCL: PREFIX has_part: SELECT ?subject ?object FROM @@ -183,6 +195,7 @@ def __init__(self): PREFIX foaf: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object { VALUES ?subject { @@ -196,6 +209,7 @@ def __init__(self): PREFIX owl: PREFIX UBERON: PREFIX CL: + PREFIX PCL: SELECT ?subject ?object WHERE { VALUES ?subject { UBERON: CL: } @@ -207,6 +221,7 @@ def __init__(self): PREFIX rdfs: PREFIX UBERON: PREFIX CL: + PREFIX PCL: PREFIX located_in: SELECT ?subject ?object FROM @@ -262,6 +277,7 @@ def construct_relation(self, subject, objects, property): PREFIX rdfs: PREFIX UBERON: PREFIX CL: + PREFIX PCL: PREFIX part_of: PREFIX connected_to: PREFIX develops_from: @@ -297,6 +313,7 @@ def construct_annotation(self, terms): PREFIX rdf: PREFIX UBERON: PREFIX CL: + PREFIX PCL: CONSTRUCT {{ ?term rdf:type owl:Class; ?APT ?APVT . @@ -335,12 +352,12 @@ def extract_results(self, list): return results def add_prefix(self, term): - return term.replace("http://purl.obolibrary.org/obo/UBERON_", "UBERON:").replace("http://purl.obolibrary.org/obo/CL_", "CL:") + return term.replace("http://purl.obolibrary.org/obo/UBERON_", "UBERON:").replace("http://purl.obolibrary.org/obo/CL_", "CL:").replace("http://purl.obolibrary.org/obo/PCL_", "PCL:") def add_prefix_ont(self, list_ontology): results = [] for ont, version in list_ontology: - ont = ont.replace("http://purl.obolibrary.org/obo/uberon/uberon-base.owl", "UBERON").replace("http://purl.obolibrary.org/obo/cl/cl-base.owl", "CL") + ont = ont.replace("http://purl.obolibrary.org/obo/uberon/uberon-base.owl", "UBERON").replace("http://purl.obolibrary.org/obo/cl/cl-base.owl", "CL").replace("http://purl.obolibrary.org/obo/PCL_", "PCL:") results.extend([ont, version]) return results diff --git a/style/ubergraph-style.json b/style/ubergraph-style.json index 02de024c8..32e9ac4a9 100644 --- a/style/ubergraph-style.json +++ b/style/ubergraph-style.json @@ -36,6 +36,9 @@ "http://purl.obolibrary.org/obo/CL_": { "fillcolor": "cyan" }, + "http://purl.obolibrary.org/obo/PCL_": { + "fillcolor": "cyan" + }, "http://purl.obolibrary.org/obo/NCBITaxon_9606": { "fillcolor": "white" }