Mercurial > repos > bobbledavidson > beagle4_0
comparison beagle4.py @ 1:c36b11eab590 draft
Beagle4 python wrapper Uploaded
author | bobbledavidson |
---|---|
date | Wed, 08 Jul 2015 10:18:45 -0400 |
parents | |
children | b970ba62539e |
comparison
equal
deleted
inserted
replaced
0:430cda98caa4 | 1:c36b11eab590 |
---|---|
1 import os | |
2 import optparse | |
3 import tempfile | |
4 import shutil | |
5 from subprocess import call | |
6 | |
7 def main(): | |
8 | |
9 parser = optparse.OptionParser() | |
10 parser.add_option('--jar', dest='jarfile', default=None) | |
11 parser.add_option('--gtgl',dest='gtgl',default='gt') | |
12 parser.add_option('--gfile',dest='gfile',default=None) | |
13 parser.add_option('--ref', dest='ref',default=None ) | |
14 parser.add_option('--impute-its',dest='impits', default="5") | |
15 parser.add_option('--phase-its',dest='phits',default="5") | |
16 parser.add_option('--out', dest='outfile', default='out.beagle4') | |
17 | |
18 (options, args) = parser.parse_args() | |
19 | |
20 if not options.jarfile: | |
21 parser.error('Jar option is not optional. Please provide full path to beagle4 jar file') | |
22 | |
23 if not options.gfile: | |
24 parser.error('Genotype file not optional. Can be genotype or genotype likelihood. Please provide --gfile argument.') | |
25 | |
26 print options.jarfile | |
27 cwd = os.getcwd() | |
28 outdir = tempfile.mkdtemp(dir=cwd) | |
29 outprefix = 'bglout' | |
30 | |
31 if options.ref: | |
32 call(['java', '-Xmx2g', '-jar', options.jarfile, 'ref='+options.ref, options.gtgl+'='+options.gfile, 'phase-its='+options.phits,'impute-its='+options.impits , 'out='+outdir+'/'+outprefix ]) | |
33 else: | |
34 call(['java', '-Xmx2g', '-jar', options.jarfile, options.gtgl+'='+options.gfile,'phase-its='+options.phits, 'impute-its='+options.impits , 'out='+outdir+'/'+outprefix ]) | |
35 | |
36 | |
37 shutil.move(outdir+'/'+outprefix+'.vcf.gz',options.outfile) | |
38 shutil.rmtree(outdir) | |
39 | |
40 | |
41 | |
42 if __name__=='__main__': | |
43 main() | |
44 |