int main(int argc, char *argv[]) { //struct timeval t0_start, t0_end, t1_start, t1_end, t2_start, t2_end; //gettimeofday(&t0_start,0); //gettimeofday(&t1_start,0); if (argc < 4) { fprintf(stderr, "usage: order <u> <a> <b> <N>\n"); return 1; } int chrom_num = 24; /***********************REPLACE WITH INPUT FILE************************/ char *chrom_names[] = { "chr1", "chr2", "chr3", "chr4", "chr5", "chr6", "chr7", "chr8", "chr9", "chr10", "chr11", "chr12", "chr13", "chr14", "chr15", "chr16", "chr17", "chr18", "chr19", "chr20", "chr21", "chr22", "chrX", "chrY" }; /**********************************************************************/ struct chr_list *U_list, *A_list, *B_list; char *U_file = argv[1], *A_file = argv[2], *B_file = argv[3]; int reps = atoi(argv[4]); if((chr_list_from_bed_file(&U_list, chrom_names, chrom_num, U_file) == 1) || (chr_list_from_bed_file(&A_list, chrom_names, chrom_num, A_file) == 1) || (chr_list_from_bed_file(&B_list, chrom_names, chrom_num, B_file) == 1) ){ fprintf(stderr, "Error parsing bed files.\n"); return 1; } int max = add_offsets(U_list, chrom_num); trim(U_list, A_list, chrom_num); trim(U_list, B_list, chrom_num); int i; int A_size, B_size, U_size; struct bed_line *U_array, *A_array, *B_array; // Move the universe and intervals from linked lists to arrays U_size = chr_array_from_list(U_list, &U_array, chrom_num); A_size = chr_array_from_list(A_list, &A_array, chrom_num); B_size = chr_array_from_list(B_list, &B_array, chrom_num); // make one large array to hold these /* * We need to put both A and B into a single array then sort it * * Each interval becomes a triple: * key: offset * sample: A (0) or B (1) * type: start (0) or end (1) * rank: order within * */ struct triple *AB = (struct triple *) malloc((2*A_size + 2*B_size)*sizeof(struct triple)); //A and B points to AB, A to the beging and B to the interior, after A struct triple *A = AB; struct triple *B = AB + 2*A_size; map_intervals(A, A_array, A_size, U_array, U_size, 0 ); map_intervals(B, B_array, B_size, U_array, U_size, 1 ); int j; // sort A and B so they can be ranked qsort(A, 2*A_size, sizeof(struct triple), compare_triple_lists); qsort(B, 2*B_size, sizeof(struct triple), compare_triple_lists); unsigned int *A_len = (unsigned int *) malloc( A_size * sizeof(unsigned int)); unsigned int *B_len = (unsigned int *) malloc( B_size * sizeof(unsigned int)); // Set ranks for (i = 0; i < 2*A_size; i++) A[i].rank = i/2; for (i = 0; i < 2*B_size; i++) B[i].rank = i/2; // Get lengths for (i = 0; i < A_size; i++) A_len[i] = A[i*2 + 1].key - A[i*2].key; for (i = 0; i < B_size; i++) B_len[i] = B[i*2 + 1].key - B[i*2].key; //for (i = 0; i < A_size; i++) //printf("(%d,%d)\n", A[i*2].key, A[i*2 + 1].key); //return 1; qsort(AB, 2*A_size + 2*B_size, sizeof(struct triple), compare_triple_lists); // find the intersecting ranks there are atmost A + B pairs unsigned int *pairs = (unsigned int *) malloc( 2 * (A_size + B_size) * sizeof(unsigned int)); int num_pairs = find_intersecting_ranks(AB, A_size, B_size, pairs); for (i = 0; i < num_pairs; i++) printf("%u\t%u\n", pairs[2*i], pairs[2*i + 1]); return 0; }
int main(int argc, char *argv[]) { if (argc < 4) { fprintf(stderr, "usage: %s <u> <a> <b>\n", argv[0]); return 1; } int chrom_num = 24; /***********************REPLACE WITH INPUT FILE************************/ char *chrom_names[] = { "chr1", "chr2", "chr3", "chr4", "chr5", "chr6", "chr7", "chr8", "chr9", "chr10", "chr11", "chr12", "chr13", "chr14", "chr15", "chr16", "chr17", "chr18", "chr19", "chr20", "chr21", "chr22", "chrX", "chrY" }; /**********************************************************************/ struct chr_list *U_list, *A_list, *B_list; char *U_file = argv[1], *A_file = argv[2], *B_file = argv[3]; if((chr_list_from_bed_file(&U_list, chrom_names, chrom_num, U_file) == 1) || (chr_list_from_bed_file(&A_list, chrom_names, chrom_num, A_file) == 1) || (chr_list_from_bed_file(&B_list, chrom_names, chrom_num, B_file) == 1) ){ fprintf(stderr, "Error parsing bed files.\n"); return 1; } int max = add_offsets(U_list, chrom_num); if (max == 0) { fprintf(stderr, "Max is zero.\n"); return 1; } trim(U_list, A_list, chrom_num); trim(U_list, B_list, chrom_num); int A_size, B_size, U_size; struct bed_line *U_array, *A_array, *B_array; // Move the universe and intervals from linked lists to arrays U_size = chr_array_from_list(U_list, &U_array, chrom_num); A_size = chr_array_from_list(A_list, &A_array, chrom_num); B_size = chr_array_from_list(B_list, &B_array, chrom_num); struct triple *AB = (struct triple *) malloc((2*A_size + 2*B_size)*sizeof(struct triple)); //A and B points to AB, A to the beging and B to the interior, after A struct triple *A = AB; struct triple *B = AB + 2*A_size; map_intervals(A, A_array, A_size, U_array, U_size, 0 ); map_intervals(B, B_array, B_size, U_array, U_size, 1 ); // sort A and B so they can be ranked start(); qsort(AB, 2*A_size + 2*B_size, sizeof(struct triple), compare_triple_lists); stop(); unsigned long sort_seq = report(); start(); int O = count_intersections_sweep_seq(AB, A_size, B_size); stop(); unsigned long count_seq = report(); unsigned long total = sort_seq + count_seq; fprintf(stderr,"O:%d\n", O); printf("%d,%d,%d\tT:%ld\t" "sort:%ld,%G\t" "search:%ld,%G\n", A_size, B_size, A_size + B_size, total, sort_seq, (double)sort_seq / (double)total, count_seq, (double)count_seq / (double)total ); return 0; }
int32 CFont::m_DrawPhrase (FONTPHRASE *phrase, float4 relpos) { int32 i, l; float4 start, end; float4 animStartScale, animEndScale; // range del keyframer di scaling float4 animStartRot, animEndRot; // range del keyframer di rotazione uint32 alpha, r, color; float4 animScaleX, animScaleY, animPos; float4 end_animScaleX, end_animScaleY; AD_Vect3D scale3D; AD_Matrix rot, end_rot; mat_identity(&rot); mat_identity(&end_rot); l=strlen(phrase->text); end_animScaleX=phrase->scaleX; end_animScaleY=phrase->scaleY; if (p_ScaleTrack.p_NumKeys>0) { p_ScaleTrack.m_GetTimeRange(&animStartScale, &animEndScale); p_ScaleTrack.m_GetData(animEndScale, &scale3D); end_animScaleX*=scale3D.x; end_animScaleY*=scale3D.y; } animScaleX=phrase->scaleX; animScaleY=phrase->scaleY; if (p_RotationTrack.p_NumKeys>0) { p_RotationTrack.m_GetTimeRange(&animStartRot, &animEndRot); p_RotationTrack.m_GetData(animEndRot, &end_rot); } // in questo intervallo la frase รจ tutta visibile completa // di transizioni (colore, alpha, animazioni) terminate if ((relpos>=phrase->phraseFixedStart) && (relpos<phrase->phraseFixedEnd)) m_DrawAnimatedText(phrase->x, phrase->y, end_animScaleX, end_animScaleX, end_animScaleX, end_animScaleY, phrase->color, phrase->text, 0, l-1, &end_rot); else if (relpos<phrase->phraseFixedStart) { for (i=0; i<l; i++) { animScaleX=phrase->scaleX; animScaleY=phrase->scaleY; // calcolo l'inizio e fine della lettera i-esima start=phrase->relstart+i*phrase->phraseDelayPerChar; if (relpos<start) continue; end=start+phrase->phraseTimePerChar; // scrivo la lettera a colore e trasformazioni piene if (relpos>=end) { m_DrawAnimatedText(phrase->x, phrase->y, end_animScaleX, end_animScaleY, end_animScaleX, end_animScaleY, phrase->color, phrase->text, i, i, &end_rot); } else { r=(uint32)(255.0f*relPos(start, end, relpos)); alpha=(phrase->color >> 24); alpha=((alpha*r)>>8) & 255; color=(phrase->color & 0x00FFFFFF) | (alpha << 24); // estrazione dell'animazione if (p_ScaleTrack.p_NumKeys>0) { animPos=map_intervals(start, end, animStartScale, animEndScale, relpos); p_ScaleTrack.m_GetData(animPos, &scale3D); animScaleX*=scale3D.x; animScaleY*=scale3D.y; } if (p_RotationTrack.p_NumKeys>0) { animPos=map_intervals(start, end, animStartRot, animEndRot, relpos); p_RotationTrack.m_GetData(animPos, &rot); } m_DrawAnimatedText(phrase->x, phrase->y, animScaleX, animScaleY, end_animScaleX, end_animScaleY, color, phrase->text, i, i, &rot); } } } else // fase di scomparsa della frase if (relpos>phrase->phraseFixedEnd)