Mercurial > repos > bobbledavidson > beagle4_0
annotate beagle4.py @ 4:b970ba62539e draft default tip
Updated beagle4.py to output uncompressed VCF files - had been outputting VCF.GZ
author | bobbledavidson |
---|---|
date | Wed, 16 Sep 2015 05:58:13 -0400 |
parents | c36b11eab590 |
children |
rev | line source |
---|---|
1 | 1 import os |
2 import optparse | |
3 import tempfile | |
4 import shutil | |
5 from subprocess import call | |
4
b970ba62539e
Updated beagle4.py to output uncompressed VCF files - had been outputting VCF.GZ
bobbledavidson
parents:
1
diff
changeset
|
6 import gzip |
1 | 7 |
8 def main(): | |
9 | |
10 parser = optparse.OptionParser() | |
11 parser.add_option('--jar', dest='jarfile', default=None) | |
12 parser.add_option('--gtgl',dest='gtgl',default='gt') | |
13 parser.add_option('--gfile',dest='gfile',default=None) | |
14 parser.add_option('--ref', dest='ref',default=None ) | |
15 parser.add_option('--impute-its',dest='impits', default="5") | |
16 parser.add_option('--phase-its',dest='phits',default="5") | |
17 parser.add_option('--out', dest='outfile', default='out.beagle4') | |
18 | |
19 (options, args) = parser.parse_args() | |
20 | |
21 if not options.jarfile: | |
22 parser.error('Jar option is not optional. Please provide full path to beagle4 jar file') | |
23 | |
24 if not options.gfile: | |
25 parser.error('Genotype file not optional. Can be genotype or genotype likelihood. Please provide --gfile argument.') | |
26 | |
27 print options.jarfile | |
28 cwd = os.getcwd() | |
29 outdir = tempfile.mkdtemp(dir=cwd) | |
30 outprefix = 'bglout' | |
31 | |
32 if options.ref: | |
33 call(['java', '-Xmx2g', '-jar', options.jarfile, 'ref='+options.ref, options.gtgl+'='+options.gfile, 'phase-its='+options.phits,'impute-its='+options.impits , 'out='+outdir+'/'+outprefix ]) | |
34 else: | |
35 call(['java', '-Xmx2g', '-jar', options.jarfile, options.gtgl+'='+options.gfile,'phase-its='+options.phits, 'impute-its='+options.impits , 'out='+outdir+'/'+outprefix ]) | |
36 | |
37 | |
4
b970ba62539e
Updated beagle4.py to output uncompressed VCF files - had been outputting VCF.GZ
bobbledavidson
parents:
1
diff
changeset
|
38 #shutil.move(outdir+'/'+outprefix+'.vcf.gz',options.outfile) |
b970ba62539e
Updated beagle4.py to output uncompressed VCF files - had been outputting VCF.GZ
bobbledavidson
parents:
1
diff
changeset
|
39 #shutil.rmtree(outdir) |
b970ba62539e
Updated beagle4.py to output uncompressed VCF files - had been outputting VCF.GZ
bobbledavidson
parents:
1
diff
changeset
|
40 with gzip.open(outdir+os.sep+outprefix+'.vcf.gz','rb') as gzinfile: |
b970ba62539e
Updated beagle4.py to output uncompressed VCF files - had been outputting VCF.GZ
bobbledavidson
parents:
1
diff
changeset
|
41 with open(options.outfile,'w') as vcfoutfile: |
b970ba62539e
Updated beagle4.py to output uncompressed VCF files - had been outputting VCF.GZ
bobbledavidson
parents:
1
diff
changeset
|
42 for line in gzinfile: |
b970ba62539e
Updated beagle4.py to output uncompressed VCF files - had been outputting VCF.GZ
bobbledavidson
parents:
1
diff
changeset
|
43 vcfoutfile.write(line) |
b970ba62539e
Updated beagle4.py to output uncompressed VCF files - had been outputting VCF.GZ
bobbledavidson
parents:
1
diff
changeset
|
44 |
1 | 45 shutil.rmtree(outdir) |
46 | |
47 | |
48 if __name__=='__main__': | |
49 main() | |
50 |