From 41b2aaedcf0cf7265f2d641b392e94be03aac8e2 Mon Sep 17 00:00:00 2001 From: Amine GHOZLANE Date: Tue, 26 Nov 2024 10:03:54 +0100 Subject: [PATCH] Fix some mypy warnings --- meteor/merging.py | 8 +++++--- meteor/phylogeny.py | 3 ++- meteor/variantcalling.py | 7 +++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/meteor/merging.py b/meteor/merging.py index a2c77da..8d14e45 100644 --- a/meteor/merging.py +++ b/meteor/merging.py @@ -423,9 +423,11 @@ def execute(self) -> None: # with h5py.File(output_name.with_suffix(".biom"), "w") as f: # table.to_hdf5(f, generated_by="Meteor", compress=True) elif my_pattern == "modules": - module_path = ( - importlib.resources.files("meteor") - / "data/modules_definition.feather" + module_path = Path( + str( + importlib.resources.files("meteor") + / "data/modules_definition.feather" + ) ) annotation = self.load_data(module_path) annotation = annotation[annotation["id"].isin(filtered_df["mod_id"])] diff --git a/meteor/phylogeny.py b/meteor/phylogeny.py index df33c2d..25dd2ca 100644 --- a/meteor/phylogeny.py +++ b/meteor/phylogeny.py @@ -37,6 +37,7 @@ from cogent3.evolve.models import GTR from cogent3.cluster.UPGMA import upgma from concurrent.futures import ProcessPoolExecutor, as_completed +from typing import Union @dataclass @@ -61,7 +62,7 @@ def compute_site_info(self, sequences: Iterable[str]) -> list[float]: def clean_sites( self, msp_file: Path, output: tempfile._TemporaryFileWrapper - ) -> Tuple[dict[str, str], int]: + ) -> Tuple[dict[Union[int, str, None]], int]: """Clean msp sequence according to a certain level of gap at each sites. :param msp_file: (Path) Fasta file :param output_file: (Path) Output cleaned fasta file diff --git a/meteor/variantcalling.py b/meteor/variantcalling.py index 4db4179..798ea2c 100644 --- a/meteor/variantcalling.py +++ b/meteor/variantcalling.py @@ -296,7 +296,7 @@ def count_reads_in_gene( multiple_iterators=False, ): read_count = sum( - 1 + True for pileupread in pileupcolumn.pileups if not pileupread.is_del and not pileupread.is_refskip ) @@ -304,7 +304,7 @@ def count_reads_in_gene( return reads_dict - def merge_vcf_files(self, vcf_file_list, output_vcf): + def merge_vcf_files(self, vcf_file_list, output_vcf) -> None: """Merge variant records (handling the same positions in multiple VCFs).""" variant_dict = defaultdict(list) @@ -332,8 +332,7 @@ def filter_low_cov_sites( self, cram_file: Path, reference_file: Path, - # temp_low_cov_sites: tempfile._TemporaryFileWrapper, - ) -> None: + ) -> tuple[pd.DataFrame]: """Create a bed file reporting a list of positions below coverage threshold :param cram_file: Path to the input cram file