KGerhardt / RecruitPlotEasy

A tool for interactive Recruitment Plot generation and viewing
4 stars 3 forks source link

TypeError: 'NoneType' object is not subscriptable #8

Open olkol321 opened 1 year ago

olkol321 commented 1 year ago

Getting an error at the database build step:

Adding reads. Traceback (most recent call last): File "/home/ok321/anaconda3/bin/rpe", line 8, in sys.exit(main()) File "/home/ok321/anaconda3/lib/python3.7/site-packages/rpe2_code/rpe2_main.py", line 14, in main run_build() File "/home/ok321/anaconda3/lib/python3.7/site-packages/rpe2_code/recruit_plot_easy_2_database.py", line 278, in run_build mn.add_reads_to_db(reads) File "/home/ok321/anaconda3/lib/python3.7/site-packages/rpe2_code/recruit_plot_easy_2_database.py", line 166, in add_reads_to_db query_gen = '"'+grouping[0]+'"' TypeError: 'NoneType' object is not subscriptable

Is something wrong with the sam/bam files? I tried both formats and indexed bam as well, but keep getting this error.

Looking forward to using this tool, the plots are so beautiful!

KGerhardt commented 1 year ago

Two reasons I can think of:

  1. You have unaligned reads in your BAM file. These would be missing data in their reference genome field, which would cause the read parser of RPE to fail. Bowtie2 would need the --no-unal flag, or equivalent for another read mapper.
  2. The BAMs you have do not have their MD tags filled, which would result in an inability for RPE to calculate percent identity. BAM files can have these fields filled after the fact using samtools calmd function - http://www.htslib.org/doc/samtools-calmd.html

However, this also appears to be an oversight in my own code. I created conditions whereby a read might return with a None value should either of the above cases occur, but then didn't actually put in code to handle Nones. And my testing data didn't produce the error, since it satisfied both of the above conditions in all cases.

I will attempt to fix the issue within the code - however, this will only be a true fix for the first problem. If it is the case that the error is caused by the second issue, it's not something I can actually solve within RPE. The result of handling that second error would be that the sample added would have 0 passing reads, and therefore lack any data to plot. The calmd fix would need to be done in either case. I will add this to the documentation as a possible source of errors after I figure out the code problems.

On Tue, Nov 15, 2022 at 12:27 PM olkol321 @.***> wrote:

Getting an error at the database build step:

Adding reads. Traceback (most recent call last): File "/home/ok321/anaconda3/bin/rpe", line 8, in sys.exit(main()) File "/home/ok321/anaconda3/lib/python3.7/site-packages/rpe2_code/rpe2_main.py", line 14, in main run_build() File "/home/ok321/anaconda3/lib/python3.7/site-packages/rpe2_code/recruit_plot_easy_2_database.py", line 278, in run_build mn.add_reads_to_db(reads) File "/home/ok321/anaconda3/lib/python3.7/site-packages/rpe2_code/recruit_plot_easy_2_database.py", line 166, in add_reads_to_db query_gen = '"'+grouping[0]+'"' TypeError: 'NoneType' object is not subscriptable

Is something wrong with the sam/bam files? I tried both formats and indexed bam as well, but keep getting this error.

Looking forward to using this tool, the plots are so beautiful!

— Reply to this email directly, view it on GitHub https://github.com/KGerhardt/RecruitPlotEasy/issues/8, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGZXG3MDPYJYDC7WY7YYWVDWIPBZPANCNFSM6AAAAAASBF2O6Y . You are receiving this because you are subscribed to this thread.Message ID: @.***>

Haelmorn commented 1 year ago

Unfortunately I have stumbled upon the same error - neither filtering out unmapped reads (even though there aren't any in the files I'm processing) nor using samtools calmd seems to work. Any updates on this issue?