poolq-jar ?= ../../poolq.jar
jvm-args := -Xmx4G -server -XX:+UseG1GC -XX:+UseFastAccessorMethods -XX:+UseCompressedOops
conditions := ../../test-data/Conditions.csv
reference := ../../test-data/Reference.csv
test-output-dir := ../test-output

# run integration tests
.PHONY: all clean test-scenario-1 test-scenario-2 test-scenario-3 test-scenario-4

all: test-scenario-1 test-scenario-2 test-scenario-3 test-scenario-4

clean:
	rm -rf test-output

test-scenario-1: wd = $(test-output-dir)/scenario1
test-scenario-1:
	@rm -rf $(wd)
	@mkdir -p $(wd)
	(cd $(wd); java $(jvm-args) -jar $(poolq-jar) \
	--conditions $(conditions) \
	--reference $(reference) \
	--scores scores.txt \
	--quality quality.txt \
	--norm-scores norm-scores.txt \
	--unexpected-sequences unexpected-sequences.txt \
	--correlation correlation.txt \
	--reads ../../test-data/scenario1/scenario1.fastq \
	--construct-start 30)
	(cd $(wd); diff scores.txt ../../test-data/expected-scores.txt)

test-scenario-2: wd = $(test-output-dir)/scenario2
test-scenario-2:
	@rm -rf $(wd)
	@mkdir -p $(wd)
	(cd $(wd); java $(jvm-args) -jar $(poolq-jar) \
	--conditions $(conditions) \
	--reference $(reference) \
	--scores scores.txt \
	--quality quality.txt \
	--norm-scores norm-scores.txt \
	--unexpected-sequences unexpected-sequences.txt \
	--correlation correlation.txt \
	--reads ../../test-data/scenario2/scenario2.fastq \
	--construct-barcode-search-prefix CACCG \
        --construct-barcode-search-start 18)
	(cd $(wd); diff scores.txt ../../test-data/expected-scores.txt)

test-scenario-3: wd = $(test-output-dir)/scenario3
test-scenario-3:
	@rm -rf $(wd)
	@mkdir -p $(wd)
	(cd $(wd); java $(jvm-args) -jar $(poolq-jar) \
	--conditions $(conditions) \
	--reference $(reference) \
	--scores scores.txt \
	--quality quality.txt \
	--norm-scores norm-scores.txt \
	--unexpected-sequences unexpected-sequences.txt \
	--correlation correlation.txt \
	--reads ../../test-data/scenario3/scenario3.1.fastq ../../test-data/scenario3/scenario3.barcode_1.fastq \
	--construct-start 29)
	(cd $(wd); diff scores.txt ../../test-data/expected-scores.txt)

test-scenario-4: wd = $(test-output-dir)/scenario4
test-scenario-4:
	@rm -rf $(wd)
	@mkdir -p $(wd)
	(cd $(wd); java $(jvm-args) -jar $(poolq-jar) \
	--conditions $(conditions) \
	--reference $(reference) \
	--scores scores.txt \
	--quality quality.txt \
	--norm-scores norm-scores.txt \
	--unexpected-sequences unexpected-sequences.txt \
	--correlation correlation.txt \
	--reads ../../test-data/scenario4/scenario4.1.fastq ../../test-data/scenario4/scenario4.barcode_1.fastq \
        --construct-barcode-search-prefix CACCG \
        --construct-barcode-search-start 18)
	(cd $(wd); diff scores.txt ../../test-data/expected-scores.txt)
