struct psl *nextPsl(struct lineFile *lf) /* Read next line from file and convert it to psl. Return * NULL at eof. */ { char *line; int lineSize; char *words[32]; int wordCount; if (!lineFileNext(lf, &line, &lineSize)) { //warn("File %s appears to be incomplete\n", lf->fileName); return NULL; } wordCount = chopTabs(line, words); if (wordCount == 21) { return pslLoad(words); } else if (wordCount == 23) { return pslxLoad(words); } else { warn("Bad line %d of %s", lf->lineIx, lf->fileName); return NULL; } }
static struct psl *queryNext(struct pslReader* pr) /* read the next record from a query */ { char **row = sqlNextRow(pr->sr); if (row == NULL) return NULL; if (pr->isPslx) return pslxLoad(row+pr->rowOffset); else return pslLoad(row+pr->rowOffset); }
void pslReps(char *inName, char *bestAliName, char *repName) /* Analyse inName and put best alignments for eacmRNA in estAliName. * Put repeat info in repName. */ { struct lineFile *in = pslFileOpen(inName); FILE *bestFile = mustOpen(bestAliName, "w"); FILE *repFile = mustOpen(repName, "w"); int lineSize; char *line; char *words[32]; int wordCount; struct psl *pslList = NULL, *psl = NULL; char lastName[512]; int aliCount = 0; quiet = sameString(bestAliName, "stdout") || sameString(repName, "stdout"); if (coverQSizeFile != NULL) loadCoverQSizes(coverQSizeFile); if (!quiet) printf("Processing %s to %s and %s\n", inName, bestAliName, repName); if (!noHead) pslWriteHead(bestFile); strcpy(lastName, ""); while (lineFileNext(in, &line, &lineSize)) { if (((++aliCount & 0x1ffff) == 0) && !quiet) { printf("."); fflush(stdout); } wordCount = chopTabs(line, words); if (wordCount == 21) psl = pslLoad(words); else if (wordCount == 23) psl = pslxLoad(words); else errAbort("Bad line %d of %s\n", in->lineIx, in->fileName); if (!sameString(lastName, psl->qName)) { doOneAcc(lastName, pslList, bestFile, repFile); pslFreeList(&pslList); safef(lastName, sizeof(lastName), "%s", psl->qName); } slAddHead(&pslList, psl); } doOneAcc(lastName, pslList, bestFile, repFile); pslFreeList(&pslList); lineFileClose(&in); fclose(bestFile); fclose(repFile); if (!quiet) printf("Processed %d alignments\n", aliCount); }
static struct psl *fileNext(struct pslReader* pr) /* read the next record from a file */ { char *row[PSLX_NUM_COLS]; int numCols; while ((numCols = lineFileChopNextTab(pr->lf, row, PSLX_NUM_COLS)) > 0) { lineFileExpectWords(pr->lf, (pr->isPslx ? PSLX_NUM_COLS : PSL_NUM_COLS), numCols); if ((pr->chrom == NULL) || (sameString(row[13], pr->chrom))) { if (pr->isPslx) return pslxLoad(row); else return pslLoad(row); } } return NULL; }