Skip to content

Commit

Permalink
skip obsolete terms in ols ingest, add mondo and doid
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesamcl committed Aug 19, 2024
1 parent 37356ae commit ffa2226
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
25 changes: 18 additions & 7 deletions 01_ingest/grebi_ingest_ols/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ struct Args {
ontologies:String,

#[arg(long)]
defining_only:bool
defining_only:bool,

#[arg(long)]
skip_obsolete:bool

}

Expand Down Expand Up @@ -57,14 +60,14 @@ fn main() {
}
json.begin_array().unwrap();
while json.has_next().unwrap() {
read_ontology(&mut json, &mut output_nodes, &datasource_name, &ontology_whitelist, args.defining_only);
read_ontology(&mut json, &mut output_nodes, &datasource_name, &ontology_whitelist, args.defining_only, args.skip_obsolete);
}
json.end_array().unwrap();
json.end_object().unwrap();

}

fn read_ontology(json: &mut JsonStreamReader<BufReader<StdinLock<'_>>>, output_nodes: &mut BufWriter<StdoutLock>, datasource_name: &str, ontology_whitelist:&HashSet<String>, defining_only:bool) {
fn read_ontology(json: &mut JsonStreamReader<BufReader<StdinLock<'_>>>, output_nodes: &mut BufWriter<StdoutLock>, datasource_name: &str, ontology_whitelist:&HashSet<String>, defining_only:bool, skip_obsolete:bool) {

json.begin_object().unwrap();

Expand Down Expand Up @@ -128,11 +131,11 @@ fn read_ontology(json: &mut JsonStreamReader<BufReader<StdinLock<'_>>>, output_n

loop {
if key.eq("classes") {
read_entities(json, output_nodes, &datasource, "ols:Class", defining_only);
read_entities(json, output_nodes, &datasource, "ols:Class", defining_only, skip_obsolete);
} else if key.eq("properties") {
read_entities(json, output_nodes, &datasource, "ols:Property", defining_only);
read_entities(json, output_nodes, &datasource, "ols:Property", defining_only, skip_obsolete);
} else if key.eq("individuals") {
read_entities(json, output_nodes, &datasource, "ols:Individual", defining_only);
read_entities(json, output_nodes, &datasource, "ols:Individual", defining_only, skip_obsolete);
} else {
panic!();
}
Expand All @@ -147,7 +150,7 @@ fn read_ontology(json: &mut JsonStreamReader<BufReader<StdinLock<'_>>>, output_n

}

fn read_entities(json: &mut JsonStreamReader<BufReader<StdinLock<'_>>>, output_nodes: &mut BufWriter<StdoutLock>, datasource:&String, grebitype:&str, defining_only:bool) {
fn read_entities(json: &mut JsonStreamReader<BufReader<StdinLock<'_>>>, output_nodes: &mut BufWriter<StdoutLock>, datasource:&String, grebitype:&str, defining_only:bool, skip_obsolete:bool) {
json.begin_array().unwrap();
while json.has_next().unwrap() {
let mut val:Value = read_value(json);
Expand All @@ -161,6 +164,14 @@ fn read_entities(json: &mut JsonStreamReader<BufReader<StdinLock<'_>>>, output_n
}
}

if skip_obsolete {
if obj.contains_key("ols:isObsolete") {
if get_string_values(obj.get("ols:isObsolete").unwrap()).iter().next().unwrap().eq(&"true") {
continue;
}
}
}

if grebitype.eq("ols:Property") {

let qualified_safe_label = {
Expand Down
2 changes: 1 addition & 1 deletion configs/datasource_configs/ols.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"ingest_files": ["/nfs/production/parkinso/spot/grebi/ontologies.json.gz"],
"ingest_script": "./target/release/grebi_ingest_ols",
"ingest_args": [
{ "name": "--ontologies", "value": "efo,mp,hp,go,ro,iao,uberon,pato,oba,chebi,bspo,iao,obi,bfo,cob,cl,so,eco,pr,ncbitaxon,oio,iao,biolink" }
{ "name": "--ontologies", "value": "efo,mp,hp,go,ro,iao,uberon,pato,oba,chebi,bspo,iao,obi,bfo,cob,cl,so,eco,pr,ncbitaxon,oio,iao,biolink,mondo,doid" }
]
}
]
Expand Down

0 comments on commit ffa2226

Please sign in to comment.