diff --git a/src/alignment_file.c b/src/alignment_file.c index 6b60062d..afc64a40 100644 --- a/src/alignment_file.c +++ b/src/alignment_file.c @@ -218,31 +218,6 @@ int detect_snps(char reference_sequence[], char filename[], int length_of_genome -int read_first_few_characters_of_line(char sequence[], FILE * pFilePtr, int max_characters) -{ - - char *pcRes = NULL; - int lineLength = 0; - char current_line_buffer[MAX_READ_BUFFER_SMALL] = {0}; - - - while((pcRes = fgets(current_line_buffer, MAX_READ_BUFFER_SMALL, pFilePtr)) != NULL){ - if(lineLength < max_characters) - { - //append string to line buffer - strcat(sequence, current_line_buffer); - strcpy(current_line_buffer, ""); - lineLength = strlen(sequence) - 1; - //if end of line character is found then exit from loop - if((sequence)[lineLength] == '\n' || (sequence)[lineLength] == '\0'){ - break; - } - } - } - return 1; -} - - char * read_line(char sequence[], FILE * pFilePtr) { diff --git a/src/alignment_file.h b/src/alignment_file.h index 567f9e4b..0eb24c29 100644 --- a/src/alignment_file.h +++ b/src/alignment_file.h @@ -33,8 +33,6 @@ int number_of_sequences_in_file(char filename[]); void get_sample_names_for_header(char filename[], char ** sequence_names, int number_of_samples); char filter_invalid_characters(char input_char); void get_bases_for_each_snp(char filename[], int snp_locations[], char ** bases_for_snps, int length_of_genome, int number_of_snps); -int read_first_few_characters_of_line(char sequence[], FILE * pFilePtr, int max_characters); - #define MAX_READ_BUFFER 65536 #define MAX_READ_BUFFER_SMALL 1024 diff --git a/src/parse_vcf.c b/src/parse_vcf.c index 97f1c03e..ddc4fcc5 100644 --- a/src/parse_vcf.c +++ b/src/parse_vcf.c @@ -32,14 +32,15 @@ int * column_data; void get_integers_from_column_in_vcf(FILE * vcf_file_pointer, int * integer_values, int number_of_snps, int column_number) { rewind(vcf_file_pointer); - char szBuffer[100000] = {0}; + char * szBuffer; + szBuffer = (char *) malloc(MAX_READ_BUFFER*sizeof(char)); int reference_index = 0; char result[1000] = {0}; do{ strcpy(szBuffer,""); - // check the first character of the line to see if its in the header - read_first_few_characters_of_line(szBuffer, vcf_file_pointer, 50); + // check the first character of the line to see if its in the header + szBuffer = read_line(szBuffer, vcf_file_pointer); if(szBuffer[0] == '\0') { @@ -61,14 +62,15 @@ void get_integers_from_column_in_vcf(FILE * vcf_file_pointer, int * integer_valu void get_sequence_from_column_in_vcf(FILE * vcf_file_pointer, char * sequence_bases, int number_of_snps, int column_number) { rewind(vcf_file_pointer); - char szBuffer[10000] = {0}; + char * szBuffer; + szBuffer = (char *) malloc(MAX_READ_BUFFER*sizeof(char)); int reference_index = 0; char result[1000] = {0}; do{ strcpy(szBuffer,""); // check the first character of the line to see if its in the header - read_first_few_characters_of_line(szBuffer, vcf_file_pointer, 1000); + szBuffer = read_line(szBuffer, vcf_file_pointer); if(szBuffer[0] == '\0') {