· 6 years ago · Jul 29, 2019, 03:26 PM
1#!/usr/bin/python3 env
2# -*- coding: utf-8 -*-
3
4"""Qsub command generator
5 Author: Arup Ghosh
6 Creation date: 17/07/2019
7 last modified: 18/07/2019
8 Email: arupneo2 [at] gmail.com
9"""
10import glob
11import os
12
13files=glob.glob("*.fastq.gz")
14nodes=open("nodefile","r").read().split()
15#print(nodes)
16def _qsubFormat(fq,node):
17 tool="/software/FastQC/fastqc -t 20 --outdir"
18 cwd = os.getcwd()
19 command="qsub -b y -q all.q@compute-0-{0} -N fastqc.{1} -e {1}_error.log -o {1}_cmd.log -V {3} {2}/test/ {2}/{1}".format(node,fq,cwd,tool)
20 return command
21
22#Assign one node to one file
23if len(files) >len(nodes):
24 #print("Split Jobs nodes {} files {}".format(len(nodes),len(files)))
25 #Split the files list based upon the following calculation
26 chunks=[files[i:i + 10] for i in range(0, len(files), 10)]
27 for block in chunks:
28 i=0
29 for fq in block:
30 i += 1
31 #fix for node no tarting at compute-0-2
32 nodeno = i+1
33 print(_qsubFormat(fq,nodeno))
34else:
35 #print("Don't split jobs nodes {} files {}".format(len(nodes),len(files)))
36 i=0
37 for fq in files:
38 i += 1
39 #fix for node no tarting at compute-0-2
40 nodeno = i+1
41 print(_qsubFormat(fq,nodeno))