Created
September 13, 2016 23:25
-
-
Save MikeDacre/df7c4170f346965e43e50b4316db56d9 to your computer and use it in GitHub Desktop.
Run simple script with python-cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""Submit a bunch of jobs.""" | |
import sys | |
import argparse | |
from time import sleep | |
import cluster | |
CMD = '/home/dacre/mike_tools/bin/rename_mesh_snps.py {bed} -i {infile} -o {outfile}' | |
def submit_files(bedfile, infiles): | |
"""Submit all infiles. | |
:bedfile: The bed file of peak locations. | |
:infiles: List of split files. | |
""" | |
for sfile in infiles: | |
job = cluster.submit(CMD.format(bed=bedfile, infile=sfile, | |
outfile=sfile+'.out'), | |
mem=8000, name=sfile) | |
sleep(1) | |
print('Submitted {}'.format(job)) | |
def main(argv=None): | |
"""Command line parsing.""" | |
if not argv: | |
argv = sys.argv[1:] | |
parser = argparse.ArgumentParser( | |
description=__doc__, | |
formatter_class=argparse.RawDescriptionHelpFormatter) | |
# Positional arguments | |
parser.add_argument('bedfile', help="Bedfile") | |
parser.add_argument('infiles', nargs='+', help="Split files") | |
args = parser.parse_args(argv) | |
submit_files(args.bedfile, args.infiles) | |
if __name__ == '__main__' and '__file__' in globals(): | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment