#!/usr/bin/env python3

import os
import subprocess
import sys
from random import randint

# xylem_shuffle.py                  
# This is a front end for shuffle. 

INFILE  = str(sys.argv[1])
WINDOW  = str(sys.argv[2])
OVERLAP = str(sys.argv[3])
OUTFILE = str(sys.argv[4])

# Abort if INFILE does not exist or is of zero length
if os.path.exists(INFILE) and os.path.getsize(INFILE) > 1 :
    tempin = open(INFILE,'r')
    tempout = open(OUTFILE,'w')
    p = subprocess.Popen(['xylem_shuffle', '-w' + WINDOW, '-o' + OVERLAP], stdin=tempin, stdout=tempout)
    p.wait()
    tempin.close()
    tempout.close()

