Пример #1
0
void block_setRootInstance(Block *block, Segment *segment) {
	block = block_getPositiveOrientation(block);
	segment = segment_getPositiveOrientation(segment);
	assert(block_getInstance(block, segment_getName(segment)) == segment);
	end_setRootInstance(block_get5End(block), segment_get5Cap(segment));
	end_setRootInstance(block_get3End(block), segment_get3Cap(segment));
}
Пример #2
0
void block_check(Block *block) {
	//Check is connected to flower properly
	cactusCheck(flower_getBlock(block_getFlower(block), block_getName(block)) == block_getPositiveOrientation(block));
	//Check we have actually set built blocks for the flower..
	cactusCheck(flower_builtBlocks(block_getFlower(block)));

	//Checks the two ends are block ends.
	End *_5End = block_get5End(block);
	End *_3End = block_get3End(block);
	cactusCheck(end_isBlockEnd(_5End));
	cactusCheck(end_isBlockEnd(_3End));
	cactusCheck(end_getOrientation(_5End) == block_getOrientation(block));
	cactusCheck(end_getOrientation(_3End) == block_getOrientation(block));
	cactusCheck(end_getBlock(_5End) == block);
	cactusCheck(end_getBlock(_3End) == block);
	cactusCheck(end_getSide(_5End)); //Check the sides of the ends are consistent.
	cactusCheck(!end_getSide(_3End));

	cactusCheck(block_getLength(block) > 0); //check block has non-zero length

	//Check reverse
	Block *rBlock = block_getReverse(block);
	cactusCheck(rBlock != NULL);
	cactusCheck(block_getReverse(block) == rBlock);
	cactusCheck(block_getOrientation(block) == !block_getOrientation(rBlock));
	cactusCheck(block_getLength(block) == block_getLength(rBlock));
	cactusCheck(block_get5End(block) == end_getReverse(block_get3End(rBlock)));
	cactusCheck(block_get3End(block) == end_getReverse(block_get5End(rBlock)));
	cactusCheck(block_getInstanceNumber(block) == block_getInstanceNumber(rBlock));
	if(block_getInstanceNumber(block) > 0) {
		cactusCheck(block_getFirst(block) == segment_getReverse(block_getFirst(rBlock)));
		if(block_getRootInstance(block) == NULL) {
			cactusCheck(block_getRootInstance(rBlock) == NULL);
		}
		else {
			cactusCheck(block_getRootInstance(block) == segment_getReverse(block_getRootInstance(rBlock)));
		}
	}

	//For each segment calls segment_check.
	Block_InstanceIterator *iterator = block_getInstanceIterator(block);
	Segment *segment;
	while((segment = block_getNext(iterator)) != NULL) {
		segment_check(segment);
	}
	block_destructInstanceIterator(iterator);
}
Пример #3
0
void testBlock_getLeftEnd(CuTest* testCase) {
    cactusBlockTestSetup();
    End *leftEnd = block_get5End(block);
    CuAssertTrue(testCase, leftEnd != NULL);
    CuAssertTrue(testCase, end_getBlock(leftEnd) == block);
    CuAssertTrue(testCase, block_getOrientation(block) == end_getOrientation(leftEnd));
    cactusBlockTestTeardown();
}
Пример #4
0
void testBlock_getChain(CuTest* testCase) {
    cactusBlockTestSetup();

    Block *block2 = block_construct(2, flower);
    Flower *flower2 = flower_construct(cactusDisk);
    eventTree_copyConstruct(flower_getEventTree(flower), flower2, NULL);
    end_copyConstruct(block_get3End(block), flower2);
    end_copyConstruct(block_get5End(block2), flower2);
    Group *group = group_construct(flower, flower2);
    Chain *chain = chain_construct(flower);
    link_construct(block_get3End(block), block_get5End(block2), group, chain);

    CuAssertTrue(testCase, block_getChain(block_construct(2, flower)) == NULL);
    CuAssertTrue(testCase, block_getChain(block) == chain);
    CuAssertTrue(testCase, block_getChain(block2) == chain);

    cactusBlockTestTeardown();
}
Пример #5
0
void testBlock_isTrivialChain(CuTest *testCase) {
    cactusBlockTestSetup();
    Group *group = group_construct2(flower);
    end_setGroup(block_get5End(block), group);
    end_setGroup(block_get3End(block), group);
    Chain *chain = chain_construct(flower);
    Group *group2 = group_construct2(flower);
    CuAssertTrue(testCase, block_isTrivialChain(block));
    Block *block1 = block_construct(1, flower);
    Block *block2 = block_construct(1, flower);
    end_setGroup(block_get5End(block2), group2);
    end_setGroup(block_get3End(block1), group2);
    link_construct(block_get3End(block1), block_get5End(block2), group2, chain);
    end_setGroup(block_get5End(block1), group);
    end_setGroup(block_get3End(block2), group);
    CuAssertTrue(testCase, block_isTrivialChain(block));
    CuAssertTrue(testCase, !block_isTrivialChain(block1));
    CuAssertTrue(testCase, !block_isTrivialChain(block2));
    cactusBlockTestTeardown();
}
Пример #6
0
void testBlock_getSetRootInstance(CuTest *testCase) {
    cactusBlockTestSetup();
    Block *block2 = block_construct(1, flower);
    CuAssertTrue(testCase, block_getRootInstance(block2) == NULL);
    block_destruct(block2);
    //block_setRootInstance(block, segment_getReverse(rootSegment)); //set in the constructor code of the test.
    CuAssertTrue(testCase, block_getRootInstance(block) == segment_getReverse(rootSegment));
    CuAssertTrue(testCase, end_getRootInstance(block_get5End(block)) == segment_get5Cap(segment_getReverse(rootSegment)));
    CuAssertTrue(testCase, end_getRootInstance(block_get3End(block)) == segment_get3Cap(segment_getReverse(rootSegment)));
    cactusBlockTestTeardown();
}
Пример #7
0
Chain *block_getChain(Block *block) {
	Link *link;
	Chain *chain1, *chain2;
	Group *group = end_getGroup(block_get5End(block));
	chain1 = (group != NULL && (link = group_getLink(group)) != NULL) ? link_getChain(link) : NULL;
	group = end_getGroup(block_get3End(block));
	chain2 = (group != NULL && (link = group_getLink(group)) != NULL) ? link_getChain(link) : NULL;
	if(chain1 != NULL && chain2 != NULL) {
		assert(chain1 == chain2); //block should not be in more than one chain!
	}
	return chain1 != NULL ? chain1 : chain2;
}
Пример #8
0
bool linked(Segment *segmentX, Segment *segmentY, int64_t difference,
        const char *eventString, bool *aligned) {
    assert(segment_getStrand(segmentX));
    assert(segment_getStrand(segmentY));
    *aligned = 0;
    if (segment_getStart(segmentX) < segment_getStart(segmentY)) {
        Block *blockX = segment_getBlock(segmentX);
        Block *blockY = segment_getBlock(segmentY);
        Block_InstanceIterator *instanceItX = block_getInstanceIterator(blockX);
        Segment *segmentX2;
        while ((segmentX2 = block_getNext(instanceItX)) != NULL) {
            if (strcmp(event_getHeader(segment_getEvent(segmentX2)),
                    eventString) == 0) {
                Block_InstanceIterator *instanceItY =
                        block_getInstanceIterator(blockY);
                Segment *segmentY2;
                while ((segmentY2 = block_getNext(instanceItY)) != NULL) {
                    if (strcmp(event_getHeader(segment_getEvent(segmentY2)),
                            eventString) == 0) {
                        *aligned = 1;
                        if (sequence_getMetaSequence(
                                segment_getSequence(segmentX2))
                                == sequence_getMetaSequence(
                                        segment_getSequence(segmentY2))) { //Have the same assembly sequence
                            //Now check if the two segments are connected by a path of adjacency from the 3' end of segmentX to the 5' end of segmentY.
                            int64_t separationDistance;
                            if (capsAreAdjacent(segment_get3Cap(segmentX2),
                                    segment_get5Cap(segmentY2),
                                    &separationDistance)) {
                                //if(difference < 10000 || (separationDistance <=  difference * 1.5 && difference <= separationDistance * 1.5)) {
                                block_destructInstanceIterator(instanceItX);
                                block_destructInstanceIterator(instanceItY);
                                return 1;
                                //}
                            }
                        }
                    }
                }
                block_destructInstanceIterator(instanceItY);
            }
        }
        block_destructInstanceIterator(instanceItX);
    } else {
        assert(segmentX == segmentY);
        if(hasCapInEvent(block_get5End(segment_getBlock(segmentX)),
                eventString)) {
            *aligned = 1;
            return 1;
        }
    }
    return 0;
}
Пример #9
0
void testEnd_isBlockOrStubEnd(CuTest* testCase) {
    cactusEndTestSetup();
    CuAssertTrue(testCase, end_isStubEnd(end));
    CuAssertTrue(testCase, !end_isBlockEnd(end));
    Block *block = block_construct(2, flower);
    End *leftEnd = block_get5End(block);
    End *rightEnd = block_get3End(block);
    CuAssertTrue(testCase, end_isBlockEnd(leftEnd));
    CuAssertTrue(testCase, end_isBlockEnd(rightEnd));
    CuAssertTrue(testCase, !end_isStubEnd(leftEnd));
    CuAssertTrue(testCase, !end_isStubEnd(rightEnd));
    cactusEndTestTeardown();
}
Пример #10
0
void testFlower_getTrivialChainNumber(CuTest* testCase) {
    cactusFlowerTestSetup();
    CuAssertIntEquals(testCase, 0, flower_getTrivialChainNumber(flower));
    chain = chain_construct(flower);
    chain2 = chain_construct(flower);
    CuAssertIntEquals(testCase, 0, flower_getTrivialChainNumber(flower));
    group = group_construct2(flower);
    group2 = group_construct2(flower);
    block = block_construct(1, flower);
    end_setGroup(block_get5End(block), group);
    end_setGroup(block_get3End(block), group2);
    CuAssertIntEquals(testCase, 1, flower_getTrivialChainNumber(flower));
    block2 = block_construct(1, flower);
    end_setGroup(block_get5End(block2), group2);
    end_setGroup(block_get3End(block2), group);
    CuAssertIntEquals(testCase, 2, flower_getTrivialChainNumber(flower));
    link_construct(block_get3End(block), block_get5End(block2), group2, chain);
    CuAssertIntEquals(testCase, 0, flower_getTrivialChainNumber(flower));
    link_construct(block_get3End(block2), block_get5End(block), group, chain);
    CuAssertIntEquals(testCase, 0, flower_getTrivialChainNumber(flower));
    cactusFlowerTestTeardown();
}
Пример #11
0
void testEnd_getSide(CuTest *testCase) {
    cactusEndTestSetup();
    Block *block = block_construct(10, flower);
    End *_5End = block_get5End(block);
    End *_3End = block_get3End(block);

    CuAssertTrue(testCase, end_getSide(end));
    CuAssertTrue(testCase, !end_getSide(end_getReverse(end)));

    CuAssertTrue(testCase, end_getSide(_5End));
    CuAssertTrue(testCase, !end_getSide(_3End));
    CuAssertTrue(testCase, end_getSide(end_getReverse(_3End)));
    CuAssertTrue(testCase, !end_getSide(end_getReverse(_5End)));

    cactusEndTestTeardown();
}
Пример #12
0
void testEnd_getOtherBlockEnd(CuTest *testCase) {
    cactusEndTestSetup();
    Block *block = block_construct(10, flower);
    End *leftEnd = block_get5End(block);
    End *rightEnd = block_get3End(block);

    CuAssertTrue(testCase, end_getOtherBlockEnd(end) == NULL);
    CuAssertTrue(testCase, end_getOtherBlockEnd(end_getReverse(end)) == NULL);

    CuAssertTrue(testCase, end_getOtherBlockEnd(leftEnd) == rightEnd);
    CuAssertTrue(testCase, end_getOtherBlockEnd(rightEnd) == leftEnd);

    CuAssertTrue(testCase, end_getOtherBlockEnd(end_getReverse(leftEnd)) == end_getReverse(rightEnd));
    CuAssertTrue(testCase, end_getOtherBlockEnd(end_getReverse(rightEnd)) == end_getReverse(leftEnd));

    cactusEndTestTeardown();
}
Пример #13
0
void testEnd_isAttachedOrFree(CuTest* testCase) {
    cactusEndTestSetup();
    End *end2 = end_construct(1, flower);
    End *end3 = end_construct(0, flower);
    Block *block = block_construct(2, flower);
    End *end4 = block_get5End(block);
    End *end5 = block_get3End(block);
    CuAssertTrue(testCase, end_isAttached(end2));
    CuAssertTrue(testCase, !end_isAttached(end3));
    CuAssertTrue(testCase, !end_isFree(end2));
    CuAssertTrue(testCase, end_isFree(end3));

    CuAssertTrue(testCase, !end_isAttached(end4));
    CuAssertTrue(testCase, !end_isAttached(end5));
    CuAssertTrue(testCase, end_isFree(end4));
    CuAssertTrue(testCase, end_isFree(end5));
    cactusEndTestTeardown();
}
Пример #14
0
void testEnd_getBlock(CuTest* testCase) {
    cactusEndTestSetup();
    Block *block = block_construct(10, flower);
    End *leftEnd = block_get5End(block);
    End *rightEnd = block_get3End(block);

    CuAssertTrue(testCase, end_getBlock(end) == NULL);
    CuAssertTrue(testCase, end_getBlock(end_getReverse(end)) == NULL);

    CuAssertTrue(testCase, end_getBlock(leftEnd) == block);
    CuAssertTrue(testCase, end_getBlock(end_getReverse(leftEnd)) == block_getReverse(block));
    CuAssertTrue(testCase, block_getOrientation(block) == end_getOrientation(leftEnd));

    CuAssertTrue(testCase, end_getBlock(rightEnd) == block);
    CuAssertTrue(testCase, end_getBlock(end_getReverse(rightEnd)) == block_getReverse(block));
    CuAssertTrue(testCase, block_getOrientation(block) == end_getOrientation(rightEnd));

    cactusEndTestTeardown();
}
Пример #15
0
void testGroup_getAttachedStubAndBlockEndNumber(CuTest* testCase) {
    cactusGroupTestSetup();
    CuAssertTrue(testCase, group_getAttachedStubEndNumber(group) == 0);
    CuAssertTrue(testCase, group_getBlockEndNumber(group) == 0);
    CuAssertIntEquals(testCase, 2, group_getStubEndNumber(group));
    CuAssertIntEquals(testCase, 2, group_getFreeStubEndNumber(group));
    end_setGroup(end_construct(1, flower), group);
    end_setGroup(end_construct(0, flower), group);
    end_setGroup(end_construct(1, flower), group);
    CuAssertTrue(testCase, group_getAttachedStubEndNumber(group) == 2);
    CuAssertTrue(testCase, group_getBlockEndNumber(group) == 0);
    CuAssertTrue(testCase, group_getStubEndNumber(group) == 5);
    CuAssertTrue(testCase, group_getFreeStubEndNumber(group) == 3);
    Block *block = block_construct(1, flower);
    end_setGroup(block_get5End(block), group);
    end_setGroup(block_get3End(block), group);
    CuAssertTrue(testCase, group_getAttachedStubEndNumber(group) == 2);
    CuAssertTrue(testCase, group_getBlockEndNumber(group) == 2);
    CuAssertTrue(testCase, group_getStubEndNumber(group) == 5);
    CuAssertTrue(testCase, group_getFreeStubEndNumber(group) == 3);
    cactusGroupTestTeardown();
}
Пример #16
0
Segment *block_getRootInstance(Block *block) {
	Cap *cap = end_getRootInstance(block_get5End(block));
	return cap != NULL ? cap_getSegment(cap) : NULL;
}