void getAccMrna(char *acc, struct sqlConnection *conn, FILE *outFa) /* get mrna for an accession */ { HGID seqId; char *faSeq; struct dnaSeq *dna; boolean cdsOk = TRUE; char accBuf[512]; struct genbankCds cds; faSeq = hGetSeqAndId(conn, acc, &seqId); if (faSeq == NULL) { fprintf(stderr, "%s\tsequence not in database\n", acc); return; } dna = faFromMemText(faSeq); if (cdsUpper || peptides) cdsOk = getCds(conn, acc, dna->size, !cdsUpperAll, &cds); if (cdsOk && cdsUpper) upperCaseCds(dna, &cds); if ((cdsOk || cdsUpperAll) && inclVer) { int ver = getVersion(conn, acc); safef(accBuf, sizeof(accBuf), "%s.%d", acc, ver); acc = accBuf; } if ((cdsOk || cdsUpperAll)) { if (peptides) writePeptide(outFa, acc, dna, &cds); else faWriteNext(outFa, acc, dna->dna, dna->size); } dnaSeqFree(&dna); }
void doRefGeneProteinSequence(struct sqlConnection *conn, struct bed *bedList) /* Fetch refGene proteins corresponding to names in bedList. */ { struct hash *uniqHash = newHash(18); struct hash *protHash = newHash(18); struct sqlResult *sr; char **row; struct bed *bed; /* Get translation from mRNA to protein from refLink table. */ sr = sqlGetResult(conn, "NOSQLINJ select mrnaAcc,protAcc from refLink"); while ((row = sqlNextRow(sr)) != NULL) { char *protAcc = row[1]; if (protAcc != NULL && protAcc[0] != 0) hashAdd(protHash, row[0], lmCloneString(protHash->lm, protAcc)); } sqlFreeResult(&sr); boolean gotResults = FALSE; for (bed = bedList; bed != NULL; bed = bed->next) { char *protAcc = hashFindVal(protHash, bed->name); if (protAcc != NULL && !hashLookup(uniqHash, protAcc)) { char *fa = hGetSeqAndId(conn, protAcc, NULL); hashAdd(uniqHash, protAcc, NULL); if (fa != NULL) hPrintf("%s", fa); freez(&fa); gotResults = TRUE; } } if (!gotResults) hPrintf(NO_RESULTS); hashFree(&protHash); hashFree(&uniqHash); }
void doRefGeneMrnaSequence(struct sqlConnection *conn, struct bed *bedList) /* Fetch refGene mRNA sequence. */ { struct hash *uniqHash = newHash(18); struct bed *bed; boolean gotResults = FALSE; for (bed = bedList; bed != NULL; bed = bed->next) { if (!hashLookup(uniqHash, bed->name)) { char *fa = hGetSeqAndId(conn, bed->name, NULL); hashAdd(uniqHash, bed->name, NULL); if (fa != NULL) hPrintf("%s", fa); freez(&fa); gotResults = TRUE; } } if (!gotResults) hPrintf(NO_RESULTS); hashFree(&uniqHash); }