struct slName *slComments(struct sqlConnection *conn,
	char *acc,	/* Primary accession. */
	char *type)	/* Comment type name, NULL for all comments. */
/* Get list of comments associated with accession. 
 * If optional type parameter is included it should be
 * something in the commentType table.  Some good types
 * are: DISEASE, FUNCTION, "SUBCELLULAR LOCATION" etc. */
{
char query[256];
if (type == NULL)
    {
    safef(query, sizeof(query),
	"select commentVal.val from comment,commentVal "
	"where comment.acc = '%s' "
	"and comment.commentVal = commentVal.id"
	, acc);
    }
else
    {
    int typeId;
    safef(query, sizeof(query),
        "select id from commentType where val = '%s'", type);
    typeId = sqlNeedQuickNum(conn, query);
    safef(query, sizeof(query),
	"select commentVal.val from comment,commentVal "
	"where comment.acc = '%s' "
	"and comment.commentType = %d "
	"and comment.commentVal = commentVal.id "
	, acc, typeId);
    }
return sqlQuickList(conn, query);
}
Example #2
0
static char *getAccVersion(struct sqlConnection *conn, char *acc)
/* given a accession, get acc.ver */
{
char query[256], accver[64];
sqlSafef(query, sizeof(query), "SELECT version FROM gbCdnaInfo WHERE acc=\"%s\"", acc);
safef(accver, sizeof(accver), "%s.%d", acc, sqlNeedQuickNum(conn, query));
return cloneString(accver);
}
int spFeatureClassId(struct sqlConnection *conn, char *name)
/* Return feature class id associated with given name. */
{
char query[256];
safef(query, sizeof(query),
	"select id from featureClass where val='%s'", name);
return sqlNeedQuickNum(conn, query);
}
int spBinomialToTaxon(struct sqlConnection *conn, char *name)
/* Return taxon associated with binomial (Mus musculus) name. */
{
char query[256];
safef(query, sizeof(query),
    "select id from taxon where binomial = '%s'", name);
return sqlNeedQuickNum(conn, query);
}
int spTaxon(struct sqlConnection *conn, char *acc)
/* Return taxon of first organism associated with accession. */
{
char query[256];
safef(query, sizeof(query), 
	"select taxon from accToTaxon where acc = '%s'", acc);
return sqlNeedQuickNum(conn, query);
}
int spMolWeight(struct sqlConnection *conn, char *acc)
/* Return molecular weight in daltons. */
{
char query[256];
safef(query, sizeof(query), 
	"select molWeight from info where acc = '%s'", acc);
return sqlNeedQuickNum(conn, query);
}
int spAaSize(struct sqlConnection *conn, char *acc)
/* Return number of amino acids. */
{
char query[256];
safef(query, sizeof(query), 
	"select aaSize from info where acc = '%s'", acc);
return sqlNeedQuickNum(conn, query);
}
boolean spIsCurated(struct sqlConnection *conn, char *acc)
/* Return TRUE if it is a curated entry. */
{
char query[256];
safef(query, sizeof(query), 
	"select isCurated from info where acc = '%s'", acc);
return sqlNeedQuickNum(conn, query);
}
Example #9
0
struct psl *getParentAligns(struct sqlConnection *conn, struct mappingInfo *mi, char **table)
{
struct ucscRetroInfo *pg = mi->pg;
struct psl *pslList = NULL;
char query[512];
if (startsWith("August",mi->geneSet))
    {
    if (hTableExists(database, "augustusXAli"))
        {
        *table = cloneString( "augustusXAli");
        pslList = loadPslRangeT(*table, mi->seqId, pg->gChrom, pg->gStart, pg->gEnd);
        }
    else if (hTableExists(database, "augustusX"))
        {
        struct sqlResult *sr;
        char **row;
        int targetSize = 0;
        *table = cloneString( "augustusX");
        sqlSafef(query, sizeof(query), "select * from augustusX where chrom = '%s' and txEnd > %d and txStart < %d and name like '%s%%'", 
                pg->gChrom, pg->gStart, pg->gEnd , mi->seqId );
        sr = sqlGetResult(conn, query);
        if ((row = sqlNextRow(sr)) != NULL)
            {
            struct genePred *gp = genePredLoad(row+1);
            sqlSafef(query, sizeof(query), 
                    "select size from chromInfo where chrom = '%s' " , gp->chrom); 
            sqlFreeResult(&sr);
            targetSize = sqlNeedQuickNum(conn, query) ;
            pslList = pslFromGenePred(gp, targetSize);
            }   
        }

    }
else if (hTableExists(database, "all_mrna"))
    {
    char parent[255];
    char *dotPtr ;
    *table = cloneString( "all_mrna");
    safef(parent, sizeof(parent), "%s",pg->name);
    /* strip off version and unique suffix when looking for parent gene*/
    dotPtr = rStringIn(".",parent) ;
    if (dotPtr != NULL)
        *dotPtr = '\0';
    pslList = loadPslRangeT(*table, mi->gbAcc, pg->gChrom, pg->gStart, pg->gEnd);
    if (pslList == NULL)
        {
        *table = cloneString( "refSeqAli");
        pslList = loadPslRangeT(*table, mi->gbAcc, pg->gChrom, pg->gStart, pg->gEnd);
        }
    }
else
    printf("no all_mrna table found<br>\n");
return pslList;
}
char *spAccFromEmbl(struct sqlConnection *conn, char *acc)
/* Get SwissProt accession associated with EMBL mRNA. */
{
char query[256];
int emblId;
safef(query, sizeof(query), "select id from extDb where val = 'EMBL'");
emblId = sqlNeedQuickNum(conn, query);
safef(query, sizeof(query),
    "select acc from extDbRef where extAcc1 = '%s' and extDb = %d"
    , acc, emblId);
return sqlQuickString(conn, query);
}
int spFeatureTypeId(struct sqlConnection *conn, char *name)
/* Return feature type id associated with given name. */
{
if (sameString(name, "n/a"))
    return 0;
else
    {
    char query[256];
    safef(query, sizeof(query),
	    "select id from featureType where val='%s'", name);
    return sqlNeedQuickNum(conn, query);
    }
}