bcgsc / straglr

Tandem repeat expansion detection or genotyping from long-read alignments
Other
69 stars 8 forks source link

TypeError: unsupported operand type(s) for /: 'str' and 'int' #11

Closed lfearnley closed 2 years ago

lfearnley commented 2 years ago

I'm encountering the following error running straglr 1.2.0:

    File "/home/ont_user/venv/bin/straglr.py", line 80, in <module>
      main()
    File "/home/ont_user/venv/bin/straglr.py", line 76, in main
      tre_finder.output_bed(variants, '{}.bed'.format(args.out_prefix))
    File "/home/ont_user/venv/lib/python3.8/site-packages/src/tre.py", line 1180, in output_bed
      copy_numbers.append(round(allele / len(variant[4]) , 1))
  TypeError: unsupported operand type(s) for /: 'str' and 'int'

Is this a known behaviour?

readmanchiu commented 2 years ago

@lfearnley, no this is not a known behaviour, I haven't encountered this bug before. Just checked the code and there is a check right before the statement to make sure the variable 'allele' is not a 'str' type. If you can share some data to let me reproduce the error, I can try to debug this.

lfearnley commented 2 years ago

@readmanchiu - I'll have to check whether we're able to share data; this is likely to take a few days. In the meantime I'll throw a few print statements in to have a look and see whether I can identify what is going on here.

kmnip commented 2 years ago

Hi @lfearnley,

Based on your error log, I am suspecting that you are not exactly using version 1.2.0 of Straglr.

For version 1.2.0, the main() function should be on line 83 instead of line 80: https://github.com/bcgsc/straglr/blob/ab3c7c06673d886423352b81bb7db53f9572dd2a/straglr.py#L83 tre_finder.output_bed(variants, '{}.bed'.format(args.out_prefix)) should be on line 79 instead of 76: https://github.com/bcgsc/straglr/blob/ab3c7c06673d886423352b81bb7db53f9572dd2a/straglr.py#L79

lfearnley commented 2 years ago

Aha, good pickup! The install instructions provided on the github repo install the current master, not the latest release.

In this particular case this was b2d4a4d378, which the version set at 1.2.0 in src/version.py, but isn't the eventual 1.2.0 release.

It may be worth updating the install instructions to avoid this happening?

readmanchiu commented 2 years ago

Thanks @kmnip for spotting this. My bad for making the versioning confusing. I've pushed some changes (tested) to the repo but haven't updated the version. But the error you see should still not be happening. If it's not too much work, @lfearnley, I would appreciate if you can put a print statement before line 1180 to print out the variable allele and its type to find out what is happening. In the meantime, I would do more extensive testing of the current code in the repo. Thanks for reporting the error.

lfearnley commented 2 years ago

Hi all, I'm sorry I've been delayed in getting back to you on this; unfortunately, we haven't been able to modify the code in our production environment to have a look at this in more detail.

I'll close this out for now - I'm chasing another strange behaviour at the moment (where straglr just isn't calling an expansion that's showing up in tandem-genotypes), and will reopen if I think this is linked.