Skip to content

Commit

Permalink
only save cache if generated
Browse files Browse the repository at this point in the history
  • Loading branch information
semenko committed Jan 19, 2024
1 parent 150de4c commit 512dfb4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/bam2tensor/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def __init__(
# Now generate windowed CpG sites for efficient querying of .bam files
self.generate_windowed_cpg_sites()

if not skip_cache:
# Save the key & expensive objects to a cache
self.save_embedding_cache()
if not skip_cache:
# Save the key & expensive objects to a cache
self.save_embedding_cache()

## Generate objects for efficient lookups
# A dict of chromosomes -> index for quick lookups (e.g. "chr1" -> 0)
Expand Down Expand Up @@ -165,11 +165,11 @@ def load_embedding_cache(self) -> bool:
"""

if self.verbose:
print(f"\tLoading all CpG sites for: {self.genome_name}")
print(f"\tLoading embedding data for: {self.genome_name}")

if os.path.exists(self.cache_file):
if self.verbose:
print(f"\t\tReading CpG sites from cache: {self.cache_file}")
print(f"\t\tReading embedding from cache: {self.cache_file}")

# TODO: Add type hinting via TypedDicts?
# e.g. https://stackoverflow.com/questions/51291722/define-a-jsonable-type-using-mypy-pep-526
Expand Down Expand Up @@ -197,7 +197,7 @@ def load_embedding_cache(self) -> bool:
}

else:
raise FileNotFoundError("\tNo cache of CpG sites found.")
raise FileNotFoundError("\tNo cache of embedding found.")

return True

Expand Down

0 comments on commit 512dfb4

Please sign in to comment.