From 937b3caf7258fb40fc391552255411569e9f2f9e Mon Sep 17 00:00:00 2001 From: Cole Lyman Date: Fri, 22 Mar 2024 14:05:11 -0600 Subject: [PATCH 1/4] Move read filtering to after merging in CRISPResso (#39) * Move read filtering to after merging This is in an effort to be consistent with the behavior and results of CRISPRessoPooled. * Properly assign the correct file names for read filtering * Add space around operators --- CRISPResso2/CRISPRessoCORE.py | 64 ++++++++++++++--------------------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/CRISPResso2/CRISPRessoCORE.py b/CRISPResso2/CRISPRessoCORE.py index 9a7c278e..5ac57018 100644 --- a/CRISPResso2/CRISPRessoCORE.py +++ b/CRISPResso2/CRISPRessoCORE.py @@ -2117,44 +2117,6 @@ def get_prime_editing_guides(this_amp_seq, this_amp_name, ref0_seq, prime_edited info('Done!', {'percent_complete': 4}) - if args.min_average_read_quality>0 or args.min_single_bp_quality>0 or args.min_bp_quality_or_N>0: - if args.bam_input != '': - raise CRISPRessoShared.BadParameterException('The read filtering options are not available with bam input') - info('Filtering reads with average bp quality < %d and single bp quality < %d and replacing bases with quality < %d with N ...' % (args.min_average_read_quality, args.min_single_bp_quality, args.min_bp_quality_or_N)) - min_av_quality = None - if args.min_average_read_quality > 0: - min_av_quality = args.min_average_read_quality - - min_single_bp_quality = None - if args.min_single_bp_quality > 0: - min_single_bp_quality = args.min_single_bp_quality - - min_bp_quality_or_N = None - if args.min_bp_quality_or_N > 0: - min_bp_quality_or_N = args.min_bp_quality_or_N - - if args.fastq_r2!='': - output_filename_r1=_jp(os.path.basename(args.fastq_r1.replace('.fastq', '')).replace('.gz', '')+'_filtered.fastq.gz') - output_filename_r2=_jp(os.path.basename(args.fastq_r2.replace('.fastq', '')).replace('.gz', '')+'_filtered.fastq.gz') - - from CRISPResso2 import filterFastqs - filterFastqs.filterFastqs(fastq_r1=args.fastq_r1, fastq_r2=args.fastq_r2, fastq_r1_out=output_filename_r1, fastq_r2_out=output_filename_r2, min_bp_qual_in_read=min_single_bp_quality, min_av_read_qual=min_av_quality, min_bp_qual_or_N=min_bp_quality_or_N) - - args.fastq_r1 = output_filename_r1 - args.fastq_r2 = output_filename_r2 - files_to_remove += [output_filename_r1] - files_to_remove += [output_filename_r2] - - else: - output_filename_r1=_jp(os.path.basename(args.fastq_r1.replace('.fastq', '')).replace('.gz', '')+'_filtered.fastq.gz') - - from CRISPResso2 import filterFastqs - filterFastqs.filterFastqs(fastq_r1=args.fastq_r1, fastq_r1_out=output_filename_r1, min_bp_qual_in_read=min_single_bp_quality, min_av_read_qual=min_av_quality, min_bp_qual_or_N=min_bp_quality_or_N) - - args.fastq_r1 = output_filename_r1 - files_to_remove += [output_filename_r1] - - #Trim and merge reads if args.bam_input != '' and args.trim_sequences: raise CRISPRessoShared.BadParameterException('Read trimming options are not available with bam input') @@ -2292,7 +2254,33 @@ def get_prime_editing_guides(this_amp_seq, this_amp_name, ref0_seq, prime_edited info('Wrote force-merged reads to ' + new_merged_filename) info('Done!', {'percent_complete': 7}) + else: # single end reads with no trimming + processed_output_filename = args.fastq_r1 + + if args.min_average_read_quality > 0 or args.min_single_bp_quality > 0 or args.min_bp_quality_or_N > 0: + if args.bam_input != '': + raise CRISPRessoShared.BadParameterException('The read filtering options are not available with bam input') + info('Filtering reads with average bp quality < %d and single bp quality < %d and replacing bases with quality < %d with N ...' % (args.min_average_read_quality, args.min_single_bp_quality, args.min_bp_quality_or_N)) + min_av_quality = None + if args.min_average_read_quality > 0: + min_av_quality = args.min_average_read_quality + + min_single_bp_quality = None + if args.min_single_bp_quality > 0: + min_single_bp_quality = args.min_single_bp_quality + + min_bp_quality_or_N = None + if args.min_bp_quality_or_N > 0: + min_bp_quality_or_N = args.min_bp_quality_or_N + + output_filename_r1 = _jp(os.path.basename( + processed_output_filename.replace('.fastq', '')).replace('.gz', '') + '_filtered.fastq.gz', + ) + + from CRISPResso2 import filterFastqs + filterFastqs.filterFastqs(fastq_r1=processed_output_filename, fastq_r1_out=output_filename_r1, min_bp_qual_in_read=min_single_bp_quality, min_av_read_qual=min_av_quality, min_bp_qual_or_N=min_bp_quality_or_N) + processed_output_filename = output_filename_r1 #count reads N_READS_AFTER_PREPROCESSING = 0 From 060f666fb4b0f3337050583f629470af8b97f988 Mon Sep 17 00:00:00 2001 From: Samuel Nichols Date: Fri, 22 Mar 2024 14:31:38 -0600 Subject: [PATCH 2/4] GitHub actions on pr (#51) * Run integration tests on pull_request * Run pytest on pull_request * Run pylint on pull_request --- .github/workflows/integration_tests.yml | 1 + .github/workflows/pylint.yml | 1 + .github/workflows/pytest.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index fae5a96b..cb9135b0 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -2,6 +2,7 @@ name: Run Integration Tests on: push: + pull_request: jobs: build: diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 67b57b6f..ee421c7d 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -2,6 +2,7 @@ name: Pylint on: push: + pull_request: jobs: build: diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index fb2a86dc..c13c8e7c 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -2,6 +2,7 @@ name: Run Pytest on: push: + pull_request: jobs: build: From e1520b59f91eb4bd375d349a1df8db0f24a96f3f Mon Sep 17 00:00:00 2001 From: Samuel Nichols Date: Fri, 22 Mar 2024 17:38:37 -0600 Subject: [PATCH 3/4] Run tests on PR only when opening PR (#53) --- .github/workflows/integration_tests.yml | 2 ++ .github/workflows/pylint.yml | 2 ++ .github/workflows/pytest.yml | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index cb9135b0..a9f3442a 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -2,7 +2,9 @@ name: Run Integration Tests on: push: + pull_request: + types: [opened, reopened] jobs: build: diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index ee421c7d..564df075 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -2,7 +2,9 @@ name: Pylint on: push: + pull_request: + types: [opened, reopened] jobs: build: diff --git a/.github/workflows/pytest.yml b/.github/workflows/pytest.yml index c13c8e7c..5cec2da2 100644 --- a/.github/workflows/pytest.yml +++ b/.github/workflows/pytest.yml @@ -2,7 +2,9 @@ name: Run Pytest on: push: + pull_request: + types: [opened, reopened] jobs: build: From 30a5d198d221aa1fe56c4a03ea78fe636d15a8a6 Mon Sep 17 00:00:00 2001 From: Cole Lyman Date: Mon, 25 Mar 2024 09:50:30 -0600 Subject: [PATCH 4/4] Update reports (#52) * Update report changes * Switch branch of integration test repo * Remove extraneous `crispresso_data_path` * Point integration tests back to master --- .github/workflows/integration_tests.yml | 2 +- CRISPResso2/CRISPRessoReports/README.md | 24 ++++++++++++++++--- .../templates/batchReport.html | 1 - .../templates/multiReport.html | 5 ++-- .../templates/pooledReport.html | 5 ++-- .../templates/wgsReport.html | 5 ++-- 6 files changed, 29 insertions(+), 13 deletions(-) diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index a9f3442a..16941ebd 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -40,7 +40,7 @@ jobs: run: | mkdir ../CRISPResso2_copy cp -r * ../CRISPResso2_copy - + - name: Copy C2_tests repo uses: actions/checkout@master with: diff --git a/CRISPResso2/CRISPRessoReports/README.md b/CRISPResso2/CRISPRessoReports/README.md index b31cff80..39487ca6 100644 --- a/CRISPResso2/CRISPRessoReports/README.md +++ b/CRISPResso2/CRISPRessoReports/README.md @@ -86,10 +86,16 @@ Also, note that the default commit message may have a summary of all commits, pl 1. In the parent repo, switch to (or create) the branch on `CRISPRessoReports` that will have the changes you push. -If you are creating a new branch based off of `CRISPRessoReports` master, run this: +If you are creating a new branch based off of `CRISPRessoReports` master, run this to switch to the reports master branch: ``` shell -git checkout -b -reports reports/master +git checkout reports/master +``` + +Then, run to actually create (and switch to) the branch that you will be working with: + +``` shell +git checkout -b -reports ``` Or if you would like to push to an existing branch on `CRISPRessoReports`, run this: @@ -106,6 +112,18 @@ git merge --squash -Xsubtree="CRISPResso2/CRISPRessoReports" --no-commit --allow *Note:* `` is the branch of the parent repo that contains the changes inside the `CRISPRessoReports` sub-directory. +3. Push to `CRISPRessoReports`. + +``` shell +git push +``` + +4. Switch back to your branch on `CRISPResso` or `C2Web`. + +``` shell +git checkout +``` + ### I am working on a feature that requires changing `CRISPRessoReports`, what do I do? If a feature that you are working on requires changes to CRISPRessoReports, you will need to perform a few steps to get setup. @@ -113,7 +131,7 @@ If a feature that you are working on requires changes to CRISPRessoReports, you 1. Create a feature branch in the parent repo, based on the parent repo master. ``` shell -git checkout -b origin/master +git checkout -b ``` 2. Create a feature branch on `CRISPRessoReports`. diff --git a/CRISPResso2/CRISPRessoReports/templates/batchReport.html b/CRISPResso2/CRISPRessoReports/templates/batchReport.html index 1255424c..49a6c9ea 100644 --- a/CRISPResso2/CRISPRessoReports/templates/batchReport.html +++ b/CRISPResso2/CRISPRessoReports/templates/batchReport.html @@ -45,7 +45,6 @@ {% endblock %} {% block content %} -
diff --git a/CRISPResso2/CRISPRessoReports/templates/multiReport.html b/CRISPResso2/CRISPRessoReports/templates/multiReport.html index 10d30063..2831d9fc 100644 --- a/CRISPResso2/CRISPRessoReports/templates/multiReport.html +++ b/CRISPResso2/CRISPRessoReports/templates/multiReport.html @@ -46,7 +46,7 @@ {% endblock %} {% block content %} - +
@@ -61,7 +61,7 @@
{{report_name}}
{% for run_name in run_names %} - {{run_name}} + {{run_name}} {% endfor %}
@@ -162,6 +162,7 @@
Summary Plots
{# column #}
+
{% endblock %} {% block foot %} diff --git a/CRISPResso2/CRISPRessoReports/templates/pooledReport.html b/CRISPResso2/CRISPRessoReports/templates/pooledReport.html index ba944d90..899f39c1 100644 --- a/CRISPResso2/CRISPRessoReports/templates/pooledReport.html +++ b/CRISPResso2/CRISPRessoReports/templates/pooledReport.html @@ -44,7 +44,6 @@ {% endblock %} {% block content %} -
@@ -60,8 +59,8 @@
{{report_name}}
{% for region_name in run_names %} - {{region_name}} - {% endfor %} + {{region_name}} + {% endfor %}
diff --git a/CRISPResso2/CRISPRessoReports/templates/wgsReport.html b/CRISPResso2/CRISPRessoReports/templates/wgsReport.html index 5f2008a4..47ab9002 100644 --- a/CRISPResso2/CRISPRessoReports/templates/wgsReport.html +++ b/CRISPResso2/CRISPRessoReports/templates/wgsReport.html @@ -45,7 +45,6 @@ {% endblock %} {% block content %} -
@@ -60,8 +59,8 @@
{{report_name}}
{% for region_name in run_names %} - {{region_name}} - {% endfor %} + {{region_name}} + {% endfor %}