Skip to content

Commit

Permalink
Merge branch 'master' into sam/pyproject-setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Colelyman committed Oct 9, 2024
2 parents a813fc6 + 14139c3 commit 2a89d86
Show file tree
Hide file tree
Showing 12 changed files with 670 additions and 537 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Run Pytest

on:
push:

pull_request:
types: [opened, reopened]

Expand All @@ -20,9 +20,8 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Conda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
mamba-version: "*"
channels: conda-forge,bioconda,defaults
auto-activate-base: false
activate-environment: test_env
Expand All @@ -32,15 +31,15 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y gcc g++ bowtie2 samtools libsys-hostname-long-perl
- name: Install Pytest
run: |
pip install pytest pytest-cov
- name: Install CRISPResso
run: |
pip install -e .
- name: Run Pytest
run: |
run: |
pytest tests --cov CRISPResso2
2 changes: 2 additions & 0 deletions CRISPResso2/CRISPRessoAggregateCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def main():

parser.add_argument('--debug', help='Show debug messages', action='store_true')
parser.add_argument('-v', '--verbosity', type=int, help='Verbosity level of output to the console (1-4), 4 is the most verbose', default=3)
parser.add_argument('--halt_on_plot_fail', action="store_true", help="Halt execution if a plot fails to generate")

# CRISPRessoPro params
parser.add_argument('--use_matplotlib', action='store_true',
Expand Down Expand Up @@ -131,6 +132,7 @@ def main():
num_processes=n_processes,
process_pool=process_pool,
process_futures=process_futures,
halt_on_plot_fail=args.halt_on_plot_fail,
)

#glob returns paths including the original prefix
Expand Down
1 change: 1 addition & 0 deletions CRISPResso2/CRISPRessoBatchCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ def main():
num_processes=n_processes_for_batch,
process_futures=process_futures,
process_pool=process_pool,
halt_on_plot_fail=args.halt_on_plot_fail,
)

window_nuc_pct_quilt_plot_names = []
Expand Down
18 changes: 12 additions & 6 deletions CRISPResso2/CRISPRessoCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,11 @@ def print_stacktrace_if_debug():

logger.addHandler(CRISPRessoShared.StatusHandler(os.path.join(OUTPUT_DIRECTORY, 'CRISPResso_status.json')))

if C2PRO_INSTALLED:
debug(f'CRISPRessoPro v{CRISPRessoProVersion} installed', {'percent_complete': 0.5})
else:
debug(f'CRISPRessoPro not installed', {'percent_complete': 0.5})

aln_matrix_loc = os.path.join(_ROOT, "EDNAFULL")
CRISPRessoShared.check_file(aln_matrix_loc)
aln_matrix = CRISPResso2Align.read_matrix(aln_matrix_loc)
Expand Down Expand Up @@ -1978,10 +1983,6 @@ def get_prime_editing_guides(this_amp_seq, this_amp_name, ref0_seq, prime_edited

#now that we're done with adding possible guides and amplicons, go through each amplicon and compute quantification windows
info('Computing quantification windows', {'percent_complete': 2})
if C2PRO_INSTALLED:
info(f'CRISPRessoPro v{CRISPRessoProVersion} installed', {'percent_complete': 3})
else:
info(f'CRISPRessoPro not installed', {'percent_complete': 3})

found_guide_seq = [False]*len(guides)
found_coding_seq = [False]*len(coding_seqs)
Expand Down Expand Up @@ -2021,14 +2022,14 @@ def get_prime_editing_guides(this_amp_seq, this_amp_name, ref0_seq, prime_edited
#for all amps in forward and reverse complement amps:
for amp_seq in [this_seq, CRISPRessoShared.reverse_complement(this_seq)]:
ref_incentive = np.zeros(len(amp_seq)+1, dtype=int)
s1, s2, score=CRISPResso2Align.global_align(guide, amp_seq, matrix=aln_matrix, gap_incentive=ref_incentive, gap_open=args.needleman_wunsch_gap_open, gap_extend=args.needleman_wunsch_gap_extend,)
s1, s2, score=CRISPResso2Align.global_align(guide, amp_seq, matrix=aln_matrix, gap_incentive=ref_incentive, gap_open=args.flexiguide_gap_open_penalty, gap_extend=args.flexiguide_gap_extend_penalty)
potential_guide = s1.strip("-")
if abs(len(potential_guide) - len(guide)) < 2: #if length of putative guide is off by less than 2, keep it (allows 1 gap)
loc = s1.find(potential_guide)
potential_ref = amp_seq[loc:loc+len(potential_guide)]
#realign to test for number of mismatches
ref_incentive = np.zeros(len(potential_ref)+1, dtype=int)
sub_s1, sub_s2, sub_score=CRISPResso2Align.global_align(guide, potential_ref, matrix=aln_matrix, gap_incentive=ref_incentive, gap_open=args.needleman_wunsch_gap_open, gap_extend=args.needleman_wunsch_gap_extend,)
sub_s1, sub_s2, sub_score=CRISPResso2Align.global_align(guide, potential_ref, matrix=aln_matrix, gap_incentive=ref_incentive, gap_open=args.flexiguide_gap_open_penalty, gap_extend=args.flexiguide_gap_extend_penalty)
mismatches = []
for i in range(len(sub_s1)):
if sub_s1[i] != sub_s2[i]:
Expand Down Expand Up @@ -3749,6 +3750,7 @@ def count_alternate_alleles(sub_base_vectors, ref_name, ref_sequence, ref_total_
num_processes=n_processes,
process_pool=process_pool,
process_futures=process_futures,
halt_on_plot_fail=args.halt_on_plot_fail,
)
###############################################################################################################################################
### FIGURE 1: Alignment
Expand Down Expand Up @@ -5177,6 +5179,10 @@ def get_scaffold_len(row, scaffold_start_loc, scaffold_seq):
print_stacktrace_if_debug()
error('Filtering error, please check your input.\n\nERROR: %s' % e)
sys.exit(13)
except CRISPRessoShared.PlotException as e:
print_stacktrace_if_debug()
error(e)
sys.exit(14)
except Exception as e:
print_stacktrace_if_debug()
error('Unexpected error, please check your input.\n\nERROR: %s' % e)
Expand Down
Loading

0 comments on commit 2a89d86

Please sign in to comment.