Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'GenomeViz' object has no attribute 'add_feature' #55

Open
Syutenjyo opened this issue Jan 15, 2025 · 4 comments
Open

Comments

@Syutenjyo
Copy link

Syutenjyo commented Jan 15, 2025

I am encountering an AttributeError when trying to use the add_feature method of the GenomeViz class in the pygenomeviz library.(portein-visualization) Here is the code snippet that I am using:

from pygenomeviz import GenomeViz
# Initialize GenomeViz
gv = GenomeViz()
# Add each annotation as a track
for ann in annotations:
    gv.add_feature(
        seq_id=ann['seq_id'],
        start=ann['start'],
        end=ann['end'],
        strand=ann['strand'],
        label=ann['annotation']
    )

The code results in the following error traceback:

Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
AttributeError: 'GenomeViz' object has no attribute 'add_feature'

Environment Information:

  • PhaBOX version: v2.1.10
  • Python version: v3.12.3
  • pyGenomeViz version: v1.5.0
@KennthShang
Copy link
Owner

Since this is an issue caused by the GenomeViz, maybe you should seek them for better help (we are not the same team and I know little about their implementation).

But I think maybe it is caused by the version of your pygenomeviz.

As a suggestion provided by the GPT-4o, a potential correction may be:

from pygenomeviz import GenomeViz

# Initialize GenomeViz
gv = GenomeViz()

# Add tracks for each sequence/annotation
for ann in annotations:
    # Add a feature track for each sequence ID
    track = gv.add_feature_track(seq_id=ann['seq_id'])
    
    # Add features (annotations) to the track
    track.add_feature(
        start=ann['start'],
        end=ann['end'],
        strand=ann['strand'],
        label=ann['annotation']
    )

Best,
Jiayu

@Syutenjyo
Copy link
Author

Thank you for your prompt response and the suggested code. However, I am still encountering an error when using the code you provided. The error traceback I am getting is as follows:

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
TypeError: GenomeViz.add_feature_track() got an unexpected keyword argument 'seq_id'

Could you please tell me the version of the pygenomeviz package you are using? It might help me identify if the issue is related to version differences.

@KennthShang
Copy link
Owner

please check the API example in https://github.com/moshi4/pyGenomeViz

@KennthShang
Copy link
Owner

The version I am using is 1.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants