void findContigsWithClones(char *cloneFile, char *ooDir, char *snoopIn) /* findContigsWithClones - find contigs that contain clones. */ { struct slName *el; cloneList = readAllLines(cloneFile); for (el = cloneList; el != NULL; el = el->next) chopSuffix(el->name); snoopFileName = snoopIn; ooToAllContigs(ooDir, doContig); }
void reverseLineOrder(char *input, char *output) /* reverseLineOrder - Write out a file with first line last and last line first.. */ { struct slName *el, *list = readAllLines(input); slReverse(&list); FILE *f = mustOpen(output, "w"); for (el = list; el != NULL; el = el->next) { fprintf(f, "%s\n", el->name); } carefulClose(&f); }
void regBedStats(char *fileOfFiles, char *output) /* regBedStats - Go through bed files and calculate a bunch of statistics on them. */ { struct slName *in, *inList = readAllLines(fileOfFiles); FILE *f = mustOpen(output, "w"); int colCount = max(chromColIx, startColIx); colCount = max(colCount, endColIx); colCount = max(colCount, scoreColIx); colCount += 1; for (in = inList; in != NULL; in = in->next) { bedFileStats(in->name, colCount, f); } carefulClose(&f); }
void rowsToCols(char *in, char *out) /* rowsToCols - Convert rows to columns and vice versa in a text file.. */ { struct slName *lineList = readAllLines(in); struct tabRow *row, *rowList; FILE *f; int i, origCols; char *s; if (fs != NULL) rowList = tabRowByChar(lineList, fs[0], in, varCol); else if (fixed) rowList = tabRowByFixedGuess(lineList, in); else if (offsets) { struct slName *nameList = commaSepToSlNames(offsets), *name; struct slInt *offList=NULL, *off; for (name = nameList; name != NULL; name = name->next) { off = slIntNew(atoi(name->name)); slAddTail(&offList, off); } rowList = tabRowByFixedOffsets(lineList, offList, in); } else rowList = tabRowByWhite(lineList, in, varCol); origCols = tabRowMaxColCount(rowList); f = mustOpen(out, "w"); for (i=0; i<origCols; ++i) { for (row = rowList; row != NULL; row = row->next) { if (i < row->colCount) s = row->columns[i]; else s = ""; fprintf(f, "%s", s); if (row->next == NULL) fprintf(f, "\n"); else fprintf(f, "\t"); } } carefulClose(&f); }
void distributeRgbRainbow(char *inList, char *inPairs, char *outTab) /* distributeRgbRainbow - Associate colors with items on a list where distance between colors * is proportional to distance between items. */ { /* Read in inputs */ struct slName *item, *itemList = readAllLines(inList); verbose(1, "%d items in %s\n", slCount(itemList), inList); struct pairDistance *pairList= pairDistanceReadAll(inPairs); verbose(1, "%d pairs in %s\n", slCount(pairList), inPairs); struct hash *pairHash = pairDistanceHashList(pairList); /* Open output, and just finish early if it should be empty */ FILE *f = mustOpen(outTab, "w"); if (itemList == NULL) return; /* Cope with invert option. */ if (optionExists("invert")) pairDistanceInvert(pairList); /* Add up total distance between all items */ double totalDistance = 0.0; for (item = itemList; item != NULL; item = item->next) { struct slName *nextItem = item->next; if (nextItem == NULL) break; totalDistance += pairDistanceHashLookup(pairHash, item->name, nextItem->name); } double colorRange = gEnd - gStart; outputItem(f, itemList->name, gStart); double soFar = 0.0; for (item = itemList; item != NULL; item = item->next) { struct slName *nextItem = item->next; if (nextItem == NULL) break; double distance = pairDistanceHashLookup(pairHash, item->name, nextItem->name); soFar += distance; outputItem(f, nextItem->name, gStart + (soFar/totalDistance * colorRange)); } carefulClose(&f); }
void regClusterMakeTableOfTables(char *type, char *input, char *output) /* regClusterMakeTableOfTables - Make up a table of tables for regCluster program. */ { FILE *f = mustOpen(output, "w"); struct slName *in, *inList = readAllLines(input); /* Generally we'll have a bunch of file names that all start and/or end with the same * thing. This loop will isolate out the bits that vary, and then call a type-specific * routine to output the metadata columns from the middle parts. */ int commonPrefix = commonPrefixSize(inList); int commonSuffix = commonSuffixSize(inList); uglyf("regClusterMakeTableOfTables(type=%s, input=%s, output=%s)\n", type, input, output); int scoreIx = scoreColIx - 1; for (in = inList; in != NULL; in = in->next) { verbose(2, "Processing %s\n", in->name); fprintf(f, "%s\t0\t1\t2\t%d\t", in->name, scoreIx); fprintf(f, "%g", calcNormScoreFactor(in->name, scoreIx)); char *s = in->name; int len = strlen(s); char *midString = cloneStringZ(s+commonPrefix, len - commonPrefix - commonSuffix); if (sameString(type, "uw01")) uw01MetaOut(f, midString); else if (sameString(type, "uw02")) uw02MetaOut(f, midString); else if (sameString(type, "ans01")) ans01MetaOut(f, midString); else if (sameString(type, "ans02")) ans02MetaOut(f, midString); else if (sameString(type, "enh01")) enh01MetaOut(f, midString); else if (sameString(type, "awgDnase01")) awgDnase01MetaOut(f, midString); else errAbort("Unknown type '%s' in first command line parameter.", type); freez(&midString); fprintf(f, "\n"); } carefulClose(&f); }
void makeConfigFromFileList(char *input, char *output) /* makeConfigFromFileList - Create config file for hgBedsToBedExps from list of files.. */ { FILE *f = mustOpen(output, "w"); struct slName *in, *inList = readAllLines(input); int commonPrefix = commonPrefixSize(inList); int commonSuffix = commonSuffixSize(inList); for (in = inList; in != NULL; in = in->next) { char *s = in->name; int len = strlen(s); char *midString = cloneStringZ(s+commonPrefix, len - commonPrefix - commonSuffix); char *factor, *cell; camelParseTwo(midString, &cell, &factor); fprintf(f, "%s\t%s\t", factor, cell); fprintf(f, "%s\t", cellAbbreviation(cell)); fprintf(f, "file\t%d\t", scoreCol-1); fprintf(f, "%g\t", calcNormScoreFactor(in->name, scoreCol-1)); fprintf(f, "%s\n", in->name); } carefulClose(&f); }