marcelauliano / MitoHiFi

Find, circularise and annotate mitogenome from PacBio assemblies
MIT License
167 stars 27 forks source link

ValueError: max() arg is an empty sequence #34

Open peterdfields opened 1 year ago

peterdfields commented 1 year ago

Hi,

I'm trying to use MitoHiFi to assemble a multi-chromosome plant mitochondrial genome (though running the pipeline on individual chromosomes at a time). I'm using a singularity instance built from pulling the github repo a few days ago. Running the example dataset completes without any errors. When I try to run my own dataset, whether with reads or with a previously generated Hifiasm assembly, I start seeing errors such as the following:

/bin/MitoHiFi/parallel_annotation.py:50: UserWarning: Contig ptg000069l does not have an annotation file, check MitoFinder's log
  warnings.warn("Contig "+ contig_id + " does not have an annotation file, check MitoFinder's log")

And the runs eventually end with:

Traceback (most recent call last):
  File "/bin/MitoHiFi/mitohifi.py", line 377, in <module>
    main()
  File "/bin/MitoHiFi/mitohifi.py", line 263, in main
    tRNA_ref = fetch.get_ref_tRNA()
  File "/bin/MitoHiFi/fetch.py", line 40, in get_ref_tRNA
    reference_tRNA = max(tRNAs, key=tRNAs.get)
ValueError: max() arg is an empty sequence

Please let me know if any additional information would be helpful.

scorreard commented 1 year ago

Same issue here, did you find a solution?

scorreard commented 1 year ago

The issue for me was that MitoFinder was not working. Make sure it is in your PATH.

Hope this helps!

peterdfields commented 1 year ago

@scorreard Thank you for your message. I haven't tried modifying my PATH variable since I was using the singularity container. Were you using a singularity or did you build the pipeline dependencies up from scratch? Or something else?

benyoung93 commented 1 year ago

@scorreard @marcelauliano I am also having this problem now and I cannot for the life of me fix it.

  1. Install the conda env using the yml
  2. Install mitofinder in my local bin (i.e. not the conda env mitohifi bin). I followed the insturcitons for this and the install.sh.tru script shows it is successfully installed.
  3. Add mitofinder to my path and reintialise
  4. test mitofinder, typing it in shows it is in the path and executable
  5. install mitohifi using the method suggested in the read me.
  6. activate conda env and then run python mitohifi.py

When running the mitohifi.py it would not work as it could not find makeblastdb. So I added the path to blast bin which was installed in the mitofinder installation. After doing this I progress past the makeblastdb piece.

I thought this would also fix the error which I get re the reference t_rnas (the query poised above). So i added all the executable dependency folders from mitofinder into my path as well hoping this would fix this error. As if right now this has not allowed me to progress past this step (ie.e. the error above).

Does anyone have any ideas for fixes for this, I feel like i have tried everything and I am stumped at this point.

scorreard commented 1 year ago

Hi! Sorry @peterdfields , I missed your comment.

I had a bunch of issues, and ended up changing my approach altogether.

For singularity, I had to modify the python files to include the complete path, for example :

    repr_contig_get_gb = ["singularity", "run", "-B",  "/projects,/home", "/projects/scratch/singularity/MitoHiFi/mitofinder_v1.4.1.sif",
                        "--new-genes", "--max-contig-size",
                        str(max_contig_size), "-j", "final_mitogenome.annotation",
                        "-a", repr_contig_fasta, "-r", args.g, "-o", args.o, "-p", str(args.p),
                        "--circular-size", "8000"]

But I don't recommend that in the long term. I ended up downloading the code from Github (https://github.com/marcelauliano/MitoHiFi/archive/refs/tags/v2.2.zip) and it was much easier. It's not big and faster than troubleshooting the issues I had with containers.

HTH, Solenne

benyoung93 commented 1 year ago

Hi all

Thank you @scorreard for your added fixes, I have also got the V3 release to work the whole way through now woooooooooooooo.

Fix 1 - added blast to the yml so that it is installed in the conda environment. Can also link the MitoFinder Blast bin to your path to fix this, but I think in the env is more elegant.

Fix 2 - to fix the problem identified in the original post, it was obviously linked to MitoFinder and the trnascan dependency. As such I went into MitoFinder and ran the testdata for annotation only and lo and behold it did not work. Despite java being installed and loaded on our cluster, this was the problem. A simple module load java in my submission script fixed this for me, and I would maybe also recomend including openjdk into the yml for the conda environment. Also, interestingly, a colleague followed the install instructions in the same order as I did (same cluster, literally same everything) and did not have this empty argument. So I do not know what is going on there.

Interestingly, I have had no problems with singularity, what error would you get thrown for this ?

Ben

scorreard commented 1 year ago

Interesting! I may try it later on, I decided to wait for a stable release for V3. I may change my mind and try it again with your recommendation.

I can't remember the singularity issue.

Thanks for updating!

benyoung93 commented 1 year ago

Of course, good luck !!!!

scorreard commented 1 year ago

Hi everyone!

A quick update.

In order to use MitoHifi V3 from reads (rather than V2 from assembly), I installed MitoHifi V3 with conda (using 'mitohifi_env.yml' from MitoHifi GitHub), and MitoHifi to see how far it would go.

I obtained the same error message all over again

Command error:
  cat: gbk.HiFiMapped.bam.filtered.assembled.a_ctg.fa: No such file or directory
  Traceback (most recent call last):
    File "/projects/cbp/scratch/singularity/MitoHiFi/mitohifi.py", line 550, in <module>
      main()
    File "/projects/cbp/scratch/singularity/MitoHiFi/mitohifi.py", line 289, in main
      tRNA_ref = fetch.get_ref_tRNA()
    File "/projects/cbp/scratch/singularity/MitoHiFi/fetch.py", line 40, in get_ref_tRNA
      reference_tRNA = max(tRNAs, key=tRNAs.get)
  ValueError: max() arg is an empty sequence

I then 'manually' install MitoFinder following the instruction : https://github.com/RemiAllio/MitoFinder Adding the path to my bashrc (as explained in MitoFinder GitHub)

And then it worked. I think they have a problem with the singularity container, and I would suggest not using it until they generate a new one. That could be a new ticket to put that on the team's radar :)

michaeljmetzger commented 9 months ago

I am getting the same error. I have tried manually installing MitoFinder several times and cannot fix it. I get the same error when I use mitos. Does anyone have any other ideas?

michaeljmetzger commented 9 months ago

To clarify, with MitoFinder I get: File "/home/metzgerm/mybiotools/MitoHiFi/src/mitohifi.py", line 566, in main() File "/home/metzgerm/mybiotools/MitoHiFi/src/mitohifi.py", line 303, in main tRNA_ref = fetch.get_ref_tRNA() File "/home/metzgerm/mybiotools/MitoHiFi/src/fetch.py", line 48, in get_ref_tRNA reference_tRNA = max(tRNAs, key=tRNAs.get) ValueError: max() arg is an empty sequence

And with mitos I get: File "/home/metzgerm/mybiotools/MitoHiFi/src/mitohifi.py", line 566, in main() File "/home/metzgerm/mybiotools/MitoHiFi/src/mitohifi.py", line 301, in main tRNA_ref = fetch_mitos.get_ref_tRNA() File "/home/metzgerm/mybiotools/MitoHiFi/src/fetch_mitos.py", line 68, in get_ref_tRNA reference_tRNA = max(tRNAs, key=tRNAs.get) ValueError: max() arg is an empty sequence

I think I am at a wall.

xin0107 commented 2 months ago

The issue for me was that MitoFinder was not working. Make sure it is in your PATH.

Hope this helps!

That's right! In addition, the argument -t mitfi should be append to the mitofinder commend line, and make sure MiTFi is installed and added to configuration file of mitofinder. The above operations ensure that mitofinder is working properly, and this error can be eliminated. In my case, it worked!