bc54347cde3cd33cbfc7427ef9739f8056663795 chmalee Wed Mar 1 11:31:01 2023 -0800 Prevent liftover from thinking colons in bed names mean input is in position format, refs #30705 diff --git src/hg/lib/liftOver.c src/hg/lib/liftOver.c index 839056c..6da453c 100644 --- src/hg/lib/liftOver.c +++ src/hg/lib/liftOver.c @@ -1394,59 +1394,60 @@ end = lineFileNeedNum(lf, words, 2); fprintf(unmapped, "%s:%d-%d\n", chrom, BEDSTART_TO_POSITION(start), end); } } lineFileClose(&lf); return ct; } enum liftOverFileType liftOverSniff(char *fileName) /* the file-sniffing bit used to distinguish bed from positions files */ /* returns enum concerning the file type */ { struct lineFile *lf = lineFileOpen(fileName, TRUE); char *line = NULL; -char *chrom, *start, *end; +char *chrom = NULL, *start = NULL, *end = NULL; boolean isPosition = FALSE; lineFileNextReal(lf, &line); if (!line) return 0; -chrom = line; +chrom = cloneString(line); +char *words[3]; +int numWords = chopLine(line, words); +if (numWords < 3) + { start = strchr(chrom, ':'); if (start) { *start++ = 0; end = strchr(start, '-'); if (end) { *end++ = 0; isPosition = TRUE; } else return 0; } + } else { - char *words[3]; - int numWords = chopLine(line, words); - if (numWords < 3) - return 0; start = words[1]; end = words[2]; } -if (!isdigit(start[0]) || !isdigit(end[0])) +if ((start && !isdigit(start[0])) || (end && !isdigit(end[0]))) return none; lineFileClose(&lf); if (isPosition) return positions; return bed; } int liftOverBedOrPositions(char *fileName, struct hash *chainHash, double minMatch, double minBlocks, int minSizeT, int minSizeQ, int minChainT, int minChainQ, bool fudgeThick, FILE *mapped, FILE *unmapped, bool multiple, bool noSerial, char *chainTable, int *errCt) /* Sniff the first line of the file, and determine whether it's a */ /* bed, a positions file, or neither. */