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

Add RGP Score to Pangenome Table #304

Merged
merged 2 commits into from
Nov 27, 2024
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
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
Loading