static char *getCds(struct sqlConnection *conn, char *acc) /* get CDS for an NM, results should be freed */ { char query[128]; sqlSafef(query, sizeof(query), "SELECT cds.name FROM gbCdnaInfo,cds WHERE (gbCdnaInfo.acc = \"%s\") AND (gbCdnaInfo.cds = cds.id)", acc); return sqlNeedQuickString(conn, query); }
char *spDescription(struct sqlConnection *conn, char *acc) /* Return protein description. FreeMem this when done. */ { char query[256]; safef(query, sizeof(query), "select val from description where acc = '%s'", acc); return sqlNeedQuickString(conn, query); }
char *spRefCite(struct sqlConnection *conn, int refId) /* Get journal/page/etc of reference. */ { char query[256]; safef(query, sizeof(query), "select cite from reference where id=%d", refId); return sqlNeedQuickString(conn, query); }
char *spFeatureClassName(struct sqlConnection *conn, int featureClass) /* Return name associated with featureClass. */ { char query[256]; safef(query, sizeof(query), "select val from featureClass where id=%d", featureClass); return sqlNeedQuickString(conn, query); }
char *spAccToId(struct sqlConnection *conn, char *acc) /* Convert primary accession to SwissProt ID (which will * often look something like HXA1_HUMAN. */ { char query[256]; safef(query, sizeof(query), "select val from displayId where acc = '%s'", acc); return sqlNeedQuickString(conn, query); }
char *spAnnDate(struct sqlConnection *conn, char *acc) /* Return annotation last update date in YYYY-MM-DD format. FreeMem * this when done. */ { char query[256]; safef(query, sizeof(query), "select annDate from info where acc = '%s'", acc); return sqlNeedQuickString(conn, query); }
char *spTaxonToBinomial(struct sqlConnection *conn, int taxon) /* Return Latin binomial name associated with taxon. */ { char query[256]; if (taxon <= 0) errAbort("Bad taxon id %d\n", taxon); safef(query, sizeof(query), "select binomial from taxon where id = %d", taxon); return sqlNeedQuickString(conn, query); }
char *spFeatureTypeName(struct sqlConnection *conn, int featureType) /* Return name associated with featureType */ { if (featureType == 0) return cloneString("n/a"); else { char query[256]; safef(query, sizeof(query), "select val from featureType where id=%d", featureType); return sqlNeedQuickString(conn, query); } }
char *spLookupPrimaryAcc(struct sqlConnection *conn, char *anyAcc) /* Primary or secondary accession. */ /* This will return the primary accession. It's ok to pass in * either a primary or secondary accession. */ { char query[256]; if (spIsPrimaryAcc(conn, anyAcc)) return cloneString(anyAcc); else { safef(query, sizeof(query), "select acc from otherAcc where val = '%s'", anyAcc); return sqlNeedQuickString(conn, query); } }
static void processProtSeq(FILE *fh, struct sqlConnection *conn, struct refSeqVerInfo *rsvi, struct hash *doneProts) /* get an protein sequence, which already includes version in name. Don't duplicate NPs */ { char query[128]; sqlSafef(query, sizeof(query), "SELECT protAcc FROM refLink WHERE mrnaAcc = \"%s\"", rsvi->acc); char *protAcc = sqlNeedQuickString(conn, query); if (isNotEmpty(protAcc) && hashLookup(doneProts, protAcc) == NULL) { struct dnaSeq *seq = hGenBankGetPepC(conn, protAcc, NULL); if (seq == NULL) errAbort("failed to get %s from database", protAcc); faWriteNext(fh, seq->name, seq->dna, seq->size); dnaSeqFree(&seq); hashAdd(doneProts, protAcc, NULL); } freeMem(protAcc); }