Skip to content
Open
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
8 changes: 8 additions & 0 deletions ALNtoPAF.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,14 @@ void *gen_paf(void *args)
ascaff = contigs1[acontig].scaf;
bscaff = contigs2[bcontig].scaf;

// Validate alignment coordinates are within bounds
// Skip alignments with invalid coordinates (can occur from edge cases in wave algorithm)
if (path->abpos < 0 || path->aepos > aln->alen || path->abpos >= path->aepos ||
path->bbpos < 0 || path->bepos > aln->blen || path->bbpos >= path->bepos)
{ continue; // Skip this invalid alignment (do NOT set alast, so sequence gets
// reloaded for next valid alignment on this contig)
}

aoff = contigs1[acontig].sbeg;

if (SWAP_G)
Expand Down
16 changes: 14 additions & 2 deletions FastGA.c
Original file line number Diff line number Diff line change
Expand Up @@ -3263,7 +3263,17 @@ static void align_contigs(uint8 *beg, uint8 *end, int swide, int ctg1, int ctg2,

rlen = path->aepos - path->abpos;
if (rlen >= alnMin && alnRate*rlen >= path->diffs)
{ Compress_TraceTo8(ovl,0);
{ uint16 *t16 = (uint16 *) ovl->path.trace;
int ti, trace_overflow = 0;
for (ti = 0; ti < ovl->path.tlen; ti++)
if (t16[ti] > 255)
{ trace_overflow = 1;
break;
}
if (trace_overflow)
goto next_alignment;

Compress_TraceTo8(ovl,0);
if (fwrite(ovl,OVL_SIZE,1,tfile) != 1)
{ fprintf(stderr,
"%s: Cannot write overlap gather file %s/%s.%d.las\n",
Expand All @@ -3280,6 +3290,8 @@ static void align_contigs(uint8 *beg, uint8 *end, int swide, int ctg1, int ctg2,
nmem += path->tlen + OVL_SIZE;
}

next_alignment:

#ifdef DEBUG_ALIGN
if (rlen >= ALIGN_MIN && ALIGN_RATE*rlen >= path->diffs)
{ Decompress_TraceTo16(ovl);
Expand Down Expand Up @@ -4933,7 +4945,7 @@ int main(int argc, char *argv[])
gdb2 = gdb1;
else
{ GEXTN2 = ".gdb";
fname = Catenate(PATH1,"/",ROOT1,GEXTN2);
fname = Catenate(PATH2,"/",ROOT2,GEXTN2);
if ((file = fopen(fname,"r")) == NULL)
GEXTN2 = ".1gdb";
else
Expand Down
Loading