src/hg/hgTracks/cds.c 1.95
1.95 2009/05/20 20:50:51 mikep
display sequence or sequence different to the genome using a bed or bigBed which has the sequence in the name (eg tagAlign) in a similar manner to PSL files (by loading the BED as a linkedFeature like a PSL)
Index: src/hg/hgTracks/cds.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/hgTracks/cds.c,v
retrieving revision 1.94
retrieving revision 1.95
diff -b -B -U 4 -r1.94 -r1.95
--- src/hg/hgTracks/cds.c 29 Apr 2009 18:47:45 -0000 1.94
+++ src/hg/hgTracks/cds.c 20 May 2009 20:50:51 -0000 1.95
@@ -284,9 +284,13 @@
if (s > winEnd || e < winStart)
continue;
if (e > s)
{
- int mrnaS = convertCoordUsingPsl(s, psl);
+ int mrnaS = -1;
+ if (psl)
+ convertCoordUsingPsl(s, psl);
+ else
+ mrnaS = sf->qStart;
if(mrnaS >= 0)
{
int i;
for (i=0; i < (e - s); i++)
@@ -822,8 +826,14 @@
else if (startsWith("extFile", seqSource))
mrnaSeq = maybeGetExtFileSeq(seqSource, name);
else if (endsWith("ExtFile", seqSource))
mrnaSeq = maybeGetExtFileSeq(seqSource, name);
+else if (sameString("nameIsSequence", seqSource))
+ {
+ mrnaSeq = newDnaSeq(cloneString(name), strlen(name), cloneString(name));
+ if (lf->orientation == -1)
+ reverseComplement(mrnaSeq->dna, mrnaSeq->size);
+ }
else
mrnaSeq = hGenBankGetMrna(database, name, NULL);
if (mrnaSeq != NULL)
@@ -1243,22 +1253,28 @@
}
static void drawDiffTextBox(struct hvGfx *hvg, int xOff, int y,
double scale, int heightPer, MgFont *font, Color color,
- char *chrom, unsigned s, unsigned e, struct psl *psl,
+ char *chrom, unsigned s, unsigned e, struct simpleFeature *sf, struct psl *psl,
struct dnaSeq *mrnaSeq, struct linkedFeatures *lf,
int grayIx, enum baseColorDrawOpt drawOpt,
int maxPixels, Color *trackColors, Color ixColor)
{
-int mrnaS = convertCoordUsingPsl( s, psl );
+int mrnaS = -1;
+if (psl)
+ mrnaS = convertCoordUsingPsl( s, psl );
+else if (sf)
+ mrnaS = sf->qStart;
if(mrnaS >= 0)
{
struct dyString *dyMrnaSeq = newDyString(256);
char mrnaBases[4];
char genomicCodon[2];
char mrnaCodon[2];
boolean queryInsertion = FALSE;
+ mrnaBases[0] = '\0';
+ if (psl)
getMrnaBases(psl, mrnaSeq, mrnaS, s, e, (lf->orientation == -1),
mrnaBases, &queryInsertion);
if (queryInsertion)
color = cdsColor[CDS_QUERY_INSERTION];
@@ -1355,9 +1371,9 @@
void baseColorDrawItem(struct track *tg, struct linkedFeatures *lf,
int grayIx, struct hvGfx *hvg, int xOff,
int y, double scale, MgFont *font, int s, int e,
int heightPer, boolean zoomedToCodonLevel,
- struct dnaSeq *mrnaSeq, struct psl *psl,
+ struct dnaSeq *mrnaSeq, struct simpleFeature *sf, struct psl *psl,
enum baseColorDrawOpt drawOpt,
int maxPixels, int winStart,
Color originalColor)
/* Draw codon/base-colored item. */
@@ -1371,21 +1387,27 @@
((drawOpt == baseColorDrawDiffBases && !zoomedToBaseLevel) ||
(drawOpt == baseColorDrawDiffCodons && !zoomedToCdsColorLevel));
if (drawOpt == baseColorDrawGenomicCodons && (e-s <= 3))
+ {
drawScaledBoxSampleWithText(hvg, s, e, scale, xOff, y, heightPer,
color, lf->score, font, codon,
zoomedToCodonLevel, winStart, maxPixels);
-else if (mrnaSeq != NULL && psl != NULL && !zoomedOutToPostProcessing &&
+ }
+else if (mrnaSeq != NULL && (psl != NULL || sf != NULL) && !zoomedOutToPostProcessing &&
drawOpt != baseColorDrawGenomicCodons)
+ {
drawDiffTextBox(hvg, xOff, y, scale, heightPer, font,
- color, chromName, s, e, psl, mrnaSeq, lf,
+ color, chromName, s, e, sf, psl, mrnaSeq, lf,
grayIx, drawOpt, maxPixels,
tg->colorShades, originalColor);
+ }
else
+ {
/* revert to normal coloring */
drawScaledBoxSample(hvg, s, e, scale, xOff, y, heightPer,
color, lf->score );
+ }
}
static void drawCdsDiffCodonsOnly(struct track *tg, struct linkedFeatures *lf,
@@ -1676,17 +1697,19 @@
drawOpt == baseColorDrawDiffCodons ||
indelShowPolyA)
{
*retMrnaSeq = maybeGetSeqUpper(lf, tg->mapName, tg);
- if (*retMrnaSeq != NULL && *retPsl != NULL)
+ if (*retMrnaSeq != NULL && *retPsl != NULL) // we have both sequence and PSL
{
if ((*retMrnaSeq)->size != (*retPsl)->qSize)
errAbort("baseColorDrawSetup: %s: mRNA size (%d) != psl qSize (%d)",
(*retPsl)->qName, (*retMrnaSeq)->size, (*retPsl)->qSize);
if ((*retPsl)->strand[0] == '-' || (*retPsl)->strand[1] == '-')
reverseComplement((*retMrnaSeq)->dna, strlen((*retMrnaSeq)->dna));
}
- else
+ // if no sequence, no base color drawing
+ // Note: we could have sequence but no PSL (eg, tagAlign format)
+ else if (*retMrnaSeq == NULL)
return baseColorDrawOff;
}
return drawOpt;