WGLab/DeepMod2

TypeError: unsupported operand type(s) for +: 'int' and 'list'

qtran1 opened this issue · 3 comments

I tried to do methylation call with deepmod2 and got this error:

Command: python /hpcf/authorized_apps/rhel8_apps/deepmod2/install/03292024/deepmod2 detect --model bilstm_r10.4.1_5khz_v4.3 --file_type pod5 --bam MA_22_00277_hac_aligned_moveTables.bam --input /research/groups/tatevgrp/projects/ONT-EMseq/common/EMseq-1-plex/MA-22-00277/20240321_1727_MN44724_FAX67420_067f3356/pod5_pass/ --output ./deepmod2/ --ref /home/qtran/ref_genomes/hg38.fa --threads 8

2024-03-29 15:32:36.273657: Starting Per Read Methylation Detection.
[E::idx_find_and_load] Could not retrieve index file for 'MA_22_00277_hac_aligned_moveTables.bam'
2024-03-29 15:32:36.377280: Getting motif positions from the reference.
2024-03-29 15:37:16.641224: Finished getting motif positions from the reference.
[E::idx_find_and_load] Could not retrieve index file for 'MA_22_00277_hac_aligned_moveTables.bam'
2024-03-29 15:37:16.701409: Building BAM index.
2024-03-29 15:51:03.729949: Finished building BAM index.
Process Process-13:
Traceback (most recent call last):
File "/hpcf/authorized_apps/rhel8_apps/deepmod2/install/deepmod2-env/lib/python3.10/multiprocessing/process.py", line 314, in _bootstrap
self.run()
File "/hpcf/authorized_apps/rhel8_apps/deepmod2/install/deepmod2-env/lib/python3.10/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/research/rgs01/applications/hpcf/authorized_apps/rhel8_apps/deepmod2/vendor/DeepMod2/src/detect.py", line 472, in process
pos_list_c, pos_list_candidates, read_to_ref_pairs=get_candidates(fq, align_data, aligned_pairs, ref_pos_dict, motif_seq, motif_base, motif_ind, position_based)
File "/research/rgs01/applications/hpcf/authorized_apps/rhel8_apps/deepmod2/vendor/DeepMod2/src/detect.py", line 97, in get_candidates
motif_id=np.array([[m.start(0)+motif_ind,-1] for m in re.finditer(r'{}'.format(motif_seq), read_seq)])
File "/research/rgs01/applications/hpcf/authorized_apps/rhel8_apps/deepmod2/vendor/DeepMod2/src/detect.py", line 97, in
motif_id=np.array([[m.start(0)+motif_ind,-1] for m in re.finditer(r'{}'.format(motif_seq), read_seq)])
TypeError: unsupported operand type(s) for +: 'int' and 'list'

Hi folks,

I'm getting the same thing.

I believe this may be due to a new change in the code. I built deepmod2-env from environment.yml as the instructions mention, but installed it in a custom location.

I believe this error could be fixed by modifying the code from:

motif_id=np.array([[m.start(0)+motif_ind,-1] for m in re.finditer(r'{}'.format(motif_seq), read_seq)])

To:

motif_id=np.array([[m.start(0)+motif_ind[0],-1] for m in re.finditer(r'{}'.format(motif_seq), read_seq)])

if motif_ind is a single-element array at this point.

Anyway, please let us know. :)

Thanks,
Walid

Hi @qtran1,

Thank you for bringing this to our attention. The issue has been fixed and you should not be getting this error now.

@walidabualafia thank you for your suggestion. I updated the code to a more general situation where all motif indices can be accommodated.

Best,
Umair

Hi @umahsn,

Thank you for fixing the issue. I tested it and it ran fine.

Best,
Quynh