shahab-sarmashghi / RESPECT

Estimating repeat spectra and genome length from low-coverage genome skims
Other
11 stars 1 forks source link

TypeError: 'NoneType' object is not subscriptable #12

Closed bistace closed 1 year ago

bistace commented 1 year ago

Hello and thank you for developing RESPECT!

I am trying to run RESPECT on a set of public data (SRR17698145) but I am running into an error and don't know how to fix it. Could you please help me? Here is the complete log:

respect -i SRR17698145_1.fastq.gz SRR17698145_2.fastq.gz -o output --threads 24

2023-03-17 10:07:46,799 INFO:Processing SRR17698145_1.fastq.gz...
2023-03-17 10:12:13,826 INFO:compute_kmer_histogram finished in 241.29436254501343 seconds
2023-03-17 10:12:13,847 INFO:Processing SRR17698145_2.fastq.gz...
2023-03-17 10:16:12,393 INFO:compute_kmer_histogram finished in 208.6772701740265 seconds
2023-03-17 10:16:12,776 INFO:Starting iterations to estimate parameters of SRR17698145_1.fastq.gz
2023-03-17 10:16:12,790 INFO:Starting iterations to estimate parameters of SRR17698145_2.fastq.gz
2023-03-17 10:16:13,450 INFO:Set parameter WLSAccessID
2023-03-17 10:16:13,450 INFO:Set parameter WLSAccessID
2023-03-17 10:16:13,450 INFO:Set parameter WLSSecret
2023-03-17 10:16:13,450 INFO:Set parameter WLSSecret
2023-03-17 10:16:13,450 INFO:Set parameter LicenseID to value 945288
2023-03-17 10:16:13,450 INFO:Set parameter LicenseID to value 945288
2023-03-17 10:16:14,222 INFO:estimate_genome_skim_parameters finished in 1.7742846012115479 seconds
2023-03-17 10:16:14,223 ERROR:Error occurred when estimating parameters for /env/export/bigtmp2/ONT/test_respect/papaver_nudicaule/SRR17698145_1.fastq.gz; it's skipped
Traceback (most recent call last):
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/paramter_estimator.py", line 344, in __call__
    return self.estimate_genomic_parameters(*args, **kwargs)
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/paramter_estimator.py", line 326, in estimate_genomic_parameters
    self.estimate_genome_skim_parameters(spectra_number, error_norm, iterations_number, min_r1l, temperature)
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/timer.py", line 68, in wrapper_timer
    return func(*args, **kwargs)
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/paramter_estimator.py", line 281, in estimate_genome_skim_parameters
    optimizer.run_simulated_annealing(iterations_number, min_r1l, temperature)
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/optimizer.py", line 395, in run_simulated_annealing
    repeat_spectra_next = self.estimate_repeat_spectra(o[1:], poisson_matrix_next[1:, :])
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/optimizer.py", line 336, in estimate_repeat_spectra
    n_splines)]
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/optimizer.py", line 335, in <listcomp>
    spectral_residuals = [1.0 * constrained_spectra[i] / norm(constrained_spectra[i:], ord=1) for i in range(
TypeError: 'NoneType' object is not subscriptable
2023-03-17 10:16:14,225 ERROR:Error occurred while trying to get estimated parameters for a sample
2023-03-17 10:16:14,248 INFO:estimate_genome_skim_parameters finished in 1.7997772693634033 seconds
2023-03-17 10:16:14,248 ERROR:Error occurred when estimating parameters for /env/export/bigtmp2/ONT/test_respect/papaver_nudicaule/SRR17698145_2.fastq.gz; it's skipped
Traceback (most recent call last):
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/paramter_estimator.py", line 344, in __call__
    return self.estimate_genomic_parameters(*args, **kwargs)
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/paramter_estimator.py", line 326, in estimate_genomic_parameters
    self.estimate_genome_skim_parameters(spectra_number, error_norm, iterations_number, min_r1l, temperature)
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/timer.py", line 68, in wrapper_timer
    return func(*args, **kwargs)
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/paramter_estimator.py", line 281, in estimate_genome_skim_parameters
    optimizer.run_simulated_annealing(iterations_number, min_r1l, temperature)
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/optimizer.py", line 395, in run_simulated_annealing
    repeat_spectra_next = self.estimate_repeat_spectra(o[1:], poisson_matrix_next[1:, :])
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/optimizer.py", line 336, in estimate_repeat_spectra
    n_splines)]
  File "/opt/conda/envs/respect/lib/python3.7/site-packages/respect-1.3.0-py3.7.egg/respect/optimizer.py", line 335, in <listcomp>
    spectral_residuals = [1.0 * constrained_spectra[i] / norm(constrained_spectra[i:], ord=1) for i in range(
TypeError: 'NoneType' object is not subscriptable
2023-03-17 10:16:14,249 ERROR:Error occurred while trying to get estimated parameters for a sample
2023-03-17 10:16:14,355 INFO:Writing the results to the output files...
shahab-sarmashghi commented 1 year ago

Hi, is Gurobi license working? If you have installed it before you still need to renew it (the same way you installed it) every few months. This seems like a license issue to me. If you run RESPECT with --debug you will get more information regarding the error

bistace commented 1 year ago

Hello, adding --debug did not change the output of RESPECT. For the license, I ran gurobi_cl and got the following output:

Set parameter WLSAccessID
Set parameter WLSSecret
Set parameter LicenseID to value 945288
Set parameter LogFile to value "gurobi.log"
Academic license - for non-commercial use only - registered to benjamin.istace@genoscope.cns.fr
Using license file /opt/gurobi.lic
bistace commented 1 year ago

In the function solve_constrained_lp_using_gurobi of optimizer.py, I see this block:

if model.status == gurobipy.GRB.Status.OPTIMAL:
                solution = model.getAttr('x', r)
                return np.array(list(solution.values()))

If the status is not set to gurobipy.GRB.Status.OPTIMAL, the function will not return anything and the constrained_spectra in the estimate_repeat_spectra function of optimizer.py will be set to None, which is indeed not indexable. Could this be a possibility?

shahab-sarmashghi commented 1 year ago

That is a possibility, but I haven't encountered that before running it on many samples. Does the code even reach to that point? You can add a print statement to test that.

What happens when you try to run RESPECT on the toy data provided with the repository?

bistace commented 1 year ago

Hello,

you were right, it was indeed a license problem. After requesting a named-user license instead of a WLS license, RESPECT runs fine on test data.

Thanks a lot for your help!