Skip to content

Commit

Permalink
Merge pull request #20 from pinellolab/doc
Browse files Browse the repository at this point in the history
Move documentation and add support for the survival screens
  • Loading branch information
jykr authored Mar 30, 2024
2 parents a93bc83 + 2ecc9b5 commit 24ad4a4
Show file tree
Hide file tree
Showing 182 changed files with 7,931 additions and 1,376 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.8'
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install torch==1.12.1+cpu torchvision==0.13.1+cpu torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cpu
pip install torch torchvision torchaudio
pip install -r requirements.txt
pip install -e .
- name: Test with pytest
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: "Sphinx: Render docs"

on: push

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install Sphinx & Dependencies
run: |
pip install sphinx sphinx_markdown_builder sphinx_rtd_theme sphinx-argparse m2r pandas bio
sudo apt-get install python3-distutils
- name: Build Documentation
working-directory: docs
run: sphinx-build . _build
- name: copy image files
run: cp -r docs/assets docs/_build/
- uses: actions/upload-pages-artifact@v3
with:
name: github-pages
path: docs/_build/

deploy:
needs: build
permissions:
id-token: write
pages: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.pyc
*.fastq
Empty file modified LICENSE
100644 → 100755
Empty file.
Empty file modified MANIFEST.in
100644 → 100755
Empty file.
490 changes: 37 additions & 453 deletions README.md
100644 → 100755

Large diffs are not rendered by default.

Empty file modified bean/__init__.py
100644 → 100755
Empty file.
Empty file modified bean/annotate/__init__.py
100644 → 100755
Empty file.
Empty file modified bean/annotate/_supporting_fn.py
100644 → 100755
Empty file.
Empty file modified bean/annotate/filter_alleles.py
100644 → 100755
Empty file.
Empty file modified bean/annotate/ldlr_exons.fa
100644 → 100755
Empty file.
Empty file modified bean/annotate/translate_allele.py
100644 → 100755
Empty file.
24 changes: 7 additions & 17 deletions bean/annotate/utils.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -218,22 +218,12 @@ def get_cds_seq_pos_from_gene_name(gene_name: str, ref_version: str = "GRCh38"):
return cds_chrom, cds_seq, cds_pos, strand


def parse_args():
"""Get the input arguments"""
print(
r"""
_ _
/ \ '\ __ _ _ _
| \ \ / _(_) | |_ ___ _ _
\ \ | | _| | | _/ -_) '_|
`.__|/ |_| |_|_|\__\___|_|
"""
)
print("bean-filter: filter alleles")
parser = argparse.ArgumentParser(
prog="allele_filter",
description="Filter alleles based on edit position in spacer and frequency across samples.",
)
def parse_args(parser=None):
if parser is None:
parser = argparse.ArgumentParser(
prog="allele_filter",
description="Filter alleles based on edit position in spacer and frequency across samples.",
)
parser.add_argument(
"bdata_path",
type=str,
Expand Down Expand Up @@ -349,7 +339,7 @@ def parse_args():
action="store_true",
help="Load temporary file and work from there.",
)
return parser.parse_args()
return parser


def check_args(args):
Expand Down
Empty file added bean/cli/__init__.py
Empty file.
195 changes: 90 additions & 105 deletions bin/bean-count → bean/cli/count.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,105 +1,90 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Count guides, optionally with reporter and alleles of a single sequencing sample."""

import logging
import os
import sys

import bean
from bean.mapping.utils import (
_check_arguments,
_get_input_parser,
_check_file,
_get_first_read_length,
_check_read_length,
)

logging.basicConfig(
level=logging.INFO,
format="%(levelname)-5s @ %(asctime)s:\n\t %(message)s \n",
datefmt="%a, %d %b %Y %H:%M:%S",
stream=sys.stderr,
filemode="w",
)
error = logging.critical
warn = logging.warning
debug = logging.debug
info = logging.info


_ROOT = os.path.abspath(os.path.dirname(__file__))


def get_input_parser():
"""Get single-sample specific argument parser."""
parser = _get_input_parser()
parser.add_argument(
"--R1",
type=str,
help="fastq file for read 1",
required=True,
default="Fastq filename",
)
parser.add_argument(
"--R2",
type=str,
help="fastq file for read 2, sorted as the same name order as in --R1 file.",
required=True,
default="Fastq filename",
)
return parser


def check_arguments(args, info_logger, warn_logger, error_logger):
args = _check_arguments(
args, info_logger=info, warn_logger=warn, error_logger=error
)
_check_file(args.R1)
_check_file(args.R2)
read_length = _get_first_read_length(args.R1)
_check_read_length(args, read_length, warn)
return args


def main():
parser = get_input_parser()
args = parser.parse_args()

args = check_arguments(args, info_logger=info, warn_logger=warn, error_logger=error)
args_dict = vars(args)

edited_from = args_dict["edited_base"]
match_target_pos = args_dict["match_target_pos"]

counter = bean.mp.GuideEditCounter(**args_dict)
counter.check_filter_fastq()

counter.get_counts()
if counter.count_reporter_edits:
counter.screen.uns["allele_counts"] = counter.screen.uns["allele_counts"].loc[
counter.screen.uns["allele_counts"].allele.map(str) != "", :
]
if match_target_pos:
base_editing_map = {"A": "G", "C": "T"}
edited_to = base_editing_map[edited_from]
counter.screen.get_edit_mat_from_uns(
edited_from, edited_to, match_target_pos
)
counter.screen.write(f"{counter.output_dir}.h5ad")
counter.screen.to_Excel(f"{counter.output_dir}.xlsx")
info(f"Output written at:\n {counter.output_dir}.h5ad,\n {counter.output_dir}.xlsx")
info("All Done!")
print(
r"""
_ _
/ \ '\ _
| \ \ __ ___ _ _ _ _| |_
\ \ | / _/ _ \ || | ' \ _|
`.__|/ \__\___/\_,_|_||_\__|
"""
)


if __name__ == "__main__":
main()
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Count guides, optionally with reporter and alleles of a single sequencing sample."""

import logging
import os
import sys

import bean
from bean.mapping.utils import (
_check_arguments,
_check_file,
_get_first_read_length,
_check_read_length,
)

logging.basicConfig(
level=logging.INFO,
format="%(levelname)-5s @ %(asctime)s:\n\t %(message)s \n",
datefmt="%a, %d %b %Y %H:%M:%S",
stream=sys.stderr,
filemode="w",
)
error = logging.critical
warn = logging.warning
debug = logging.debug
info = logging.info


_ROOT = os.path.abspath(os.path.dirname(__file__))





def check_arguments(args, info_logger, warn_logger, error_logger):
args = _check_arguments(
args, info_logger=info, warn_logger=warn, error_logger=error
)
_check_file(args.R1)
_check_file(args.R2)
read_length = _get_first_read_length(args.R1)
_check_read_length(args, read_length, warn)
return args


def main(args):
"""Get the input data"""
print(
r"""
_ _
/ \ '\ _
| \ \ __ ___ _ _ _ _| |_
\ \ | / _/ _ \ || | ' \ _|
`.__|/ \__\___/\_,_|_||_\__|
"""
)
args = check_arguments(args, info_logger=info, warn_logger=warn, error_logger=error)
args_dict = vars(args)

edited_from = args_dict["edited_base"]
match_target_pos = args_dict["match_target_pos"]

counter = bean.mp.GuideEditCounter(**args_dict)
counter.check_filter_fastq()

counter.get_counts()
if counter.count_reporter_edits:
counter.screen.uns["allele_counts"] = counter.screen.uns["allele_counts"].loc[
counter.screen.uns["allele_counts"].allele.map(str) != "", :
]
if match_target_pos:
base_editing_map = {"A": "G", "C": "T"}
edited_to = base_editing_map[edited_from]
counter.screen.get_edit_mat_from_uns(
edited_from, edited_to, match_target_pos
)
counter.screen.write(f"{counter.output_dir}.h5ad")
counter.screen.to_Excel(f"{counter.output_dir}.xlsx")
info(f"Output written at:\n {counter.output_dir}.h5ad,\n {counter.output_dir}.xlsx")
info("All Done!")
print(
r"""
_ _
/ \ '\ _
| \ \ __ ___ _ _ _ _| |_
\ \ | / _/ _ \ || | ' \ _|
`.__|/ \__\___/\_,_|_||_\__|
"""
)
Loading

0 comments on commit 24ad4a4

Please sign in to comment.