From ecae33492383559633fee0ba1cced93475ec5d4d Mon Sep 17 00:00:00 2001 From: JeanMainguy Date: Wed, 27 Nov 2024 10:47:26 +0100 Subject: [PATCH 1/2] clean unused import --- ppanggolin/RGP/genomicIsland.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ppanggolin/RGP/genomicIsland.py b/ppanggolin/RGP/genomicIsland.py index e7d8918d..33373341 100644 --- a/ppanggolin/RGP/genomicIsland.py +++ b/ppanggolin/RGP/genomicIsland.py @@ -4,7 +4,7 @@ import logging import argparse from pathlib import Path -from typing import Set, Iterable, List, Tuple +from typing import Set, Iterable # installed libraries from tqdm import tqdm From 0875aad5462bfc9210b0a4572c94a4f70cac4ae6 Mon Sep 17 00:00:00 2001 From: JeanMainguy Date: Wed, 27 Nov 2024 10:50:07 +0100 Subject: [PATCH 2/2] add score to RGP table in h5 --- ppanggolin/formats/readBinaries.py | 6 ++++++ ppanggolin/formats/writeBinaries.py | 2 ++ ppanggolin/region.py | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ppanggolin/formats/readBinaries.py b/ppanggolin/formats/readBinaries.py index 650b4bc7..c2607aa1 100644 --- a/ppanggolin/formats/readBinaries.py +++ b/ppanggolin/formats/readBinaries.py @@ -971,7 +971,13 @@ def read_rgp(pangenome: Pangenome, h5f: tables.File, disable_bar: bool = False): region = pangenome.get_region(row["RGP"].decode()) except KeyError: region = Region(row["RGP"].decode()) + + # starting from v2.2.1 score is part of RGP table in h5. + if "score" in row.dtype.names: + region.score = row["score"] + pangenome.add_region(region) + gene = pangenome.get_gene(row["gene"].decode()) region.add(gene) pangenome.status["predictedRGP"] = "Loaded" diff --git a/ppanggolin/formats/writeBinaries.py b/ppanggolin/formats/writeBinaries.py index 17ba76ab..67dc0463 100644 --- a/ppanggolin/formats/writeBinaries.py +++ b/ppanggolin/formats/writeBinaries.py @@ -299,6 +299,7 @@ def rgp_desc(max_rgp_len, max_gene_len): return { "RGP": tables.StringCol(itemsize=max_rgp_len), "gene": tables.StringCol(itemsize=max_gene_len), + "score": tables.UInt32Col(), } @@ -355,6 +356,7 @@ def write_rgp( for gene in region.genes: rgp_row["RGP"] = region.name rgp_row["gene"] = gene.ID + rgp_row["score"] = region.score rgp_row.append() rgp_table.flush() diff --git a/ppanggolin/region.py b/ppanggolin/region.py index e2589e13..39f90326 100644 --- a/ppanggolin/region.py +++ b/ppanggolin/region.py @@ -51,7 +51,7 @@ def __init__(self, name: str): super().__init__() self._genes_getter = {} self.name = name - self.score = 0 + self.score = None self._starter = None self._stopper = None self._coordinates = None