void writeOutput(double *gcBins, unsigned int windowSize, double totalWindows, char *outFilename) { unsigned int i = 0; FILE *fout = mustOpen(outFilename, "w"); double percentGc = 0, percentTotal = 0; for(i=0; i<=windowSize; i++) { percentGc = (double)i/(double)windowSize; percentTotal = gcBins[i]/totalWindows; fprintf(fout, "%u %f %f\n", i, percentGc, percentTotal); } carefulClose(&fout); }
void cnvBedToPsl(char *chromSizesFile, char *bedFile, char *pslFile) /* convert bed format files to PSL format */ { struct hash *chromSizes = loadChromSizes(chromSizesFile); struct lineFile *bedLf = lineFileOpen(bedFile, TRUE); FILE *pslFh = mustOpen(pslFile, "w"); char *line; while (lineFileNextReal(bedLf, &line)) cnvBedRec(line, chromSizes, pslFh); carefulClose(&pslFh); lineFileClose(&bedLf); }
void ldGencodeIntron(char *database, char *table, int gtfCount, char *gtfNames[]) /* Load Gencode intron status table from GTF files with * intron_id and intron_status keywords */ { struct gffFile *gff, *gffList = NULL; struct gffLine *gffLine; struct gencodeIntron *intron, *intronList = NULL; struct sqlConnection *conn; FILE *f; int i; int introns = 0; for (i=0; i<gtfCount; i++) { verbose(1, "Reading %s\n", gtfNames[i]); gff = gffRead(gtfNames[i]); for (gffLine = gff->lineList; gffLine != NULL; gffLine = gffLine->next) { if (sameWord(gffLine->feature, "intron")) { AllocVar(intron); intron->chrom = gffLine->seq; intron->chromStart = gffLine->start; intron->chromEnd = gffLine->end; intron->name = gffLine->intronId; intron->strand[0] = gffLine->strand; intron->strand[1] = 0; intron->status = gffLine->intronStatus; intron->transcript = gffLine->group; intron->geneId = gffLine->geneId; slAddHead(&intronList, intron); verbose(2, "%s %s\n", intron->chrom, intron->name); introns++; } } } slSort(&intronList, bedCmp); f = hgCreateTabFile(".", table); for (intron = intronList; intron != NULL; intron = intron->next) gencodeIntronTabOut(intron, f); carefulClose(&f); verbose(1, "%d introns in %d files\n", introns, gtfCount); hSetDb(database); conn = sqlConnect(database); gencodeIntronTableCreate(conn, table, hGetMinIndexLength()); hgLoadTabFile(conn, ".", table, &f); sqlDisconnect(&conn); }
void pickCassettePcrPrimers(char *db, char *bedFileName, char *primerFaName, char *primerBedName) /* pickCassettePcrPrimers - Takes a bedFile with three exons and for each bed calls primer3 to pick primers that will detect the inclusion or exclusion of the exon.. */ { struct bed *bed=NULL, *bedList = NULL; FILE *primerFa = NULL; FILE *primerBed = NULL; struct cassetteSeq *cseq = NULL; int targetExon = optionInt("targetExon", 1); hSetDb(db); bed = bedList = bedLoadAll(bedFileName); primerFa = mustOpen(primerFaName, "w"); primerBed = mustOpen(primerBedName, "w"); for(bed=bedList; bed != NULL; bed = bed->next) { cseq = cassetteSeqFromBed(bed, targetExon); callPrimer3(cseq, primerFa, primerBed); cassetteSeqFree(&cseq); } bedFreeList(&bedList); carefulClose(&primerFa); carefulClose(&primerBed); }
static void getProtSeqs(struct sqlConnection *conn, struct hash *refSeqVerInfoTbl, char *outFile) /* get request prot sequences from database */ { struct hash *doneProts = hashNew(16); FILE *fh = mustOpen(outFile, "w"); struct hashCookie cookie = hashFirst(refSeqVerInfoTbl); struct hashEl *hel; while ((hel = hashNext(&cookie)) != NULL) { processProtSeq(fh, conn, hel->val, doneProts); } carefulClose(&fh); hashFree(&doneProts); }
void invokeR(struct dyString *script) /* Call R on our script. */ { struct tempName rScript; FILE *out = NULL; char command[256]; assert(script); makeTempName(&rScript, "sp", ".R"); out = mustOpen(rScript.forCgi, "w"); fprintf(out, "%s", script->string); carefulClose(&out); safef(command, sizeof(command), "R --vanilla < %s >& /dev/null ", rScript.forCgi); system(command); }
int main(int argc, char *argv[]) { if (argc != 3) usage(); db = argv[1]; hSetDb(db); if (!hTableExists(argv[2])) { verbose(1, "can't find table %s\n", argv[2]); return 1; } errorFileHandle = mustOpen("hapmapValidate.error", "w"); complexFileHandle = mustOpen("hapmapValidate.complex", "w"); dynamicObserved = newDyString(32); hapmapValidate(argv[2]); carefulClose(&errorFileHandle); carefulClose(&complexFileHandle); return 0; }
static void getGeneAnns(struct sqlConnection *conn, struct hash *refSeqVerInfoTbl, char *outFile) /* get request genePred annotations from database */ { struct genePredReader *gpr = genePredReaderQuery(conn, "refGene", NULL); FILE *fh = mustOpen(outFile, "w"); struct genePred *gp; while ((gp = genePredReaderNext(gpr)) != NULL) { processGenePred(fh, refSeqVerInfoTbl, gp); genePredFree(&gp); } carefulClose(&fh); genePredReaderFree(&gpr); }
void faLowerToN(char *inName, char *outName) /* faLowerToN - Convert lower case bases to N.. */ { struct lineFile *lf = lineFileOpen(inName, TRUE); FILE *f = mustOpen(outName, "w"); char *line; while (lineFileNext(lf, &line, NULL)) { if (line[0] != '>') lowerToN(line); fprintf(f, "%s\n", line); } carefulClose(&f); }
void aNotB(char *aFile, char *bFile, char *outFile) /* aNotB - List symbols that are in a but not b. */ { struct hash *bHash = hashFirstWord(bFile); struct lineFile *lf = lineFileOpen(aFile, TRUE); FILE *f = mustOpen(outFile, "w"); char *row[1]; while (lineFileRow(lf, row)) { if (!hashLookup(bHash, row[0])) fprintf(f, "%s\n", row[0]); } carefulClose(&f); }
struct sanger22extra *makeFixedGffAndReadExtra(char *txGff, char *cdsGff, char *fixedGff, struct hash *extraHash) /* Combine txGff and cdsGff into something our regular GFF to * genePred routine can handle. */ { FILE *f = mustOpen(fixedGff, "w"); struct sanger22extra *extraList = NULL; processOneGff(txGff, f, "exon", extraHash, &extraList, FALSE); processOneGff(cdsGff, f, "CDS", extraHash, &extraList, TRUE); carefulClose(&f); slReverse(&extraList); return extraList; }
int main(int argc, char *argv[]) /* Process command line. */ { optionInit(&argc, argv, options); if (argc != 4) usage(); refType = optionVal("refType", refType); char *fileName = optionVal("constExon", NULL); if (fileName != NULL) fConst = mustOpen(fileName, "w"); txgAnalyze(argv[1], argv[2], argv[3]); carefulClose(&fConst); return 0; }
int main(int argc, char *argv[]) /* read chrN_snpTmp, handle locType, rewrite to individual chrom tables */ { struct slName *chromList, *chromPtr; int expandCount = 0; if (argc != 3) usage(); snpDb = argv[1]; contigGroup = argv[2]; hSetDb(snpDb); chromList = getChromListFromContigInfo(contigGroup); if (chromList == NULL) { verbose(1, "couldn't get chrom info\n"); return 1; } errorFileHandle = mustOpen("snpLocType125.errors", "w"); exceptionFileHandle = mustOpen("snpLocType125.exceptions", "w"); for (chromPtr = chromList; chromPtr != NULL; chromPtr = chromPtr->next) { verbose(1, "chrom = %s\n", chromPtr->name); expandCount = expandCount + doLocType(chromPtr->name); recreateDatabaseTable(chromPtr->name); loadDatabase(chromPtr->name); } if (expandCount > 0) verbose(1, "need to expand %d alleles\n", expandCount); carefulClose(&errorFileHandle); carefulClose(&exceptionFileHandle); return 0; }
void doFetch(char *inputFileName, char *sequenceFileName, char *outputFileName) /* lookup sequence for each line */ { struct lineFile *lf = NULL; char *line; char *row[6]; int elementCount; struct twoBitFile *tbf; char *fileChrom = NULL; int start = 0; int end = 0; char *name = NULL; int score = 0; char *strand = NULL; struct dnaSeq *chunk = NULL; FILE *outputFileHandle = mustOpen(outputFileName, "w"); tbf = twoBitOpen(sequenceFileName); lf = lineFileOpen(inputFileName, TRUE); while (lineFileNext(lf, &line, NULL)) { elementCount = chopString(line, "\t", row, ArraySize(row)); if (elementCount != 6) continue; fileChrom = cloneString(row[0]); start = sqlUnsigned(row[1]); end = sqlUnsigned(row[2]); name = cloneString(row[3]); score = sqlUnsigned(row[4]); strand = cloneString(row[5]); if (start == end) continue; assert (end > start); chunk = twoBitReadSeqFrag(tbf, fileChrom, start, end); touppers(chunk->dna); if (sameString(strand, "-")) reverseComplement(chunk->dna, chunk->size); fprintf(outputFileHandle, "%s\t%d\t%d\t%s\t%d\t%s\t%s\n", fileChrom, start, end, name, score, strand, chunk->dna); dnaSeqFree(&chunk); } lineFileClose(&lf); carefulClose(&outputFileHandle); }
void dnaseHg38AddTreatments(char *inTab, char *outTab) /* dnaseHg38AddTreatments - Add treatments to dnase hg38 metadata. */ { struct sqlConnection *conn = sqlConnect("hgFixed"); struct lineFile *lf = lineFileOpen(inTab, TRUE); FILE *f = mustOpen(outTab, "w"); char *line; while (lineFileNext(lf, &line, NULL)) { if (line[0] == '#') fprintf(f, "%s\ttreatment\tlabel\n", line); else { char *inRow[5]; int wordCount = chopByWhite(line, inRow, ArraySize(inRow)); lineFileExpectWords(lf, 4, wordCount); char *acc = inRow[0]; char *biosample = inRow[1]; char query[512]; sqlSafef(query, sizeof(query), "select expVars from encodeExp where accession = '%s'", acc); char varBuf[1024]; char *treatment = "n/a"; char *label = biosample; char labelBuf[256]; char *vars = sqlQuickQuery(conn, query, varBuf, sizeof(varBuf)); if (!isEmpty(vars)) { treatment = vars + strlen("treatment="); if (sameString(treatment, "4OHTAM_20nM_72hr")) safef(labelBuf, sizeof(labelBuf), "%s 40HTAM", biosample); else if (sameString(treatment, "diffProtA_14d")) safef(labelBuf, sizeof(labelBuf), "%s diff 14d", biosample); else if (sameString(treatment, "diffProtA_5d")) safef(labelBuf, sizeof(labelBuf), "%s diff 5d", biosample); else if (sameString(treatment, "DIFF_4d")) safef(labelBuf, sizeof(labelBuf), "%s diff 4d", biosample); else if (sameString(treatment, "Estradiol_100nM_1hr")) safef(labelBuf, sizeof(labelBuf), "%s estradi 1h", biosample); else if (sameString(treatment, "Estradiol_ctrl_0hr")) safef(labelBuf, sizeof(labelBuf), "%s estradi 0h", biosample); else errAbort("Unknown treatment %s", treatment); label = labelBuf; } fprintf(f, "%s\t%s\t%s\t%s\t%s\t%s\n", inRow[0], inRow[1], inRow[2], inRow[3], treatment, label); } } carefulClose(&f); }
void mafStats(char *twoBitFile, char *mafDir, char *outFile) /* mafStats - Calculate basic stats on maf file including species-by-species * coverage and percent ID. */ { struct twoBitFile *tbf = twoBitOpen(twoBitFile); FILE *f = mustOpen(outFile, "w"); struct twoBitIndex *ix; long genomeSize = 0; struct hash *speciesHash = hashNew(0); struct speciesAcc *speciesList = NULL, *species; for (ix = tbf->indexList; ix != NULL; ix = ix->next) { unsigned chromSize = twoBitSeqSizeNoNs(tbf, ix->name); genomeSize += chromSize; char mafFileName[PATH_LEN]; safef(mafFileName, sizeof(mafFileName), "%s/%s.maf", mafDir, ix->name); struct mafFile *mf = mafMayOpen(mafFileName); verbose(1, "processing %s\n", ix->name); if (mf == NULL) { warn("%s doesn't exist", mafFileName); continue; } struct mafAli *maf; while ((maf = mafNext(mf)) != NULL) { struct mafComp *mc; for (mc = maf->components; mc != NULL; mc = mc->next) { if (mc->text != NULL) toUpperN(mc->text, maf->textSize); } addCounts(maf, speciesHash, &speciesList); mafAliFree(&maf); } mafFileFree(&mf); } slReverse(&speciesList); for (species = speciesList; species != NULL; species = species->next) { fprintf(f, "counts: %s\t%ld\t%ld\t%ld\n", species->name, species->covCount, species->aliCount, species->idCount); fprintf(f, "precents: %s\t%4.2f%%\t%4.2f%%\t%4.2f%%\n", species->name, 100.0 * species->covCount/genomeSize, 100.0 * species->aliCount/genomeSize, 100.0 * species->idCount/species->aliCount); } carefulClose(&f); }
void output_matrix_long(struct perBaseMatrix *pbm, int decimals, struct slName *labels, boolean keep_bed, int left, int right, int tile, boolean header, char *outputfile) /* long output. right this is just patching things up. this and some other stuff could be combined */ /* with aggregate some day. */ { FILE *out = mustOpen(outputfile, "w"); int i,j,k, lr_pos; int n_labels = slCount(labels); int unfused_cols = pbm->ncol / n_labels; assert(unfused_cols == (left+right)/tile); struct slName *lab; if (header) { if (keep_bed) fprintf(out, "chrom\tchromStart\tchromEnd\tname\tscore\tstrand\tSignal\tPosition\tValue\n"); else fprintf(out, "Signal\tRegion\tPosition\tValue\n"); } /* Do label, region, Position, Value */ for (lr_pos = -1 *left, k = 0; (lr_pos <= right) && (k < unfused_cols); lr_pos += (lr_pos + tile == 0) ? 2*tile : tile, k++) { for (lab = labels, j = 0; (lab != NULL) && (j < n_labels); lab = lab->next, j++) { for (i = 0; i < pbm->nrow; i++) { int jj = j*unfused_cols + k; struct perBaseWig *pbw = pbm->array[i]; if (keep_bed) { char strand = pbw->strand[0]; char *chrom = pbw->chrom; int chromStart = k*tile + pbw->chromStart; if (strand == '-') chromStart = pbw->chromEnd - k*tile - 1; fprintf(out, "%s\t%d\t%d\t", chrom, chromStart, chromStart + tile); fprintf(out, "%s\t", pbw->name); fprintf(out, "%d\t%c\t", pbw->score, strand); } fprintf(out, "%s\t", lab->name); if (!keep_bed) fprintf(out, "%s\t", (pbw->name) ? pbw->name : "."); fprintf(out, "%d\t", lr_pos); na_or_num(out, pbm->matrix[i][jj], decimals); fprintf(out, "\n"); } } } carefulClose(&out); }
void bwtool_find_extrema(struct hash *options, char *favorites, char *regions, unsigned decimals, double fill, char *bigfile, char *tmp_dir, char *outputfile) /* find local extrema */ { unsigned min_sep = sqlUnsigned((char *)hashOptionalVal(options, "min-sep", "0")); char *other_bigfile = (char *)hashOptionalVal(options, "against", NULL); enum ex_removal rem = get_removal(options); struct metaBig *main_big = metaBigOpen_check(bigfile, tmp_dir, regions); struct metaBig *other_big = NULL; struct extrema *main_list; struct extrema *other_list = NULL; struct extrema *ex; unsigned shift = 0; FILE *out; if (other_bigfile) { char *num; if (rem == no_removal) errAbort("must specify either -maxima or -minima with -against"); if (!strchr(other_bigfile, ',')) errAbort("must specify shift limit in -against option"); num = chopPrefixAt(other_bigfile, ','); shift = sqlUnsigned(num); other_big = metaBigOpen_check(other_bigfile, tmp_dir, regions); } if (!main_big || (!other_big && other_bigfile)) errAbort("could not open bigWig file"); main_list = extrema_find(main_big, min_sep, rem); slReverse(&main_list); if (other_bigfile) { other_list = extrema_find(other_big, min_sep, rem); extrema_find_shifts(main_list, other_list, shift); } metaBigClose(&main_big); if (other_big) metaBigClose(&other_big); out = mustOpen(outputfile, "w"); if (other_bigfile) for (ex = main_list; ex != NULL; ex = ex->next) fprintf(out, "%s\t%d\t%d\t%d\t1000\t%c\n", ex->chrom, ex->chromStart, ex->chromStart+1, (int)ex->val, ex->min_or_max); else { slSort(&main_list, extrema_bed_cmp); for (ex = main_list; ex != NULL; ex = ex->next) fprintf(out, "%s\t%d\t%d\t%0.*f\t1000\t%c\n", ex->chrom, ex->chromStart, ex->chromStart+1, decimals, ex->val, ex->min_or_max); } carefulClose(&out); extrema_free_list(&main_list); }
boolean safeGetOne(char *source, char *md5, char *dest) /* Fetch file from source to tmp file. Check md5. If * it doesn't work return FALSE. If it does work * rename tmp file to dest and return TRUE. */ { struct dyString *command = dyStringNew(0); boolean ok = TRUE; int err; dyStringClear(command); dyStringPrintf(command, "wget -nv --timestamping -O %s '%s'", tmpName, source); verbose(1, "%s\n", command->string); if ((err = system(command->string)) != 0) { warn("Error %d on %s", err, command->string); ok = FALSE; } verbose(1, "wget returned %d\n", err); /* Make up a little md5 file. */ if (ok) { FILE *f = mustOpen(md5tmp, "w"); fprintf(f, "%s %s\n", md5, tmpName); carefulClose(&f); /* Run md5sum. */ dyStringClear(command); dyStringPrintf(command, "md5sum -c %s", md5tmp); verbose(1, "%s\n", command->string); err = system(command->string); verbose(1, "md5sum returned %d\n", err); if (err != 0) { warn("md5sum failed on %s", source); ok = FALSE; } } /* Rename file to proper name */ if (ok) { if ((err = rename(tmpName, dest)) < 0) errnoAbort("Couldn't rename %s to %s", tmpName, dest); } dyStringFree(&command); return ok; }
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); }
struct nt4Seq *loadNt4(char *fileName, char *seqName) /* Load up an nt4 sequence from a file. */ { bits32 size; struct nt4Seq *seq; FILE *f = nt4OpenVerify(fileName); mustReadOne(f, size); if (seqName == NULL) seqName = fileName; seq = allocNt4(size, seqName); mustRead(f, seq->bases, bits32PaddedSize(size)); carefulClose(&f); return seq; }
void edwAddSubmitJob(struct sqlConnection *conn, char *userEmail, char *url, boolean update) /* Add submission job to table and wake up daemon. */ { /* Create command and add it to edwSubmitJob table. */ char command[strlen(url) + strlen(userEmail) + 256]; safef(command, sizeof(command), "edwSubmit %s'%s' %s", (update ? "-update " : ""), url, userEmail); char query[strlen(command)+128]; sqlSafef(query, sizeof(query), "insert edwSubmitJob (commandLine) values('%s')", command); sqlUpdate(conn, query); /* Write sync signal (any string ending with newline) to fifo to wake up daemon. */ FILE *fifo = mustOpen("../userdata/edwSubmit.fifo", "w"); fputc('\n', fifo); carefulClose(&fifo); }
void shuffleLines(char *in, char *out) /* shuffleLines - Create a version of file with lines shuffled.. */ { struct lineFile *lf = lineFileOpen(in, TRUE); FILE *f = mustOpen(out, "w"); struct slName *list = NULL, *el; char *line; while (lineFileNext(lf, &line, NULL)) slNameAddHead(&list, line); shuffleList(&list); for (el = list; el != NULL; el = el->next) fprintf(f, "%s\n", el->name); carefulClose(&f); }
void splitByName(char *inName, char *outRoot) /* Split into chunks using sequence names. */ { struct dnaSeq seq; struct lineFile *lf = lineFileOpen(inName, TRUE); FILE *f = NULL; char outDir[256], outFile[128], ext[64], outPath[512]; ZeroVar(&seq); splitPath(outRoot, outDir, outFile, ext); while (faMixedSpeedReadNext(lf, &seq.dna, &seq.size, &seq.name)) { carefulClose(&f); if (outDirDepth > 0) { char *ptr; for(ptr=&seq.name[strlen(seq.name) - 1]; isdigit(*ptr); ptr--) ; if (ptr > &seq.name[strlen(seq.name)]) errAbort("outDirDepth specified but sequence name doesn't have any digits"); ptr++; mkOutPath(outPath, outRoot, 0, atoi(ptr)); safef(outPath+strlen(outPath), sizeof(outPath) - strlen(outPath), "%s.fa", seq.name); } else sprintf(outPath, "%s%s.fa", outDir, seq.name); verbose(2, "writing %s\n", outPath); f = mustOpen(outPath, "w"); faWriteNext(f, seq.name, seq.dna, seq.size); } carefulClose(&f); lineFileClose(&lf); }
void makeIncreasing(char *fileName) /* Make simple fixed step wiggle with increasing sequence. */ { FILE *f = mustOpen(fileName, "w"); int i; double inc = 0.001; double x = 0; fprintf(f, "fixedStep chrom=chr1 start=1 step=10 span=5\n"); for (i=0; i<1000000; ++i) { fprintf(f, "%f\n", x); x += inc; } carefulClose(&f); }
void chimpHiQualDiffs(char *axtDir, char *qacName, char *bedName) /* chimpHiQualDiffs - Create list of chimp high quality differences. */ { struct hash *qacHash = qacReadToHash(qacName); struct fileInfo *axtEl, *axtList = listDirX(axtDir, "*.axt", TRUE); FILE *f = mustOpen(bedName, "w"); if (axtList==NULL) axtList = listDirX(axtDir, "*.axt.gz", TRUE); if (axtList==NULL) printf("No axt files were found in the '%s' directory.\n",axtDir); for (axtEl = axtList; axtEl != NULL; axtEl = axtEl->next) axtHiQualDiffs(axtEl->name, qacHash, f); carefulClose(&f); }
void mafToPsl(char *querySrc, char *targetSrc, char *inName, char *outName) /* mafToPsl - Convert maf to psl format. */ { struct mafFile *mf = mafOpen(inName); FILE *pslFh = mustOpen(outName, "w"); struct mafAli *maf; while ((maf = mafNext(mf)) != NULL) { mafAliToPsl(querySrc, targetSrc, maf, pslFh); mafAliFree(&maf); } carefulClose(&pslFh); mafFileFree(&mf); }
void output_centroids(struct cluster_bed_matrix *cbm, char *centroid_file, int decimals) /* strictly the centroids */ { FILE *out2 = mustOpen(centroid_file, "w"); int i, j, k = cbm->k; int total = cbm->n - cbm->num_na; fprintf(out2, "# num NA = %d, num total = %d\n", cbm->num_na, total); for (i = 0; i < k; i++) { fprintf(out2, "cluster %d\tsize = %d (%0.2f)\tvalues = ", i, cbm->cluster_sizes[i], (double)cbm->cluster_sizes[i]/total); for (j = 0; j < cbm->m; j++) fprintf(out2, "%f%c", cbm->centroids[i][j], (j == cbm->m-1) ? '\n' : ','); } carefulClose(&out2); }
static void pslMapPostChain(char* inPslFile, char* outPslFile) /* do chaining */ { struct hash* pslsByQName = loadPslByQname(inPslFile); FILE* outPslFh = mustOpen(outPslFile, "w"); struct hashEl *hel; struct hashCookie cookie = hashFirst(pslsByQName); while ((hel = hashNext(&cookie)) != NULL) { struct psl** queryPsls = (struct psl**)&hel->val; chainQuery(queryPsls, outPslFh); } carefulClose(&outPslFh); }
void mafToFa(char *inName, char *outName) /* mafToFa - convert maf file to fasta. */ { struct mafFile *mf = mafOpen(inName); FILE *faFh = mustOpen(outName, "w"); struct mafAli *maf; while ((maf = mafNext(mf)) != NULL) { mafAliToFa(maf, faFh); mafAliFree(&maf); } carefulClose(&faFh); mafFileFree(&mf); }