Edinburgh-Genome-Foundry / DnaFeaturesViewer

:eye: Python library to plot DNA sequence features (e.g. from Genbank files)
https://edinburgh-genome-foundry.github.io/DnaFeaturesViewer/
MIT License
584 stars 90 forks source link

Cannot apply sequence translation on plot_on_multiple_lines or plot_on_multiple_pages #61

Open RekhaAngara opened 3 years ago

RekhaAngara commented 3 years ago

Is it possible to use sequence translation (plot_translation) with plot_on_multiple_lines or plot_on_multiple_pages. I would like to ideally have a sequence on multiple lines/pages represented both as nuc and aminoacid sequence.

veghp commented 3 years ago

Thanks, I agree that it would be an interesting feature, which is not implemented currently (I think).

A solution would be to include a call to plot_translation() in MultilinePlottableMixin.plot_on_multiple_lines() after the line https://github.com/Edinburgh-Genome-Foundry/DnaFeaturesViewer/blob/6ace5cdff96bf995aa26167868b0dbb47f5f5952/dna_features_viewer/GraphicRecord/MultilinePlottableMixin.py#L74

As a proof of concept, a call there:

line_record.plot_translation(
    ax=line_ax,
    location=(0, 66),
    fontdict={"weight": "bold"},
    long_form_translation=False,
)

returns: multiline_translation

@Zulko do you think that's a good solution? I can add a dict parameter like translation_params=None in plot_on_multiple_lines() which would be passed on to plot_translation() if not None etc.

RekhaAngara commented 3 years ago

I'll try that solution, thank you for your prompt response