Monday, March 28, 2011

Phylip command-line

Phylip is a a pain in the ass when you're running it from a command line. You need to create a file which has all interactive prompts and then feed that along.

phylip proml < input > screenout

However, this is ANNOYING to do with python's subprocess module. It can't deal with the redirections so you have to use the subprocess input/output:

        if capture_output:
            out = open('screenout', 'w')
        else:
            out = open(os.devnull, 'w')
        inbuf = open('input','w')
        args = shlex.split(cmd)
        call(args, stdin = inbuf, stdout = out)

This is already in the code, just posting it here for reference

No comments:

Post a Comment