-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmake-fastqc-slurms.py
executable file
·44 lines (38 loc) · 1.05 KB
/
make-fastqc-slurms.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env python
import sys
import os
import basic
import glob
import re
# Global variables
samplesDir="/data/chilab/RNAseq_2015-07"
slurmDir="/data/chilab/bill/slurm-fastqc"
outputDir="/data/chilab/bill/fastqc"
fastqc="/data/chilab/bill/software/FastQC/fastqc"
# Make output directory
if(not os.path.exists(slurmDir)):
os.makedirs(slurmDir)
# Get list of sample directories
samples=glob.glob(samplesDir+"/Sample_*")
# Process each sample
jobID=1
for sample in samples:
match=re.search("(Sample_\S+)",sample); id=match.group(0)
outfile=slurmDir+"/"+id+".slurm"
OUT=open(outfile,"w")
header="\n".join(["#!/bin/bash",
"#",
"#SBATCH -J FASTQC%(jobID)i" % locals(),
"#SBATCH -o FASTQC%(jobID)i.output" % locals(),
"#SBATCH -e FASTQC%(jobID)i.output" % locals(),
"#SBATCH -A FASTQC%(jobID)i" % locals(),
"#\n"])
print >>OUT, header
print >>OUT, "cd "+outputDir
# Process each file
files=glob.glob(sample+"/*.fastq.gz")
for file in files:
command=fastqc+" -o "+outputDir+" "+file
print >>OUT, command
OUT.close()
jobID=jobID+1