Exemple #1
0
 def partial_digests_analysis(self, data, clones_observations):
     analysis = clones_observations.partial_digests_analysis()
     best = max(analysis, key=lambda a: analysis[a]["valid_clones"])
     if analysis[best]["valid_clones"] == analysis[()]["valid_clones"]:
         return {
             "message": "The partial digest analysis did not find any "
             "significant results",
             "success": "yeah!",
         }
     ax = clones_observations.plot_partial_digests_analysis(analysis)
     validations = analysis[best]["validations"]
     observations = ClonesObservations(
         clones_observations.clones,
         clones_observations.constructs_records,
         partial_cutters=best,
     )
     pdf_data = observations.plot_all_validations_patterns(validations)
     return {
         "pdf_file": {
             "data":
             data_to_html_data(pdf_data, "pdf"),
             "name":
             "digest_validation_assuming_partial_%s.pdf" % "_".join(best),
             "mimetype":
             "application/pdf",
         },
         "message":
         ("The analysis shows that the following enzyme(s) were"
          " possibly only partially cutting: %s. <br/>The report below"
          " shows the validation under this hypothesis.") %
         (", ".join(["<b>%s</b>" % b for b in best])),
         "figure_data":
         matplotlib_figure_to_svg_base64_data(ax.figure,
                                              bbox_inches="tight"),
         "success":
         "yeah!",
     }
Exemple #2
0
 def partial_digests_analysis(self, data, clones_observations):
     analysis = clones_observations.partial_digests_analysis()
     best = max(analysis, key=lambda a: analysis[a]['valid_clones'])
     if analysis[best]['valid_clones'] == analysis[()]['valid_clones']:
         return {
             'message': 'The partial digest analysis did not find any '
             'significant results',
             'success': 'yeah!'
         }
     ax = clones_observations.plot_partial_digests_analysis(analysis)
     validations = analysis[best]['validations']
     observations = ClonesObservations(
         clones_observations.clones,
         clones_observations.constructs_records,
         partial_cutters=best)
     pdf_data = observations.plot_all_validations_patterns(validations)
     return {
         'pdf_file': {
             'data':
             data_to_html_data(pdf_data, 'pdf'),
             'name':
             'digest_validation_assuming_partial_%s.pdf' % "_".join(best),
             'mimetype':
             'application/pdf'
         },
         'message':
         ("The analysis shows that the following enzyme(s) were"
          " possibly only partially cutting: %s. <br/>The report below"
          " shows the validation under this hypothesis.") %
         (", ".join(["<b>%s</b>" % b for b in best])),
         'figure_data':
         matplotlib_figure_to_svg_base64_data(ax.figure,
                                              bbox_inches='tight'),
         'success':
         'yeah!'
     }
Exemple #3
0
clones_map = {
    well.name: well.data.construct
    for well in clones_plate.iter_wells()
    if 'construct' in well.data
    and str(well.data.construct) != 'nan'
}
bands_observations = BandsObservation.from_aati_fa_archive(
    data_dir.aati_files_zip._path)

clones = {
    well_name: Clone(name=well_name, construct_id=clones_map[well_name],
                     digestions={("NcoI",): bands_observations[well_name]})
    for well_name, construct_id in clones_map.items()
}


# VALIDATE ALL CLONES WITH BANDWITCH
clones_observations = ClonesObservations(clones, constructs_dict)
validations = clones_observations.validate_all_clones(relative_tolerance=0.03)
validations_summary = clones_observations.validations_summary(validations)


# CREATE A FOLDER WITH VALIDATION REPORTS
report_root = flametree.file_tree('.').examples_output._dir('band_validation')
report_root._file('validations.pdf').write(
    clones_observations.plot_all_validations_patterns(validations)
)
ax = clones_observations.plot_validations_plate_map(validations)
ax.figure.savefig(report_root._file('success_map.pdf').open('wb'),
                  format='pdf', bbox_inches='tight')