-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path13-seq_metrics.py
executable file
·88 lines (74 loc) · 3.12 KB
/
13-seq_metrics.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#! /usr/bin/env python
# PBS cluster job submission in Python
# To calculate percent of bases on target, etc using Picard
# By Jean P. Elbers
# Last modified 22 Jan 2015
###############################################################################
Usage = """
13-seq_metrics.py - version 1.0
Command:
cd InDir = /work/jelber2/immunome_2014/combined/call-SNPs-recal03
1.CalculateHSMetrics:
java -Xmx2g -jar ~/bin/picard-tools-1.118/CalculateHsMetrics.jar \
BAIT_INTERVALS=/work/jelber2/reference/immunome_baits_C_picta-3.0.3.interval.list \
BAIT_SET_NAME=Immunome \
#TARGET_INTERVALS=/work/jelber2/reference/immunome_targetregion_C_picta-3.0.3.list \ #Sample-baits-targets.hsmetrics.txt
TARGET_INTERVALS=/work/jelber2/reference/immunome_baits_C_picta-3.0.3.interval.list \ #Sample-baitsonly.hsmetrics.txt
METRIC_ACCUMULATION_LEVEL=SAMPLE \
R=/work/jelber2/reference/GCF_000241765.3_Chrysemys_picta_bellii-3.0.3_genomic.fna \
I=Sample.bam \
O=Sample-baitsonly.hsmetrics.txt
InDir = /work/jelber2/immunome_2014/combined/call-SNPs-recal03
Input Files = *.bam
Usage (execute following code in InDir):
~/scripts/immunome_2014/13-seq_metrics.py Sample.bam
"""
###############################################################################
import os, sys, subprocess #imports os, sys, subprocess modules
if len(sys.argv)<2:
print Usage
else:
FileList = sys.argv[1:]
RefDir = "/work/jelber2/reference"
InDir = os.getcwd()
OutDir = InDir
for InFileName in FileList: # do the following steps for each file in the inputstream
FileSuffix = ".bam"
Sample = InFileName.replace(FileSuffix,'') # create file prefix string
# Customize your job options here
Queue = "single"
Allocation = "hpc_gopo02"
Processors = "nodes=1:ppn=4"
WallTime = "01:00:00"
LogOut = OutDir
LogMerge = "oe"
JobName = "seq-metrics-%s" % (Sample)
Command ="""
java -Xmx2g -jar ~/bin/picard-tools-1.118/CalculateHsMetrics.jar \
BAIT_INTERVALS=/work/jelber2/reference/immunome_baits_C_picta-3.0.3.interval.list \
BAIT_SET_NAME=Immunome \
TARGET_INTERVALS=/work/jelber2/reference/immunome_baits_C_picta-3.0.3.interval.list \
METRIC_ACCUMULATION_LEVEL=SAMPLE \
R=/work/jelber2/reference/GCF_000241765.3_Chrysemys_picta_bellii-3.0.3_genomic.fna \
I=%s.bam \
O=%s-baitsonly.hsmetrics.txt""" % (Sample, Sample)
JobString = """
#!/bin/bash
#PBS -q %s
#PBS -A %s
#PBS -l %s
#PBS -l walltime=%s
#PBS -o %s
#PBS -j %s
#PBS -N %s
cd %s
%s\n""" % (Queue, Allocation, Processors, WallTime, LogOut, LogMerge, JobName, InDir, Command)
#Create pipe to qsub
proc = subprocess.Popen(['qsub'], shell=True,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, close_fds=True)
(child_stdout, child_stdin) = (proc.stdout, proc.stdin)
#Print JobString
JobName = proc.communicate(JobString)[0]
print JobString
print JobName