Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
Chiara Rasi committed Jun 14, 2024
1 parent 710667b commit fb461b0
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions scout/build/genes/hgnc_gene.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def build_phenotype(phenotype_info):
return phenotype_obj


def build_hgnc_gene(gene_info: dict, cyoband_coords: Dict[str, dict], build: str = "37") -> dict:
def build_hgnc_gene(gene_info: dict, cytoband_coords: Dict[str, dict], build: str = "37") -> dict:
"""Build a hgnc_gene object
Returns:
Expand Down Expand Up @@ -64,7 +64,7 @@ def build_hgnc_gene(gene_info: dict, cyoband_coords: Dict[str, dict], build: str

if gene_info.get("chromosome") is None: # Gene not present in Ensembl.
# Try to use cytoband coordinates instead
cytoband_coords: Optional[dict] = cyoband_coords.get(gene_info["location"])
cytoband_coords: Optional[dict] = cytoband_coords.get(gene_info["location"])
if not cytoband_coords:
LOG.warning(
f"Gene {gene_info.get('hgnc_symbol') or gene_info.get('hgnc_id')} doesn't have coordinates and cytoband not present in database, skipping."
Expand Down
4 changes: 2 additions & 2 deletions scout/load/hgnc_gene.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,13 @@ def load_hgnc_genes(
nr_genes = len(genes)
LOG.info(f"Building info for {nr_genes} genes")

cyoband_coords: Dict[str, dict] = adapter.cytoband_to_coordinates(build=build)
cytoband_coords: Dict[str, dict] = adapter.cytoband_to_coordinates(build=build)

with progressbar(genes.values(), label="Building genes", length=nr_genes) as bar:
for gene_data in bar:
gene_obj = build_hgnc_gene(
gene_data,
cyoband_coords=cyoband_coords,
cytoband_coords=cytoband_coords,
build=build,
)

Expand Down
9 changes: 3 additions & 6 deletions tests/build/test_build_hgnc_gene.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from pprint import pprint as pp

import pytest

from scout.build.genes.hgnc_gene import build_hgnc_gene
Expand All @@ -11,7 +9,7 @@ def test_build_hgnc_genes(genes):
# WHEN building hgnc gene objecs
for hgnc_id in genes:
gene_info = genes[hgnc_id]
gene_obj = build_hgnc_gene(gene_info=gene_info, cyoband_coords={})
gene_obj = build_hgnc_gene(gene_info=gene_info, cytoband_coords={})
# THEN check that the gene models have a hgnc id
assert gene_obj["hgnc_id"]

Expand All @@ -25,20 +23,19 @@ def test_build_hgnc_gene():
"start": 1,
"end": 1000,
}
gene_obj = build_hgnc_gene(gene_info=gene_info, cyoband_coords={})
gene_obj = build_hgnc_gene(gene_info=gene_info, cytoband_coords={})

assert gene_obj["hgnc_id"] == gene_info["hgnc_id"]
assert gene_obj["hgnc_symbol"] == gene_info["hgnc_symbol"]
assert gene_obj["length"] == gene_info["end"] - gene_info["start"]
assert gene_obj["ensembl_id"] == gene_info["ensembl_gene_id"]


# TODO: are 'ensembl_gene_id' and 'ensembl_id' the same thing? -both seem to be used!
@pytest.mark.parametrize("key", ["hgnc_id", "hgnc_symbol", "chromosome", "start", "end"])
def test_build_hgnc_gene_missing_hgnc_symbol(test_gene, key):
## GIVEN a dictionary with gene information

# WHEN deleting a required key
test_gene.pop(key)
# THEN calling build_hgnc_gene() will return None
assert build_hgnc_gene(gene_info=test_gene, cyoband_coords={}) is None
assert build_hgnc_gene(gene_info=test_gene, cytoband_coords={}) is None
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def gene_bulk(genes):
"""Return a list with HgncGene objects"""
bulk = []
for gene_key in genes:
bulk.append(build_hgnc_gene(genes[gene_key]))
bulk.append(build_hgnc_gene(genes[gene_key], cytoband_coords={}))

return bulk

Expand All @@ -249,7 +249,7 @@ def gene_bulk_38(genes):
"""Return a list with HgncGene objects"""
bulk = []
for gene_key in genes:
gene_obj = build_hgnc_gene(genes[gene_key])
gene_obj = build_hgnc_gene(genes[gene_key], cytoband_coords={})
gene_obj["build"] = "38"
bulk.append(gene_obj)

Expand Down

0 comments on commit fb461b0

Please sign in to comment.