Search code examples
pythonwindowsbioinformaticsvcf-variant-call-format

Running with IDLE vs running the script


So I have some Python Code (Running Python 2.7.12), which uses VEP to annotate a vcf file against specific transcripts.

When I run the script by double clicking on it (Or running it from command prompt) it gives the following error:

C:\annotatetsca_KH\annotate.py:364: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal

if transcript in specified_transcripts:

This then causes some variants to not be annotated against specified transcript. However if I load the script into IDLE and then run exactly the same code through IDLE I do not get this error and the variants are annotated correctly.

Does anyone know why running the script through IDLE would yield different results? As far as I knew, and from some colleagues I've spoken to, IDLE and Python should treat everything exactly the same. And does anyone know a way to get around having to run the script through IDLE to avoid this error as this script is used by a number of people who aren't familiar with Python/IDLE and would find it much easier to just run the script by double clicking it (like any other Windows application).

EDIT (SOLVED):

I found the cause of the problem. The a few of the transcripts in the transcript list had a space at the end. It appears that IDLE strips trailing spaces but running the python script directly does not. So when running it directly the trailing space got converted to "\xa0", so when it was trying to match the transcript to one in the specified list it did not match. I've removed all spaces and it works fine, and I'll also add a line to remove any spaces when loading in the transcript list!


Solution

  • I found the cause of the problem. The a few of the transcripts in the transcript list had a space at the end. It appears that IDLE strips trailing spaces but running the python script directly does not. So when running it directly the trailing space got converted to "\xa0", so when it was trying to match the transcript to one in the specified list it did not match. I've removed all spaces and it works fine, and I'll also add a line to remove any spaces when loading in the transcript list!