bfcfffa0ad0401f5264bb656e569a78a12847e12 aamp Tue Feb 28 15:59:13 2012 -0800 changed hgLiftOver to only output message out multiple option not being suppported for the positions format ONLY if the input is positions format and if the multiple option is checked diff --git src/hg/lib/liftOver.c src/hg/lib/liftOver.c index ad15316..d9444ea 100644 --- src/hg/lib/liftOver.c +++ src/hg/lib/liftOver.c @@ -1187,38 +1187,33 @@ fprintf(unmapped, "%s\n", line); else { wordCount = chopLine(line, words); chrom = words[0]; start = lineFileNeedNum(lf, words, 1); end = lineFileNeedNum(lf, words, 2); fprintf(unmapped, "%s:%d-%d\n", chrom, BEDSTART_TO_POSITION(start), end); } } lineFileClose(&lf); return ct; } -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, char *chainTable, int *errCt) -/* Sniff the first line of the file, and determine whether it's a */ -/* bed, a positions file, or neither. */ +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; boolean isPosition = FALSE; lineFileNextReal(lf, &line); if (!line) return 0; chrom = line; start = strchr(chrom, ':'); if (start) { *start++ = 0; end = strchr(start, '-'); if (end) @@ -1227,39 +1222,56 @@ 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])) - return 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, char *chainTable, int *errCt) +/* Sniff the first line of the file, and determine whether it's a */ +/* bed, a positions file, or neither. */ +{ +enum liftOverFileType lft = liftOverSniff(fileName); +if (lft == positions) return liftOverPositions(fileName, chainHash, minMatch, minBlocks, minSizeT, minSizeQ, minChainT, minChainQ, fudgeThick, mapped, unmapped, multiple, chainTable, errCt); +if (lft == bed) return liftOverBed(fileName, chainHash, minMatch, minBlocks, minSizeT, minSizeQ, minChainT, minChainQ, fudgeThick, mapped, unmapped, multiple, chainTable, errCt); +return -1; } static char *remapBlockedPsl(struct hash *chainHash, struct psl *psl, double minMatch, double minBlocks, bool fudgeThick) /* Remap blocks in psl, and also chromStart/chromEnd. * Return NULL on success, an error string on failure. */ { struct chain *chainList = NULL, *chain; int pslSize = sumPslBlocks(psl); struct binElement *binList; struct binElement *el; struct liftRange *rangeList, *badRanges = NULL, *range; char *error = NULL; int i, start, end = 0; //int pslStart = psl->tStart;