pbs scripts

Discussion in 'Python' started by aoife, Dec 2, 2009.

  1. aoife

    aoife Guest

    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
     
    aoife, Dec 2, 2009
    #1
    1. Advertising

  2. 2009/12/2 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


    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.
     
    Simon Brunning, Dec 2, 2009
    #2
    1. Advertising

  3. aoife

    r0g Guest

    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.
     
    r0g, Dec 3, 2009
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Steve

    PBS and Python

    Steve, Dec 23, 2003, in forum: Python
    Replies:
    0
    Views:
    647
    Steve
    Dec 23, 2003
  2. Jan Danielsson
    Replies:
    8
    Views:
    644
    Mike Meyer
    Jul 22, 2005
  3. Jp Calderone
    Replies:
    0
    Views:
    467
    Jp Calderone
    Jul 21, 2005
  4. davidj411
    Replies:
    0
    Views:
    552
    davidj411
    Jun 27, 2008
  5. Replies:
    13
    Views:
    554
    Anno Siegel
    Sep 10, 2007
Loading...

Share This Page