Skip to content

Commit

Permalink
Merge pull request #304 from labgem/add_rgp_score_to_h5
Browse files Browse the repository at this point in the history
Add RGP Score to Pangenome Table
  • Loading branch information
axbazin authored Nov 27, 2024
2 parents d5df368 + 0875aad commit 638f30b
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ppanggolin/RGP/genomicIsland.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions ppanggolin/formats/readBinaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions ppanggolin/formats/writeBinaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
}


Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion ppanggolin/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 638f30b

Please sign in to comment.