Commit 881338dd authored by Steffen Möller's avatar Steffen Möller

New upstream version 1.6.5+dfsg

parent 66bc47fd
This diff is collapsed.
......@@ -22,7 +22,7 @@
#include <assert.h>
#include <stdarg.h>
#include <math.h>
//#include <zutil.h>
#include <unistd.h>
#ifdef MACOS
......@@ -35,6 +35,10 @@
#include <net/if_dl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <mach/mach.h>
#include <mach/vm_statistics.h>
#else
......@@ -43,7 +47,8 @@
#include <netinet/in.h>
#include <net/if.h>
#endif
#include <unistd.h>
#include <sys/types.h>
#include <sys/sysinfo.h>
#endif
......@@ -53,6 +58,39 @@
#include "gene-algorithms.h"
#include "HelperFunctions.h"
size_t get_sys_mem_info(char * keyword){
FILE * mfp = fopen("/proc/meminfo","r");
if(mfp==NULL) return -1;
char linebuf[1000];
size_t ret = -1;
while(1){
char * rret = fgets(linebuf, 999, mfp);
if(memcmp( keyword, linebuf, strlen(keyword) ) == 0 && strstr(linebuf," kB")) {
ret=0;
int ii ,state=0;
for(ii=strlen(keyword);; ii++){
//SUBREADprintf("CH[%d] = %d '%c' at state %d\n", ii, linebuf[ii], linebuf[ii], state);
if(state == 0 && linebuf[ii]==' ') state = 1;
if(state == 1 && linebuf[ii]!=' ') state = 2;
if(state == 2 && linebuf[ii]==' ') state = 9999;
if(state == 2 && !isdigit(linebuf[ii])){
SUBREADprintf("WRONG MEMORY INFO '%s'\n", linebuf);
ret = -1;
break;
}
if(state == 2) ret = ret*10 + ( linebuf[ii] - '0' );
if(state >= 9999) {
ret *=1024;
break;
}
}
}
if(!rret) break;
}
fclose(mfp);
return ret;
}
char * get_short_fname(char * lname){
char * ret = lname;
......@@ -2648,3 +2686,31 @@ void main(){
}
#endif
int get_free_total_mem(size_t * total, size_t * free_mem){
#ifdef FREEBSD
return -1;
#endif
#ifdef MACOS
mach_msg_type_number_t count = HOST_VM_INFO_COUNT;
vm_statistics_data_t vmstat;
int page_size = getpagesize();
if(KERN_SUCCESS != host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat, &count))
return -1;
//printf("PSIZE=%d\nACT=%u; INACT=%u; FREE=%u\n", page_size, vmstat.active_count, vmstat.inactive_count, vmstat.free_count);
size_t btlen = sizeof(*total);
if(sysctl( (int[]) { CTL_HW, HW_MEMSIZE }, 2, total, &btlen, NULL, 0)) return -1;
*free_mem = (vmstat.free_count + vmstat.inactive_count) * 1llu * page_size;
return 0;
#else
struct sysinfo sinf;
sysinfo(&sinf);
size_t cached_mem = get_sys_mem_info("Cached:");
if(cached_mem<0)cached_mem=0;
*free_mem = cached_mem + sinf.bufferram+sinf.freeram;
*total = sinf.totalram;
return 0;
#endif
}
......@@ -235,5 +235,6 @@ void TNbignum_dec(struct bn* n); /* Decrement: subtr
void TNbignum_pow(struct bn* a, struct bn* b, struct bn* c); /* Calculate a^b -- e.g. 2^10 => 1024 */
void TNbignum_isqrt(struct bn* a, struct bn* b); /* Integer square root -- e.g. isqrt(5) => 2*/
void TNbignum_assign(struct bn* dst, struct bn* src); /* Copy src into dst -- dst := src */
size_t get_sys_mem_info(char * keyword);
int get_free_total_mem(size_t * total, size_t * free_mem);
#endif
......@@ -12,7 +12,7 @@ LDFLAGS = ${STATIC_MAKE} -pthread -lz ${MACOS} -O${OPT_LEVEL} -DMAKE_FOR_EXON -D
CC = ${CC_EXEC} ${CCFLAGS} -fmessage-length=0 -ggdb
ALL_LIBS= core core-junction core-indel sambam-file sublog gene-algorithms hashtable input-files sorted-hashtable gene-value-index exon-algorithms HelperFunctions interval_merge long-hashtable core-bigtable seek-zlib
ALL_LIBS= core core-junction core-indel sambam-file sublog gene-algorithms hashtable input-files sorted-hashtable gene-value-index exon-algorithms HelperFunctions interval_merge long-hashtable core-bigtable seek-zlib input-blc
ALL_OBJECTS=$(addsuffix .o, ${ALL_LIBS})
ALL_H=$(addsuffix .h, ${ALL_LIBS})
ALL_C=$(addsuffix .c, ${ALL_LIBS})
......
This diff is collapsed.
......@@ -1929,12 +1929,20 @@ int find_new_indels(global_context_t * global_context, thread_context_t * thread
voting_position = current_result -> selected_position;
//SUBREADprintf("NR=%d\n", indel_recorder[0]);
if(!indel_recorder[0])
return 0;
gene_value_index_t * current_value_index = thread_context?thread_context->current_value_index:global_context->current_value_index;
if(0){ // test "shifting indels" -- not needed when "NEW" go_Q used
int last_offset = 0;
for(i=0; indel_recorder[i] && (i<MAX_INDEL_SECTIONS); i+=3){
last_offset = indel_recorder[i+2];
}
if(0==last_offset) return 0;
}
for(i=0; indel_recorder[i] && (i<MAX_INDEL_SECTIONS); i+=3)
{
int indels = indel_recorder[i+2] - last_indel;
......@@ -2035,8 +2043,8 @@ int find_new_indels(global_context_t * global_context, thread_context_t * thread
{
int old_event_id = -1;
if(0)if(indel_left_boundary >= 44438630 + 1210 - 200 && indel_left_boundary <= 44438630 + 1210 + 200 && current_indel_len == 6){
SUBREADprintf("ADD AN INDEL: %s : %u ; len = %u\n", read_name, indel_left_boundary, current_indel_len);
if(0)if(indel_left_boundary >= 46481340 + 1210 - 200 && indel_left_boundary <= 46481340 + 1210 + 200 && abs(current_indel_len )==4){
SUBREADprintf("ADD AN INDEL: %s : %u ; len = %d\n", read_name, indel_left_boundary, current_indel_len);
}
chromosome_event_t * new_event = local_add_indel_event(global_context, thread_context, event_table, read_text + cursor_on_read + min(0,current_indel_len), indel_left_boundary - 1, current_indel_len, 1, ambiguous_count, 0, &old_event_id);
mark_gapped_read(current_result);
......@@ -2324,7 +2332,7 @@ int write_indel_final_results(global_context_t * global_context)
chromosome_event_t * event_body = indel_context -> event_space_dynamic +xk1;
//#warning " ================= REMOVE '- 1' from the next LINE!!! ========================="
// #warning " ================= REMOVE '- 1' from the next LINE!!! ========================="
if((event_body -> event_type != CHRO_EVENT_TYPE_INDEL && event_body->event_type != CHRO_EVENT_TYPE_LONG_INDEL && event_body -> event_type != CHRO_EVENT_TYPE_POTENTIAL_INDEL)|| (event_body -> final_counted_reads < 1 && event_body -> event_type == CHRO_EVENT_TYPE_INDEL) )
continue;
......@@ -4329,7 +4337,7 @@ int finalise_long_insertions_by_hashtable(global_context_t * global_context)
int chro_i;
assert(global_context -> index_block_number == 1);
unsigned int chro_start_pos = 0;
char tmp_fname[350];
char tmp_fname[MAX_FILE_NAME_LENGTH+40];
sprintf(tmp_fname,"%s.reassembly.fa", global_context->config.output_prefix);
global_context->long_insertion_FASTA_fp = f_subr_open(tmp_fname ,"wb");
......@@ -4395,7 +4403,7 @@ void COREMAIN_SIGINT_hook(int param)
int xk1, last_slash = -1;
if(_COREMAIN_delete_temp_prefix != NULL)
{
char del2[300], del_suffix[200], del_name[400];
char del2[MAX_FILE_NAME_LENGTH], del_suffix[MAX_FILE_NAME_LENGTH], del_name[MAX_FILE_NAME_LENGTH];
SUBREADprintf("\n\nReceived a terminal signal. The temporary files were removed.\n");
for(xk1=0; _COREMAIN_delete_temp_prefix[xk1]; xk1++)
{
......
This diff is collapsed.
......@@ -79,7 +79,9 @@ typedef struct{
int best_matching_bases;
int best_second_match_diff;
int second_best_matching_bases;
int best_indel_penalty;
int tmp_total_matched_bases;
int tmp_indel_penalty;
int is_currently_tie;
int best_is_complex;
int best_support_as_simple;
......
This diff is collapsed.
......@@ -62,7 +62,7 @@
#define CORE_MAX_CIGAR_STR_LEN 110
#define CORE_ADDITIONAL_INFO_LENGTH 400
#define READPAIRS_FOR_CALC_EXPT_TLEN 1000
typedef struct{
subread_read_number_t fragments;
......@@ -384,6 +384,7 @@ typedef struct{
short chromosomal_length;
short MAPQ_adjustment;
int known_junction_supp;
int final_penalty;
} realignment_result_t;
#define BUCKETED_TABLE_INIT_ITEMS 3
......@@ -541,6 +542,8 @@ typedef struct{
double timecost_before_realign;
double timecost_for_realign;
unsigned long long expected_TLEN_sum;
unsigned int expected_TLEN_read_numbers;
unsigned long long all_processed_reads;
unsigned long long all_correct_PE_reads;
unsigned int all_junctions;
......
......@@ -20,8 +20,8 @@ int max_M = 10;
int paired_end = 0;
int ignore_bad_pair = 0;
int base_values = 0;
char input_file_name[300];
char output_file_name[300];
char input_file_name[MAX_FILE_NAME_LENGTH];
char output_file_name[MAX_FILE_NAME_LENGTH];
HashTable * cov_bin_table;
......
......@@ -2,23 +2,23 @@
The Subread and Rsubread software packages are free
software packages:
you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the
of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License,
or (at your option) any later version.
Subread is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
Authors: Drs Yang Liao and Wei Shi
***************************************************************/
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
......@@ -48,12 +48,16 @@
#include "seek-zlib.h"
#include "HelperFunctions.h"
#define MERGING_MODE_CHOPPING 100 // keep all the edges : [100,199] + [150,249] = [100,149], [150,199], [200,249]
#define MERGING_MODE_MERGING 0 // just merge into one: [100,199] + [150,249] = [100, 249]
typedef struct{
char GTF_gene_id_column[MAX_READ_NAME_LEN];
char GTF_wanted_feature_type[MAX_READ_NAME_LEN];
char GTF_file_name[MAX_FILE_NAME_LENGTH];
char output_file_name[MAX_FILE_NAME_LENGTH];
FILE * output_FP;
int merging_mode;
HashTable * gene_to_chro_strand_table;
HashTable * gene_chro_strand_to_exons_table;
......@@ -89,6 +93,9 @@ void flatAnno_print_usage(){
SUBREADputs(" This attribute type is used to group features into meta-");
SUBREADputs(" features.");
SUBREADputs("");
SUBREADputs(" -C Merging overlapping exons into multiple non-overlapping exons but");
SUBREADputs(" all the edges are kept.");
SUBREADputs("");
}
int flatAnno_finalise(flatAnno_context_t * context){
......@@ -105,14 +112,14 @@ int flatAnno_do_anno_1R(char * gene_name, char * transcript_name, char * chro_na
if(NULL == chro_strand_list_for_gene){
char * mem_gene = malloc(strlen(gene_name)+1);
strcpy(mem_gene, gene_name);
chro_strand_list_for_gene = ArrayListCreate(3);
chro_strand_list_for_gene = ArrayListCreate(3);
ArrayListSetDeallocationFunction(chro_strand_list_for_gene, free);
HashTablePut(context -> gene_to_chro_strand_table, mem_gene, chro_strand_list_for_gene);
}
int i, found = 0;
char chro_strand[MAX_CHROMOSOME_NAME_LEN+10+FEATURE_NAME_LENGTH];
sprintf( chro_strand, "%s\t%s\t%c", gene_name,chro_name,is_negative_strand?'-':'+');
sprintf( chro_strand, "%s\t%s\t%c", gene_name,chro_name,is_negative_strand?'-':'+');
for(i=0; i<chro_strand_list_for_gene->numOfElements; i++){
char * old_ch_st = ArrayListGet(chro_strand_list_for_gene,i);
if(strcmp(old_ch_st, chro_strand) == 0){
......@@ -145,6 +152,77 @@ int flatAnno_do_anno_merge_one_array_compare(void * vL, void * vR){
return 0;
}
void flatAnno_do_anno_chop_one_array(void * key, void * hashed_obj, HashTable * tab){
ArrayList * this_list = hashed_obj; // each element is a pair of integers defining start and end of an exon.
ArrayList * edge_before_me_List = ArrayListCreate( this_list->numOfElements * 2 );
int i;
for(i=0; i<this_list -> numOfElements; i++){
int * curr_2i = this_list -> elementList[ i ];
int findi, endi;
for(endi = 0; endi < 2; endi++){
assert(curr_2i[endi]>0);
int search_tag = curr_2i[endi] + endi, found=0;
for(findi = 0; findi < edge_before_me_List->numOfElements; findi++){
if(ArrayListGet(edge_before_me_List,findi)-NULL == search_tag){
found = 1;
break;
}
}
if(0==found) ArrayListPush(edge_before_me_List, NULL+search_tag);
}
}
ArrayListSort(edge_before_me_List, NULL);
char * continue_after_an_edge = malloc(edge_before_me_List -> numOfElements -1);
memset(continue_after_an_edge,0, edge_before_me_List -> numOfElements -1);
int missed_gaps = edge_before_me_List->numOfElements -1;
for(i=0; i<edge_before_me_List->numOfElements -1; i++){
int an_edge_before_me = edge_before_me_List-> elementList[i]-NULL;
int j;
for(j=0; j<this_list->numOfElements; j++){
int * curr_2i = this_list -> elementList[ j ];
if( curr_2i[0] <= an_edge_before_me && curr_2i[1] >= an_edge_before_me ) {
continue_after_an_edge[i]=1;
missed_gaps --;
break;
}
}
}
long old_capacity = this_list -> capacityOfElements, old_items = this_list -> numOfElements;
if(edge_before_me_List->numOfElements -1 - missed_gaps > old_capacity){
this_list -> elementList = realloc( this_list -> elementList, sizeof(void*) * edge_before_me_List->numOfElements -1 -missed_gaps );
this_list -> capacityOfElements = edge_before_me_List->numOfElements -1 -missed_gaps ;
}
int written_i = 0;
for(i=0; i<edge_before_me_List->numOfElements -1; i++){
int * curr_2i = NULL;
//if(edge_before_me_List->elementList[i] - NULL == 108395906)SUBREADprintf("CV_I %d = %ld ~ %ld ; CTN=%d\n", i, edge_before_me_List->elementList[i] - NULL, edge_before_me_List -> elementList[i+1] -NULL-1, continue_after_an_edge[i]);
if(0==continue_after_an_edge[i]){
// SUBREADprintf("NC_I %d ~ [ 0 , %ld ]\n", i, edge_before_me_List->numOfElements -2);
assert(i>0 && i<edge_before_me_List->numOfElements -2);
assert(continue_after_an_edge[i+1] && continue_after_an_edge[i-1] ); // otherwise it is a singleton edge.
continue;
}
if(written_i < old_items){
curr_2i = this_list -> elementList[ written_i ];
}else{
curr_2i = malloc(sizeof(int)*2);
this_list -> elementList[ written_i ] = curr_2i;
}
curr_2i[0] = edge_before_me_List -> elementList[i] -NULL;
curr_2i[1] = edge_before_me_List -> elementList[i+1] -NULL-1;
written_i++;
}
assert(written_i == edge_before_me_List->numOfElements -1 - missed_gaps );
for(i=written_i; i<old_items; i++) free( this_list -> elementList[i]);
this_list -> numOfElements = written_i;
ArrayListDestroy(edge_before_me_List);
free(continue_after_an_edge);
}
void flatAnno_do_anno_merge_one_array(void * key, void * hashed_obj, HashTable * tab){
ArrayList * this_list = hashed_obj;
ArrayListSort(this_list, flatAnno_do_anno_merge_one_array_compare);
......@@ -171,7 +249,7 @@ void flatAnno_do_anno_merge_one_array(void * key, void * hashed_obj, HashTable *
int flatAnno_do_anno_merge_and_write(flatAnno_context_t * context){
context -> gene_chro_strand_to_exons_table -> appendix1 = context;
HashTableIteration(context -> gene_chro_strand_to_exons_table, flatAnno_do_anno_merge_one_array);
HashTableIteration(context -> gene_chro_strand_to_exons_table, context -> merging_mode == MERGING_MODE_CHOPPING? flatAnno_do_anno_chop_one_array :flatAnno_do_anno_merge_one_array);
ArrayList * all_chro_st_list = HashTableKeyArray(context -> gene_chro_strand_to_exons_table);
ArrayListSort(all_chro_st_list, (int(*)(void * , void*))strcmp);
......@@ -222,7 +300,7 @@ int flatAnno_start(flatAnno_context_t * context){
SUBREADprintf("Error: no output file is specified.\n");
return -1;
}
SUBREADprintf("Flatting GTF file: %s\n", context -> GTF_file_name);
SUBREADprintf("Flattening GTF file: %s\n", context -> GTF_file_name);
SUBREADprintf("Output SAF file: %s\n", context -> output_file_name);
context -> output_FP = fopen(context -> output_file_name, "w");
if(NULL == context -> output_FP ){
......@@ -249,12 +327,15 @@ int R_flattenAnnotations(int argc, char ** argv)
strcpy(context.GTF_gene_id_column, "gene_id");
strcpy(context.GTF_wanted_feature_type, "exon");
int option_index = 0,c;
int option_index = 0,c;
optind=0;
opterr=1;
optopt=63;
while ((c = getopt_long (argc, argv, "t:g:a:o:v?", long_options, &option_index)) != -1)
while ((c = getopt_long (argc, argv, "Ct:g:a:o:v?", long_options, &option_index)) != -1)
switch(c) {
case 'C':
context.merging_mode = MERGING_MODE_CHOPPING;
break;
case 'o':
strcpy(context.output_file_name, optarg);
break;
......
......@@ -155,7 +155,7 @@ void full_scan_read(char * index_name, char * read_str)
int main (int argc , char ** argv)
{
char index_name [1200];
char index_name [MAX_FILE_NAME_LENGTH];
char read_str [1208];
char c;
int i;
......@@ -166,7 +166,7 @@ int main (int argc , char ** argv)
switch(c)
{
case 'i':
strncpy(index_name, optarg, 1199);
strncpy(index_name, optarg, MAX_FILE_NAME_LENGTH-1);
break;
case 'm':
MIN_REPORTING_RATIO = atof(optarg);
......
......@@ -92,6 +92,7 @@ int print_usage_gen_reads(char * pgname) {
static struct option long_options[] =
{
{"quiet", no_argument, 0, 'Q'},
{"truthInReadNames", no_argument, 0, 'T'},
{"simpleTranscriptId", no_argument, 0, 'C'},
{"summarizeFasta", no_argument, 0, 'M'},
......@@ -129,6 +130,7 @@ typedef struct {
int insertion_length_max;
int insertion_length_min;
float insertion_length_sigma;
int quiet;
int read_length;
int no_actual_reads;
......@@ -500,6 +502,13 @@ int grc_summary_fasta(genRand_context_t * grc){
char clinebuf[TRANSCRIPT_FASTA_LINE_WIDTH];
int rlength = autozip_gets(&auto_FP, clinebuf, TRANSCRIPT_FASTA_LINE_WIDTH -1);
if(rlength < 1)break;
if(rlength > 1 && clinebuf[rlength-2] =='\r' ){
rlength--;
clinebuf[rlength-1]='\n';
clinebuf[rlength]=0;
}else if(clinebuf[rlength-1]=='\r'){
clinebuf[rlength-1]='\n';
}
if(rlength >= TRANSCRIPT_FASTA_LINE_WIDTH -1 || clinebuf[rlength]!='\0' || clinebuf[rlength-1]!='\n'){
SUBREADprintf("Error: The line width of the fasta file excessed %d bytes!\n", TRANSCRIPT_FASTA_LINE_WIDTH);
ret = 1;
......@@ -595,7 +604,7 @@ int grc_summary_fasta(genRand_context_t * grc){
}
HashTableDestroy(reprs_tab);
if(total_rep_seq)SUBREADprintf("Warning: %d duplicate sequences were found in the input. Please check the summary table.\n",total_rep_seq);
if(total_rep_seq && grc->quiet==0)SUBREADprintf("Warning: %d duplicate sequences were found in the input. Please check the summary table.\n",total_rep_seq);
ArrayListDestroy(seq_name_list);
HashTableDestroy(seq_length_tab);
......@@ -882,8 +891,11 @@ int gen_rnaseq_reads_main(int argc, char ** argv)
long long seed = -1;
while ((c = getopt_long (argc, argv, "O:TCxS:V:N:X:F:L:q:r:t:e:o:pM?", long_options, &option_index)) != -1) {
while ((c = getopt_long (argc, argv, "QO:TCxS:V:N:X:F:L:q:r:t:e:o:pM?", long_options, &option_index)) != -1) {
switch(c){
case 'Q':
grc.quiet=1;
break;
case 'x':
grc.no_actual_reads = 1;
break;
......
......@@ -402,7 +402,7 @@ int remove_repeated_reads(gehash_t * table, gehash_t * huge_table, int index_thr
else if(val_len[j]> index_threshold)
{
gehash_remove(table, vals[j]);
gehash_insert(huge_table, vals[j], 1);
gehash_insert(huge_table, vals[j], 1, NULL);
all_removed += val_len[j];
}
}
......@@ -1131,7 +1131,7 @@ void explain_indel_in_middle(gene_allvote_t* allvote, int qid , int pos, char *
int evaluate_piece(char * piece_str, int chron, int offset, int is_counterpart, int start_pos, int end_pos)
{
char fname[300];
char fname[MAX_FILE_NAME_LENGTH];
int inner_pos = 0, i;
FILE * fp;
char next_char=0;
......@@ -1474,7 +1474,7 @@ void destroy_offsets(gene_offset_t* offsets)
int load_offsets(gene_offset_t* offsets , const char index_prefix [])
{
char fn[300];
char fn[MAX_FILE_NAME_LENGTH];
FILE * fp;
int n=0;
int padding = 0;
......@@ -1509,7 +1509,7 @@ int load_offsets(gene_offset_t* offsets , const char index_prefix [])
{
int i=0, step = 0, j=0;
read_line(299,fp, fn, 0);
read_line(MAX_FILE_NAME_LENGTH-1,fp, fn, 0);
if (strlen(fn)<2)continue;
while (fn[i])
{
......
......@@ -39,7 +39,7 @@ unsigned int linear_gene_position(const gene_offset_t* offsets , char *chro_name
int remove_repeated_reads(gehash_t * table, gehash_t * huge_table,int index_threshold);
#define init_gene_vote(a) {memset((a)->items, 0, GENE_VOTE_TABLE_SIZE*sizeof( *((a)->items))); (a)->max_vote = 0; (a) -> max_indel_recorder[0]=0; (a)->max_tmp_indel_recorder = NULL; (a)->max_mask = 0; (a) -> noninformative_subreads = 0; }
#define init_gene_vote(a) {memset((a)->items, 0, GENE_VOTE_TABLE_SIZE*sizeof( *((a)->items))); (a)->max_vote = 0; (a) -> max_indel_recorder[0]=0; (a)->max_tmp_indel_recorder = NULL; (a)->max_mask = 0; (a) -> noninformative_subreads = 0;}
// return current votes for a given position
// if create_new_pos == 0 then do not take this position if it does not exist in the vote array
//void add_gene_vote(gene_vote_t* vote, int position, int create_new_pos);
......
......@@ -26,11 +26,11 @@
#include "input-files.h"
int gvindex_init(gene_value_index_t * index, unsigned int start_point)
int gvindex_init(gene_value_index_t * index, unsigned int start_point, unsigned int total_bases_estimated)
{
index->start_point = start_point;
index->memory_block_size = 100000000;
index->values = malloc(index->memory_block_size);
index->memory_block_size = total_bases_estimated/4+10;
index->values = calloc(index->memory_block_size,1);
if(!index->values)
{
SUBREADputs(MESSAGE_OUT_OF_MEMORY);
......@@ -141,6 +141,7 @@ void gvindex_set(gene_value_index_t * index, gehash_data_t offset, gehash_key_t
unsigned int offset_byte_margin = offset_byte + (padding / 8 +1);
if(index -> memory_block_size <= offset_byte_margin + 2)
{
assert(index -> memory_block_size> offset_byte_margin+2);
index -> memory_block_size *= 1.5;
index->values = realloc(index->values, index -> memory_block_size);
}
......
......@@ -24,7 +24,7 @@
#include "subread.h"
#include "sorted-hashtable.h"
int gvindex_init(gene_value_index_t * index, unsigned int start_point);
int gvindex_init(gene_value_index_t * index, unsigned int start_point, unsigned int all_bases_estm);
void gvindex_set (gene_value_index_t * index, gehash_data_t offset, gehash_key_t base_value, int padding);
......
......@@ -96,9 +96,9 @@ typedef struct{
#define GRA_DEBUG_ASSEMBLING 4
typedef struct {
char input_file_name [300];
char input_file_name2 [300];
char output_file_name [300];
char input_file_name [MAX_FILE_NAME_LENGTH];
char input_file_name2 [MAX_FILE_NAME_LENGTH];
char output_file_name [MAX_FILE_NAME_LENGTH];
int is_BAM_input;
int total_threads;
int shortest_read_allowed;
......@@ -134,7 +134,7 @@ typedef struct {
lnhash_t assembling_index;
// ====== Global System ======
char tmp_file_prefix[300];
char tmp_file_prefix[MAX_FILE_NAME_LENGTH];
unsigned int random_seeds[8];
pid_t system_pid;
......@@ -365,7 +365,7 @@ int calc_2r_overlapping(GRA_global_context_t * global_context, char * r1, char *
int GRA_trim_reads(GRA_global_context_t * global_context)
{
int line_buff_len = MAX_READ_LENGTH * 2 + MAX_READ_NAME_LEN + MAX_CHROMOSOME_NAME_LEN * 3 + 500;
char tmp_fname[300],
char tmp_fname[MAX_FILE_NAME_LENGTH],
* read1_tmp = malloc(line_buff_len),
* line_buff = malloc(line_buff_len),
* in_sequence = malloc(MAX_READ_LENGTH),
......@@ -707,7 +707,7 @@ int GRA_build_read_index(GRA_global_context_t* global_context)
lnhash_create(&global_context -> assembling_index, 666661);
char tmp_fname[300],
char tmp_fname[MAX_FILE_NAME_LENGTH],
* in_sequence_1 = malloc(MAX_READ_LENGTH),
* in_quality_string_1 = malloc(MAX_READ_LENGTH),
* in_sequence_2 = malloc(MAX_READ_LENGTH),
......@@ -808,7 +808,7 @@ int GRA_mark_read_extension(GRA_global_context_t* global_context)
unsigned long long report_step = max(1, global_context -> all_fragments/20);
FILE * fp_fraglist;
GRA_frag_properties_t * frag_prop;
char tmp_fname[300],
char tmp_fname[MAX_FILE_NAME_LENGTH],
* in_sequence_1 = malloc(MAX_READ_LENGTH),
* in_quality_string_1 = malloc(MAX_READ_LENGTH),
* in_sequence_2 = malloc(MAX_READ_LENGTH),
......@@ -1474,7 +1474,7 @@ int GRA_reassemble_reads_LR(GRA_global_context_t* global_context, int to_right)
if(global_context -> debug_flags & GRA_DEBUG_ASSEMBLING)
{
char spaces[300];
char spaces[MAX_FILE_NAME_LENGTH];
SUBREADprintf(" === %s {%d} V=%d, MM=%d === NEXT_REV=%d \n", to_right?">>>":"<<<", is_current_read2_extension?2:1, current_read_votes, mm, next_reversed_map);
for(xk1=0;xk1< current_map_pos; xk1++)
......@@ -1671,7 +1671,7 @@ void GRA_destroy_context(GRA_global_context_t* global_context)
int GRA_memory_map(GRA_global_context_t* global_context)
{
char tmp_fname[300];
char tmp_fname[MAX_FILE_NAME_LENGTH];
sprintf(tmp_fname, "%s.fragproperties", global_context -> tmp_file_prefix);
......@@ -1756,7 +1756,7 @@ int main(int argc, char ** argv)
return -1;
}
char * tmptmp = malloc(320);
char * tmptmp = malloc(MAX_FILE_NAME_LENGTH);
while ((c = getopt_long (argc, argv, "2:t:Q:V:L:i:I:o:bHCR6", GRA_long_options, &option_index)) != -1)
switch(c)
{
......
......@@ -6,7 +6,7 @@
* Released to the public domain.
*
*--------------------------------------------------------------------------
* $Id: hashtable.c,v 9999.32 2019/01/31 03:15:09 cvs Exp $
* $Id: hashtable.c,v 9999.34 2019/07/02 12:03:19 cvs Exp $
\*--------------------------------------------------------------------------*/
#include <stdio.h>
......@@ -116,6 +116,12 @@ void ArrayListSetDeallocationFunction(ArrayList * list, void (*elem_deallocator
list -> elemDeallocator = elem_deallocator;
}
int ArrayListSort_comp_pntr( void * L_elem, void * R_elem ){
if( L_elem > R_elem )return 1;
if( L_elem < R_elem )return -1;
return 0;
}
int ArrayListSort_compare(void * sortdata0, int L, int R){
void ** sortdata = sortdata0;
ArrayList * list = sortdata[0];
......@@ -144,12 +150,17 @@ void ArrayListSort_merge(void * sortdata0, int start, int items, int items2){
int write_cursor, read1=start, read2=start+items;
for(write_cursor = 0; write_cursor < items + items2; write_cursor++){
void * Elm1 = list -> elementList[read1];
void * Elm2 = list -> elementList[read2];
void * Elm1 = (read1 == start + items)? NULL:list -> elementList[read1];
void * Elm2 = (read2 == start + items + items2)?NULL:list -> elementList[read2];
int select_1 = (read1 == start + items)?0:( read2 == start + items + items2 || comp_elems(Elm1, Elm2) < 0 );
if(select_1) merged[write_cursor] = list -> elementList[read1++];
else merged[write_cursor] = list -> elementList[read2++];
if(read2 > start + items + items2){
SUBREADprintf("R1: %d < %d ; R2: %d < %d\n", read1, start + items, read2, start + items + items2);
}
assert(read2 <=start + items + items2);
assert(read1 <=start + items);
}
memcpy(list -> elementList + start, merged, sizeof(void *) * (items + items2));
......@@ -159,7 +170,7 @@ void ArrayListSort_merge(void * sortdata0, int start, int items, int items2){
void ArrayListSort(ArrayList * list, int compare_L_minus_R(void * L_elem, void * R_elem)){
void * sortdata[2];
sortdata[0] = list;
sortdata[1] = compare_L_minus_R;
sortdata[1] = compare_L_minus_R?compare_L_minus_R:ArrayListSort_comp_pntr;
merge_sort(sortdata, list -> numOfElements, ArrayListSort_compare, ArrayListSort_exchange, ArrayListSort_merge);
}
......
This diff is collapsed.
This diff is collapsed.
#ifndef _INPUT_BLC_H
#define _INPUT_BLC_H
#include <stdio.h>
#include <stdlib.h>
#include "subread.h"
#include "seek-zlib.h"
#define INPUT_BLC_MAX_READS 20
typedef struct {
unsigned long long read_number;
int total_bases_in_each_cluster;
int single_read_lengths[INPUT_BLC_MAX_READS+1];
int single_read_is_index[INPUT_BLC_MAX_READS];
int current_lane, bcl_is_gzipped, filter_is_gzipped;
char bcl_format_string[MAX_FILE_NAME_LENGTH];
char filter_format_string[MAX_FILE_NAME_LENGTH];
union{
seekable_zfile_t ** bcl_gzip_fps;
FILE ** bcl_fps;
};
union{
seekable_zfile_t * filter_gzip_fp;
FILE * filter_fp;