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

AttributeError: 'Seq' object has no attribute 'defined' #88

Open sbassi opened 3 weeks ago

sbassi commented 3 weeks ago

Got this error:

Traceback (most recent call last):
  File "/opt/MitoHiFi/src/mitohifi.py", line 566, in <module>
    main()
  File "/opt/MitoHiFi/src/mitohifi.py", line 491, in main
    plot_annotation.plot_annotation("final_mitogenome.gb", "final_mitogenome.annotation.png")
  File "/opt/MitoHiFi/src/plot_annotation.py", line 38, in plot_annotation
    graphic_record = MyCustomTranslator().translate_record(in_gb)
  File "/usr/local/lib/python3.6/dist-packages/dna_features_viewer/BiopythonTranslator/BiopythonTranslatorBase.py", line 89, in translate_record
    sequence=str(record.seq) if record.seq.defined else None,
AttributeError: 'Seq' object has no attribute 'defined'

I did a modification to line 89 and it worked, so will commit my patch.

Changing:

sequence=str(record.seq) if record.seq.defined else None

To:

sequence=str(record.seq) if record.seq else None

Since I don't know about defined for Biopython Seq, maybe is something old?

veghp commented 1 week ago

Thank you, actually it's a new property: https://biopython.org/docs/1.81/api/Bio.Seq.html and has been addressed in https://github.com/Edinburgh-Genome-Foundry/DnaFeaturesViewer/pull/79

My solution would be to update Biopython (and Python as support for 3.6 ended a while ago).