コード例 #1
0
void testMetaSequence_serialisation(CuTest* testCase) {
	cactusMetaSequenceTestSetup();
	int64_t i;
	Name name = metaSequence_getName(metaSequence);
	CuAssertTrue(testCase, cactusDisk_getMetaSequence(cactusDisk, name) == metaSequence);
	void *vA = binaryRepresentation_makeBinaryRepresentation(metaSequence,
			(void (*)(void *, void (*)(const void *, size_t, size_t)))metaSequence_writeBinaryRepresentation, &i);
	CuAssertTrue(testCase, i > 0);
	metaSequence_destruct(metaSequence);
	CuAssertTrue(testCase, cactusDisk_getMetaSequence(cactusDisk, name) == NULL);
	void *vA2 = vA;
	metaSequence = metaSequence_loadFromBinaryRepresentation(&vA2, cactusDisk);
	CuAssertTrue(testCase, name == metaSequence_getName(metaSequence));
	CuAssertStrEquals(testCase, headerString, metaSequence_getHeader(metaSequence));
	CuAssertTrue(testCase, cactusDisk_getMetaSequence(cactusDisk, name) == metaSequence);
	cactusDisk_write(cactusDisk);
	metaSequence_destruct(metaSequence);
	CuAssertTrue(testCase, cactusDisk_getMetaSequence(cactusDisk, name) != NULL);
	metaSequence = cactusDisk_getMetaSequence(cactusDisk, name);
	nestedTest = 1;
	testMetaSequence_getName(testCase);
	testMetaSequence_getStart(testCase);
	testMetaSequence_getLength(testCase);
	testMetaSequence_getEventName(testCase);
	testMetaSequence_getString(testCase);
	testMetaSequence_getHeader(testCase);
	testMetaSequence_isTrivialSequence(testCase);
	nestedTest = 0;
	cactusMetaSequenceTestTeardown();
}
コード例 #2
0
void metaSequence_writeBinaryRepresentation(MetaSequence *metaSequence,
		void (*writeFn)(const void * ptr, size_t size, size_t count)) {
	binaryRepresentation_writeElementType(CODE_META_SEQUENCE, writeFn);
	binaryRepresentation_writeName(metaSequence_getName(metaSequence), writeFn);
	binaryRepresentation_writeInteger(metaSequence_getStart(metaSequence), writeFn);
	binaryRepresentation_writeInteger(metaSequence_getLength(metaSequence), writeFn);
	binaryRepresentation_writeName(metaSequence_getEventName(metaSequence), writeFn);
	binaryRepresentation_writeName(metaSequence->stringName, writeFn);
	binaryRepresentation_writeString(metaSequence_getHeader(metaSequence), writeFn);
	binaryRepresentation_writeBool(metaSequence_isTrivialSequence(metaSequence), writeFn);
}
コード例 #3
0
int main(int argc, char *argv[])
{
    char *cactusDiskString = NULL;
    stKVDatabaseConf *kvDatabaseConf;
    CactusDisk *cactusDisk;
    Flower *flower;
    Flower_SequenceIterator *flowerIt;
    Sequence *sequence;
    struct option longopts[] = { {"cactusDisk", required_argument, NULL, 'c' },
                                 {0, 0, 0, 0} };
    int flag;
    while((flag = getopt_long(argc, argv, "", longopts, NULL)) != -1) {
        switch(flag) {
        case 'c':
            cactusDiskString = stString_copy(optarg);
            break;
        case '?':
        default:
            usage();
            return 1;
        }
    }
    if (cactusDiskString == NULL) {
        st_errAbort("--cactusDisk option must be provided");
    }
    kvDatabaseConf = stKVDatabaseConf_constructFromString(cactusDiskString);
    cactusDisk = cactusDisk_construct(kvDatabaseConf, 0);
    // Get top-level flower.
    flower = cactusDisk_getFlower(cactusDisk, 0);
    flowerIt = flower_getSequenceIterator(flower);
    while((sequence = flower_getNextSequence(flowerIt)) != NULL) {
        MetaSequence *metaSequence = sequence_getMetaSequence(sequence);
        const char *header;
        char *firstToken, *newHeader;
        stList *tokens;
        // Strip the ID token from the header (should be the first
        // |-separated token) and complain if there isn't one.
        header = metaSequence_getHeader(metaSequence);
        tokens = fastaDecodeHeader(header);
        assert(stList_length(tokens) > 1);
        firstToken = stList_removeFirst(tokens);
        assert(!strncmp(firstToken, "id=", 3));
        free(firstToken);
        newHeader = fastaEncodeHeader(tokens);
        metaSequence_setHeader(metaSequence, newHeader);
    }
    cactusDisk_write(cactusDisk);
}
コード例 #4
0
ファイル: cactusSequence.c プロジェクト: benedictpaten/cactus
const char *sequence_getHeader(Sequence *sequence) {
	return metaSequence_getHeader(sequence->metaSequence);
}
コード例 #5
0
void testMetaSequence_getHeader(CuTest* testCase) {
	cactusMetaSequenceTestSetup();
	CuAssertStrEquals(testCase, headerString, metaSequence_getHeader(metaSequence));
	cactusMetaSequenceTestTeardown();
}