Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7570397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T15:24:55+00:00 2026-05-30T15:24:55+00:00

I asked a similar question before, but got no helpful response so I will

  • 0

I asked a similar question before, but got no helpful response so I will try to make things more clear.

What I am looking for is to run a multithreaded or preferably multiprocessing approach to a certain linux command. If anyone is familiar with Picard, I am wanting to run an earlier version on a bam file and at the same time run a newer version on the same bam file. The idea is to test how much quicker the newer version is and if it gives the same result.

My major problem is that I have no idea how to implement multiprocessing on a Popen command. E.g.

cmd1 = ['nice', 'time', 'java', '-Xmx6G', '-jar', '/comparison/old_picard/MarkDuplicates.jar', 'I=/comparison/old.bam', 'O=/comparison/old_picard/markdups/old.dupsFlagged.bam', 'M=/comparison/old_picard/markdups/old.metrics.txt', 'TMP_DIR=/comparison', 'VALIDATION_STRINGENCY=LENIENT', 'ASSUME_SORTED=true']
cmd2 = ['nice', 'time', 'java', '-Xmx6G', '-jar', '/comparison/new_picard/MarkDuplicates.jar', 'I=/comparison/new.bam', 'O=/comparison/new_picard/markdups/new.dupsFlagged.bam', 'M=/comparison/new_picard/markdups/new.metrics.txt', 'TMP_DIR=/comparison', 'VALIDATION_STRINGENCY=LENIENT', 'ASSUME_SORTED=true']

c1 = subprocess.Popen(cmd1, stdout=subprocess.PIPE)
c2 = subprocess.Popen(cmd2, stdout=subprocess.PIPE)

And then I have a timer function:

def timeit(c):
    past = time.time()
    results = [c.communicate()]
    present = time.time()
    total = present - past
    results.append(total)
    return results

What I WANT to do is this:

p = Process(target=timeit, args=(c1,c2))
p.start()
p.join()

However I get “Popen object not iterable” error. Does anyone have a better idea than what I have now? I don’t want to go off in a completely different direction only to hit another wall. In summary I want to run c1 on one cpu and c2 on the other at the same time, Please help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T15:24:57+00:00Added an answer on May 30, 2026 at 3:24 pm

    Instead of passing the subprocess.Popen (which will run them serially instead of in parallel when it is first defined), pass the command:

    import time
    import subprocess
    from multiprocessing import Process
    
    cmd1 = ['nice', 'time', 'java', '-Xmx6G', '-jar', '/comparison/old_picard/MarkDuplicates.jar', 'I=/comparison/old.bam', 'O=/comparison/old_picard/markdups/old.dupsFlagged.bam', 'M=/comparison/old_picard/markdups/old.metrics.txt', 'TMP_DIR=/comparison', 'VALIDATION_STRINGENCY=LENIENT', 'ASSUME_SORTED=true']
    cmd2 = ['nice', 'time', 'java', '-Xmx6G', '-jar', '/comparison/new_picard/MarkDuplicates.jar', 'I=/comparison/new.bam', 'O=/comparison/new_picard/markdups/new.dupsFlagged.bam', 'M=/comparison/new_picard/markdups/new.metrics.txt', 'TMP_DIR=/comparison', 'VALIDATION_STRINGENCY=LENIENT', 'ASSUME_SORTED=true']
    
    def timeit(cmd):
        print cmd
        past = time.time()
        p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
        results = [p.communicate()]
        present = time.time()
        total = present - past
        results.append(total)
        return results
    
    p1 = Process(target=timeit, args=(cmd1,))
    p2 = Process(target=timeit, args=(cmd2,))
    
    for p in (p1, p2):
        p.start()
    for p in (p1, p2):
        p.join()
    

    ETA: While the above solution is the way to do multiprocessing in general, @Jordan is exactly right that you shouldn’t use this approach to time two versions of software. Why not run them sequentially?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

OK, I had asked a similar question before and had got an answer but
I've asked a similar question before, but I've done some more research and this
I asked similar question before and got some nice code, but i'm concerned with
A similar question was asked before , but I'm looking for a jQuery solution
I asked a similar question before, and got some good answers, but I think
I have asked a similar question before, but I didn't have a firm grasp
I have asked a similar question before and got an convincing answer as well?
I've asked very similar question before and should have mentioned more detailed. Last time
I have asked a similar question before, but didn't get very good results. I've
I have asked a similar question before and while the answers I got were

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.