pbs scripts

r0g aioe.org at technicalbloke.com
Thu Dec 3 03:29:13 EST 2009


aoife wrote:
> Hi,very new.hoping to incorporate python into my postgrad.
> 
> Basically I have 2,000 files.I want to write a script that says:
> 
> open each file in turn
> for each file:
>        open this pbs script and run MUSCLE (a sequence alignment tool)
> on each file
>        close this file
>        move on to next file.
> 
> any help would be great.
> Aoife


Hi Aoife,

import os

for each_pbs in os.listdir("/home/user/pbs_files/"): # loop thru dir
    if each_pbs[-4:].upper() == ".PBS":              # check extension
        os.system("MUSCLE " + each_pbs)              # call CLI prog


I don't think you need to open or close the files if their names (As
opposed to their contents) are just going to be parameters to this
MUSCLE program.

If you want it to look in subfolders replace 'os.listdir' with 'os.walk'.

Hope this helps, if not please clarify :)

Cheers,

Roger.



More information about the Python-list mailing list