void checkLine(int lineNumber, char *line, char *regex, int childNum) { ArrayList* result = matchingPositions(line, regex); for (int i = 0; i < result->size; i++) { int position = alGet(result, i); printf("%d:%d\n", lineNumber, position); // for (int k = 0; k < position; k++) printf(" "); // printf("^\n"); } alDelete(result); usleep(100); }
void mergeAll() /* read through nameHash */ /* look up in 4 population hashes */ /* call logMissing to report on missing data */ /* check chrom, position, strand, observed */ { char outputFileName[64]; FILE *outputFileHandle = NULL; struct hashCookie cookie; struct hashEl *nameHashElement = NULL; struct hashEl *helCEU = NULL; struct hashEl *helCHB = NULL; struct hashEl *helJPT = NULL; struct hashEl *helYRI = NULL; boolean allMatch = TRUE; struct hapmapSnpsCombined *hap = NULL; safef(outputFileName, sizeof(outputFileName), "hapmapSnpsCombined.tab"); outputFileHandle = mustOpen(outputFileName, "w"); cookie = hashFirst(nameHash); while ((nameHashElement = hashNext(&cookie)) != NULL) { helCEU = hashLookup(hashCEU, nameHashElement->name); helCHB = hashLookup(hashCHB, nameHashElement->name); helJPT = hashLookup(hashJPT, nameHashElement->name); helYRI = hashLookup(hashYRI, nameHashElement->name); /* should convert to instance of hapmapSnps here */ logMissing(nameHashElement->name, helCEU, helCHB, helJPT, helYRI); allMatch = matchingChroms(helCEU, helCHB, helJPT, helYRI); if (!allMatch) { fprintf(errorFileHandle, "different chroms for %s\n", nameHashElement->name); continue; } allMatch = matchingPositions(helCEU, helCHB, helJPT, helYRI); if (!allMatch) { fprintf(errorFileHandle, "different positions for %s\n", nameHashElement->name); continue; } /* if strand is different, log and fix if possible */ allMatch = matchingStrand(helCEU, helCHB, helJPT, helYRI); if (!allMatch) { fprintf(errorFileHandle, "different strands for %s\n", nameHashElement->name); hap = fixStrandAndMerge(helCEU, helCHB, helJPT, helYRI); if (hap) writeOutput(hap, outputFileHandle); continue; } /* different observed is not a fatal error? */ allMatch = matchingObserved(helCEU, helCHB, helJPT, helYRI); if (!allMatch) { fprintf(errorFileHandle, "different observed for %s\n", nameHashElement->name); continue; } /* should just have 2 alleles in all */ allMatch = matchingAlleles(helCEU, helCHB, helJPT, helYRI); if (!allMatch) { fprintf(errorFileHandle, "different alleles for %s\n", nameHashElement->name); continue; } hap = mergeOne(helCEU, helCHB, helJPT, helYRI); if (hap) writeOutput(hap, outputFileHandle); } carefulClose(&outputFileHandle); }