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

Functional refactor #81

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ wandb/
*slurm*
tests/data/genomes
tests/data/test_pipeline
tests/data/test_contribution_scores/

# Sphinx documentation
_build
Expand All @@ -12,4 +13,4 @@ node_modules
.DS_Store
._.DS_Store
docs/tutorials/mouse_biccn.ipynb
docs/tutorials/.ipynb_checkpoints
docs/tutorials/.ipynb_checkpoints
1 change: 1 addition & 0 deletions docs/api/utils.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ CREsted provides a few utility function to help with sequence encoding, function
fetch_sequences
reverse_complement
permute_model
calculate_gc_distribution
setup_logging
```
16 changes: 15 additions & 1 deletion src/crested/_genome.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,14 @@ def name(self) -> str:
return basename
return self._name

def fetch(self, chrom=None, start=None, end=None, strand="+", region=None) -> str:
def fetch(
self,
chrom: str | None = None,
start: int | None = None,
end: int | None = None,
strand: str = "+",
region: str | None = None,
) -> str:
"""
Fetch a sequence from a genomic region.

Expand Down Expand Up @@ -196,6 +203,13 @@ def fetch(self, chrom=None, start=None, end=None, strand="+", region=None) -> st
else:
return seq

def __repr__(self) -> str:
"""Return a string representation of the Genome object."""
fasta_exists = self.fasta is not None
chrom_sizes_exists = self.chrom_sizes is not None
annotations_exists = self.annotation is not None
return f"Genome({self.name}, fasta={fasta_exists}, chrom_sizes={chrom_sizes_exists}, annotation={annotations_exists})"


def register_genome(genome: Genome):
"""
Expand Down
12 changes: 12 additions & 0 deletions src/crested/tl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
from . import data, losses, metrics, zoo
from ._configs import TaskConfig, default_configs
from ._crested import Crested
from ._tools import (
contribution_scores,
contribution_scores_specific,
extract_layer_embeddings,
predict,
score_gene_locus,
)

if find_spec("modiscolite") is not None:
MODISCOLITE_AVAILABLE = True
Expand Down Expand Up @@ -35,6 +42,11 @@
"TaskConfig",
"default_configs",
"Crested",
"extract_layer_embeddings",
"predict",
"contribution_scores",
"contribution_scores_specific",
"score_gene_locus",
]

if MODISCOLITE_AVAILABLE:
Expand Down
3 changes: 0 additions & 3 deletions src/crested/tl/_crested.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,6 @@ def fit(
if self.model and (
not hasattr(self.model, "optimizer") or self.model.optimizer is None
):
logger.warning(
"Model does not have an optimizer. Please compile the model before training."
)
self.model.compile(
optimizer=self.config.optimizer,
loss=self.config.loss,
Expand Down
Loading
Loading