dc4322ce21733176ef6b04f060f15c6a3c7c773a hiram Thu Sep 29 12:09:25 2022 -0700 moving the reading of rmsk .out files into library function refs #29819 diff --git src/lib/repMask.c src/lib/repMask.c index 88fad17..8bf11a4 100644 --- src/lib/repMask.c +++ src/lib/repMask.c @@ -1,26 +1,28 @@ /* repMask.c was originally generated by the autoSql program, which also * generated repMask.h and repMask.sql. This module links the database and the RAM * representation of objects. */ /* Copyright (C) 2011 The Regents of the University of California * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */ #include "common.h" #include "sqlList.h" #include "sqlNum.h" #include "repMask.h" +#include "net.h" +#include "linefile.h" void repeatMaskOutStaticLoad(char **row, struct repeatMaskOut *ret) /* Load a row from repeatMaskOut table into ret. The contents of ret will * be replaced at the next call to this function. */ { int i; ret->score = sqlUnsigned(row[0]); ret->percDiv = atof(row[1]); ret->percDel = atof(row[2]); ret->percInc = atof(row[3]); ret->qName = row[4]; ret->qStart = sqlSigned(row[5]); ret->qEnd = sqlSigned(row[6]); @@ -159,15 +161,43 @@ fprintf(f, "%s", el->rFamily); if (sep == ',') fputc('"',f); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->rStart); if (sep == ',') fputc('"',f); fputc(sep,f); fprintf(f, "%u", el->rEnd); fputc(sep,f); if (sep == ',') fputc('"',f); fprintf(f, "%s", el->rLeft); if (sep == ',') fputc('"',f); fputc(lastSep,f); } +struct lineFile *rmskLineFileOpen(char *fileName) +/* open a repeat masker .out file or die trying */ +{ +struct lineFile *lf; +char *line; +int lineSize; + +if (udcIsLocal(fileName)) + lf = lineFileOpen(fileName, TRUE); +else + lf = netLineFileOpen(fileName); + +if (!lineFileNext(lf, &line, &lineSize)) + errAbort("Empty %s", lf->fileName); + +if (!(startsWith(" SW perc perc", line) || + startsWith(" SW perc perc", line) || + startsWith(" SW perc perc", line) || + startsWith(" bit perc perc", line))) + { + errAbort("%s doesn't seem to be a RepeatMasker .out file, first " + "line seen:\n%s", lf->fileName, line); + } +lineFileNext(lf, &line, &lineSize); +lineFileNext(lf, &line, &lineSize); + +return lf; +}