GenomeRIK / tama

Transcriptome Annotation by Modular Algorithms (for long read RNA sequencing data)
GNU General Public License v3.0
125 stars 24 forks source link

tama_collapse.py bug: var_pos at last position in scaffold not taken into account and throws IndexError: list index out of range #97

Closed NLykoskoufis closed 1 year ago

NLykoskoufis commented 1 year ago

Hello,

I am using the tama_collapse.py script to collapse Isoseq transcripts. I am getting an error where the var_pos is at exactly the last position in the scaffold.

Command error:
  Traceback (most recent call last):
    File "/usr/local/tama/tama_collapse.py", line 6228, in <module>
      ref_allele = fasta_dict[scaffold][var_pos]
  IndexError: list index out of range

If var_pos is higher than the length of the scaffold or if var_pos is smaller than 0, the script just continues. However, when var_pos == len(scaffold), then it tries to extract the position from fasta_dict[scaffold][var_pos] and throws an IndexError.

code snippet line 6218-6222

if var_pos > len(fasta_dict[scaffold]) or var_pos < 0:
                print("Read mapping off scaffold")
                print(scaffold +" : "+ str(var_pos))
                print(var_cov_trans_id_list)
                continue

In my case I have a var_pos of 16569 which is the exact length of chrM scaffold.

tama_collapse.py fails when it tries to get the position at line 6228:

ref_allele = fasta_dict[scaffold][var_pos]

Since var_pos is 16,569 but the positions in the dictionary are 0 based, the last position of the scaffold is 16,568 thus it throws an error if not mistaken.

Thank you in advance for checking this out.. Kind regards, Nikos

GenomeRIK commented 1 year ago

Hi Nikos,

Thank you for using TAMA!

And thank you for pointing out this issue.

I have just corrected it and updated the repo. Could you try it again to see if it is now working ok for you?

Thank you, Richard

NLykoskoufis commented 1 year ago

Hi Richard,

Thank you for your prompt response. I have tried it and it works. Thank you very much.

Nikos