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

How to put label off #40

Open sameerh opened 4 years ago

sameerh commented 4 years ago

While plotting from genbank file, how to keep the label off?

veghp commented 4 years ago

I have not found such option in the docs, but if you remove labels then you can get a plot without labels:

from dna_features_viewer import BiopythonTranslator
graphic_record = BiopythonTranslator().translate_record("example_sequence.gb")
for feature in graphic_record.features:
    feature.label = None
graphic_record.plot(figure_width=5)

index

Zulko commented 4 years ago

One way is to redefine compute_feature_label like in the last example in the Readme. Here is the minimal version:

from dna_features_viewer import BiopythonTranslator

class MyCustomTranslator(BiopythonTranslator):
    def compute_feature_label(self, feature):
        # display labels for CDS only, no label for other features
        return "CDS here" if (feature.type == "CDS") else None

graphic_record = MyCustomTranslator().translate_record("example_sequence.gb")
sameerh commented 4 years ago

I have not found such option in the docs, but if you remove labels then you can get a plot without labels:

from dna_features_viewer import BiopythonTranslator
graphic_record = BiopythonTranslator().translate_record("example_sequence.gb")
for feature in graphic_record.features:
    feature.label = None
graphic_record.plot(figure_width=5)

Hi Veghp and Zulko, Thank you for your help. I will try this. Appreciate your help.