static void readFromBuffer(Chain* chain, char* fileBuffer, SWPrefs* swPrefs) { Matcher* matcher = swPrefsGetMatcher(swPrefs); int shotgun = swPrefsShotgun(swPrefs); int fileLength = strlen(fileBuffer); // Maximum chain length is equal to input file length. chain->items = (ChainItem*) malloc(sizeof(ChainItem) * fileLength); chain->codes = (ChainCode*) malloc(sizeof(ChainCode) * fileLength); chain->length = 0; int fileCharIdx; int isSpace; // boolean ChainItem chainItem; ChainItem chainCode; int fillItems = (matcherGetType(matcher) == MATCHER_MATCH_MISMATCH); int start = 0; while (fileBuffer[start] != '\n') start++; chain->name = malloc((start + 1) * sizeof(char)); chain->name = strncpy(chain->name, fileBuffer, start); chain->name[start] = '\0'; // Read all items into the item array. Use matcher object to get the item // codes and write them to code array. for (fileCharIdx = start; fileCharIdx < fileLength; ++fileCharIdx) { isSpace = isspace(fileBuffer[fileCharIdx]); if (isSpace) { continue; } chainItem = (ChainItem) toupper(fileBuffer[fileCharIdx]); chain->items[chain->length] = chainItem; if (fillItems) matcherAddItem(matcher, chainItem); chainCode = (ChainCode) matcherGetCode(matcher, chainItem, shotgun); chain->codes[chain->length] = chainCode; if (chain->codes[chain->length] == MATCHER_CODE_NOT_FOUND) { printf("Item not in matching table %c.\n", chainItem); exit(-1); } chain->length++; } if (!TEST_MODE) { printf("%.55s... length:%14d\n", chain->name, chain->length); } }
extern SWData* swSolveGPU(Chain* rowChain, Chain* columnChain, SWPrefs* swPrefs) { int matcherType = matcherGetType(swPrefsGetMatcher(swPrefs)); if (matcherType == MATCHER_MATRIX) { return swSolveGPUSM(rowChain, columnChain, swPrefs); } else { return swSolveGPUMM(rowChain, columnChain, swPrefs); } }