python, bowtie and bad coding practices

I did Biochemistry, and then I jumpt to Bioinformatics, so you can imagine that my programming skills are focused on getting a quick result, and not a great, clean, and very documented code.

So what happen when someone like me creates a python script, which calls bowtie to be executed using os.sytem() function, and you call the fasta file: temp.fa? (because is a temporal file, so it is an obvious name, right?)

well bowtie gives you a warning saying that: there are no sequences in the input file!!!!

I though, shit! I am generating a empty fasta file, probably because I chose the wrong column when writing the file….But not, I checked the temp.fa file, and had a lot of sequences.

So, I directly typed the same command in the shell, and everything worked perfectly. So, WHAT!!!!!

A few days later, I tried again, and I realized that I haven’t closed the file before sending the command line to be executed. So, for the system, the file was empty, but I saw it full of sequences when I checked it, because the file is closed when the script ends.

This is a good reason to use good coding practices, and also to use the warnings option to debug your code, it would save you a lot of time in many situations.

Thanks python and bowtie community/developers to give easy-to-use tools for my work

Advertisements

About lpantano

Post-doctoral fellow at IBB PhD in Biomedicine at UPF Msc in Bioinformatics for health science Bachelor in Biochemistry at UG
This entry was posted in coding and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s