bool _load_fonts(void) { #if ENABLE(FONT_CONFIG) load_font_from_fontconfig(); #elif defined(__ANDROID__) load_font_from_android(); #else FILE *pf = 0; if ((pf = OPENFILE(CONFIG_FILE, F("r")))) { load_font_from_file(pf); fclose(pf); } else { // not found config file. write_default(); } #endif if (!g_font_map.size()) { font_item* ansi_font = get_font_item("arial", "arial.ttf"); font_item* uni_font = get_font_item("sung", "sung.ttf"); g_font_map.add(uni_font); g_font_map.add(ansi_font); } if (FT_Init_FreeType(&g_library) == 0) return true; else return false; }
char *query (char *query, char *bloom_filter, double tole_rate, double sampling_rate, char *list, char *target_path, char *report_fmt, char mode) { gzFile zip = NULL; char type = '@'; int normal = 0; int threads = 0; BIGCAST offset = 0; char *position = NULL; static char timestamp[40] = {0}; // Get current timestamp, for benchmarking purposes (begin of run timestamp) isodate(timestamp); bloom *bl_2 = NEW (bloom); F_set *File_head = make_list (bloom_filter, list); /*initialization for python interface*/ File_head->hits = 0; File_head->all_k = 0; File_head->reads_num = 0; File_head->reads_contam = 0; File_head->filename = bloom_filter; //extra initialization for python interface if (load_bloom (File_head->filename, bl_2)<=0) //load a bloom filter exit(-1); if (tole_rate == 0) { tole_rate = mco_suggestion (bl_2->k_mer); // suggest an optimal match cut-off } if (mode == 'r') { init_string(ONEG); // initialize strings for containing reads } /* if ((get_size (query) < 2 * ONEG) && !strstr (query, ".gz") && !strstr (query, ".tar")) normal = 0; else { if ((zip = gzopen (query, "rb")) < 0) { perror ("query open error...\n"); exit (-1); } normal = 0; } */ if ((zip = gzopen (query, "rb")) <= 0) { fprintf(stderr, "%s\n", strerror(errno)); exit(EXIT_FAILURE); } if (strstr (query, ".fastq") != NULL || strstr (query, ".fq") != NULL) type = '@'; else type = '>'; if (normal == 0) position = (char *) calloc (1,(ONEG+1)*sizeof (char)); while (offset != -1) { if (normal == 1) { position = mmaping (query); offset = -1; } else { offset = CHUNKer (zip, offset, ONEG, position, type); } Queue *head = NEW (Queue); head->location = NULL; Queue *tail = NEW (Queue); head->next = tail; Queue *head2 = head; get_parainfo (position, head, type); #pragma omp parallel { // XXX: Awesome will be the day when OpenMP is in OSX #ifndef __APPLE__ threads = omp_get_num_threads(); #endif #pragma omp single nowait { while (head != tail) { #pragma omp task firstprivate(head) { if (head->location != NULL) { read_process (bl_2, head, tail, File_head, sampling_rate, tole_rate, mode, type); } } head = head->next; } // End of firstprivate } // End of single - no implied barrier (nowait) } // End of parallel region - implied barrier if (position != NULL && normal == 0) { memset (position, 0, strlen (position)); } else if (normal == 1) { munmap (position, strlen (position)); } else { perror ("Cannot memset, wrong position on fastq file\n"); exit (-1); } clean_list (head2, tail); if (mode == 'r') { if (target_path!=NULL) { save_result (query, File_head->filename, type, target_path, re_clean(), re_contam()); //save results into file if facs remove is called } else { write_default(re_clean(), re_contam(), offset); } reset_string(); } } //end while if (normal == 0) { bloom_destroy(bl_2); gzclose(zip); free (position); //dont like file mapping, strings need to be freed in a normal way } /* mode c and r refer to contamination checking and removal function respectively. The following 9 lines make sure that json/tsv output is printed after the checking process, but willnot be written in stdout when running removal process. */ if (target_path!=NULL || mode == 'c') { return report(File_head, query, report_fmt, target_path, timestamp, prob_suggestion(bl_2->k_mer), threads); } else { char *s = ""; return s; } }