SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
python script modification of LSC0.2.4 ? arthur.yxt Bioinformatics 0 06-11-2013 01:32 PM
Error running oases_pipeline python script InesSoriguer Illumina/Solexa 4 05-21-2013 02:10 AM
gatk python script m_elena_bioinfo Bioinformatics 7 11-20-2011 06:40 AM
DEXSeq python script error message shilez Bioinformatics 4 09-08-2011 10:55 PM
About script to combine steps of BWA CNVboy Bioinformatics 5 06-22-2011 06:16 AM

Reply
 
Thread Tools
Old 07-15-2013, 06:41 AM   #1
prs321
Member
 
Location: US

Join Date: Jun 2013
Posts: 96
Default How would I go about calling BWA from a python script?

I am trying to make a python script that reads in a text file of pair end reads and then calls BWA mem on the pairs and outputs SAM files.
prs321 is offline   Reply With Quote
Old 07-15-2013, 06:45 AM   #2
rhinoceros
Senior Member
 
Location: sub-surface moon base

Join Date: Apr 2013
Posts: 372
Default

Why not just make it a shell script?

script.sh
Code:
BWA-MEM $1
sh script.sh yourfile.txt
rhinoceros is offline   Reply With Quote
Old 07-15-2013, 06:45 AM   #3
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

os.system, os.popen, os.fork, etc. There are a few different ways to do that, each with their pros and cons.

Edit: As rhinoceros mentions, depending on the amount of processing you want done, this would normally performed via shell script.
dpryan is offline   Reply With Quote
Old 07-15-2013, 07:06 AM   #4
prs321
Member
 
Location: US

Join Date: Jun 2013
Posts: 96
Default

I was told specifically to make a python script because it is more stable.
prs321 is offline   Reply With Quote
Old 07-15-2013, 07:14 AM   #5
dpryan
Devon Ryan
 
Location: Freiburg, Germany

Join Date: Jul 2011
Posts: 3,480
Default

You can ignore whomever told you that, he/she doesn't have a clue.

Python is more powerful, in that you can certainly do more with it easily, but doing something simple like stitching together a pipeline is often easier to do in a shell script (that's their intended purpose).

There are a lot of tools, learning which ones are most convenient for what situations are an important (and error ridden) part of the learning process.
dpryan is offline   Reply With Quote
Old 07-15-2013, 07:42 AM   #6
liux
Member
 
Location: Midwest

Join Date: Mar 2009
Posts: 30
Default

If you have to, use subprocess package. It should work fine.

I think shell script is straightforward, and should be used, if all it does is to run a simple command. But I prefer python when the pipeline is complex.

In my case, it is a little more complicated. In one of pipelines I created in python, I need to submit jobs to clusters. It is so much easier to read run configuration file, parse out sample name, create proper path, make meaningful job name in python (try it in bash script, you will know why I prefer python). However the submitted command errored out when it submitted from python, but pasted the print-out commands in terminal worked fine without any problem. I did not have time to find out a solution, so I let the python script generate a full set of shell commands with all the path, parameters, job dependencies, etc, nicely made, output to a xxxx.sh file, and run the shell script afterward. I probably did it backward, and need to do one extra step, but it did work well. I COULD have done all of it in shell script but then I am not so good at shell script, especially when it comes to text manipulation.
liux is offline   Reply With Quote
Old 07-15-2013, 07:48 AM   #7
themerlin
Member
 
Location: Flagstaff, AZ

Join Date: Feb 2010
Posts: 51
Default

If you will have future python scripts that will use BWA, then it would be worth the time to create a python function that calls bwa. If it is a one time thing, a shell script should be fine.
themerlin is offline   Reply With Quote
Old 07-07-2019, 05:20 AM   #8
brojee
Member
 
Location: Bhopal

Join Date: Jul 2019
Posts: 19
Default

On the off chance that you need to, use subprocess bundle. It should work fine.

I think shell content is direct, and ought to be utilized, if everything it does is to run a basic order. In any case, I lean toward python when the pipeline is intricate.

For my situation, it is somewhat more entangled. In one of pipelines I made in python, I have to submit occupations to bunches. It is such a great amount of simpler to peruse run setup document, parse out example name, make appropriate way, make significant employment name in python (attempt it in slam content, you will know why I lean toward python). Anyway the submitted order errored out when it submitted from python, however glued the print-out directions in terminal worked fine with no issue. I didn't have sufficient energy to discover an answer, so I let the python content produce a full arrangement of shell directions with all the way, parameters, work conditions, and so forth, pleasantly made, yield to a xxxx.sh record, and run the shell content thereafter. I most likely did it in reverse, and need to complete one additional progression, yet it worked well. I COULD have done every last bit of it in shell content however then I am not all that great at shell content, particularly with regards to content control.
I hope that was helpfu.
brojee is offline   Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 11:14 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO