static struct customTrack *beginCustomTrack(char *table, int fields, boolean doCt, boolean doWigHdr, boolean doDataPoints) /* If doCt, return a new custom track object from TB cart settings and params; * if !doCt, return NULL but print out a header line. */ { char *ctName = cgiUsualString(hgtaCtName, table); char *ctDesc = cgiUsualString(hgtaCtDesc, table); char *ctUrl = cgiUsualString(hgtaCtUrl, ""); char *ctVis = cgiUsualString(hgtaCtVis, "dense"); int visNum = (int) hTvFromStringNoAbort(ctVis); struct customTrack *ctNew = NULL; if (visNum < 0) visNum = 0; if (doCt) { ctNew = newCt(ctName, ctDesc, visNum, ctUrl, fields); if (doDataPoints) { struct dyString *wigSettings = newDyString(0); struct tempName tn; trashDirFile(&tn, "ct", hgtaCtTempNamePrefix, ".wib"); ctNew->wibFile = cloneString(tn.forCgi); char *wiggleFile = cloneString(ctNew->wibFile); chopSuffix(wiggleFile); strcat(wiggleFile, ".wia"); ctNew->wigAscii = cloneString(wiggleFile); chopSuffix(wiggleFile); /* .wig file will be created upon encoding in customFactory */ /*strcat(wiggleFile, ".wig"); ctNew->wigFile = cloneString(wiggleFile); */ ctNew->wiggle = TRUE; dyStringPrintf(wigSettings, "type wiggle_0\nwibFile %s\n", ctNew->wibFile); ctNew->tdb->settings = dyStringCannibalize(&wigSettings); freeMem(wiggleFile); } } else { if (doWigHdr) hPrintf("track type=wiggle_0 name=\"%s\" description=\"%s\" " "visibility=%d url=%s \n", ctName, ctDesc, visNum, ctUrl); else hPrintf("track name=\"%s\" description=\"%s\" visibility=%d url=%s \n", ctName, ctDesc, visNum, ctUrl); } return ctNew; }
void qaDirs(char *qaDir, char *faDir) /* check that all the files in faDir have quality * files in faDir. */ { char qaName[512]; char faName[512]; char cloneName[512]; int ix = 0; struct slName *el, *list; struct qaSeq *qaList; printf("Comparing %s and %s\n", qaDir, faDir); list = listDir(faDir, "*.fa"); for (el = list; el != NULL; el = el->next) { strcpy(cloneName, el->name); chopSuffix(cloneName); sprintf(qaName, "%s/%s.qa", qaDir, cloneName); sprintf(faName, "%s/%s.fa", faDir, cloneName); if (!fileExists(qaName)) warn("%s doesn't exist", qaName); qaList = qaReadBoth(qaName, faName); qaSeqFreeList(&qaList); if ((++ix & 0x3f) == 0) { printf("."); fflush(stdout); } } printf("\n"); }
void splitNcbiFa(char *ncbiIn, char *outDir) /* splitNcbiFa - Split up NCBI format fa file into UCSC formatted ones.. */ { struct lineFile *lf = lineFileOpen(ncbiIn, TRUE); static struct dnaSeq seq; ZeroVar(&seq); makeDir(outDir); while (faSpeedReadNext(lf, &seq.dna, &seq.size, &seq.name)) { FILE *f; char fileName[512]; char *row[5]; int wordCount; char ourName[129]; char cloneName[128]; wordCount = chopByChar(seq.name, '|', row, ArraySize(row)); if (wordCount != 5) errAbort("Expecting 5 | separated fields line %d of %s", lf->lineIx, lf->fileName); strcpy(cloneName, row[3]); chopSuffix(cloneName); sprintf(fileName, "%s/%s.fa", outDir, cloneName); sprintf(ourName, "%s_1", row[3]); faWrite(fileName, ourName, seq.dna, seq.size); } }
void readBad(struct hash *badHash, char *fileName, int cloneWord) /* Read bad clones into hash. */ { char *words[8]; struct lineFile *lf = lineFileOpen(fileName, TRUE); int wordCount; char *acc; int badCount = 0; while ((wordCount = lineFileChop(lf, words)) != 0) { if (wordCount < cloneWord+1) { errAbort("Expecting at least %d words line %d of %s", cloneWord+1, lf->lineIx, lf->fileName); } acc = words[cloneWord]; chopSuffix(acc); if (!checkAccFormat(acc)) errAbort("Badly formatted accession line %d of %s", lf->lineIx, lf->fileName); hashStore(badHash, acc); ++badCount; } lineFileClose(&lf); printf("Got %d clones to avoid from %s\n", badCount, fileName); }
void readGl(char *fileName, struct clonePos **retList, struct hash **retHash) /* Read gl formatted files. */ { struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[3]; struct clonePos *cpList = NULL, *cp; struct hash *hash = newHash(0); while (lineFileRow(lf, row)) { char *clone = row[0]; int fragStart, fragEnd; double fragSize; chopSuffix(clone); fragStart = lineFileNeedNum(lf, row, 1); fragEnd = lineFileNeedNum(lf, row, 2); fragSize = fragEnd - fragStart; if ((cp = hashFindVal(hash, clone)) == NULL) { AllocVar(cp); hashAddSaveName(hash, clone, cp, &cp->name); slAddHead(&cpList, cp); } cp->weightedPos += fragSize * fragStart; cp->totSize += fragSize; } lineFileClose(&lf); slReverse(&cpList); for (cp = cpList; cp != NULL; cp = cp->next) cp->pos = cp->weightedPos/cp->totSize; *retList = cpList; *retHash = hash; }
void txCdsToGene(char *txBed, char *txFa, char *txCds, char *outGtf, char *outFa) /* txCdsToGene - Convert transcript bed and best cdsEvidence to genePred and * protein sequence. */ { struct hash *txSeqHash = faReadAllIntoHash(txFa, dnaLower); verbose(2, "Read %d transcript sequences from %s\n", txSeqHash->elCount, txFa); struct hash *cdsHash = cdsEvidenceReadAllIntoHash(txCds); verbose(2, "Read %d cdsEvidence from %s\n", cdsHash->elCount, txCds); struct lineFile *lf = lineFileOpen(txBed, TRUE); FILE *fGtf = mustOpen(outGtf, "w"); FILE *fFa = mustOpen(outFa, "w"); char *row[12]; while (lineFileRow(lf, row)) { struct bed *bed = bedLoad12(row); verbose(2, "processing %s\n", bed->name); struct cdsEvidence *cds = hashFindVal(cdsHash, bed->name); struct dnaSeq *txSeq = hashFindVal(txSeqHash, bed->name); char *cdsSource = NULL; if (txSeq == NULL) errAbort("%s is in %s but not %s", bed->name, txBed, txFa); if (cds != NULL) { outputProtein(cds, txSeq, fFa); if (cds->cdsCount > 1) { struct bed *newBed = breakUpBedAtCdsBreaks(cds, bed); if (fTweaked) fprintf(fTweaked, "%s\n", newBed->name); bedFree(&bed); bed = newBed; } cdsSource = cds->accession; if (sameString(cds->accession, ".")) cdsSource = cds->source; } /* Set bed CDS bounds and optionally output bed. */ cdsEvidenceSetBedThick(cds, bed); if (fBed) bedTabOutN(bed, 12, fBed); /* Parse out bed name, which is in format chrom.geneId.txId.accession */ char *geneName = cloneString(bed->name); char *accession = strrchr(geneName, '.'); assert(accession != NULL); *accession++ = 0; chopSuffix(geneName); /* Output as GTF */ bedToGtf(bed, accession, cdsSource, geneName, fGtf); /* Clean up for next iteration of loop. */ freez(&geneName); bedFree(&bed); } lineFileClose(&lf); carefulClose(&fFa); carefulClose(&fGtf); }
char *getHost() /* Return host name. */ { static char *hostName = NULL; static char buf[128]; if (hostName == NULL) { hostName = getenv("HTTP_HOST"); if (hostName == NULL) { hostName = getenv("HOST"); if (hostName == NULL) { if (hostName == NULL) { static struct utsname unamebuf; if (uname(&unamebuf) >= 0) hostName = unamebuf.nodename; else hostName = "unknown"; } } } strncpy(buf, hostName, sizeof(buf)); chopSuffix(buf); hostName = buf; } return hostName; }
void doGzippedSomethingToBigBed(struct encode2Manifest *mi, char *sourcePath, char *assembly, char *destDir, char *destFileName, char *bedConverter, char *tempNameRoot, struct slName **pTargetList, FILE *f, FILE *manF) /* Convert something that has a bed-converter program to bigBed. */ { char bigBedName[PATH_LEN]; safef(bigBedName, sizeof(bigBedName), "%s%s%s", destDir, destFileName, ".bigBed"); char tempBigBed[PATH_LEN]; safef(tempBigBed, sizeof(tempBigBed), "%s.tmp", bigBedName); char *tempBed = veryTempName(tempDir, tempNameRoot, ".bed"); char *sortedTempBed = veryTempName(tempDir, tempNameRoot, ".sorted"); fprintf(f, "%s: %s\n", bigBedName, sourcePath); fprintf(f, "\t%s %s %s\n", bedConverter, sourcePath, tempBed); fprintf(f, "\tsort -k1,1 -k2,2n %s > %s\n", tempBed, sortedTempBed); fprintf(f, "\trm %s\n", tempBed); char *clippedTempBed = veryTempName(tempDir, tempNameRoot, ".clipped"); fprintf(f, "\tbedClip %s %s/%s/chrom.sizes %s\n", sortedTempBed, dataDir, assembly, clippedTempBed); fprintf(f, "\trm %s\n", sortedTempBed); fprintf(f, "\tbedToBigBed %s %s/%s/chrom.sizes %s\n", clippedTempBed, dataDir, assembly, tempBigBed); fprintf(f, "\trm %s\n", clippedTempBed); fprintf(f, "\tmv %s %s\n", tempBigBed, bigBedName); slNameAddHead(pTargetList, bigBedName); /* Print out info about bigBed we made to new manifest files. */ char localFileName[PATH_LEN+8]; // a little extra for .bigBed safef(localFileName, PATH_LEN, "%s", mi->fileName); chopSuffix(localFileName); strcat(localFileName, ".bigBed"); mi->fileName = localFileName; encode2ManifestShortTabOut(mi, manF); }
void rmFromFinf(char *listFile, char *oldFinf, char *newFinf) /* rmFromFinf - Remove clones in list from finf file. */ { struct hash *rmHash = hashList(listFile); struct lineFile *lf = lineFileOpen(oldFinf, TRUE); FILE *f = mustOpen(newFinf, "w"); char *row[7]; int i; char clone[256]; while (lineFileRow(lf, row)) { strcpy(clone, row[0]); chopSuffix(clone); if (!hashLookup(rmHash, clone)) { for (i=0; i<ArraySize(row); ++i) { fprintf(f, "%s", row[i]); if (i == ArraySize(row)-1) fputc('\n', f); else fputc('\t', f); } } else printf("Skipping %s\n", clone); } }
struct hash *mtfToRnaHash(char *pcrBed) /* Make hash keyed by numeric part of MTF id with values * of rnaList type */ { struct rnaList *rl; struct hash *hash = hashNew(0); struct lineFile *lf = lineFileOpen(pcrBed, TRUE); char *row[6]; while (lineFileRow(lf, row)) { char *mtf = row[3] + 3; char *rna = row[0]; struct slName *el; rl = hashFindVal(hash, mtf); if (rl == NULL) { AllocVar(rl); hashAdd(hash, mtf, rl); } chopSuffix(rna); el = slNameNew(rna); slAddHead(&rl->accList, el); } lineFileClose(&lf); return hash; }
void *addExtensionAndSearch(char *name, struct hash *hash, boolean alias) { char *addName = NULL, *newName = NULL, *nameLower = NULL; void *result = NULL; boolean found = FALSE; int i; addName = cloneString(name); if (alias) { nameLower = cloneString(name); touppers(addName); } for (i = 0; (i < NUMEXT) && (!found); i++) { newName = NULL; newName = addSuffix(addName, extensions[i]); /* for alias, check the lower case name */ if (alias && ((result = hashFindVal(hash, newName)) != NULL) ) found = TRUE; /* change name to upper case and check in hash */ touppers(newName); if (!found && (result = hashFindVal(hash, newName)) != NULL) found = TRUE; else if (!found) { /* remove the suffix after the last '.' and compare */ chopSuffix(addName); if (alias) chopSuffix(nameLower); if (!sameString(name, addName) && (result = hashFindVal(hash, addName)) != NULL) found = TRUE; else if (alias) /* check also lower case name */ { if (!sameString(name, nameLower) && (result = hashFindVal(hash, nameLower)) != NULL) found = TRUE; } } } if (found) return result; else return NULL; }
void faRecNameToQaFileName(char *outDir, char *ucscName, char *path) /* Convert fa record name to qa file name. */ { char *dup = cloneString(ucscName); chopSuffix(dup); sprintf(path, "%s/%s.qa", outDir, dup); freeMem(dup); }
void chopDotsAndUnderbars(const char *s, char *d) /* Remove everything past _ or . */ { strcpy(d, s); chopSuffix(d); if ((d = strchr(d, '_')) != NULL) *d = 0; }
struct hash *hashTwoColumn(struct sqlConnection *conn, char *query, boolean chop) /* Make hash based on knownToEnsembl. */ { struct sqlResult *sr; char **row; struct hash *hash = newHash(16); sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { if (chop) { chopSuffix(row[0]); chopSuffix(row[1]); } hashAdd(hash, row[0], cloneString(row[1])); } sqlFreeResult(&sr); return hash; }
void findContigsWithClones(char *cloneFile, char *ooDir, char *snoopIn) /* findContigsWithClones - find contigs that contain clones. */ { struct slName *el; cloneList = readAllLines(cloneFile); for (el = cloneList; el != NULL; el = el->next) chopSuffix(el->name); snoopFileName = snoopIn; ooToAllContigs(ooDir, doContig); }
void addStageInfo(char *gsDir, struct hash *cloneHash) /* Add info about which file and what stage clone is in. */ /* TSF - This is no longer used due to unavailability of *.finf files - 4/7/2003 */ { static char *finfFiles[] = {"ffa/finished.finf", "ffa/draft.finf", "ffa/predraft.finf", "ffa/extras.finf" }; static char stages[] = "FDPD"; struct lineFile *lf; char *line; char *words[7]; int numStages = strlen(stages); int i; char pathName[512]; char *finfFile, stage; int warnsLeft = maxWarn; /* Only show first maxWarn warnings about missing clones. */ char cloneName[256]; struct clonePos *clone; int wordCount, cloneCount; for (i=0; i<numStages; ++i) { finfFile = finfFiles[i]; stage = stages[i]; sprintf(pathName, "%s/%s", gsDir, finfFile); printf("Processing %s\n", pathName); lf = lineFileOpen(pathName, TRUE); cloneCount = 0; while (lineFileNext(lf, &line, NULL)) { wordCount = chopLine(line, words); assert(wordCount == 7); strncpy(cloneName, words[1], sizeof(cloneName)); chopSuffix(cloneName); if ((clone = hashFindVal(cloneHash, cloneName)) == NULL) { if (warnsLeft > 0) { --warnsLeft; warn("%s is in %s but not in ooDir/*/*.gl", cloneName, pathName); } else if (warnsLeft == 0) { --warnsLeft; warn("(Truncating additional warnings)"); } continue; } clone->stage[0] = stage; cloneCount++; } lineFileClose(&lf); printf("Got %d clones in %s\n", cloneCount, pathName); } }
char *qacPathFromFaPath(char *faName) /* Given an fa path name return path name of corresponding qac * file. Copy this result somewhere if you wish to keep it * longer than the next call to qacPathFromFaPath. */ { static char qacPath[512]; strcpy(qacPath, faName); chopSuffix(qacPath); strcat(qacPath, ".qac"); return qacPath; }
char *fixVersion(char *accVer, struct hash *versionHash) /* See if accVer ends in .0. If so try to fix it via * hash lookup. */ { static char fixed[128]; char cloneName[128]; char *s; strcpy(cloneName, accVer); chopSuffix(cloneName); return hashMustFindVal(versionHash, cloneName); }
void vgPrepImage(char *sourceDir, char *thumbDir, char *fullDir, char *fileName) /* vgPrepImage - Create thumbnail and image pyramid scheme for image, * also link in full sized image. */ { char source[PATH_LEN], thumb[PATH_LEN], full[PATH_LEN], pyramid[PATH_LEN]; char outFullDir[PATH_LEN], outFullRoot[PATH_LEN]; int nWidth, nHeight; int quality[7]; boolean makeFullSize = FALSE; unsigned char *(*readScanline)() = NULL; /* Figure out full paths. */ safef(source, sizeof(source), "%s/%s", sourceDir, fileName); safef(thumb, sizeof(thumb), "%s/%s", thumbDir, fileName); safef(full, sizeof(full), "%s/%s", fullDir, fileName); splitPath(full, outFullDir, outFullRoot, NULL); outFullDir[strlen(outFullDir)-1]=0; /* knock off trailing slash */ strcpy(pyramid,full); chopSuffix(pyramid); makeDirForFile(thumb); makeDirForFile(full); makeDir(pyramid); if (endsWith(source,".jp2")) { thumb[strlen(thumb)-1]='g'; /* convert the extension */ noLink = TRUE; /* for jp2, symlink to source automatically suppressed */ makeFullSize = TRUE; /* instead we'll have the tile-maker make a fullsize jpg for us */ quality[0] = 50; quality[1] = 60; quality[2] = 70; quality[3] = 80; quality[4] = 85; quality[5] = 85; quality[6] = 85; jp2DecInit(source, &nWidth, &nHeight); readScanline = &jp2ReadScanline; jpgTiles(nWidth, nHeight, outFullDir, outFullRoot, thumb, readScanline, quality, makeFullSize); jp2Destroy(); } else if (endsWith(source,".jpg")) { jpgDecInit(source, &nWidth, &nHeight); readScanline = &jpgReadScanline; jpgTiles(nWidth, nHeight, outFullDir, outFullRoot, thumb, readScanline, NULL, makeFullSize); /* NULL quality will default to 75 for all */ jpgDestroy(); } if (!noLink) makeLink(source, full); }
char *unburyAcc(struct lineFile *lf, char *longNcbiName) /* Return accession given a long style NCBI name. * Cannibalizes the longNcbiName. */ { char *parts[5]; int partCount; partCount = chopByChar(longNcbiName, '|', parts, ArraySize(parts)); if (partCount < 4) errAbort("Badly formed longNcbiName line %d of %s\n", lf->lineIx, lf->fileName); chopSuffix(parts[3]); return parts[3]; }
void loadPslTable(char *database, struct sqlConnection *conn, char *pslFile) /* load one psl table */ { char table[128]; char *tabFile; boolean indirectLoad = FALSE; verbose(1, "Processing %s\n", pslFile); /* determine table name to use */ if (clTableName != NULL) safef(table, sizeof(table), "%s", clTableName); else { if (endsWith(pslFile, ".gz")) { char *stripGz; stripGz = cloneString(pslFile); chopSuffix(stripGz); splitPath(stripGz, NULL, table, NULL); freeMem(stripGz); } else splitPath(pslFile, NULL, table, NULL); } setupTable(database, conn, table); /* if a bin column is being added or if the input file is * compressed, we must copy to an intermediate tab file */ indirectLoad = ((pslCreateOpts & PSL_WITH_BIN) != 0) || endsWith(pslFile, ".gz") || !noSort; if (indirectLoad) { tabFile = "psl.tab"; if (pslCreateOpts & PSL_XA_FORMAT) copyPslXaToTab(pslFile, tabFile); else copyPslToTab(pslFile, tabFile); } else tabFile = pslFile; sqlLoadTabFile(conn, tabFile, table, pslLoadOpts); if (!noHistory) hgHistoryComment(conn, "Add psl alignments to %s table", table); if (indirectLoad && !keep) unlink(tabFile); }
void processOneGff(char *gffName, FILE *f, char *exonType, struct hash *extraHash, struct sanger22extra **pExtraList, boolean isCds) /* Parse through a GFF and store it in f, hash, and list. */ { char *line, *name, *group, *fields[9]; struct lineFile *lf = lineFileOpen(gffName, TRUE); struct sanger22extra *extra; while (lineFileNext(lf, &line, NULL)) { if (lineToGffFields(lf, line, fields)) { fields[0] = "chr22"; group = fields[8]; fields[8] = name = findVal(lf, group, "Sequence"); if (name == NULL) continue; if (endsWith(name, ".mRNA")) chopSuffix(name); if (sameString(fields[2], "exon")) { fields[2] = exonType; writeGffLine(f, fields); if ((extra = hashFindVal(extraHash, name)) == NULL) { extra = sanger22extraNew(name); hashAdd(extraHash, name, extra); slAddHead(pExtraList, extra); } if (isCds) extra->cdsType = cloneString(fields[1]); else extra->geneType = cloneString(fields[1]); } else if (sameString(fields[2], "Sequence")) { if ((extra = hashFindVal(extraHash, name)) == NULL) { extra = sanger22extraNew(name); hashAdd(extraHash, name, extra); slAddHead(pExtraList, extra); } if (extra->description[0] == 0) extra->description = cloneString(findVal(lf, group, "Description")); if (extra->locus[0] == 0) extra->locus = cloneString(findVal(lf, group, "Locus")); } } } lineFileClose(&lf); }
void getText(struct kgXref *kg, struct hash *refSeqHash, struct sqlConnection *conn, struct sqlConnection *spConn, struct sqlConnection *goConn, FILE *f) /* Get loads of text and write it out. */ { char query[512]; struct hash *uniqHash = hashNew(0); char *spAcc = spFindAcc(spConn, kg->spID); subChar(kg->description, '\n', ' '); fprintf(f, "%s\t%s\t%s\t%s", kg->kgID, kg->geneSymbol, kg->kgID, kg->description); hashAdd(uniqHash, kg->geneSymbol, NULL); hashAdd(uniqHash, kg->kgID, NULL); addSimple(kg->kgID, "kgAlias", "kgID", "alias", conn, uniqHash, f); addSimple(kg->kgID, "kgProtAlias", "kgID", "alias", conn, uniqHash, f); if (refSeqHash != NULL) { char *s = hashFindVal(refSeqHash, kg->refseq); if (s == NULL && strchr(kg->refseq, '.') != NULL) { char *accOnly = cloneString(kg->refseq); chopSuffix(accOnly); s = hashFindVal(refSeqHash, accOnly); freeMem(accOnly); } if (s == NULL) s = ""; fprintf(f, "\t%s", s); } sqlSafef(query, sizeof(query), "select commentVal.val from comment,commentVal " "where comment.acc='%s' and comment.commentVal=commentVal.id" , spAcc); addText(query, spConn, f); sqlSafef(query, sizeof(query), "select term.name from goaPart,term " "where goaPart.dbObjectId='%s' " "and goaPart.goId=term.acc" , spAcc); addText(query, goConn, f); fprintf(f, "\n"); hashFree(&uniqHash); freeMem(spAcc); }
struct hash *ensProtToTrans(char *database) /* Use ensGtp table to create hash keyed by protein and * returning transcript values. */ { char *table = "ensGtp"; struct sqlConnection *conn = sqlConnect(database); char query[256], **row; struct sqlResult *sr; struct hash *hash = newHash(16); if (!sqlTableExists(conn, table)) errAbort("No %s table, need to build that first", table); sqlSafef(query, sizeof(query), "select protein,transcript from %s", table); sr = sqlGetResult(conn, query); while ((row = sqlNextRow(sr)) != NULL) { chopSuffix(row[0]); chopSuffix(row[1]); hashAdd(hash, row[0], cloneString(row[1])); } sqlFreeResult(&sr); sqlDisconnect(&conn); return hash; }
void crunchDir(char *dir, FILE *f) /* Crunch list of files in dir. */ { struct fileInfo *fileList = listDirX(dir, NULL, FALSE), *file; for (file = fileList; file != NULL; file = file->next) { char path[PATH_LEN]; if (file->isDir) continue; safef(path, sizeof(path), "%s/%s", dir, file->name); chopSuffix(file->name); crunchOne(path, f, file->name, 0); } slFreeList(&fileList); }
struct expRecord *createExpRec(char *file, int expNum) { struct expRecord *er = NULL; char * name = cloneString(file); char *exp=NULL, *tissue=NULL; chopSuffix(name); chopSuffix(name); AllocVar(er); er->name = cloneString(name); tissue = strrchr(name,'_'); if(tissue != NULL) { *tissue = '\0'; tissue++; } else { tissue = "DUPLICATE"; } er->id = expNum; er->description = description; er->url = url; er->ref = reference; er->credit = credit; er->numExtras = 2; er->extras = needMem(sizeof(char *) * er->numExtras); exp = strstr(name, "_"); if(exp != NULL) { *exp = '\0'; } er->extras[0] = name; er->extras[1] = tissue; return er; }
void addCloneToHash(struct hash *hash, char *accVer) /* Add accession.ver name to hash. */ { char cloneName[256]; struct clone *clone; strcpy(cloneName, accVer); chopSuffix(cloneName); if (!hashLookup(hash, cloneName)) { AllocVar(clone); hashAddSaveName(hash, cloneName, clone, &clone->name); clone->version = cloneString(accVer); } }
void addSeqInfo(char *seqInfoName, struct hash *cloneHash) /* Add in information from sequence.info file. */ /* TSF - stage info now being derived from here - 4/7/2003 */ { struct lineFile *lf = lineFileOpen(seqInfoName, TRUE); char *line, *words[16]; int lineSize, wordCount; struct clonePos *clone; struct gsSeqInfo gs; int warnsLeft = maxWarn; /* Only show first maxWarn warnings about missing clones. */ static char stages[] = "PPDF"; printf("Processing %s\n", seqInfoName); while (lineFileNext(lf, &line, &lineSize)) { if (line[0] == '#') continue; wordCount = chopLine(line, words); if (wordCount == 0) continue; if (wordCount < 8) errAbort("Expecting 8 words line %d of %s", lf->lineIx, lf->fileName); gsSeqInfoStaticLoad(words, &gs); /* TSF - Phase 0 clones now included in contig_overlaps.agp 4/23/2003 */ /*if (gs.phase != 0) {*/ chopSuffix(gs.acc); if ((clone = hashFindVal(cloneHash, gs.acc)) == NULL) { if (warnsLeft > 0) { --warnsLeft; warn("%s is in %s but not in ooDir/*/*.gl", gs.acc, seqInfoName); } else if (warnsLeft == 0) { --warnsLeft; warn("(Truncating additional warnings)"); } continue; } clone->seqSize = gs.size; clone->phase = gs.phase; clone->stage[0] = stages[atoi(words[3])]; /* } */ } lineFileClose(&lf); }
void doRnaFoldDisplay(struct sqlConnection *conn, char *geneId, char *geneName) /* Show RNA folding somehow. */ { char *table = cartString(cart, hggMrnaFoldRegion); char *how = cartString(cart, hggDoRnaFoldDisplay); struct rnaFold *fold = loadFold(conn, table, geneId); if (fold == NULL) { warn("Couldn't load %s from %s", geneId, table); return; } if (sameString(how, "text")) { hPrintf("<TT><PRE>"); hPrintf("%s\n%s (%1.2f)\n", fold->seq, fold->fold, fold->energy); hPrintf("</PRE></TT>"); } else if (sameString(how, "picture")) { char *psFile = cartString(cart, hggMrnaFoldPs); char *rootName = cloneString(psFile); char pngName[256]; char pdfName[256]; chopSuffix(rootName); safef(pngName, sizeof(pngName), "%s.png", rootName); safef(pdfName, sizeof(pngName), "%s.pdf", rootName); hPrintf("<H2>%s (%s) %s energy %1.2f</H2>\n", geneName, geneId, table, fold->energy); if (!fileExists(pdfName)) { char command[512]; safef(command, sizeof(command), "ps2pdf %s %s" , psFile, pdfName); mustSystem(command); } hPrintf("Click <A HREF=\"%s\">here for PDF version</A><BR>", pdfName); if (!fileExists(pngName)) { char command[512]; safef(command, sizeof(command), "gs -sDEVICE=png16m -sOutputFile=%s -dBATCH -dNOPAUSE -q %s" , pngName, psFile); mustSystem(command); } hPrintf("<IMG SRC=\"%s\">", pngName); } }
void makeCloneVerHash(char *fileName, struct hash *cloneVerHash) /* Make up a hash indexed by clone accession that has accession.version * values. */ { struct lineFile *lf = lineFileOpen(fileName, TRUE); char *row[8]; char acc[32]; while (lineFileRow(lf, row)) { strncpy(acc, row[0], sizeof(acc)); chopSuffix(acc); hashAdd(cloneVerHash, acc, cloneString(row[0])); } lineFileClose(&lf); }