[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #23 from TravisWheelerLab/fixFastaHeaders
Browse files Browse the repository at this point in the history
Fix fasta headers
  • Loading branch information
Sawwave committed Jan 11, 2024
2 parents b7cb72e + 6695dc6 commit 890249b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/AwFmFile.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ enum AwFmReturnCode awFmReadIndexFromFile(

// free the sequence buffer in the fastaVector, since it won't be used here
fastaVectorStringDealloc(&fastaVector->sequence);
fastaVector->sequence.charData = NULL;
fastaVector->sequence.capacity = 0;
fastaVector->sequence.count = 0;

indexData->fastaVector = fastaVector;
size_t fastaVectorHeaderLength;
Expand All @@ -367,13 +370,29 @@ enum AwFmReturnCode awFmReadIndexFromFile(
awFmDeallocIndex(indexData);
return AwFmAllocationFailure;
}

elementsRead = fread(&fastaVector->header.charData, sizeof(char), fastaVectorHeaderLength, fileHandle);
if(elementsRead != fastaVectorHeaderLength) {
fclose(fileHandle);
awFmDeallocIndex(indexData);
return AwFmAllocationFailure;
}

fastaVector->metadata.data =
realloc(fastaVector->metadata.data, fastaVectorMetadataLength * sizeof(struct FastaVectorMetadata));
if(!fastaVector->metadata.data) {
fclose(fileHandle);
awFmDeallocIndex(indexData);
return AwFmAllocationFailure;
}

elementsRead = fread(&fastaVector->metadata.data, sizeof(struct FastaVectorMetadata), fastaVectorMetadataLength, fileHandle);
if(elementsRead != fastaVectorMetadataLength) {
fclose(fileHandle);
awFmDeallocIndex(indexData);
return AwFmAllocationFailure;
}

fastaVector->header.count = fastaVectorHeaderLength;
fastaVector->header.capacity = fastaVectorHeaderLength;
fastaVector->metadata.count = fastaVectorMetadataLength;
Expand Down

0 comments on commit 890249b

Please sign in to comment.