Fix: Support for chromosomes >1GB in size #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
TRF crashed when processing T2T (telomere-to-telomere) chromosome assemblies longer than 1-2 GB. The errors varied depending on chromosome size, initially appearing to be a genome size issue but actually stemming from individual chromosome length limitations. Example Lissotriton helveticus genome assembly, chromosome: 4_1
The root cause was the use of 32-bit integer types (
int,unsigned int) for sequence indices and lengths, which limited processing to ~2GB (2^31 bytes for signed int).Solution
Replaced 32-bit integer types with 64-bit
size_ttypes throughout the codebase for all sequence-related indices, positions, and lengths. This enables TRF to process sequences up to system memory limits (theoretically 2^64 bytes).Changes by file
tr30dat.h - Core data type replacements:
int Length→size_t Length(global sequence length variable)unsigned int maxwraplength→size_t maxwraplengthFASTASEQUENCE,pairalign,TRFPARAMSET,bestperiodlistelement,distanceentry,distancelist,distanceseenarrayelement,distancelistelementtrfrun.h - Index and position variables:
index_liststructure (repeat positions)charcount,flankstart,flankendLoadSequenceFromFileBenson,LoadSequenceFromFileEugenetrf.c - Command-line parsing:
ParseSize()function usingstrtoull()for 64-bit values-lparameter parsing formaxwraplengthtr30dat.c - Memory allocation:
new1Darrayfuncmacro for correct memory allocation%d→%zufor all outputTesting
Successfully processes amphibian chromosomes and T2T assemblies exceeding 1-2 GB without crashes.