Skip to content

Commit

Permalink
Adding limit to n rows of table
Browse files Browse the repository at this point in the history
  • Loading branch information
pnrobinson committed Jan 18, 2025
1 parent 1cc5f8a commit ed28d56
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/pyphetools/visualization/individual_table.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from collections import defaultdict
import phenopackets as PPKt
import typing
import sys


from ..creation.constants import Constants
Expand Down Expand Up @@ -77,10 +78,18 @@ def __init__(self,
self._caption = f"{n_phenopackets} phenopackets - {pmid_str}"


def to_html(self) -> str:
def to_html(self, max_rows_to_show: int = None) -> str:
header_items = ["Individual", "Disease", "Genotype", "Phenotypic features"]
rows = []
MAX_INT = sys.maxsize
if max_rows_to_show is None:
max_rows_to_show = MAX_INT # show all rows
n_rows = 0
for spat in self._spat_list:
if n_rows >= max_rows_to_show:
break
else:
n_rows += 1
rows.append(self._simple_patient_to_table_row(spat))
generator = HtmlTableGenerator(caption=self._caption, header_items=header_items, rows=rows)
return generator.get_html()
Expand Down

0 comments on commit ed28d56

Please sign in to comment.