changeset 1:c36b11eab590 draft

Beagle4 python wrapper Uploaded
author bobbledavidson
date Wed, 08 Jul 2015 10:18:45 -0400
parents 430cda98caa4
children e7e5432588ea
files beagle4.py
diffstat 1 files changed, 44 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/beagle4.py	Wed Jul 08 10:18:45 2015 -0400
@@ -0,0 +1,44 @@
+import os
+import optparse
+import tempfile
+import shutil
+from subprocess import call
+
+def main():
+  
+    parser = optparse.OptionParser()
+    parser.add_option('--jar', dest='jarfile', default=None)
+    parser.add_option('--gtgl',dest='gtgl',default='gt')
+    parser.add_option('--gfile',dest='gfile',default=None)
+    parser.add_option('--ref', dest='ref',default=None )
+    parser.add_option('--impute-its',dest='impits', default="5")
+    parser.add_option('--phase-its',dest='phits',default="5")
+    parser.add_option('--out', dest='outfile', default='out.beagle4')
+	
+    (options, args) = parser.parse_args()
+
+    if not options.jarfile:
+    	parser.error('Jar option is not optional. Please provide full path to beagle4 jar file')
+
+    if not options.gfile:
+        parser.error('Genotype file not optional. Can be genotype or genotype likelihood. Please provide --gfile argument.')
+
+    print options.jarfile
+    cwd = os.getcwd()
+    outdir = tempfile.mkdtemp(dir=cwd)
+    outprefix = 'bglout'
+    
+    if options.ref:
+        call(['java', '-Xmx2g', '-jar', options.jarfile, 'ref='+options.ref, options.gtgl+'='+options.gfile, 'phase-its='+options.phits,'impute-its='+options.impits , 'out='+outdir+'/'+outprefix ])
+    else:
+    	call(['java', '-Xmx2g', '-jar', options.jarfile, options.gtgl+'='+options.gfile,'phase-its='+options.phits, 'impute-its='+options.impits , 'out='+outdir+'/'+outprefix ])
+   
+
+    shutil.move(outdir+'/'+outprefix+'.vcf.gz',options.outfile)
+    shutil.rmtree(outdir)
+
+
+
+if __name__=='__main__':
+    main()
+