Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isort all .py files #214

Merged
merged 6 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Modified code to support upgraded libraries
- Rename a test file from `test_d4.py` to `test_handle_d4.py` and add 2 new tests to it
- Fix return type of `get_intervals_completeness` function
- Isort imports of the entire repo

## [1.2]
### Added
Expand Down
2 changes: 1 addition & 1 deletion src/chanjo2/constants.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from typing import Callable, Dict, List

from schug.load.ensembl import (
fetch_ensembl_exons,
fetch_ensembl_genes,
fetch_ensembl_transcripts,
fetch_ensembl_exons,
)

SAMPLE_NOT_FOUND: str = "One of more requested samples were not present in the database"
Expand Down
2 changes: 1 addition & 1 deletion src/chanjo2/crud/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlalchemy.engine.cursor import CursorResult
from sqlalchemy.orm import Session, query

from chanjo2.models import SQLCase, SQLSample, CaseSample
from chanjo2.models import CaseSample, SQLCase, SQLSample
from chanjo2.models.pydantic_models import Case, CaseCreate


Expand Down
2 changes: 1 addition & 1 deletion src/chanjo2/crud/intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
from sqlalchemy.orm import Session, query
from sqlalchemy.sql.expression import Delete

from chanjo2.models import SQLExon, SQLGene, SQLTranscript
from chanjo2.models.pydantic_models import (
Builds,
ExonBase,
GeneBase,
TranscriptBase,
TranscriptTag,
)
from chanjo2.models import SQLGene, SQLExon, SQLTranscript

LOG = logging.getLogger("uvicorn.access")

Expand Down
4 changes: 2 additions & 2 deletions src/chanjo2/crud/samples.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Optional, Union, Tuple
from typing import List, Optional, Tuple, Union

from fastapi import HTTPException, status
from pyd4 import D4File
Expand All @@ -10,7 +10,7 @@
from chanjo2.constants import SAMPLE_NOT_FOUND, WRONG_COVERAGE_FILE_MSG
from chanjo2.crud.cases import filter_cases_by_name
from chanjo2.meta.handle_d4 import get_d4_file
from chanjo2.models import SQLCase, SQLSample, CaseSample
from chanjo2.models import CaseSample, SQLCase, SQLSample
from chanjo2.models.pydantic_models import SampleCreate


Expand Down
2 changes: 1 addition & 1 deletion src/chanjo2/endpoints/cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session

from chanjo2.crud.cases import create_db_case, get_case, get_cases, delete_case
from chanjo2.crud.cases import create_db_case, delete_case, get_case, get_cases
from chanjo2.dbutil import get_session
from chanjo2.models.pydantic_models import Case, CaseCreate

Expand Down
23 changes: 10 additions & 13 deletions src/chanjo2/endpoints/coverage.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,30 @@
from typing import List, Optional, Tuple, Dict
from typing import Dict, List, Optional, Tuple

from fastapi import APIRouter, HTTPException, status, Depends
from fastapi import APIRouter, Depends, HTTPException, status
from pyd4 import D4File
from sqlalchemy.orm import Session

from chanjo2.constants import (
WRONG_BED_FILE_MSG,
WRONG_COVERAGE_FILE_MSG,
)
from chanjo2.constants import WRONG_BED_FILE_MSG, WRONG_COVERAGE_FILE_MSG
from chanjo2.crud.intervals import get_genes
from chanjo2.crud.samples import get_samples_coverage_file
from chanjo2.dbutil import get_session
from chanjo2.meta.handle_bed import parse_bed
from chanjo2.meta.handle_d4 import (
intervals_coverage,
get_intervals_mean_coverage,
get_d4_file,
set_interval,
get_samples_sex_metrics,
get_intervals_completeness,
get_intervals_mean_coverage,
get_sample_interval_coverage,
get_samples_sex_metrics,
intervals_coverage,
set_interval,
)
from chanjo2.models import SQLExon, SQLGene, SQLTranscript
from chanjo2.models.pydantic_models import (
SampleGeneIntervalQuery,
FileCoverageQuery,
FileCoverageIntervalsFileQuery,
IntervalCoverage,
FileCoverageQuery,
GeneCoverage,
IntervalCoverage,
SampleGeneIntervalQuery,
)

router = APIRouter()
Expand Down
12 changes: 5 additions & 7 deletions src/chanjo2/endpoints/intervals.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
from typing import List, Optional, Iterator
from typing import Iterator, List, Optional

from fastapi import APIRouter, Depends, HTTPException, Response, status
from fastapi.responses import JSONResponse
from sqlalchemy.orm import Session

from chanjo2.constants import (
MULTIPLE_PARAMS_NOT_SUPPORTED_MSG,
)
from chanjo2.crud.intervals import get_genes, get_gene_intervals
from chanjo2.constants import MULTIPLE_PARAMS_NOT_SUPPORTED_MSG
from chanjo2.crud.intervals import get_gene_intervals, get_genes
from chanjo2.dbutil import get_session
from chanjo2.meta.handle_bed import resource_lines
from chanjo2.meta.handle_load_intervals import (
Expand All @@ -20,9 +18,9 @@
Builds,
Exon,
Gene,
Transcript,
GeneQuery,
GeneIntervalQuery,
GeneQuery,
Transcript,
)

router = APIRouter()
Expand Down
6 changes: 3 additions & 3 deletions src/chanjo2/endpoints/overview.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
from os import path

from fastapi import APIRouter, Request, Depends
from fastapi import APIRouter, Depends, Request
from fastapi.encoders import jsonable_encoder
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
Expand All @@ -11,10 +11,10 @@
from chanjo2.dbutil import get_session
from chanjo2.demo import DEMO_COVERAGE_QUERY_DATA
from chanjo2.meta.handle_report_contents import (
get_report_data,
get_gene_overview_coverage_stats,
get_report_data,
)
from chanjo2.models.pydantic_models import ReportQuery, GeneReportForm, GeneCoverage
from chanjo2.models.pydantic_models import GeneCoverage, GeneReportForm, ReportQuery

LOG = logging.getLogger("uvicorn.access")

Expand Down
2 changes: 1 addition & 1 deletion src/chanjo2/endpoints/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from os import path
from typing import Dict

from fastapi import APIRouter, Request, Depends
from fastapi import APIRouter, Depends, Request
from fastapi.responses import HTMLResponse
from fastapi.templating import Jinja2Templates
from sqlalchemy.orm import Session
Expand Down
2 changes: 1 addition & 1 deletion src/chanjo2/endpoints/samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

from chanjo2.crud.samples import (
create_sample_in_case,
delete_sample,
get_case_samples,
get_sample,
get_samples,
delete_sample,
)
from chanjo2.dbutil import get_session
from chanjo2.models.pydantic_models import Sample, SampleCreate
Expand Down
2 changes: 1 addition & 1 deletion src/chanjo2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from chanjo2 import __version__
from chanjo2.dbutil import engine
from chanjo2.endpoints import cases, intervals, samples, coverage, report, overview
from chanjo2.endpoints import cases, coverage, intervals, overview, report, samples
from chanjo2.models.sql_models import Base
from chanjo2.populate_demo import load_demo_data

Expand Down
2 changes: 1 addition & 1 deletion src/chanjo2/meta/handle_bed.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Tuple, Iterator
from typing import Iterator, List, Tuple


def resource_lines(file_path: str) -> Iterator[str]:
Expand Down
6 changes: 3 additions & 3 deletions src/chanjo2/meta/handle_d4.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import logging
from statistics import mean
from typing import List, Optional, Tuple, Union, Dict
from typing import Dict, List, Optional, Tuple, Union

from pyd4 import D4File
from sqlalchemy.orm import Session

from chanjo2.crud.intervals import get_gene_intervals
from chanjo2.models import SQLExon, SQLGene, SQLTranscript
from chanjo2.models.pydantic_models import (
IntervalCoverage,
Sex,
GeneCoverage,
IntervalCoverage,
IntervalType,
Sex,
TranscriptTag,
)

Expand Down
2 changes: 1 addition & 1 deletion src/chanjo2/meta/handle_load_intervals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
from typing import Iterator, List, Union, Optional
from typing import Iterator, List, Optional, Union

import requests
from schug.load.biomart import EnsemblBiomartClient
Expand Down
10 changes: 5 additions & 5 deletions src/chanjo2/meta/handle_report_contents.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import logging
from collections import OrderedDict
from statistics import mean
from typing import List, Dict, Tuple, Union, Set, Optional
from typing import Dict, List, Optional, Set, Tuple, Union

from pyd4 import D4File
from sqlalchemy.orm import Session

from chanjo2.crud.intervals import get_genes, get_hgnc_gene
from chanjo2.crud.samples import get_sample
from chanjo2.meta.handle_d4 import get_samples_sex_metrics, get_sample_interval_coverage
from chanjo2.meta.handle_d4 import get_sample_interval_coverage, get_samples_sex_metrics
from chanjo2.models import SQLExon, SQLGene, SQLSample, SQLTranscript
from chanjo2.models.pydantic_models import (
GeneCoverage,
GeneReportForm,
IntervalType,
ReportQuery,
ReportQuerySample,
SampleSexRow,
GeneCoverage,
IntervalType,
GeneReportForm,
)

LOG = logging.getLogger("uvicorn.access")
Expand Down
8 changes: 4 additions & 4 deletions src/chanjo2/models/pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
from datetime import datetime
from enum import Enum
from pathlib import Path
from typing import Any, List, Optional, Dict
from typing import Any, Dict, List, Optional

import validators
from pydantic import BaseModel, field_validator, model_validator, Field
from pydantic import BaseModel, Field, field_validator, model_validator
from pydantic_settings import SettingsConfigDict

from chanjo2.constants import (
WRONG_COVERAGE_FILE_MSG,
MULTIPLE_GENE_LISTS_NOT_SUPPORTED_MSG,
AMBIGUOUS_SAMPLES_INPUT,
DEFAULT_COMPLETENESS_LEVELS,
MULTIPLE_GENE_LISTS_NOT_SUPPORTED_MSG,
WRONG_COVERAGE_FILE_MSG,
)

LOG = logging.getLogger("uvicorn.access")
Expand Down
2 changes: 1 addition & 1 deletion src/chanjo2/models/sql_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import dataclass

from sqlalchemy import Column, DateTime, Enum, ForeignKey, Integer, String, Index, Table
from sqlalchemy import Column, DateTime, Enum, ForeignKey, Index, Integer, String, Table
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func

Expand Down
8 changes: 4 additions & 4 deletions src/chanjo2/populate_demo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Tuple, Iterator
from typing import Iterator, List, Tuple

from schug.demo import (
EXONS_37_FILE_PATH,
Expand All @@ -14,14 +14,14 @@
from chanjo2.crud.cases import create_db_case
from chanjo2.crud.samples import create_sample_in_case
from chanjo2.dbutil import get_session
from chanjo2.demo import DEMO_SAMPLE, DEMO_CASE
from chanjo2.demo import DEMO_CASE, DEMO_SAMPLE
from chanjo2.meta.handle_bed import resource_lines
from chanjo2.meta.handle_load_intervals import (
update_exons,
update_genes,
update_transcripts,
update_exons,
)
from chanjo2.models.pydantic_models import CaseCreate, SampleCreate, Builds
from chanjo2.models.pydantic_models import Builds, CaseCreate, SampleCreate

db: sessionmaker = next(get_session())

Expand Down
5 changes: 2 additions & 3 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

from chanjo2.constants import BUILD_38, BUILD_37
from chanjo2.constants import BUILD_37, BUILD_38
from chanjo2.crud.intervals import get_genes
from chanjo2.dbutil import DEMO_CONNECT_ARGS, get_session
from chanjo2.demo import DEMO_SAMPLE
from chanjo2.demo import d4_demo_path, gene_panel_path
from chanjo2.demo import DEMO_SAMPLE, d4_demo_path, gene_panel_path
from chanjo2.main import Base, app, engine
from chanjo2.meta.handle_bed import parse_bed
from chanjo2.meta.handle_d4 import get_d4_file
Expand Down
2 changes: 1 addition & 1 deletion tests/src/chanjo2/crud/test_crud_intervals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import List, Dict
from typing import Dict, List

from sqlalchemy.orm import sessionmaker

Expand Down
12 changes: 6 additions & 6 deletions tests/src/chanjo2/endpoints/test_coverage.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import copy
from typing import Type, Dict, List
from typing import Dict, List, Type

import pytest
from fastapi import status
from fastapi.testclient import TestClient

from chanjo2.constants import (
WRONG_COVERAGE_FILE_MSG,
WRONG_BED_FILE_MSG,
MULTIPLE_GENE_LISTS_NOT_SUPPORTED_MSG,
AMBIGUOUS_SAMPLES_INPUT,
MULTIPLE_GENE_LISTS_NOT_SUPPORTED_MSG,
WRONG_BED_FILE_MSG,
WRONG_COVERAGE_FILE_MSG,
)
from chanjo2.demo import gene_panel_path
from chanjo2.models.pydantic_models import Builds, Sex, GeneCoverage, IntervalCoverage
from chanjo2.populate_demo import DEMO_SAMPLE, DEMO_CASE
from chanjo2.models.pydantic_models import Builds, GeneCoverage, IntervalCoverage, Sex
from chanjo2.populate_demo import DEMO_CASE, DEMO_SAMPLE

COVERAGE_COMPLETENESS_THRESHOLDS: List[int] = [10, 20, 30]

Expand Down
9 changes: 2 additions & 7 deletions tests/src/chanjo2/endpoints/test_intervals.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,11 @@

from chanjo2.constants import MULTIPLE_PARAMS_NOT_SUPPORTED_MSG
from chanjo2.meta.handle_bed import resource_lines
from chanjo2.models.pydantic_models import (
Builds,
Exon,
Gene,
Transcript,
)
from chanjo2.models.pydantic_models import Builds, Exon, Gene, Transcript
from chanjo2.populate_demo import (
BUILD_EXONS_RESOURCE,
BUILD_GENES_RESOURCE,
BUILD_TRANSCRIPTS_RESOURCE,
BUILD_EXONS_RESOURCE,
)

MOCKED_FILE_PARSER = "chanjo2.meta.handle_load_intervals.read_resource_lines"
Expand Down
2 changes: 1 addition & 1 deletion tests/src/chanjo2/endpoints/test_overview.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Type, Dict, List
from typing import Dict, List, Type

from fastapi import status
from fastapi.testclient import TestClient
Expand Down
3 changes: 1 addition & 2 deletions tests/src/chanjo2/endpoints/test_samples.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
from fastapi.testclient import TestClient
from pytest_mock.plugin import MockerFixture

from chanjo2.models.pydantic_models import Case
from chanjo2.models.pydantic_models import WRONG_COVERAGE_FILE_MSG, Sample
from chanjo2.models.pydantic_models import WRONG_COVERAGE_FILE_MSG, Case, Sample
from chanjo2.populate_demo import DEMO_CASE, DEMO_SAMPLE


Expand Down
Loading
Loading