Skip to content

Commit

Permalink
add support for PCL (#174)
Browse files Browse the repository at this point in the history
Co-authored-by: Anita Caron <anitacaron@users.noreply.github.com>
  • Loading branch information
Anita Caron and anitacaron authored Aug 19, 2022
1 parent 389a5f4 commit 340d2b8
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
Binary file modified graphs/ccf_Brain_graph.pdf
Binary file not shown.
Binary file modified graphs/ccf_Brain_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/ccf_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
28 changes: 14 additions & 14 deletions src/template_generation_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'])
Expand All @@ -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'])
Expand Down Expand Up @@ -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))


Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand Down
21 changes: 19 additions & 2 deletions src/uberongraph_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def __init__(self):
PREFIX part_of: <http://purl.obolibrary.org/obo/BFO_0000050>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/ontology>
FROM <http://reasoner.renci.org/redundant>
Expand All @@ -23,6 +24,7 @@ def __init__(self):
PREFIX overlaps: <http://purl.obolibrary.org/obo/RO_0002131>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/ontology>
FROM <http://reasoner.renci.org/redundant>
Expand All @@ -37,6 +39,7 @@ def __init__(self):
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/ontology/closure>
{
Expand All @@ -51,6 +54,7 @@ def __init__(self):
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject
FROM <http://reasoner.renci.org/ontology>
{
Expand All @@ -64,6 +68,7 @@ def __init__(self):
PREFIX connected_to: <http://purl.obolibrary.org/obo/RO_0002170>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/ontology>
FROM <http://reasoner.renci.org/redundant>
Expand All @@ -79,6 +84,7 @@ def __init__(self):
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
{
VALUES ?subject {
Expand All @@ -93,6 +99,7 @@ def __init__(self):
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/redundant>
{
Expand All @@ -107,6 +114,7 @@ def __init__(self):
PREFIX part_of: <http://purl.obolibrary.org/obo/BFO_0000050>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/nonredundant>
{
Expand All @@ -121,6 +129,7 @@ def __init__(self):
PREFIX overlaps: <http://purl.obolibrary.org/obo/RO_0002131>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/nonredundant>
{
Expand All @@ -135,6 +144,7 @@ def __init__(self):
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/ontology>
{
Expand All @@ -150,6 +160,7 @@ def __init__(self):
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
PREFIX part_of: <http://purl.obolibrary.org/obo/BFO_0000050>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/ontology>
Expand All @@ -167,6 +178,7 @@ def __init__(self):
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
PREFIX has_part: <http://purl.obolibrary.org/obo/BFO_0000051>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/ontology>
Expand All @@ -183,6 +195,7 @@ def __init__(self):
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
{
VALUES ?subject {
Expand All @@ -196,6 +209,7 @@ def __init__(self):
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/uberon/uberon-base.owl>
PREFIX CL: <http://purl.obolibrary.org/obo/cl/cl-base.owl>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
SELECT ?subject ?object
WHERE {
VALUES ?subject { UBERON: CL: }
Expand All @@ -207,6 +221,7 @@ def __init__(self):
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
PREFIX located_in: <http://purl.obolibrary.org/obo/RO_0001025>
SELECT ?subject ?object
FROM <http://reasoner.renci.org/ontology>
Expand Down Expand Up @@ -262,6 +277,7 @@ def construct_relation(self, subject, objects, property):
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
PREFIX part_of: <http://purl.obolibrary.org/obo/BFO_0000050>
PREFIX connected_to: <http://purl.obolibrary.org/obo/RO_0002170>
PREFIX develops_from: <http://purl.obolibrary.org/obo/RO_0002202>
Expand Down Expand Up @@ -297,6 +313,7 @@ def construct_annotation(self, terms):
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX UBERON: <http://purl.obolibrary.org/obo/UBERON_>
PREFIX CL: <http://purl.obolibrary.org/obo/CL_>
PREFIX PCL: <http://purl.obolibrary.org/obo/PCL_>
CONSTRUCT
{{
?term rdf:type owl:Class; ?APT ?APVT .
Expand Down Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions style/ubergraph-style.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down

0 comments on commit 340d2b8

Please sign in to comment.