#!/usr/bin/env python

import sys
import subprocess
import glob
import shutil
import os

directory = sys.argv[1]
bigwigs = glob.glob(os.path.join(directory + "x", '*.bw'))

if len(bigwigs) > 0:
	command = ['bigWigCat', directory] + bigwigs
	p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	return_code = p.wait()

	if return_code != 0:
		out, err = p.communicate()
		print "Failed: %s" % " ".join(command)
		print "Stdout:"
		print out
		print "Stderr:"
		print err
		sys.exit(100)

else:
	# Create empty file with .empty suffix
	open(directory + ".empty", "w").close()

shutil.rmtree(directory + "x")

5fe032fb9aef4e26c572beb5dd19fe33c7b58eed
#!/usr/bin/env python

import sys
import subprocess
import glob
import shutil
import os

directory = sys.argv[1]
bigwigs = glob.glob(os.path.join(directory + "x", '*.bw'))

if len(bigwigs) > 0:
	command = ['bigWigCat', directory] + bigwigs
	p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
	return_code = p.wait()

	if return_code != 0:
		out, err = p.communicate()
		print "Failed: %s" % " ".join(command)
		print "Stdout:"
		print out
		print "Stderr:"
		print err
		sys.exit(100)

else:
	# Create empty file with .empty suffix
	open(directory + ".empty", "w").close()

shutil.rmtree(directory + "x")
