Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > pbs scripts

Reply
Thread Tools

pbs scripts

 
 
aoife
Guest
Posts: n/a
 
      12-02-2009
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
 
Reply With Quote
 
 
 
 
Simon Brunning
Guest
Posts: n/a
 
      12-02-2009
2009/12/2 aoife <(E-Mail Removed)>:
> 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, see <http://bit.ly/4zvi9P>.

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

--
Cheers,
Simon B.
 
Reply With Quote
 
 
 
 
r0g
Guest
Posts: n/a
 
      12-03-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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
PBS "American Masters" - Annie Leibovitz Alan Browne Digital Photography 19 01-09-2007 05:15 AM
WTB: PBS "Nature" Special, "The Goonies Of Midway" Glenn P., DVD Video 0 01-03-2006 01:05 PM
New releases: Star Wars Re-release, Raymond & PBS blitz: Updated complete downloadable R1 DVD DB & info lists Doug MacLean DVD Video 1 10-04-2005 12:59 PM
Visions of Italy PBS series Juan C. Rodriguez DVD Video 2 07-15-2004 10:48 PM
PBS and Python Steve Python 0 12-23-2003 01:35 AM



Advertisments