tschuelia / PyPythia

Lightweight python library for predicting the difficulty of alignments in phylogenetics
GNU General Public License v3.0
16 stars 0 forks source link

TypeError: '>' not supported between instances of 'NoneType' and 'int' #13

Closed liamxg closed 10 months ago

liamxg commented 10 months ago

Dear @tschuelia,

if the predicted difficulty for MSA is: 0.64, it is very hard or hard?

Edit from @tschuelia:

The original issue was:

Dear @tschuelia I have error:

(base) simon@192 raxml-ng_v1.2.0_macos_x86_64 % pythia -m data/example.phy -r raxml-ng -v -b
PyPythia version 1.0.1 released by The Exelixis Lab
Developed by: Julia Haag
Latest version: [tschuelia/PyPythia](https://github.com/tschuelia/PyPythia)
Questions/problems/suggestions? Please open an issue on GitHub.

[00:00:00] Starting prediction.
[00:00:00] Loading predictor /Users/simon/opt/miniconda3/lib/python3.9/site-packages/pypythia/predictors/predictor_lgb_v1.0.0.pckl
[00:00:01] Checking MSA
[00:00:01] Starting to compute MSA features for MSA data/example.phy
[00:00:01] Retrieving num_patterns, percentage_gaps, percentage_invariant
[00:00:01] Retrieving num_taxa, num_sites
[00:00:01] Inferring 100 parsimony trees
[00:00:04] Computing the RF-Distance for the parsimony trees
[00:00:14] Predicting the difficulty
Traceback (most recent call last):
File "/Users/simon/opt/miniconda3/lib/python3.9/site-packages/pypythia/predictor.py", line 86, in predict
prediction = self.predictor.predict(df, num_threads=1)
File "/Users/simon/opt/miniconda3/lib/python3.9/site-packages/lightgbm/sklearn.py", line 899, in predict
predict_params = self._process_params(stage="predict")
File "/Users/simon/opt/miniconda3/lib/python3.9/site-packages/lightgbm/sklearn.py", line 674, in _process_params
if self._n_classes > 2:
TypeError: '>' not supported between instances of 'NoneType' and 'int'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/simon/opt/miniconda3/bin/pythia", line 10, in
sys.exit(main())
File "/Users/simon/opt/miniconda3/lib/python3.9/site-packages/pypythia/prediction.py", line 259, in main
difficulty = predictor.predict(msa_features)
File "/Users/simon/opt/miniconda3/lib/python3.9/site-packages/pypythia/predictor.py", line 92, in predict
raise PyPythiaException(
pypythia.custom_errors.PyPythiaException: An error occurred predicting the difficulty for the provided set of MSA features.

I'm keeping this to make sure other uses having the same error can find the solution 🙂

tschuelia commented 10 months ago

Hi Liam, we just had this error recently with a colleague as well and it turned out that conda sometimes installs an old version of PyPythia (1.0.1 as can be seen in the first line of the output), but the current version is 1.1.4. Can you try to upgrade PyPythia by typing conda install pypythia=1.1.4, or (even better) try to create a new conda environment (conda env create -n pythia and conda activate pythia) and install PyPythia again (conda install pypythia -c conda-forge), that should automatically install the correct latest version. Let me know if that works! 🙂

liamxg commented 10 months ago

Dear @tschuelia, Thank you for your great help.

I am confused again, which one should I use: conda install pypythia=1.1.4 or conda install pypythia -c conda-forge or conda install pypythia -c conda-forge -c nodefaults

tschuelia commented 10 months ago

Hi @liamxg, sorry for the confusion!

In theory, all three commands should do the same thing if you are installing Pythia in a new conda environment. However, when you are adding Pythia to an existing environment, some previous configurations might result in conda solving for an old version of Pythia (it solved for 1.0.1 in your initial error) causing Pythia to fail du to mismatching versions. In this case conda install pypythia=1.1.4 explicitly asks conda to install the 1.1.4 version. The modifier -c coda-forge tells conda in which channel to look for Pythia and -c nodefaults means to not use the default conda packages, as they are sometimes broken and it's better to use the conda-forge builds.

As for your question on the difficulty of your MSA: I opened a new issue (#14) for your new question. Please don't change the title and text of an issue to make sure other uses who might have a similar issue can find the solution as well 🙂

liamxg commented 10 months ago

Dear @tschuelia, thanks.