Skip to content

Commit dde4476

Browse files
author
Bill Majoros
committed
update
1 parent 5cbf261 commit dde4476

5 files changed

+74
-5
lines changed

ProgramName.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import sys
2+
import os
3+
4+
def programName():
5+
return os.path.basename(sys.argv[0])
6+

extract-gaa.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import gzip
55

66
if(len(sys.argv)!=4):
7-
print sys.argv[0]+" <in.vcf.gz> <begin> <end>"
7+
print(sys.argv[0]+" <in.vcf.gz> <begin> <end>")
88
sys.exit(0)
99
[infile,begin,end]=sys.argv[1:]
1010
begin=int(begin)
@@ -17,10 +17,10 @@
1717
if len(fields)<7: continue
1818
if fields[0]=="#CHROM":
1919
header=fields
20-
print line
20+
print(line)
2121
elif fields[6]=="PASS":
2222
[chr,pos,id,ref,alt]=fields[:5]
2323
pos=int(pos)
24-
if pos>=begin and pos<=end: print line
24+
if pos>=begin and pos<=end: print(line)
2525

2626

get-SNP-IDs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
name=sys.argv[0];
88
if(len(sys.argv)!=2):
9-
print name+" <*.vcf>"
9+
print(name+" <*.vcf>")
1010
sys.exit(0)
1111
[name,vcfFile]=sys.argv;
1212

@@ -23,6 +23,6 @@
2323
if(len(ref)!=1 or len(alt)!=1): continue
2424
if(not re.search("rs",id)):
2525
id=chr+"at"+pos;
26-
print id+"\t"+chr+"\t"+pos+"\t"+ref+"\t"+alt
26+
print(id+"\t"+chr+"\t"+pos+"\t"+ref+"\t"+alt)
2727
IN.close();
2828

hello-world.py

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/env python
2+
from __future__ import (absolute_import, division, print_function,
3+
unicode_literals, generators, nested_scopes, with_statement)
4+
from builtins import (bytes, dict, int, list, object, range, str, ascii, chr,
5+
hex, input, next, oct, open, pow, round, super, filter, map, zip)
6+
from ProgramName import *
7+
8+
name=programName();
9+
print(name)
10+
11+
print ("Hello, world\n")
12+
13+
for i in range(1,10):
14+
print (i,end="")
15+
print("\n")
16+
17+

make-bam-slurms.py

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python
2+
import sys
3+
import os
4+
import basic
5+
import glob
6+
import re
7+
8+
# Global variables
9+
jobName="bam"
10+
slurmDir="/data/chilab/bill/slurm-bam"
11+
samDir="/data/chilab/bill/sam"
12+
memory=10000
13+
samtools="/usr/local/bin/samtools"
14+
15+
# Make output directories
16+
if(not os.path.exists(slurmDir)):
17+
os.makedirs(slurmDir)
18+
19+
# Get list of sam files
20+
samFiles=glob.glob(samDir+"/*.sam")
21+
22+
# Process each sam file
23+
jobID=1
24+
for samfile in samFiles:
25+
match=re.search("([^/]+)\.sam",samfile);
26+
bamfile=samDir+"/"+match.group(1)+".bam"
27+
bamStem=samDir+"/"+match.group(1)
28+
slurmFile=slurmDir+"/"+str(jobID)+".slurm"
29+
OUT=open(slurmFile,"w")
30+
header="\n".join(["#!/bin/bash",
31+
"#",
32+
"#SBATCH -J %(jobName)s%(jobID)i" % locals(),
33+
"#SBATCH -o %(jobName)s%(jobID)i.output" % locals(),
34+
"#SBATCH -e %(jobName)s%(jobID)i.output" % locals(),
35+
"#SBATCH -A %(jobName)s%(jobID)i" % locals(),
36+
"#SBATCH --mem %(memory)i" %locals(),
37+
"#"])
38+
print >>OUT, header
39+
print >>OUT, "cd "+samDir
40+
command="%(samtools)s view -bS %(samfile)s | samtools sort - %(bamStem)s" % locals()
41+
print >>OUT, command
42+
command="%(samtools)s index %(bamfile)s" % locals()
43+
print >>OUT, command
44+
OUT.close()
45+
jobID=jobID+1
46+

0 commit comments

Comments
 (0)