void extractPslForLfs(char *pslFile, char *lfsFile, char *out) /* Extract psl alignments for alignments in lfs bed file */ { struct lineFile *pf, *bf; FILE *pslOut; char errorFile[256] = "error.log"; struct hash *pslHash = newHash(20); struct bed *bedList = NULL; struct psl *pslList = NULL; fprintf(stdout,"NOTE: Program assumes that chrom, chromStart and chromEnd \n"); fprintf(stdout, "are unique for each item in the lfs file so only one PSL \n"); fprintf(stdout, "alignment will be picked for each specific item and \n"); fprintf(stdout, "genomic location.\n\n"); fprintf(stdout, "Opening files ...\n"); bf = lineFileOpen(lfsFile, TRUE); pslOut = mustOpen(out, "w"); stderr = mustOpen(errorFile, "w"); /* Open psl alignments file */ pf = pslFileOpen(pslFile); /* Read in psl file of alignments */ verbose(1, "Reading psl and storing alignments file ...\n"); readPslFile(pf, &pslHash); /* Read in lfs BED file of alignments */ verbose(1, "Reading and storing lfs alignments file ...\n"); bedList = convertLfsToBed(bf); verbose(1, "Extracting psl alignments ... \n"); pslList = getPslList(pslHash, bedList); /* print out the psl file without the header */ pslWriteAll(pslList, out, FALSE); /* close files */ lineFileClose(&bf); lineFileClose(&pf); carefulClose(&pslOut); carefulClose(&stderr); }
int main(int argc, char *argv[]) { struct lineFile *pf, *prf; char filename[64], *pslTable; optionInit(&argc, argv, optionSpecs); if (argc < 4) usage(); VERBOSE = optionExists("verbose"); SLOP = optionExists("slop"); SHORT = optionExists("short"); LONG = optionExists("long"); MISMATCH = optionExists("mismatch"); ORPHAN = optionExists("orphan"); NORANDOM = optionExists("noRandom"); NOBIN = optionExists("noBin"); MIN = optionInt("min",MIN); MAX = optionInt("max",MAX); TINSERT = optionInt("tInsert",TINSERT); HARDMAX = optionInt("hardMax",HARDMAX); if (SLOP) SLOPVAL = optionInt("slopval",SLOPVAL); else SLOPVAL = 0; NEARTOP = optionFloat("nearTop",NEARTOP); NEARTOP = 1 - NEARTOP; MIN_ID = optionFloat("minId",MIN_ID); MIN_ORPHAN_ID = optionFloat("minOrphanId",MIN_ORPHAN_ID); pf = pslFileOpen(argv[1]); prf = lineFileOpen(argv[2],TRUE); pslTable = cloneString(argv[3]); sprintf(filename, "%s.pairs", argv[4]); of = mustOpen(filename, "w"); if (SLOP) { sprintf(filename, "%s.slop", argv[4]); sf = mustOpen(filename, "w"); } if (ORPHAN) { sprintf(filename, "%s.orphan", argv[4]); orf = mustOpen(filename, "w"); } if (MISMATCH) { sprintf(filename, "%s.mismatch", argv[4]); mf = mustOpen(filename, "w"); } if (SHORT) { sprintf(filename, "%s.short", argv[4]); esf = mustOpen(filename, "w"); } if (LONG) { sprintf(filename, "%s.long", argv[4]); elf = mustOpen(filename, "w"); } if (VERBOSE) printf("Reading pair file\n"); clones = newHash(23); leftNames = newHash(23); rightNames = newHash(23); readPairFile(prf); if (VERBOSE) printf("Reading psl file\n"); readPslFile(pf); if (VERBOSE) printf("Creating Pairs\n"); pslPairs(); if (VERBOSE) printf("Writing to files\n"); printOut(pslTable); lineFileClose(&pf); lineFileClose(&prf); fclose(of); if (ORPHAN) fclose(orf); if (SLOP) fclose(sf); if (MISMATCH) fclose(mf); if (SHORT) fclose(esf); if (LONG) fclose(elf); return 0; }