Skip to content

Commit

Permalink
statis ingest
Browse files Browse the repository at this point in the history
  • Loading branch information
pnrobinson committed Oct 18, 2024
1 parent 6172831 commit 9e5d3ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pyphetools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from . import validation


__version__ = "0.9.110"
__version__ = "0.9.111"


__all__ = [
Expand Down
21 changes: 21 additions & 0 deletions src/pyphetools/visualization/phenopacket_ingestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,25 @@ def ingest_from_file(self, json_file:str) -> PPKt.Phenopacket:
jsondata = json.loads(data)
ppack = Parse(json.dumps(jsondata), PPKt.Phenopacket())
return ppack


@staticmethod
def from_directory(indir: str, disease_id:str=None) -> typing.List[PPKt.Phenopacket]:
if not os.path.isdir(indir):
raise FileNotFoundError(f"argument indir={indir} is not a directory")
ingestor = PhenopacketIngestor(indir=indir, disease_id=disease_id)
return ingestor.get_phenopacket_list()

@staticmethod
def filter_phenopackets(ppkt_list: typing.List[PPKt.Phenopacket], disease_id:str) -> typing.List[PPKt.Phenopacket]:
ppkt_target_disease = list()
skipped_count = 0
for ppkt in ppkt_list:
if PhenopacketIngestor.has_disease_id(ppkt=ppkt, disease_id=disease_id):
ppkt_target_disease.append(ppkt)
else:
skipped_count += 1
print(f"Returning {len(ppkt_target_disease)} phenopackets for disease {disease_id}, ommiting {skipped_count} phenopackets.")
return ppkt_target_disease


0 comments on commit 9e5d3ee

Please sign in to comment.