Skip to content

Commit

Permalink
Merge pull request #33 from Clinical-Genomics/level_up
Browse files Browse the repository at this point in the history
Move inner schug dir one level up
  • Loading branch information
northwestwitch authored Mar 15, 2023
2 parents bb6fbbf + 26eff77 commit db382ff
Show file tree
Hide file tree
Showing 40 changed files with 33 additions and 29 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
[unreleased]
### Changed
- Move the `schug` directory up in root dir folder
### Fixed
- Use a memory database as default database in demo instance
- Issues flagged by SonarCloud

[1.0.0]
### Added
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "schug"
version = "0.1.0"
version = "1.0.0"
description = "Keep track of genes, transcripts and exons from different sources"
authors = ["moonso <mans.magnusson@scilifelab.se>"]
readme = "README.md"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
15 changes: 15 additions & 0 deletions schug/demo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from pathlib import Path

import importlib_resources

# Paths
EXONS_37_FILE_PATH: Path = Path(importlib_resources.files("schug"), "demo", "exons_37.tsv")
EXONS_38_FILE_PATH: Path = Path(importlib_resources.files("schug"), "demo", "exons_38.tsv")
GENES_37_FILE_PATH: Path = Path(importlib_resources.files("schug"), "demo", "genes_37.tsv")
GENES_38_FILE_PATH: Path = Path(importlib_resources.files("schug"), "demo", "genes_38.tsv")
TRANSCRIPTS_37_FILE_PATH: Path = Path(
importlib_resources.files("schug"), "demo", "transcripts_37.tsv"
)
TRANSCRIPTS_38_FILE_PATH: Path = Path(
importlib_resources.files("schug"), "demo", "transcripts_38.tsv"
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import urllib
import zlib
from typing import List
from typing import AsyncGenerator, List
from urllib.request import urlopen
from urllib.response import addinfourl

Expand Down Expand Up @@ -61,7 +61,7 @@ def fetch_resource(url: str) -> List[str]:
return data


async def stream_resource(url: str) -> bytes:
async def stream_resource(url: str) -> AsyncGenerator:
"""Stream a file from an external service"""
async with httpx.AsyncClient(timeout=None) as client:
async with client.stream("GET", url) as r:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def fetch_genes_to_hpo_to_disease() -> List[str]:

def fetch_hgnc() -> List[str]:
"""Fetch the hgnc genes file from
ftp://ftp.ebi.ac.uk/pub/databases/genenames/new/tsv/hgnc_complete_set.txt
sftp://sftp.ebi.ac.uk/pub/databases/genenames/new/tsv/hgnc_complete_set.txt
Returns:
hgnc_gene_lines(list(str))
"""
url = "ftp://ftp.ebi.ac.uk/pub/databases/genenames/new/tsv/hgnc_complete_set.txt"
url = "sftp://sftp.ebi.ac.uk/pub/databases/genenames/new/tsv/hgnc_complete_set.txt"
LOG.info("Fetching HGNC genes from %s", url)

return fetch_resource(url)
Expand All @@ -41,7 +41,7 @@ def fetch_exac_constraint() -> List[str]:
"""Fetch the file with exac constraint scores"""
file_name = "fordist_cleaned_exac_r03_march16_z_pli_rec_null_data.txt"
url = (
"ftp://ftp.broadinstitute.org/pub/ExAC_release/release0.3/functional_gene_constraint" "/{0}"
"sftp://sftp.broadinstitute.org/pub/ExAC_release/release0.3/functional_gene_constraint/{0}"
).format(file_name)

LOG.info("Fetching ExAC genes")
Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions src/schug/main.py → schug/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from .endpoints import exons, genes, transcripts

app = FastAPI()
NOT_FOUND_MESSAGE = "Not found"

### REST API

Expand All @@ -17,20 +18,20 @@ async def root():
genes.router,
prefix="/genes",
tags=["genes"],
responses={status.HTTP_404_NOT_FOUND: {"description": "Not found"}},
responses={status.HTTP_404_NOT_FOUND: {"description": NOT_FOUND_MESSAGE}},
)


app.include_router(
transcripts.router,
prefix="/transcripts",
tags=["transcripts"],
responses={status.HTTP_404_NOT_FOUND: {"description": "Not found"}},
responses={status.HTTP_404_NOT_FOUND: {"description": NOT_FOUND_MESSAGE}},
)

app.include_router(
exons.router,
prefix="/exons",
tags=["exons"],
responses={status.HTTP_404_NOT_FOUND: {"description": "Not found"}},
responses={status.HTTP_404_NOT_FOUND: {"description": NOT_FOUND_MESSAGE}},
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions src/schug/models/gene.py → schug/models/gene.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TYPE_CHECKING, List, Optional, Literal
from typing import TYPE_CHECKING, List, Literal, Optional

from pydantic import BaseModel
from pydantic import Field as PydanticField
Expand Down Expand Up @@ -50,10 +50,10 @@ def convert_to_none(cls, v):
return None
return v

@validator('hgnc_id', pre=True)
@validator("hgnc_id", pre=True)
def modify_id(cls, v):
if type(v) != int:
return v.replace('HGNC:', '')
return v.replace("HGNC:", "")
return v


Expand All @@ -63,7 +63,7 @@ class HgncGene(BaseModel):
entrez_id: int
hgnc_symbol: str = PydanticField(None, alias="HGNC symbol")
hgnc_id: str
ccds_id: str = None
ccds_id: Optional[str] = None
short_description: str = PydanticField(None, alias="alias_name")
alias_symbol: str

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class EnsemblTranscript(BaseModel):
refseq_mrna: str = PydanticField(None, alias="RefSeq mRNA ID")
refseq_mrna_predicted: str = PydanticField(None, alias="RefSeq mRNA predicted ID")
refseq_ncrna_predicted: str = PydanticField(None, alias="RefSeq ncRNA ID")
refseq_id: str = None
refseq_id: Optional[str] = None

@validator("refseq_id", always=True)
def set_refseq_id(cls, _, values: dict) -> Optional[str]:
Expand Down
15 changes: 0 additions & 15 deletions src/schug/demo/__init__.py

This file was deleted.

0 comments on commit db382ff

Please sign in to comment.