// ***************************************************************************
// AlignmentQualityTest.cpp - provides unit tests for CAlignmentQuality.
// ---------------------------------------------------------------------------
// (c) 2006 - 2009 Michael Strömberg
// Marth Lab, Department of Biology, Boston College
// ---------------------------------------------------------------------------
// Dual licenced under the GNU General Public License 2.0+ license or as
// a commercial license with the Marth Lab.
// ***************************************************************************

#include <string>
#include <vector>
#include "Alignment.h"
#include "AlignmentQuality.h"
#include "WinUnit.h"

using namespace std;

BEGIN_TEST(CAlignmentQuality_CalculateQuality_454_FullGenome) {

	// initialize our alignment quality object
	CAlignmentQuality aq(false, 2832376426);

	// initialize our alignments
	vector<Alignment> alignments;
	Alignment al_0mm_36bp;
	al_0mm_36bp.Reference     = "TCCATCTGAAGGTTCTAAGGGAAAATCTGTTTCTCT";
	al_0mm_36bp.Query         = "TCCATCTGAAGGTTCTAAGGGAAAATCTGTTTCTCT";
	al_0mm_36bp.BaseQualities = "????????????????????????????????????";

	Alignment al_1mm_253bp;
	al_1mm_253bp.Reference     = "GAACACACTTGGAGAACGACCAGGTTAAGGGACTAGTCTTGAAAATAGTGCTATAATACAAATCTAGATCCAACACAAGACGTCTGTGGCCGCCCACCACCCCTTTCTTTACAGGTGTGTGGCATTTTATTTCTCCACCAGCAATAGCCTCAGTTGGGTCCGCTCTGCCCGGCTTCACTGATTCACTGCCTAGAAGGCTGCCTTCCCTGTCTGCAGCACCCCCAGAGCAGCCAGCCAGAGCCTCCAGTTGGGG";
	al_1mm_253bp.Query         = "GAACACACTTGGAGAACGACCAGGTTAAGGGACTAGTCTTGAAAATAGTGCTATAATACAAATCTAGATCCAACACAAGACGTCTGTGGCCGCCCACCACCCCTTTCTTTACAGGTGTGTGGCATTTTATTTCTCCACCAGCAATAGCCTCAGTTGGGTCCGCTCTGCCCAGCTTCACTGATTCACTGCCTAGAAGGCTGCCTTCCCTGTCTGCAGCACCCCCAGAGCAGCCAGCCAGAGCCTCCAGTTGGGG";
	al_1mm_253bp.BaseQualities = "?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????";

	Alignment al_4mm_500bp;
	al_4mm_500bp.Reference     = "AAAGCAGGCATCCTTGTTTAAGCTCTTAGGGTAAAAGCTTTCAGTCTTTCACCATAATGTTAGCTGTCTTTTTTTTTTTTTTAATATAACGTATTATGTTAAGGTGTTTTCTTTCTTTTTATAGTTTATTAAGTGTCTTTTATCATGAACGTGGGCTAAATTTTGATAAGTGCTTTTTCTTCTTTAAGATGATCACAGGTTTTTTTTCTTCTTTATGTGAATGTGGTATTACACTGATTTTCATGTGTTGGAGTGTACTTTTATTTCAGGAGTCAATTATACTCATTCATGGTGTATAATCCTTTTAATATACTGCCAAATTTGAATTGCTGGTATCTTGTTGAGGATTTTTGCATCAGCATTTGTAAGGGATGTTTGTTTGTAGTTTTCTTATGGTGTCTTCGTCTGGCTTGGTGTCAGAGTACTGGCTTCATAGAATAAGTTAGAAAATGTTACCCCCTCTTCAACGTTTTGAAGGCGTTTGAGGAAAACTGGTGTTA";
	al_4mm_500bp.Query         = "AAAGCAGGCATCCTTGTTTAAGCTCTTAGGGTAAAAGCTTTCAGTCTTTCACCATAATGTTAGCTGTCTTTTTTTATTTTTTAATATAACGTATTATGTTAAGGTGTTTTCTTTCTTTTTATAGTTTATTAAGTGTCTTTTATCATGAACGTGGGCTAAATTTTGATAAGTGCTTTTTCTTCTTTAAGATGATCACAGGTTTTTTTTCTTCTTTATGTGAATGTGGTATTACACTGATTTTCATGTGTTGGAGTGTACTTTTATTTCAGGAGTCAATTATACTCATTCATGGTGTATAATCCTTTTAATATACTGCCAAATTTGAATTGCTGGTATCTTGTTGAGGATTTTTGCATCAGCATTTGTAAGGGATGTTTGTTTGTAGTTTTCTTAAGGTGTCTTCGTCTGGCTTGGTGTCAGAGTACTGGCTACATAGAATAAGTTAGAAAATGTTACCCCCTCTTCAACGTTTTGAAGGCGTTTGAGGAAAACTGGAGTTA";
	al_4mm_500bp.BaseQualities = "????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????";

	// add the alignments to the vector
	alignments.push_back(al_0mm_36bp);
	alignments.push_back(al_1mm_253bp);
	alignments.push_back(al_4mm_500bp);

	// calculate the alignment qualities
	vector<Alignment>::iterator alIter = alignments.begin();
	unsigned char expectedQuality;

	// check the 36 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 35;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 36 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 253 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 44;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 253 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 500 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 49;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 500 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
}
END_TEST

BEGIN_TEST(CAlignmentQuality_CalculateQuality_454_HalfGenome) {

	// initialize our alignment quality object
	CAlignmentQuality aq(false, 1344640582);

	// initialize our alignments
	vector<Alignment> alignments;
	Alignment al_0mm_36bp;
	al_0mm_36bp.Reference     = "TCCATCTGAAGGTTCTAAGGGAAAATCTGTTTCTCT";
	al_0mm_36bp.Query         = "TCCATCTGAAGGTTCTAAGGGAAAATCTGTTTCTCT";
	al_0mm_36bp.BaseQualities = "????????????????????????????????????";

	Alignment al_1mm_253bp;
	al_1mm_253bp.Reference     = "GAACACACTTGGAGAACGACCAGGTTAAGGGACTAGTCTTGAAAATAGTGCTATAATACAAATCTAGATCCAACACAAGACGTCTGTGGCCGCCCACCACCCCTTTCTTTACAGGTGTGTGGCATTTTATTTCTCCACCAGCAATAGCCTCAGTTGGGTCCGCTCTGCCCGGCTTCACTGATTCACTGCCTAGAAGGCTGCCTTCCCTGTCTGCAGCACCCCCAGAGCAGCCAGCCAGAGCCTCCAGTTGGGG";
	al_1mm_253bp.Query         = "GAACACACTTGGAGAACGACCAGGTTAAGGGACTAGTCTTGAAAATAGTGCTATAATACAAATCTAGATCCAACACAAGACGTCTGTGGCCGCCCACCACCCCTTTCTTTACAGGTGTGTGGCATTTTATTTCTCCACCAGCAATAGCCTCAGTTGGGTCCGCTCTGCCCAGCTTCACTGATTCACTGCCTAGAAGGCTGCCTTCCCTGTCTGCAGCACCCCCAGAGCAGCCAGCCAGAGCCTCCAGTTGGGG";
	al_1mm_253bp.BaseQualities = "?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????";

	Alignment al_4mm_500bp;
	al_4mm_500bp.Reference     = "AAAGCAGGCATCCTTGTTTAAGCTCTTAGGGTAAAAGCTTTCAGTCTTTCACCATAATGTTAGCTGTCTTTTTTTTTTTTTTAATATAACGTATTATGTTAAGGTGTTTTCTTTCTTTTTATAGTTTATTAAGTGTCTTTTATCATGAACGTGGGCTAAATTTTGATAAGTGCTTTTTCTTCTTTAAGATGATCACAGGTTTTTTTTCTTCTTTATGTGAATGTGGTATTACACTGATTTTCATGTGTTGGAGTGTACTTTTATTTCAGGAGTCAATTATACTCATTCATGGTGTATAATCCTTTTAATATACTGCCAAATTTGAATTGCTGGTATCTTGTTGAGGATTTTTGCATCAGCATTTGTAAGGGATGTTTGTTTGTAGTTTTCTTATGGTGTCTTCGTCTGGCTTGGTGTCAGAGTACTGGCTTCATAGAATAAGTTAGAAAATGTTACCCCCTCTTCAACGTTTTGAAGGCGTTTGAGGAAAACTGGTGTTA";
	al_4mm_500bp.Query         = "AAAGCAGGCATCCTTGTTTAAGCTCTTAGGGTAAAAGCTTTCAGTCTTTCACCATAATGTTAGCTGTCTTTTTTTATTTTTTAATATAACGTATTATGTTAAGGTGTTTTCTTTCTTTTTATAGTTTATTAAGTGTCTTTTATCATGAACGTGGGCTAAATTTTGATAAGTGCTTTTTCTTCTTTAAGATGATCACAGGTTTTTTTTCTTCTTTATGTGAATGTGGTATTACACTGATTTTCATGTGTTGGAGTGTACTTTTATTTCAGGAGTCAATTATACTCATTCATGGTGTATAATCCTTTTAATATACTGCCAAATTTGAATTGCTGGTATCTTGTTGAGGATTTTTGCATCAGCATTTGTAAGGGATGTTTGTTTGTAGTTTTCTTAAGGTGTCTTCGTCTGGCTTGGTGTCAGAGTACTGGCTACATAGAATAAGTTAGAAAATGTTACCCCCTCTTCAACGTTTTGAAGGCGTTTGAGGAAAACTGGAGTTA";
	al_4mm_500bp.BaseQualities = "????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????";

	// add the alignments to the vector
	alignments.push_back(al_0mm_36bp);
	alignments.push_back(al_1mm_253bp);
	alignments.push_back(al_4mm_500bp);

	// calculate the alignment qualities
	vector<Alignment>::iterator alIter = alignments.begin();
	unsigned char expectedQuality;

	// check the 36 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 39;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 36 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 253 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 48;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 253 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 500 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 50;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 500 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
}
END_TEST

BEGIN_TEST(CAlignmentQuality_CalculateQuality_454_Chr1) {

	// initialize our alignment quality object
	CAlignmentQuality aq(false, 224999719);

	// initialize our alignments
	vector<Alignment> alignments;
	Alignment al_0mm_36bp;
	al_0mm_36bp.Reference     = "TCCATCTGAAGGTTCTAAGGGAAAATCTGTTTCTCT";
	al_0mm_36bp.Query         = "TCCATCTGAAGGTTCTAAGGGAAAATCTGTTTCTCT";
	al_0mm_36bp.BaseQualities = "????????????????????????????????????";

	Alignment al_1mm_253bp;
	al_1mm_253bp.Reference     = "GAACACACTTGGAGAACGACCAGGTTAAGGGACTAGTCTTGAAAATAGTGCTATAATACAAATCTAGATCCAACACAAGACGTCTGTGGCCGCCCACCACCCCTTTCTTTACAGGTGTGTGGCATTTTATTTCTCCACCAGCAATAGCCTCAGTTGGGTCCGCTCTGCCCGGCTTCACTGATTCACTGCCTAGAAGGCTGCCTTCCCTGTCTGCAGCACCCCCAGAGCAGCCAGCCAGAGCCTCCAGTTGGGG";
	al_1mm_253bp.Query         = "GAACACACTTGGAGAACGACCAGGTTAAGGGACTAGTCTTGAAAATAGTGCTATAATACAAATCTAGATCCAACACAAGACGTCTGTGGCCGCCCACCACCCCTTTCTTTACAGGTGTGTGGCATTTTATTTCTCCACCAGCAATAGCCTCAGTTGGGTCCGCTCTGCCCAGCTTCACTGATTCACTGCCTAGAAGGCTGCCTTCCCTGTCTGCAGCACCCCCAGAGCAGCCAGCCAGAGCCTCCAGTTGGGG";
	al_1mm_253bp.BaseQualities = "?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????";

	Alignment al_4mm_500bp;
	al_4mm_500bp.Reference     = "AAAGCAGGCATCCTTGTTTAAGCTCTTAGGGTAAAAGCTTTCAGTCTTTCACCATAATGTTAGCTGTCTTTTTTTTTTTTTTAATATAACGTATTATGTTAAGGTGTTTTCTTTCTTTTTATAGTTTATTAAGTGTCTTTTATCATGAACGTGGGCTAAATTTTGATAAGTGCTTTTTCTTCTTTAAGATGATCACAGGTTTTTTTTCTTCTTTATGTGAATGTGGTATTACACTGATTTTCATGTGTTGGAGTGTACTTTTATTTCAGGAGTCAATTATACTCATTCATGGTGTATAATCCTTTTAATATACTGCCAAATTTGAATTGCTGGTATCTTGTTGAGGATTTTTGCATCAGCATTTGTAAGGGATGTTTGTTTGTAGTTTTCTTATGGTGTCTTCGTCTGGCTTGGTGTCAGAGTACTGGCTTCATAGAATAAGTTAGAAAATGTTACCCCCTCTTCAACGTTTTGAAGGCGTTTGAGGAAAACTGGTGTTA";
	al_4mm_500bp.Query         = "AAAGCAGGCATCCTTGTTTAAGCTCTTAGGGTAAAAGCTTTCAGTCTTTCACCATAATGTTAGCTGTCTTTTTTTATTTTTTAATATAACGTATTATGTTAAGGTGTTTTCTTTCTTTTTATAGTTTATTAAGTGTCTTTTATCATGAACGTGGGCTAAATTTTGATAAGTGCTTTTTCTTCTTTAAGATGATCACAGGTTTTTTTTCTTCTTTATGTGAATGTGGTATTACACTGATTTTCATGTGTTGGAGTGTACTTTTATTTCAGGAGTCAATTATACTCATTCATGGTGTATAATCCTTTTAATATACTGCCAAATTTGAATTGCTGGTATCTTGTTGAGGATTTTTGCATCAGCATTTGTAAGGGATGTTTGTTTGTAGTTTTCTTAAGGTGTCTTCGTCTGGCTTGGTGTCAGAGTACTGGCTACATAGAATAAGTTAGAAAATGTTACCCCCTCTTCAACGTTTTGAAGGCGTTTGAGGAAAACTGGAGTTA";
	al_4mm_500bp.BaseQualities = "????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????";

	// add the alignments to the vector
	alignments.push_back(al_0mm_36bp);
	alignments.push_back(al_1mm_253bp);
	alignments.push_back(al_4mm_500bp);

	// calculate the alignment qualities
	vector<Alignment>::iterator alIter = alignments.begin();
	unsigned char expectedQuality;

	// check the 36 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 45;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 36 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 253 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 55;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 253 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 500 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 51;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 500 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
}
END_TEST

BEGIN_TEST(CAlignmentQuality_CalculateQuality_Illumina_FullGenome) {

	// initialize our alignment quality object
	CAlignmentQuality aq(true, 2832376426);

	// initialize our alignments
	vector<Alignment> alignments;
	Alignment al_0mm_36bp;
	al_0mm_36bp.Reference     = "CTCTTAAGAGAGGCCTTTTCTTATTCTATCTAAAAT";
	al_0mm_36bp.Query         = "CTCTTAAGAGAGGCCTTTTCTTATTCTATCTAAAAT";
	al_0mm_36bp.BaseQualities = "????????????????????????????????????";

	Alignment al_1mm_51bp;
	al_1mm_51bp.Reference     = "TCTGAATGTGCTGTTGCTACTCCAAACTATCAAAGAGTGACTAAGAGAAAC";
	al_1mm_51bp.Query         = "TCTGAATGTGCTGTTGCTACTCCAATCTATCAAAGAGTGACTAAGAGAAAC";
	al_1mm_51bp.BaseQualities = "???????????????????????????????????????????????????";

	Alignment al_2mm_76bp;
	al_2mm_76bp.Reference     = "AATACTGATAATTCCAGTAGAATATTCACAGTTTTCTTCAACATAACTCCATTTCCTCCCTCCTCTATTGTGCTAT";
	al_2mm_76bp.Query         = "AATACTGATAATTCCAGTAGAATATTCACAGTTATCTTCAACATAACTCCATATCCTCCCTCCTCTATTGTGCTAT";
	al_2mm_76bp.BaseQualities = "????????????????????????????????????????????????????????????????????????????";

	// add the alignments to the vector
	alignments.push_back(al_0mm_36bp);
	alignments.push_back(al_1mm_51bp);
	alignments.push_back(al_2mm_76bp);

	// calculate the alignment qualities
	vector<Alignment>::iterator alIter = alignments.begin();
	unsigned char expectedQuality;

	// check the 36 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 56;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 36 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 51 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 33;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 51 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 76 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 36;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 76 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
}
END_TEST

BEGIN_TEST(CAlignmentQuality_CalculateQuality_Illumina_HalfGenome) {

	// initialize our alignment quality object
	CAlignmentQuality aq(true, 1344640582);

	// initialize our alignments
	vector<Alignment> alignments;
	Alignment al_0mm_36bp;
	al_0mm_36bp.Reference     = "CTCTTAAGAGAGGCCTTTTCTTATTCTATCTAAAAT";
	al_0mm_36bp.Query         = "CTCTTAAGAGAGGCCTTTTCTTATTCTATCTAAAAT";
	al_0mm_36bp.BaseQualities = "????????????????????????????????????";

	Alignment al_1mm_51bp;
	al_1mm_51bp.Reference     = "TCTGAATGTGCTGTTGCTACTCCAAACTATCAAAGAGTGACTAAGAGAAAC";
	al_1mm_51bp.Query         = "TCTGAATGTGCTGTTGCTACTCCAATCTATCAAAGAGTGACTAAGAGAAAC";
	al_1mm_51bp.BaseQualities = "???????????????????????????????????????????????????";

	Alignment al_2mm_76bp;
	al_2mm_76bp.Reference     = "AATACTGATAATTCCAGTAGAATATTCACAGTTTTCTTCAACATAACTCCATTTCCTCCCTCCTCTATTGTGCTAT";
	al_2mm_76bp.Query         = "AATACTGATAATTCCAGTAGAATATTCACAGTTATCTTCAACATAACTCCATATCCTCCCTCCTCTATTGTGCTAT";
	al_2mm_76bp.BaseQualities = "????????????????????????????????????????????????????????????????????????????";

	// add the alignments to the vector
	alignments.push_back(al_0mm_36bp);
	alignments.push_back(al_1mm_51bp);
	alignments.push_back(al_2mm_76bp);

	// calculate the alignment qualities
	vector<Alignment>::iterator alIter = alignments.begin();
	unsigned char expectedQuality;

	// check the 36 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 58;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 36 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 51 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 34;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 51 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 76 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 38;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 76 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
}
END_TEST

BEGIN_TEST(CAlignmentQuality_CalculateQuality_Illumina_Chr1) {

	// initialize our alignment quality object
	CAlignmentQuality aq(true, 224999719);

	// initialize our alignments
	vector<Alignment> alignments;
	Alignment al_0mm_36bp;
	al_0mm_36bp.Reference     = "CTCTTAAGAGAGGCCTTTTCTTATTCTATCTAAAAT";
	al_0mm_36bp.Query         = "CTCTTAAGAGAGGCCTTTTCTTATTCTATCTAAAAT";
	al_0mm_36bp.BaseQualities = "????????????????????????????????????";

	Alignment al_1mm_51bp;
	al_1mm_51bp.Reference     = "TCTGAATGTGCTGTTGCTACTCCAAACTATCAAAGAGTGACTAAGAGAAAC";
	al_1mm_51bp.Query         = "TCTGAATGTGCTGTTGCTACTCCAATCTATCAAAGAGTGACTAAGAGAAAC";
	al_1mm_51bp.BaseQualities = "???????????????????????????????????????????????????";

	Alignment al_2mm_76bp;
	al_2mm_76bp.Reference     = "AATACTGATAATTCCAGTAGAATATTCACAGTTTTCTTCAACATAACTCCATTTCCTCCCTCCTCTATTGTGCTAT";
	al_2mm_76bp.Query         = "AATACTGATAATTCCAGTAGAATATTCACAGTTATCTTCAACATAACTCCATATCCTCCCTCCTCTATTGTGCTAT";
	al_2mm_76bp.BaseQualities = "????????????????????????????????????????????????????????????????????????????";

	// add the alignments to the vector
	alignments.push_back(al_0mm_36bp);
	alignments.push_back(al_1mm_51bp);
	alignments.push_back(al_2mm_76bp);

	// calculate the alignment qualities
	vector<Alignment>::iterator alIter = alignments.begin();
	unsigned char expectedQuality;

	// check the 36 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 62;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 36 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 51 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 34;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 51 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
	++alIter;

	// check the 76 bp alignment quality
	aq.CalculateQuality(alIter);
	expectedQuality = 39;
	WIN_ASSERT_EQUAL(expectedQuality, alIter->Quality, _T("Failed 76 bp alignment quality calculation: Expected: %u, Actual: %u\n"), expectedQuality, alIter->Quality);
}
END_TEST
