Errors with normalize_by_copy_number.py in PICRUSt

164 views
Skip to first unread message

Sarah Hancock

unread,
Feb 25, 2021, 5:02:03 PM2/25/21
to picrust-users
Hi there, 
I tried to run the script normalize_by_copy_number.py in the command line and I am getting this error: 
File "normalize_by_copy_number.py", line 72

    print "Loading trait table: ", input_count_table

          ^

SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Loading trait table: ", input_count_table)?


When I edited the script and added parentheses, and ran it again, it gives this: 

File "normalize_by_copy_number.py", line 110

    raise ValueError,\

                    ^

SyntaxError: invalid syntax

How do I fix this? Is there an updated normalize_by_copy_number.py file for PICRUSt that runs? 

Thanks!

Screen Shot 2021-02-25 at 5.01.34 PM.png

Gavin Douglas

unread,
Feb 25, 2021, 5:47:00 PM2/25/21
to 'cervant...@licifug.ugto.mx' via picrust-users
Hey there,

The requirement for parentheses to be present was added in Python 3, while PICRUSt1 requires Python 2. I think there must be something wrong with your installation. I would recommend re-installing and making sure it's in a Python 2 environment (which you could specify with conda).


Cheers,

Gavin
--
You received this message because you are subscribed to the Google Groups "picrust-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to picrust-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/picrust-users/285011ec-5eef-4830-9321-92dd51fd25adn%40googlegroups.com.

Sarah Hancock

unread,
Feb 25, 2021, 7:43:38 PM2/25/21
to picrust-users
Thanks for the quick response. I will look into creating a Python 2 environment, which I'm not entirely sure how to do but I'm sure google does.

Thanks, 

Sarah Hancock
Emory University 

Gavin Douglas

unread,
Feb 25, 2021, 8:30:46 PM2/25/21
to 'cervant...@licifug.ugto.mx' via picrust-users
No worries! The conda command for installing PICRUSt1 are listed here, which should work for you: http://picrust.github.io/picrust/install.html#install


Cheers,

Gavin

Sarah Hancock

unread,
Mar 4, 2021, 4:35:06 PM3/4/21
to picrust-users
Hi Gavin, 

So I originally downloaded Picrust1 with the link you sent me. On my computer I have Python2, Python2.7, all the way up to Python 3.8. I tried calling Python2.7 and running the script and it still did not work. The attached images shows running the script in python 2.7. I also called Python2 and ran the script and it gives the same error. 

Would uninstalling it still help?
If this does not work should the next step be downloading PICRUSt2 instead? 

Thanks, 
Sarah Hancock
Emory University

Screen Shot 2021-03-04 at 4.28.36 PM.png
Screen Shot 2021-03-04 at 4.34.15 PM.png

Gavin Douglas

unread,
Mar 4, 2021, 5:37:55 PM3/4/21
to picrus...@googlegroups.com
Hey Sarah,

I think there must be something wrong with the Python environment you’re working with because that is a Python 2 vs Python 3 error for sure. You could try using the galaxy interface instead: http://galaxy.morganlangille.com/

You can definitely use PICRUSt2 instead - on a laptop you might have the most luck running the SEPP version of the QIIME 2 plugin tutorial: https://github.com/picrust/picrust2/wiki/q2-picrust2-Tutorial


Cheers,

Gavin



To view this discussion on the web visit https://groups.google.com/d/msgid/picrust-users/8006f97a-1804-443a-9400-807908f74f51n%40googlegroups.com.
<Screen Shot 2021-03-04 at 4.28.36 PM.png><Screen Shot 2021-03-04 at 4.34.15 PM.png>

Sarah Hancock

unread,
Mar 4, 2021, 6:08:03 PM3/4/21
to picrust-users
Hi there, 

Okay I will try to uninstall PICRUSt and make sure to put it in the correct environment.  On the other hand, I have tried using Galaxy before to create a workflow and I get error messages. When I try to run the workflow Input Data --> Normalize by copy number --> Predict Metagenome I get this error with Sample biom Data:

Fatal error: Exit code 1 ()
Traceback (most recent call last):
  File "/home/galaxy/galaxy/tools/picrust_galaxy/normalize_by_copy_number.py", line 132, in <module>
    main()
  File "/home/galaxy/galaxy/tools/picrust_galaxy/normalize_by_copy_number.py", line 85, in main
    count_table = convert_precalc_to_biom(count_table_fh, ids_to_load)
  File "/home/galaxy/galaxy/.venv/local/lib/python2.7/site-packages/picrust/util.py", line 101, in convert_precalc_to_biom
    raise ValueError,"One or more OTU ids were not found in the precalculated file!\nAre you using the correct --gg_version?\nExample of (the {0}) unknown OTU ids: {1}".format(len(ids_to_load),', '.join(list(ids_to_load)[:5]))
ValueError: One or more OTU ids were not found in the precalculated file!
Are you using the correct --gg_version?
Example of (the 276) unknown OTU ids: 323445, 465087, 140061, 165676, 307981
'

And this Error when I run it with my experimental biom data:

Fatal error: Exit code 1 ()
Traceback (most recent call last):
  File "/home/galaxy/galaxy/tools/picrust_galaxy/normalize_by_copy_number.py", line 132, in <module>
    main()
  File "/home/galaxy/galaxy/tools/picrust_galaxy/normalize_by_copy_number.py", line 85, in main
    count_table = convert_precalc_to_biom(count_table_fh, ids_to_load)
  File "/home/galaxy/galaxy/.venv/local/lib/python2.7/site-packages/picrust/util.py", line 98, in convert_precalc_to_biom
    raise ValueError,"No OTUs match identifiers in precalculated file. PICRUSt requires an OTU table reference/closed picked against GreenGenes.\nExample of the first 5 OTU ids from your table: {0}".format(', '.join(list(ids_to_load)[:5]))
ValueError: No OTUs match identifiers in precalculated file. PICRUSt requires an OTU table reference/closed picked against GreenGenes.
Example of the first 5 OTU ids from your table: 50af92111d1cc3dd9110795e6d4c9ab4, 590bd75259fa1fd51d554a938c17f622, ad3cdf30f7fc76062d8d89d63f70dbbd, 99c016f0143cf03a39a619c7ec820dc2, 24844049657ccb2116826f5e10fb371b

So with these errors, that is why I tried to do it directly through PICRUSt 

Gavin Douglas

unread,
Mar 8, 2021, 8:07:31 AM3/8/21
to picrus...@googlegroups.com
Hey there,

Actually you will run into exactly the same errors with the command-line version of PICRUSt1. The problem is that the expected 97% Greengenes OTU ids weren’t found (which is what the OTU ids need to be by default) and the ids in the file aren’t recognized. If you run PICRUSt2 you can avoid this problem! If you are low on memory (< 16 GB RAM) I would recommend running the SEPP to place sequences (as described in the QIIME 2 plugin tutorial).


Cheers,

Gavin

Reply all
Reply to author
Forward
0 new messages