Skip to content

Commit

Permalink
add preferred source arg
Browse files Browse the repository at this point in the history
  • Loading branch information
elewis2 committed Dec 28, 2023
1 parent f3a17ae commit 642fcd3
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions graphkb/genes.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,16 @@ def get_preferred_gene_name(
genes = source_filtered_genes

gene_names = [g["displayName"] for g in genes if g]
if 'ENS' in gene_name:
import pdb; pdb.set_trace()
if len(gene_names) > 1:
logger.error(
f"Multiple gene names found for: {gene_name} - using {gene_names[0]}, ignoring {gene_names[1:]}"
)
return gene_names[0]


def get_cancer_predisposition_info(conn: GraphKBConnection) -> Tuple[List[str], Dict[str, str]]:
def get_cancer_predisposition_info(conn: GraphKBConnection, source: str = PREFERRED_GENE_SOURCE) -> Tuple[List[str], Dict[str, str]]:
"""
Return two lists from GraphKB, one of cancer predisposition genes and one of associated variants.
Expand Down Expand Up @@ -287,7 +289,7 @@ def get_cancer_predisposition_info(conn: GraphKBConnection) -> Tuple[List[str],
if name and biotype == "gene":
genes.add(name)
elif name:
gene = get_preferred_gene_name(conn, name)
gene = get_preferred_gene_name(conn, name, source)
if gene:
infer_genes.add((gene, name, biotype))
else:
Expand All @@ -306,7 +308,7 @@ def get_cancer_predisposition_info(conn: GraphKBConnection) -> Tuple[List[str],
return sorted(genes), variants


def get_pharmacogenomic_info(conn: GraphKBConnection) -> Tuple[List[str], Dict[str, str]]:
def get_pharmacogenomic_info(conn: GraphKBConnection, source: str = PREFERRED_GENE_SOURCE) -> Tuple[List[str], Dict[str, str]]:
"""
Return two lists from GraphKB, one of pharmacogenomic genes and one of associated variants.
Expand Down Expand Up @@ -362,7 +364,7 @@ def get_pharmacogenomic_info(conn: GraphKBConnection) -> Tuple[List[str], Dict[s
if name and biotype == "gene":
genes.add(name)
elif name:
gene = get_preferred_gene_name(conn, name)
gene = get_preferred_gene_name(conn, name, source)
if gene:
infer_genes.add((gene, name, biotype))
else:
Expand Down

0 comments on commit 642fcd3

Please sign in to comment.