Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • prs321
    Member
    • Jun 2013
    • 96

    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.
  • rhinoceros
    Senior Member
    • Apr 2013
    • 372

    #2
    Why not just make it a shell script?

    script.sh
    Code:
    BWA-MEM $1
    sh script.sh yourfile.txt
    savetherhino.org

    Comment

    • dpryan
      Devon Ryan
      • Jul 2011
      • 3478

      #3
      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.

      Comment

      • prs321
        Member
        • Jun 2013
        • 96

        #4
        I was told specifically to make a python script because it is more stable.

        Comment

        • dpryan
          Devon Ryan
          • Jul 2011
          • 3478

          #5
          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.

          Comment

          • liux
            Member
            • Mar 2009
            • 30

            #6
            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.

            Comment

            • themerlin
              Member
              • Feb 2010
              • 51

              #7
              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.

              Comment

              Latest Articles

              Collapse

              • SEQadmin2
                Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                by SEQadmin2


                I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

                Here are nine questions we think about, in roughly the order they matter, before...
                06-18-2026, 07:11 AM
              • SEQadmin2
                From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
                by SEQadmin2


                Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


                The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
                ...
                06-02-2026, 10:05 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, Today, 05:37 AM
              0 responses
              5 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-26-2026, 11:10 AM
              0 responses
              16 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-17-2026, 06:09 AM
              0 responses
              50 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-09-2026, 11:58 AM
              0 responses
              109 views
              0 reactions
              Last Post SEQadmin2  
              Working...