Skip to content

Commit

Permalink
Merge with c2pro
Browse files Browse the repository at this point in the history
  • Loading branch information
Snicker7 committed Mar 21, 2024
1 parent 2de605f commit 31430c7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
8 changes: 8 additions & 0 deletions CRISPResso2/CRISPRessoBatchCORE.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
from CRISPResso2 import CRISPRessoShared
try:
from CRISPRessoPro import plot as CRISPRessoPlot
pro_installed = True
except:
from CRISPResso2 import CRISPRessoPlot
pro_installed = False
from CRISPResso2 import CRISPRessoMultiProcessing
from CRISPResso2.CRISPRessoReports import CRISPRessoReport

Expand Down Expand Up @@ -119,6 +121,12 @@ def main():

_jp = lambda filename: os.path.join(OUTPUT_DIRECTORY, filename) #handy function to put a file in the output directory

if args.use_matplotlib or not pro_installed:
from CRISPResso2 import CRISPRessoPlot
else:
from CRISPRessoPro import plot as CRISPRessoPlot
CRISPRessoPlot.setMatplotlibDefaults()

try:
info('Creating Folder %s' % OUTPUT_DIRECTORY, {'percent_complete': 0})
os.makedirs(OUTPUT_DIRECTORY)
Expand Down
14 changes: 8 additions & 6 deletions CRISPResso2/CRISPRessoReports/CRISPRessoReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,12 @@ def make_batch_report_from_folder(crispressoBatch_report_file, crispresso2_info,

summary_plot_htmls = {}
for plot_name in window_nuc_pct_quilts + nuc_pct_quilts:
with open(os.path.join(batch_folder, f'{plot_name}.json')) as window_nuc_pct_json_fh:
summary_plot_htmls[plot_name] = f"""
<div class="d-flex justify-content-between" style="max-height: 80vh; overflow-y: auto;" id="{plot_name}"></div>
<script type="text/javascript">const {plot_name} = {window_nuc_pct_json_fh.read().strip()}</script>
"""
if os.path.exists(os.path.join(batch_folder, f'{plot_name}.json')):
with open(os.path.join(batch_folder, f'{plot_name}.json')) as window_nuc_pct_json_fh:
summary_plot_htmls[plot_name] = f"""
<div class="d-flex justify-content-between" style="max-height: 80vh; overflow-y: auto;" id="{plot_name}"></div>
<script type="text/javascript">const {plot_name} = {window_nuc_pct_json_fh.read().strip()}</script>
"""

#find path between the report and the data (if the report is in another directory vs in the same directory as the data)
crispresso_data_path = os.path.relpath(batch_folder, os.path.dirname(crispressoBatch_report_file))
Expand Down Expand Up @@ -325,6 +326,7 @@ def make_batch_report_from_folder(crispressoBatch_report_file, crispresso2_info,
nuc_conv_plots=nuc_conv_plots,
allele_modification_heatmap_plot=allele_modification_heatmap_plot,
allele_modification_line_plot=allele_modification_line_plot,
pro_installed=pro_installed,
)


Expand Down Expand Up @@ -507,7 +509,7 @@ def fill_default(dictionary, key, default_type=list):
dictionary[key] = default_type()

j2_env = Environment(
loader=FileSystemLoader(os.path.join(_ROOT, 'CRISPRessoReports', 'templates')),
loader=FileSystemLoader([os.path.join(_ROOT, 'CRISPRessoReports', 'templates'), os.path.join(_ROOT, "CRISPRessoPro", "templates")]),
)
j2_env.filters['dirname'] = dirname
if crispresso_tool == 'batch':
Expand Down
2 changes: 1 addition & 1 deletion CRISPResso2/CRISPRessoReports/templates/batchReport.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,6 @@ <h5>{{allele_modification_heatmap_plot_titles[heatmap_plot_name]}}</h5>
{% block foot %}
{% if pro_installed %}
<script src="https://unpkg.com/d3@5"></script>
{{ render_partial('shared/partials/batch_d3.html', nucleotide_quilt_slugs=(window_nuc_pct_quilts + nuc_pct_quilts))}}
{{ render_partial('partials/batch_d3.html', nucleotide_quilt_slugs=(window_nuc_pct_quilts + nuc_pct_quilts))}}
{% endif %}
{% endblock %}

0 comments on commit 31430c7

Please sign in to comment.