Skip to content

Commit

Permalink
add file extension enum
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrOertlin committed Mar 20, 2024
1 parent 5ac2636 commit 02290f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion genotype_api/constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
"""Constants used over the package"""

from enum import Enum
from enum import Enum, StrEnum
from pydantic import BaseModel


class FileExtension(StrEnum):
VCF: str = ".vcf"


class Types(str, Enum):
GENOTYPE = "genotype"
SEQUENCE = "sequence"
Expand Down
4 changes: 2 additions & 2 deletions genotype_api/services/analysis_service/analysis_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from fastapi import UploadFile
from sqlmodel import Session

from genotype_api.constants import Types
from genotype_api.constants import Types, FileExtension
from genotype_api.database.crud.create import create_analyses_samples, create_analysis
from genotype_api.database.crud.read import (
get_analysis_by_id,
Expand Down Expand Up @@ -48,7 +48,7 @@ def get_upload_sequence_analyses(self, file: UploadFile) -> list[AnalysisRespons
"""
Reading VCF file, creating and uploading sequence analyses and sample objects to the database.
"""
file_name: Path = check_file(file_path=file.filename, extension=".vcf")
file_name: Path = check_file(file_path=file.filename, extension=FileExtension.VCF)
content = file.file.read().decode("utf-8")
sequence_analysis = SequenceAnalysis(vcf_file=content, source=str(file_name))
analyses: list[Analysis] = list(sequence_analysis.generate_analyses())
Expand Down

0 comments on commit 02290f8

Please sign in to comment.