pbs scripts

A

aoife

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
 
S

Simon Brunning

2009/12/2 aoife said:
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

If they are in one directory, look at the glob module. If they are in
a bunch of sub-directories, see os.walk(), or <http://bit.ly/5Q5Qiv>.

For looping through the files said:
for each file:
      open this pbs script and run MUSCLE (a sequence alignment tool)
on each file

Is MUSCLE a command-line tool? If so, see the subprocess module.
      close this file

Do you actually need to open the file, or just run a command on it?
Sounds like the latter to me.
      move on to next file.

Give it a go. Any problems, I'm sure we'd be happy to help.
 
R

r0g

aoife said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top