Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove calls to reading beginnign of line #38

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/alignment_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
2 changes: 0 additions & 2 deletions src/alignment_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions src/parse_vcf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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')
{
Expand All @@ -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')
{
Expand Down