-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
eec3176
commit f71e34d
Showing
9 changed files
with
229 additions
and
784 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,53 @@ This repository provides a simulator for an ONT device controlled by the ReadUnt | |
The code is well-tested with `pytest` and an example usecase combining the simulator with ReadFish and NanoSim is provided. | ||
Access the documentation [here](https://ratschlab.github.io/sim_read_until/). | ||
|
||
See below for a [quick start](#quick-start). | ||
A video for the CLI interface of the simulator (as described in [usecases](usecases/README.md)) is available here: [CLI interface Youtube](https://youtu.be/8GDTD4Memes) | ||
See below for an [overview](#overview). | ||
|
||
## Quick Start | ||
|
||
Clone the repository, install the virtual environment and run the usecase, as explained below. | ||
|
||
### Installation and Setup | ||
|
||
We have tested the code with python3.10 and python3.8 on Linux and Mac OS X, so try to use it: | ||
```{bash} | ||
# create a shared directory: | ||
mkdir ~/ont_project_all | ||
cd ~/ont_project_all | ||
git clone --depth 1 [email protected]:ratschlab/sim_read_until.git ont_project | ||
# the NanoSim repository (integrated as a submodule here) is quite large (2Gb) due to pre-computed models, so we omit it here | ||
# if you want it, do: git clone --recurse-submodules [email protected]:ratschlab/sim_read_until.git ont_project | ||
# conda deactivate # if you have a conda environment activated, including base env | ||
python3.10 -m venv ont_project_venv | ||
source ~/ont_project_all/ont_project_venv/bin/activate | ||
pip install --upgrade pip | ||
pip install ont_project/ | ||
pip install --upgrade seaborn | ||
``` | ||
|
||
Take a look at the directory [usecase](usecases/) to run some example usecases. | ||
|
||
If the installation fails due to dependency issues, you can alternatively run it as a Docker image that comes with the dependencies and runs Jupyter lab: | ||
```{bash} | ||
# to update the Docker image if a new one was published | ||
# note: it may not always be up-to-date with the main branch, check the release date online | ||
docker pull ghcr.io/ratschlab/sim_read_until:main_dev | ||
cd ~/ont_project_all | ||
./ont_project/start_docker_container.sh | ||
# to see the options | ||
# ./ont_project/start_docker_container.sh -h | ||
``` | ||
Several Docker containers can run in parallel, provided you modify the port and container name via the options `-n` and `-p`. | ||
|
||
**Note**: Conda is not officially supported, but you can set up your environment with: | ||
```{bash} | ||
conda create -y -n ont_project_venv python=3.10 pip | ||
``` | ||
Some scripts activate the virtual environment, so you have to change it to `conda activate ont_project_venv`. | ||
|
||
## Overview | ||
|
||
|
@@ -57,52 +103,7 @@ The repository contains the following directories (as submodules): | |
- `runs`: for local runs; in `.gitignore` | ||
- `apidocs`: location for API docs; in `.gitignore` | ||
|
||
## Quick Start | ||
|
||
Clone the repository, install the virtual environment and run the usecase, as explained below. | ||
|
||
### Installation and Setup | ||
|
||
We have tested the code with python3.10 and python3.8, so try to use it: | ||
```{bash} | ||
# create a shared directory: | ||
mkdir ~/ont_project_all | ||
cd ~/ont_project_all | ||
git clone --depth 1 [email protected]:ratschlab/sim_read_until.git ont_project | ||
# the NanoSim repository (integrated as a submodule here) is quite large (2Gb) due to pre-computed models, so we omit it here | ||
# if you want it, do: git clone --recurse-submodules [email protected]:ratschlab/sim_read_until.git ont_project | ||
# conda deactivate # if you have a conda environment activated, including base env | ||
python3.10 -m venv ont_project_venv | ||
source ~/ont_project_all/ont_project_venv/bin/activate | ||
pip install --upgrade pip | ||
pip install ont_project/ | ||
pip install --upgrade seaborn | ||
``` | ||
|
||
Take a look at the directory [usecase](usecases/) to run some example usecases. | ||
|
||
If the installation fails due to dependency issues, you can alternatively run it as a Docker image that comes with the dependencies and runs Jupyter lab: | ||
```{bash} | ||
# to update the Docker image if a new one was published | ||
# note: it may not always be up-to-date with the main branch, check the release date online | ||
docker pull ghcr.io/ratschlab/sim_read_until:main_dev | ||
cd ~/ont_project_all | ||
./ont_project/start_docker_container.sh | ||
# to see the options | ||
# ./ont_project/start_docker_container.sh -h | ||
``` | ||
Several Docker containers can run in parallel, provided you modify the port and container name via the options `-n` and `-p`. | ||
|
||
**Note**: Conda is not officially supported, but you can set up your environment with: | ||
```{bash} | ||
conda create -y -n ont_project_venv python=3.10 pip | ||
``` | ||
Some scripts activate the virtual environment, so you have to change it to `conda activate ont_project_venv`. | ||
|
||
### Comparison with UNCALLED | ||
## Comparison with UNCALLED | ||
|
||
We tried comparing with UNCALLED, but it didn't work due to a segmentation fault without any useful error message, see [uncalled_comparison](uncalled_comparison.md) for details. | ||
According to the authors, the UNCALLED simulator is superseeded by the recent tool Icarust, which is a tool that addresses a similar setting as we do. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
102 changes: 102 additions & 0 deletions
102
src/simreaduntil/usecase_helpers/cli_usecase/make_html_report.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
""" | ||
Make an overview page from all figures in the directory | ||
""" | ||
import argparse | ||
import logging | ||
from pathlib import Path | ||
import sys | ||
from simreaduntil.shared_utils.logging_utils import add_comprehensive_stream_handler_to_logger, setup_logger_simple | ||
from simreaduntil.shared_utils.utils import print_args | ||
|
||
logger = setup_logger_simple(__name__) | ||
"""module logger""" | ||
|
||
mainpage_template = r""" | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Generated Figures</title> | ||
</head> | ||
<style> | ||
img { | ||
display: inline-block; | ||
margin: 5px; | ||
max-width: 100%; | ||
max-height: 400px; | ||
text-align: center; | ||
} | ||
</style> | ||
<body> | ||
<h1>Generated Figures</h1> | ||
{FIGURES_HTML} | ||
</body> | ||
</html> | ||
""" | ||
figure_template = r""" | ||
<h2 class="image-name">{figure_name}</h2> | ||
<div class="photo"> | ||
<img src="{figure_filename}"> | ||
</div> | ||
<hr style="height:2px;border-width:0;color:gray;background-color:gray"> | ||
""" | ||
|
||
def parse_args(args=None): | ||
parser = argparse.ArgumentParser(description="Combine images into html report") | ||
parser.add_argument("figure_dir", type=Path, help="Directory containing figures (.png files)") | ||
|
||
args = parser.parse_args(args) | ||
print_args(args, logger=logger) | ||
return args | ||
|
||
def main(): | ||
log_level = logging.DEBUG | ||
logging.getLogger(__name__).setLevel(log_level) # log level of this script (running as __main__) | ||
add_comprehensive_stream_handler_to_logger(None, level=log_level) | ||
|
||
args = parse_args() | ||
|
||
figure_dir = args.figure_dir | ||
assert figure_dir.exists(), f"figure_dir '{figure_dir}' does not exist" | ||
|
||
figure_htmls = "" | ||
for filename in figure_dir.glob("*.png"): | ||
logger.info(f"Adding '{filename}'") | ||
# using relative path wrt to final file! | ||
figure_htmls += figure_template.format(figure_name=filename.name, figure_filename=filename.name) | ||
|
||
html_filename = figure_dir / "figures.html" | ||
with open(html_filename, "w") as f: | ||
f.write(mainpage_template.replace("{FIGURES_HTML}", figure_htmls)) | ||
|
||
|
||
# template | ||
# <!DOCTYPE html> | ||
# <html> | ||
# <head> | ||
# <title>Generated Figures</title> | ||
# </head> | ||
# <style> | ||
# img { | ||
# display: inline-block; | ||
# margin: 5px; | ||
# width: 100%; | ||
# max-height: 400px; | ||
# text-align: center; | ||
# } | ||
|
||
# </style> | ||
# <body> | ||
# <h1>Generated Figures</h1> | ||
|
||
# <h2 class="image-name">nb_basepairs_recrej_per_channel.png</h2> | ||
# <div class="photo"> | ||
# <img src="figures/nb_basepairs_recrej_per_channel.png"> | ||
# </div> | ||
# <hr style="height:2px;border-width:0;color:gray;background-color:gray"> | ||
|
||
# </body> | ||
# </html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.