contig alignment function