Edinburgh-Genome-Foundry / DnaChisel

:pencil2: A versatile DNA sequence optimizer
https://edinburgh-genome-foundry.github.io/DnaChisel/
MIT License
219 stars 40 forks source link

Feature: Add "use_breach_form" field in "constraints_breaches_dataframe" #56

Open andrewshvv opened 3 years ago

andrewshvv commented 3 years ago

Scenario: I would like to use constraints_breaches_dataframe for generating my own report and upload SeqRecord in Benchling instead of the .pdf.

Problem: For our customers, we need a bit more general description of why their sequence doesn't pass the constraints, and currently, I need to copy/paste the whole function instead of re-using it with the use_breach_form=False field.

Zulko commented 3 years ago

Sorry I didn't get what use_breach_form means, could you give an example of the ideal code you'd write and what it would do?

andrewshvv commented 3 years ago

Let me describe it in a bit more general form:

As a User of dna-chisel I want to define my own description of constraint and be able to use constraints_breaches_dataframe function with this longer version of the description, instead of the breach_label description. So that I could use the annotated records and upload them in Benchling for further inspection and correction.

Currently, I have achieved that by inheriting from the constraints class and redefining breach_label function, which takes my description.

Initially, I thought it would be good to pass the use_breach_form in the constraints_breaches_dataframe function. But I believe defining the general high-level description will give you space for implementing it in a way you feel appropriate.

def constraints_breaches_dataframe(
    constraints, sequences, display_constraints_locations=False,
):

.........

    dataframe_records = [
        dict(
            [("sequence", name)]
            + [
                (
                    constraint.label(
                        use_breach_form=True, <======== HERE
                        with_location=display_constraints_locations,
                    ),
andrewshvv commented 3 years ago

An example of what I have achieved with longer description:

image