示例#1
0
void makeActiveImagePB(char *psOutput, char *psOutput2)
/* Make image and image map. */
{
char *mapName = "map";
int pixWidth, pixHeight;

char *answer;
char cond_str[255];
struct sqlConnection *conn;
struct sqlConnection *connCentral;
char query[256];
struct sqlResult *sr;
char **row;
int  iypos;
char *blatGbDb;
char *sciName, *commonName;
char *spDisplayId;
char *oldDisplayId;
conn  = sqlConnect(UNIPROT_DB_NAME);
hPrintf("<br><font size=4>Protein ");

hPrintf("<A HREF=\"http://www.uniprot.org/uniprot/%s\" TARGET=_blank><B>%s</B></A>\n",
        proteinID, proteinID);

spDisplayId = spAccToId(conn, spFindAcc(conn, proteinID));
if (strstr(spDisplayId, spFindAcc(conn, proteinID)) == NULL)
    {
    hPrintf(" (aka %s", spDisplayId);
    /* show once if the new and old displayId are the same */
    oldDisplayId = oldSpDisplayId(spDisplayId);
    if (oldDisplayId != NULL)
        {
        if (!sameWord(spDisplayId, oldDisplayId))
            {
            hPrintf(" or %s", oldSpDisplayId(spDisplayId));
            }
        }
    hPrintf(")\n");
    }
hPrintf(" %s\n", description);
hPrintf("</font><br>");

hPrintf("Organism: ");
/* get scientific and Genbank common name of this organism */
sciName    = NULL;
commonName = NULL;
sqlSafefFrag(cond_str, sizeof(cond_str),"accession='%s'", proteinID);
answer = sqlGetField(PROTEOME_DB_NAME, "spXref3", "division", cond_str);
if (answer != NULL)
    {
    sqlSafefFrag(cond_str, sizeof(cond_str), "id=%s and nameType='scientific name'", answer);
    sciName = sqlGetField(PROTEOME_DB_NAME, "taxonNames", "name", cond_str);

    sqlSafefFrag(cond_str, sizeof(cond_str), "id=%s and nameType='genbank common name'", answer);
    commonName = sqlGetField(PROTEOME_DB_NAME, "taxonNames", "name", cond_str);
    }
if (sciName != NULL)
    {
    hPrintf("%s", sciName);
    }
if (commonName != NULL)
    {
    hPrintf(" (%s)", commonName);
    }
hPrintf("<br>");

protSeq = getAA(proteinID);
if (protSeq == NULL)
    {
    hUserAbort("%s is not a current valid entry in UniProtKB\n", proteinID);
    }
protSeqLen = strlen(protSeq);

fflush(stdout);

iypos = 15;
doTracks(proteinID, mrnaID, protSeq, &iypos, psOutput);
if (!hTableExists(database, "pbStamp")) goto histDone;

pbScale = 3;
pixWidth = 765;
insideWidth = pixWidth-gfxBorder;

pixHeight = 350;

if (psOutput2)
    {
    vg2 = vgOpenPostScript(pixWidth, pixHeight, psOutput2);
    }
else
    {
    trashDirFile(&gifTn2, "pbt", "pbt", ".png");
    vg2 = vgOpenPng(pixWidth, pixHeight, gifTn2.forCgi, FALSE);
    }

g_vg = vg2;

pbRed    = vgFindColorIx(vg2, 0xf9, 0x51, 0x59);
pbBlue   = vgFindColorIx(g_vg, 0x00, 0x00, 0xd0);

normalColor   = pbBlue;
abnormalColor = pbRed;

bkgColor = vgFindColorIx(vg2, 255, 254, 232);
vgBox(vg2, 0, 0, insideWidth, pixHeight, bkgColor);

/* Start up client side map. */
mapName=cloneString("pbStamps");
hPrintf("\n<MAP Name=%s>\n", mapName);

vgSetClip(vg2, 0, gfxBorder, insideWidth, pixHeight - 2*gfxBorder);
iypos = 15;

/* Draw stamps. */

doStamps(proteinID, mrnaID, protSeq, vg2, &iypos);

/* Finish map. */
hPrintf("</MAP>\n");

/* Save out picture and tell html file about it. */
vgClose(&vg2);
hPrintf("<P>");

hPrintf("\n<IMG SRC=\"%s\" BORDER=1 WIDTH=%d HEIGHT=%d USEMAP=#%s><BR>",
            gifTn2.forCgi, pixWidth, pixHeight, mapName);
if (proteinInSupportedGenome)
    {
    hPrintf("\n<A HREF=\"../goldenPath/help/pbTracksHelpFiles/pbTracksHelp.shtml#histograms\" TARGET=_blank>");
    }
else
    {
    hPrintf("\n<A HREF=\"../goldenPath/help/pbTracksHelpFiles/pbTracksHelp.shtml#histograms\" TARGET=_blank>");
    }

hPrintf("Explanation of Protein Property Histograms</A><BR>");

hPrintf("<P>");

histDone:

hPrintf("<P>");
fflush(stdout);

/* See if a UCSC Genome Browser exist for this organism.  If so, display BLAT link. */
connCentral = hConnectCentral();
sqlSafef(query, sizeof(query),
      "select defaultDb.name from dbDb, defaultDb where dbDb.scientificName='%s' and dbDb.name=defaultDb.name",
      sciName);
sr = sqlGetResult(connCentral, query);
row = sqlNextRow(sr);
if (row != NULL)
    {
    blatGbDb = strdup(row[0]);
    }
else
    {
    blatGbDb = NULL;
    }
sqlFreeResult(&sr);
hDisconnectCentral(&connCentral);

if (proteinInSupportedGenome || (blatGbDb != NULL))
    {
    hPrintf("\n<B>UCSC Links:</B><BR>\n ");
    hPrintf("<UL>\n");

    /* Show GB links only if the protein belongs to a supported genome */
    if (proteinInSupportedGenome)
        {
        doGenomeBrowserLink(proteinID, mrnaID, hgsidStr);
        doGeneDetailsLink(proteinID, mrnaID, hgsidStr);
        }

    /* Show Gene Sorter link only if it is valid for this genome */
    if (hgNearOk(database))
        {
        doGeneSorterLink(protDisplayID, mrnaID, hgsidStr);
        }

    /* Show BLAT link if we have UCSC Genome Browser for it */
    if (blatGbDb != NULL)
        {
        doBlatLink(blatGbDb, sciName, commonName, protSeq);
        }

    hPrintf("</UL><P>");
    }

/* This section shows various types of  domains */
conn = sqlConnect(UNIPROT_DB_NAME);
domainsPrint(conn, proteinID);

hPrintf("<P>");

/* Do Pathway section only if the protein belongs to a supported genome */
if (proteinInSupportedGenome);
    {
    doPathwayLinks(proteinID, mrnaID);
    }

printFASTA(proteinID, protSeq);
}
void makeActiveImagePB(char *psOutput, char *psOutput2)
/* Make image and image map. */
{
char *mapName = "map";
int pixWidth, pixHeight;

struct sqlConnection *conn;
char query[256];
struct sqlResult *sr;
char **row;

int  iypos;
char *spDisplayId;
char *oldDisplayId;
conn  = sqlConnect(UNIPROT_DB_NAME);
printf("<BR>");
hPrintf("<BR><font size=4><B>Protein: ");
hPrintf("%s</B>", proteinID);

/* Please note the hiv database name is hard wired here.*/
safef(query, sizeof(query), 
"select subjId from hivVax003Vax004.gsIdXref where aaSeqId = '%s'", proteinID);
sr = sqlMustGetResult(conn, query);
row = sqlNextRow(sr);
if (row != NULL)
    {
    printf("<BR>");
    hPrintf("<font size=4><B>Subject: ");
    hPrintf("<A HREF=\"../cgi-bin/gsidSubj?hgs_subj=%s&submit=Go!\">", row[0]);
    hPrintf("%s</A></B><BR>", row[0]);
    }
sqlFreeResult(&sr);

spDisplayId = spAccToId(conn, spFindAcc(conn, proteinID));
if (strstr(spDisplayId, spFindAcc(conn, proteinID)) == NULL)
	{
	hPrintf(" (aka %s", spDisplayId);
	/* show once if the new and old displayId are the same */
 	oldDisplayId = oldSpDisplayId(spDisplayId);
	if (oldDisplayId != NULL)
 	    {
            if (!sameWord(spDisplayId, oldDisplayId))
	    	{
	    	hPrintf(" or %s", oldSpDisplayId(spDisplayId));
	    	}
	    }
	hPrintf(")\n");
	}
hPrintf("</font><br>");

protSeq = getAA(proteinID);
if (protSeq == NULL)
    {
    errAbort("%s is not a current valid entry in UniProt(SWISS-PROT/TrEMBL)\n", proteinID);
    }
protSeqLen = strlen(protSeq);

fflush(stdout);

iypos = 15; 
doTracks(proteinID, mrnaID, protSeq, &iypos, psOutput);
if (!hTableExists(database, "pbStamp")) goto histDone; 

pbScale = 3;
pixWidth = 520;
insideWidth = pixWidth-gfxBorder;

pixHeight = 350;

if (psOutput2)
    {
    vg2 = vgOpenPostScript(pixWidth, pixHeight, psOutput2);
    }
else
    {
    trashDirFile(&gifTn2, "pbt", "pbt", ".gif");
    vg2 = vgOpenGif(pixWidth, pixHeight, gifTn2.forCgi, FALSE);
    }

g_vg = vg2;

pbRed    = vgFindColorIx(vg2, 0xf9, 0x51, 0x59);
pbBlue   = vgFindColorIx(g_vg, 0x00, 0x00, 0xd0);

normalColor   = pbBlue;
abnormalColor = pbRed;

bkgColor = vgFindColorIx(vg2, 255, 254, 232);
vgBox(vg2, 0, 0, insideWidth, pixHeight, bkgColor);

/* Start up client side map. */
mapName=cloneString("pbStamps");
hPrintf("\n<MAP Name=%s>\n", mapName);

vgSetClip(vg2, 0, gfxBorder, insideWidth, pixHeight - 2*gfxBorder);
iypos = 15;

/* Draw stamps. */

doStamps(proteinID, mrnaID, protSeq, vg2, &iypos);

/* Finish map. */
hPrintf("</MAP>\n");

/* Save out picture and tell html file about it. */
vgClose(&vg2);
hPrintf("<P>");

hPrintf("\n<IMG SRC=\"%s\" BORDER=1 WIDTH=%d HEIGHT=%d USEMAP=#%s><BR>",
            gifTn2.forCgi, pixWidth, pixHeight, mapName);
if (proteinInSupportedGenome)
    {
    hPrintf("\n<A HREF=\"../goldenPath/help/pbTracksHelpFiles/pbTracksHelp.shtml#histograms\" TARGET=_blank>");
    }
else
    {
    hPrintf("\n<A HREF=\"../goldenPath/help/pbTracksHelpFiles/pbGsid/pbTracksHelp.shtml#histograms\" TARGET=_blank>");
    }

hPrintf("Explanation of Protein Property Histograms</A><BR>");

hPrintf("<P>");

histDone:

hPrintf("<P>");
fflush(stdout);

printFASTA(proteinID, protSeq);
}