/* * Copyright (C) 2009-2011 by Benedict Paten (benedictpaten@gmail.com) * * Released under the MIT license, see LICENSE.txt */ /* * stPosetAlignmentTest.c * * Created on: 1 June 2010 * Author: benedictpaten */ #include #include "sonLib.h" #include "stPosetAlignment.h" #include "CuTest.h" /* * The following test code builds a random alignment and checking as each * extra pair of aligned positions is added to the alignment that the alignment * remains partially ordered. */ static const int32_t MAX_SEQUENCE_NUMBER = 10; static const int32_t MAX_SEQUENCE_SIZE = 100; static const int32_t MAX_ALIGNMENTS = 100; static const int32_t MAX_ALIGNED_PAIRS = 10000; static int32_t sequenceNumber; static stPosetAlignment *posetAlignment = NULL; static void teardown() { if(posetAlignment != NULL) { stPosetAlignment_destruct(posetAlignment); posetAlignment = NULL; } } static void setup() { teardown(); sequenceNumber = st_randomInt(0, MAX_SEQUENCE_NUMBER); posetAlignment = stPosetAlignment_construct(sequenceNumber); } /* * Tests the constructor and the basic setup. */ static void test_stPosetAlignment_getSequenceNumber(CuTest *testCase) { setup(); CuAssertTrue(testCase, sequenceNumber == stPosetAlignment_getSequenceNumber(posetAlignment)); teardown(); } /* * This builds an adjacency list structure for the the sequences. Every sequence-position * has a column in the hash with which it can be aligned with. */ static stHash *buildAdjacencyList(stList *pairs, int32_t sequenceNumber) { stHash *hash = stHash_construct3((uint32_t (*)(const void *))stIntTuple_hashKey, (int (*)(const void *, const void *))stIntTuple_equalsFn, (void (*)(void *))stIntTuple_destruct, NULL); for(int32_t seq=0; seq 0) { for(int32_t i=0; i