#!/opt/conda/conda-bld/albatradis_1758427780971/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_pl/bin/python
import argparse
import sys
import os
import pkg_resources
sys.path.append('../')
sys.path.append('./')
from albatradis.AlbaTraDISArtemisProject import AlbaTraDISArtemisProject


version = ''
try:
	version = pkg_resources.get_distribution("albatradis").version
except pkg_resources.DistributionNotFound:
	version = 'x.y.z'

parser = argparse.ArgumentParser(
	description = 'Create an artemis project file',
	usage = 'albatradis-artemis_project [options] reference experiments_metadata.csv', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('reference', help='reference EMBL file', type=str)	
parser.add_argument('experiments_metadata', help='experiments metadata spreadsheet', type=str)

parser.add_argument('--control', '-c',  help='control files (can use multiple times)', type=str, action='append')
parser.add_argument('--outputfile', '-o',  help='Output filename', type=str, default='project.properties')
parser.add_argument('--verbose', '-v', action='store_true', help='Print out more information while it runs', default = False)
parser.add_argument('--debug', action='store_true', help='Turn on debugging', default = False)
parser.add_argument('--version', action='version', version=str(version))


options = parser.parse_args()

if options.debug:
	options.verbose = True
	import cProfile, pstats, io
	pr = cProfile.Profile()
	pr.enable()
		
	albatradis = AlbaTraDISArtemisProject(options)
	albatradis.run()
		
	pr.disable()
	s = io.StringIO()
	sortby = 'cumulative'
	ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
	ps.print_stats()
	print(s.getvalue())
else:
	albatradis = AlbaTraDISArtemisProject(options)
	albatradis.run()
