#!/bin/bash

html=index.html
reference=$1
shift

echo "<html><body>" >$html
echo "<table>" >>$html


echo "<tr>" >>$html
echo "<td></td>" >>$html

for file in $@;
do
    echo "<td style=\"border:1px solid black;\">"$(basename $file .vcf.gz | cut -f 3 -d. | cut -f 1 -d_)"</td>" >>$html
done

echo "</tr>" >>$html

for fileA in $@;
do
    echo "<tr>" >>$html
    echo "<td style=\"border:1px solid black;\">"$(basename $fileA .vcf.gz | cut -f 3 -d. | cut -f 1 -d_)"</td>" >>$html
    for fileB in $@;
    do
	echo $fileA vs $fileB
	echo "<td style=\"border:1px solid black;\">" >>$html
	if [ "$fileA" = "$fileB" ]
	then
	    echo "<a href=\""$(basename $fileA).stats.txt"\">" >>$html
	    echo self >>$html
	    echo "</a>" >>$html
	else
	    echo "<a href=\""$(basename $fileA).common.$(basename $fileB).stats.txt"\">" >>$html
	    echo common >>$html
	    echo "</a><br>" >>$html
	    echo "<a href=\""$(basename $fileA).unique.$(basename $fileB).stats.txt"\">" >>$html
	    echo unique >>$html
	    echo "</a>" >>$html
	fi
	echo "</td>" >>$html
    done
    echo "</tr>" >>$html
done

echo "</table>" >>$html
echo "</body></html>" >>$html
