int main() {

  uint64_t data = 0xdead;
  uint16_t addr = 1;
  printf("[INFO] Write R[%d] = %lx\n", addr, data);
  doWrite(addr, data);

  printf("[INFO] Read R[%d]\n", addr);
  uint64_t y = doRead(addr);
  printf("[INFO]   Received %lx\n", y);
  assert(y == data);

  uint64_t data_accum = -0x1fbe;
  printf("[INFO] Accum R[%d] with %lx\n", addr, data_accum);
  y = doAccum(addr, data_accum);
  printf("[INFO]   Received %lx\n", y);
  assert(y == data);

  printf("[INFO] Read R[%d]\n", addr);
  y = doRead(addr);
  printf("[INFO]   Received %lx\n", y);
  assert(y == data + data_accum);

  data = 0xbeef;
  uint64_t data_addr = doTranslate((void *) &data);
  printf("[INFO] Load %lx (0x%lx) via L1 data cache\n",
         data, data_addr);
  y = doLoad(addr, data_addr);
  printf("[INFO]   Received %lx\n", y);

  return 0;
}
Exemple #2
0
/* translate nuc sequence into an sequence of amino acids */
void translateProtein(struct speciesInfo *si)
{
struct dnaSeq thisSeq;
aaSeq *outSeq;

thisSeq.dna = si->nucSequence;
thisSeq.size = si->size;
outSeq =  doTranslate(&thisSeq, 0,  0, FALSE);
si->aaSequence  = outSeq->dna;
si->aaSize = outSeq->size;
}
Exemple #3
0
void outSpeciesExons(FILE *f, char *dbName, struct speciesInfo *si, 
    struct exonInfo *giList)
{
int exonNum = 1;
struct dnaSeq thisSeq;
aaSeq *outSeq;
int exonCount = 0;
struct exonInfo *gi = giList;

for(; gi; gi = gi->next)
    exonCount++;

for(gi = giList; gi; gi = gi->next, exonNum++)
    {
    struct speciesInfo *siTemp = si;
    if (gi->frame->strand[0] == '-')
	slReverse(&gi->frame);

    struct mafFrames *startFrame = gi->frame;
    assert(startFrame->isExonStart == TRUE);
    struct mafFrames *lastFrame = startFrame;
    assert(gi->exonSize < MAX_EXON_SIZE);

    while(lastFrame->next)
	lastFrame = lastFrame->next;
    assert(lastFrame->isExonEnd == TRUE);

    for(; siTemp ; siTemp = siTemp->next)
	{
	char *ptr = exonBuffer;

	switch(startFrame->frame)
	    {
	    case 0: /* just copy the sequence over */
		memcpy(ptr, 
		    &siTemp->nucSequence[gi->exonStart], gi->exonSize);
		ptr += gi->exonSize;
		break;
	    case 1: /* we need to grab one nuc from the end 
	             * of the previous exon */
		*ptr++ = siTemp->nucSequence[gi->exonStart - 1];
		memcpy(ptr, 
		    &siTemp->nucSequence[gi->exonStart], gi->exonSize);
		ptr += gi->exonSize;
		break;

	    case 2: /* we need to delete the first nuc from this exon
	             * because we included it on the last exon */
		memcpy(ptr, 
		    &siTemp->nucSequence[gi->exonStart+1], gi->exonSize - 1);
		ptr += gi->exonSize - 1;
		break;
	    }

	int lastFrame = (startFrame->frame + gi->exonSize) % 3;
	if (lastFrame == 1) /* delete the last nucleotide */
	    --ptr;
	else if (lastFrame == 2) /* add one more nucleotide from
	                          * the next exon */
	    *ptr++ = siTemp->nucSequence[gi->exonStart + gi->exonSize];
	*ptr++ = 0;   /* null terminate */

	thisSeq.dna = exonBuffer;
	thisSeq.size = ptr - exonBuffer;
	outSeq =  doTranslate(&thisSeq, 0,  0, FALSE);
	if (!allDashes(outSeq->dna))
	    {
	    fprintf(f, ">%s_%s_%d_%d %d %d %d %s",
		gi->name, 
		siTemp->name, exonNum, exonCount, 
		outSeq->size,
		startFrame->frame, lastFrame,
		siTemp->curPosString->name);
		//dbName, gi->frame->chrom,
		//gi->chromStart+1, gi->chromEnd, startFrame->strand[0]);

	    maybePrintGeneName(gi->name, f);

	    fprintf(f, "\n%s\n",  outSeq->dna);
	    }
	siTemp->curPosString = siTemp->curPosString->next;
	}
    fprintf(f, "\n");
    }
fprintf(f, "\n");
}
Exemple #4
0
static void outSpeciesExons(FILE *f, char *dbName, struct speciesInfo *si, 
    struct exonInfo *giList, boolean doBlank, boolean doTable, int numCols)
{
int exonNum = 1;
struct dnaSeq thisSeq;
aaSeq *outSeq;
int exonCount = 0;
struct exonInfo *gi = giList;

for(; gi; gi = gi->next)
    {
    if (gi->exonSize > 1)
	exonCount++;
    }

for(gi = giList; gi; gi = gi->next, exonNum++)
    {
    struct speciesInfo *siTemp = si;
    
    if (gi->exonSize == 1)
	continue;

    for(; siTemp ; siTemp = siTemp->next)
	{
	char *ptr = exonBuffer;

	switch(gi->frame)
	    {
	    case 0: /* just copy the sequence over */
		memcpy(ptr, 
		    &siTemp->nucSequence[gi->exonStart], gi->exonSize);
		ptr += gi->exonSize;
		break;
	    case 1: /* we need to grab one nuc from the end 
	             * of the previous exon */
		*ptr++ = siTemp->nucSequence[gi->exonStart - 1];
		memcpy(ptr, 
		    &siTemp->nucSequence[gi->exonStart], gi->exonSize);
		ptr += gi->exonSize;
		break;

	    case 2: /* we need to delete the first nuc from this exon
	             * because we included it on the last exon */
		memcpy(ptr, 
		    &siTemp->nucSequence[gi->exonStart+1], gi->exonSize - 1);
		ptr += gi->exonSize - 1;
		break;
	    }

	int lastFrame = (gi->frame + gi->exonSize) % 3;
	if (lastFrame == 1) /* delete the last nucleotide */
	    --ptr;
	else if (lastFrame == 2) /* add one more nucleotide from
	                          * the next exon */
	    *ptr++ = siTemp->nucSequence[gi->exonStart + gi->exonSize];
	*ptr++ = 0;   /* null terminate */

	thisSeq.dna = exonBuffer;
	thisSeq.size = ptr - exonBuffer;
	outSeq =  doTranslate(&thisSeq, 0,  0, FALSE);
	char buffer[10 * 1024];

	safef(buffer, sizeof buffer,  "%s_%s_%d_%d %d %d %d %s",
	    gi->name, 
	    siTemp->name, exonNum, exonCount, 
	    outSeq->size,
	    gi->frame, lastFrame,
	    siTemp->curPosString->name);

	if (doBlank || !allDashes(outSeq->dna))
	    {
	    if (doTable)
		{
		if (numCols == -1)
		    fprintf(f, "%s ", buffer);
		else
		    {
		    if (strlen(buffer) > numCols)
			buffer[numCols] = 0;
		    fprintf(f, "%-*s ", numCols, buffer);
		    }
		}
	    else
		fprintf(f, ">%s\n", buffer);

	    fprintf(f, "%s\n", outSeq->dna);
	    }
	siTemp->curPosString = siTemp->curPosString->next;
	}
    fprintf(f, "\n");
    }
fprintf(f, "\n");
}