Skip to content

Commit

Permalink
add ensembl prefix to gwas gene ids
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesamcl committed Dec 7, 2024
1 parent 497cd13 commit c6489df
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dataload/01_ingest/grebi_ingest_gwas/src/write_associations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ pub fn write_associations(csv_reader: &mut csv::Reader<BufReader<StdinLock>>,nod
"grebi:type": ["gwas:SNP"],
"rdf:type": ["so:0000694"], // SNP
"gwas:mapped_gene": mapped_gene.split(", ").collect::<Vec<&str>>(),
"gwas:upstream_gene_id": [upstream_gene_id],
"gwas:downstream_gene_id": [downstream_gene_id],
"gwas:snp_gene_ids": snp_gene_ids.split(", ").collect::<Vec<&str>>(),
"gwas:upstream_gene_id": add_prefix(upstream_gene_id, "ensembl:"),
"gwas:downstream_gene_id": add_prefix(downstream_gene_id, "ensembl:"),
"gwas:snp_gene_ids": snp_gene_ids.split(", ").map(|s| add_prefix(s, "ensembl:")).collect::<Vec<String>>(),
"gwas:associated_with": Value::Array(mapped_trait_uri.split(", ").map(|tr| {
return json!({
"grebi:value": tr,
Expand Down Expand Up @@ -163,3 +163,11 @@ pub fn write_associations(csv_reader: &mut csv::Reader<BufReader<StdinLock>>,nod
}

}

fn add_prefix(s:&str, prefix:&str) -> String {
if s.is_empty() {
return "".to_owned();
} else {
return prefix.to_owned() + s;
}
}

0 comments on commit c6489df

Please sign in to comment.