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

Error in ppanggolin msa when running all partitions #198

Closed
ktmeaton opened this issue Mar 20, 2024 · 3 comments
Closed

Error in ppanggolin msa when running all partitions #198

ktmeaton opened this issue Mar 20, 2024 · 3 comments
Labels

Comments

@ktmeaton
Copy link
Contributor

I'm getting an error when I try to run ppanggolin msa with --partition all:

2024-03-20 17:46:53 writeMSA.py:l214 INFO       Computing the MSA ...
Traceback (most recent call last):
  File "/home/username/.conda/envs/ppanggolin-2.0.4/bin/ppanggolin", line 10, in <module>
    sys.exit(main())
  File "/home/username/.conda/envs/ppanggolin-2.0.4/lib/python3.10/site-packages/ppanggolin/main.py", line 197, in main
    ppanggolin.formats.writeMSA.launch(args)
  File "/home/username/.conda/envs/ppanggolin-2.0.4/lib/python3.10/site-packages/ppanggolin/formats/writeMSA.py", line 348, in launch
    write_msa_files(pangenome, args.output, cpu=args.cpu, partition=args.partition, tmpdir=args.tmpdir,
  File "/home/username/.conda/envs/ppanggolin-2.0.4/lib/python3.10/site-packages/ppanggolin/formats/writeMSA.py", line 325, in write_msa_files
    compute_msa(families, outdir, cpu=cpu, tmpdir=tmpdir, source=source, use_gene_id=use_gene_id, code=code,
  File "/home/username/.conda/envs/ppanggolin-2.0.4/lib/python3.10/site-packages/ppanggolin/formats/writeMSA.py", line 215, in compute_msa
    bar = tqdm(range(len(families)), unit="family", disable=disable_bar)
TypeError: object of type 'generator' has no len()

I think the issue might be that when you use the all partition, the gene families are a generator in get_families_to_write. But for any non-all partition (ex. core), the gene families are a set:

families = set()
nb_org = pangenome.number_of_organisms
if partition_filter == "all":
return pangenome.gene_families

Which then fails when it tries to call the len method on a generator in compute_msa:

bar = tqdm(range(len(families)), unit="family", disable=disable_bar)

If I change the return value to a set in get_families_to_write, it seems to work!

if partition_filter == "all":
    return set(pangenome.gene_families)

Is this a reproducible error for other users, and does this solution seem feasible? Thanks!

@axbazin
Copy link
Member

axbazin commented Mar 21, 2024

Hi,

The problem is indeed reproducible, and the solution is exactly the one we're going for.

It will be coming up as soon as we merge #196 and get it to the next patch release.

Thank you for the bug report !

Adelme

@axbazin axbazin added the bug label Mar 21, 2024
@ktmeaton
Copy link
Contributor Author

Thank you!

@JeanMainguy
Copy link
Member

The fix has been released in version 2.0.5.
It should be available in bioconda very soon.

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

No branches or pull requests

3 participants