Skip to content

Commit

Permalink
add score to RGP table in h5
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMainguy committed Nov 27, 2024
1 parent ecae334 commit 0875aad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
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 0875aad

Please sign in to comment.