//-------------------------------------------------------------- void testApp::draw(){ ofEnableNormalizedTexCoords(); switch(switchInt) { case 1: posterize(); break; case 2: rgbPosterize(); break; case 3: wobble(); break; case 4: abberation(); break; case 5: perlinLab(); break; case 6: wobbleAbberation(); break; case 7: liquifyRender(); break; case 8: perlinXyz(); break; default: liquifyRenderS(); break; } /* cout << "\nMFCCS: "; ofSetColor(255, 0, 0,100); float xinc = 900.0 / 13; for(int i=0; i < 13; i++) { float height = mfccs[i] * 250.0; ofRect(100 + (i*xinc),600 - height,40, height); cout << mfccs[i] << ","; } */ }
void Sim4::slide_intron(int in_w, Exon *first, Exon *last, int spl_model, sim4_stats_t *st) { Exon *t0, *t1, *head = first; splice_t *g, *c, *cell; char type; int w1, w2; int numG=0, numC=0, numE=0, numN=0, model; t0 = head; while (t0 && (t0!=last) && (t1=t0->next_exon) && t1->toGEN) { g = c = NULL; if (t1->frEST-t0->toEST-1==0) { if (!strncmp((char *)(_genSeq+t0->toGEN),"GT",2) && !strncmp((char *)(_genSeq+t1->frGEN-3),"AG",2)) { t0->ori = 'G'; numG++; #ifdef SPLSCORE t0->splScore = 999999; #endif } else if (!strncmp((char *)(_genSeq+t0->toGEN),"CT",2) && !strncmp((char *)(_genSeq+t1->frGEN-3),"AC",2)) { t0->ori = 'C'; numC++; #ifdef SPLSCORE t0->splScore = 888888; #endif } else { int gtag=0, ctac=0; char *s; w1 = MIN(in_w, (int)(0.5*MIN(t0->length-2, t0->toGEN-t0->frGEN-1))); w2 = MIN(in_w, (int)(0.5*MIN(t1->length-2, t1->toGEN-t1->frGEN-1))); model = ((t0->toGEN-w1<=MAX_SPAN) || (t1->frGEN+w2+MAX_SPAN+2>_genLen)) ? SPLICE_ORIGINAL : spl_model; splice(_genSeq, t0->toGEN-w1, t0->toGEN+w1, t1->frGEN-w2, t1->frGEN+w2, _estSeq, t0->toEST-w1, t1->frEST+w2, &g, &c, BOTH, model); if (g->score>c->score) { cell = g; type = 'G'; } else if (c->score>g->score) { cell = c; type = 'C'; } else { cell = g; type = 'G'; } #ifdef SPLSCORE t0->splScore = (model==spl_model) ? cell->score : 777777; #endif t0->toGEN = cell->xs; t0->toEST = cell->ys; t1->frGEN = cell->xe; t1->frEST = cell->ye; t0->length = t0->toEST-t0->frEST+1; t1->length = t1->toEST-t1->frEST+1; wobble(t0,t1,(type=='G')? "GT":"CT",(type=='G')? "AG":"AC",_genSeq); ckfree(g); ckfree(c); /* determine the type, based on the # matches w/ GT-AG (CT-AC) */ s = _genSeq+t0->toGEN; if (*s=='G') gtag++; else if (*s=='C') ctac++; ++s; if (*s=='T') { gtag++; ctac++;} s = _genSeq+t1->frGEN-3; if (*s=='A') { gtag++; ctac++; } ++s; if (*s=='G') gtag++; else if (*s=='C') ctac++; if (gtag>ctac) { type = 'G'; numG++; } else if (ctac>gtag) { type = 'C'; numC++; } else { type = 'N'; numN++; } t0->ori = type; } } else { t0->ori = 'E'; numE++; } t0 = t1; } st->orientation = BOTH; if ((numG > 0) && ((numC + numE + numN) == 0)) { st->orientation = FWD; } else if ((numC > 0) && ((numG + numE + numN) == 0)) { st->orientation = BWD; } /* code not actually used - sim4cc (-interspecies) currently uses only sync_slide_intron(), but provided here in case that changes */ if ((globalParams->_interspecies) && (st->orientation == BOTH)) { if (numG > numC) st->orientation = FWD; if (numG < numC) st->orientation = BWD; } if ((globalParams->_forceStrandPrediction) && (st->orientation == BOTH)) { if (numG > numC) st->orientation = FWD; if (numG < numC) st->orientation = BWD; // otherwise, st->orientation = match orientation, but we // don't know that here. It's set in sim4string.C:run() } }
void Sim4::sync_slide_intron(int in_w, Exon *first, Exon *last, int spl_model, sim4_stats_t *st) { Exon *t0=NULL, *t1=NULL, *head = first; splice_t *g=NULL, *c=NULL, *cell=NULL; splice_t **Glist, **Clist; int Gscore=0, Cscore=0; char *oris; int w1, w2, ni, i, numC, numG, model; ni = 0; numG = numC = 0; // Count the exons to allocate space for Glist, Clist and oris // t0 = head; while (t0 && (t0!=last) && (t1=t0->next_exon) && t1->toGEN) { ni++; t0 = t1; } Glist = (splice_t **)ckalloc((ni + 1) * sizeof(splice_t *)); Clist = (splice_t **)ckalloc((ni + 1) * sizeof(splice_t *)); oris = (char *) ckalloc((ni + 1) * sizeof(char)); memset(Glist, 0, (ni + 1) * sizeof(splice_t *)); memset(Clist, 0, (ni + 1) * sizeof(splice_t *)); memset(oris, 0, (ni + 1) * sizeof(char)); if ((Glist == 0L) || (Clist == 0L) || (oris == 0L)) { fprintf(stderr, "Can't allocate memory for sync_slide_intron() with %d exons.\n", ni); exit(1); } ni = 0; /* assume forward orientation */ t0 = head; while (t0 && (t0!=last) && (t1=t0->next_exon) && t1->toGEN) { g = c = NULL; if (t1->frEST-t0->toEST-1==0) { if (!strncmp((char *)(_genSeq+t0->toGEN),"GT",2) && !strncmp((char *)(_genSeq+t1->frGEN-3),"AG",2)) { g = new_splice('G',t0->toGEN,t1->frGEN,t0->toEST,t1->frEST,-1,NULL); t0->ori = 'G'; oris[ni] = 'G'; numG++; #ifdef SPLSCORE t0->splScore = 999999; #endif } else if (!strncmp((char *)(_genSeq+t0->toGEN),"CT",2) && !strncmp((char *)(_genSeq+t1->frGEN-3),"AC",2)) { c = new_splice('C',t0->toGEN,t1->frGEN,t0->toEST,t1->frEST,-1,NULL); t0->ori = 'C'; oris[ni] = 'C'; numC++; #ifdef SPLSCORE t0->splScore = 888888; #endif } else { w1 = MIN(in_w, (int)(0.5*MIN(t0->length-1, t0->toGEN-t0->frGEN))); w2 = MIN(in_w, (int)(0.5*MIN(t1->length-1, t1->toGEN-t1->frGEN))); model = ((t0->toGEN-w1<=MAX_SPAN) || (t1->frGEN+w2+MAX_SPAN+2>_genLen)) ? SPLICE_ORIGINAL : spl_model; splice(_genSeq, t0->toGEN-w1, t0->toGEN+w1, t1->frGEN-w2, t1->frGEN+w2, _estSeq, t0->toEST-w1, t1->frEST+w2, &g, &c, BOTH, model); Gscore += g->score; Cscore += c->score; cell = NULL; oris[ni] = '*'; if (g->score>c->score) { numG++; cell = g; oris[ni] = 'G'; } else if (c->score>g->score) { numC++; cell = c; oris[ni] = 'C'; } else if (c->score==g->score) { numG++; numC++; cell = g; oris[ni] = 'G'; } #ifdef SPLSCORE t0->splScore = (model==spl_model) ? cell->score : 777777; #endif t0->ori = oris[ni]; t0->toGEN = cell->xs; t0->toEST = cell->ys; t1->frGEN = cell->xe; t1->frEST = cell->ye; t0->length = t0->toEST-t0->frEST+1; t1->length = t1->toEST-t1->frEST+1; } Clist[ni] = c; Glist[ni] = g; } else { t0->ori = 'E'; oris[ni] = 'E'; } ni++; t0 = t1; } st->orientation = BOTH; if ((numG==1) && (numC==1) && (!Glist[0] || !Clist[0] || !Glist[1] || !Clist[1])) goto free_all; if (numG && numG>=numC) { /* revisit all previous assignments that are inconsistent */ for (i=0, t0=head; i<ni; i++, t0=t1) { t1 = t0->next_exon; switch (oris[i]) { case 'G': break; case 'C': if (Glist[i]==NULL) { /* compute the values for C */ w1 = MIN(in_w, (int)(0.5*MIN(t0->length-1, t0->toGEN-t0->frGEN))); w2 = MIN(in_w, (int)(0.5*MIN(t1->length-1, t1->toGEN-t1->frGEN))); model = ((t0->toGEN-w1<=MAX_SPAN) || (t1->frGEN+w2+MAX_SPAN+2>_genLen)) ? SPLICE_ORIGINAL : spl_model; splice(_genSeq, t0->toGEN-w1, t0->toGEN+w1, t1->frGEN-w2, t1->frGEN+w2, _estSeq, t0->toEST-w1, t1->frEST+w2, &g, &c, FWD, model); } else g = Glist[i]; #ifdef SPLSCORE t0->splScore = (model==spl_model) ? g->score : 777777; #endif t0->ori = 'G'; t0->toGEN = g->xs; t0->toEST = g->ys; t1->frGEN = g->xe; t1->frEST = g->ye; t0->length = t0->toEST-t0->frEST+1; t1->length = t1->toEST-t1->frEST+1; break; case 'E': break; default : fatal("sim4b1.c: intron orientation not initialized."); } if (oris[i]!='E') wobble(t0,t1,"GT","AG",_genSeq); } st->orientation = FWD; } else if (numC) { /* analyze all assignments for consistency */ for (i=0, t0=head; i<ni; i++, t0=t1) { t1 = t0->next_exon; switch (oris[i]) { case 'C': break; case 'G': if (Clist[i]==NULL) { /* compute the values for C */ w1 = MIN(in_w, (int)(0.5*MIN(t0->length-1, t0->toGEN-t0->frGEN))); w2 = MIN(in_w, (int)(0.5*MIN(t1->length-1, t1->toGEN-t1->frGEN))); model = ((t0->toGEN-w1<=MAX_SPAN) || (t1->frGEN+w2+MAX_SPAN+2>_genLen)) ? SPLICE_ORIGINAL : spl_model; splice(_genSeq, t0->toGEN-w1, t0->toGEN+w1, t1->frGEN-w2, t1->frGEN+w2, _estSeq, t0->toEST-w1, t1->frEST+w2, &g, &c, BWD, model); } else c = Clist[i]; #ifdef SPLSCORE t0->splScore = (spl_model==model) ? c->score : 777777; #endif t0->ori = 'C'; t0->toGEN = c->xs; t0->toEST = c->ys; t1->frGEN = c->xe; t1->frEST = c->ye; t0->length = t0->toEST-t0->frEST+1; t1->length = t1->toEST-t1->frEST+1; break; case 'E': break; default : fatal("sim4b1.c: intron orientation not initialized."); } if (oris[i]!='E') wobble(t0,t1,"CT","AC",_genSeq); } st->orientation = BWD; } /* now free all memory allocated */ free_all: for (i=0; i<ni; i++) { ckfree(Glist[i]); ckfree(Clist[i]); } ckfree(Glist); ckfree(Clist); ckfree(oris); return; }
void main(void) { uint32_t limit; gpio_init(); pwm_init(); systick_init(); pwm_set(0); while(1) { wait: limit = 10; while(!get_switch()) ; fade_to(PWM_MAX, 5); delay_ticks(RELEASE_TIME); start: if(limit > 120) limit = 120; for(uint32_t i = 0; i < limit * 60 * 100; i++) { uint32_t cnt = 0; while(get_switch()) { cnt++; if(cnt > 300) { limit = 60; strobe(); delay_ticks(2*RELEASE_TIME); goto start; } delay_ticks(10); } if(cnt) { fade_to(0, 5); goto wait; } delay_ticks(10); } wobble(); for(uint32_t i = 0; i < 30 * 100; i++) { uint32_t cnt = 0; while(get_switch()) { cnt++; if(cnt > 300) { limit = 60; strobe(); delay_ticks(2*RELEASE_TIME); goto start; } delay_ticks(10); } if(cnt) { limit += limit; delay_ticks(1000); goto start; } delay_ticks(10); } fade_to(0, 30); } }