Skip to content

Commit

Permalink
add unqiue and sorted sites validation
Browse files Browse the repository at this point in the history
  • Loading branch information
mdrasmus committed Aug 9, 2015
1 parent b32460b commit fee3d32
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/argweaver/sequences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,20 @@ bool read_sites(FILE *infile, Sites *sites,
}

// convert to 0-index
sites->append(position - 1, col, true);
position--;

// validate site locations are unique and sorted.
int npos = sites->get_num_sites();
if (npos > 0 && sites->positions[npos-1] >= position) {
printError("invalid site location %d >= %d (line %d)",
sites->positions[npos-1], position, lineno);
printError("sites must be sorted and unique.");
delete [] line;
return false;
}

// record site.
sites->append(position, col, true);
}

delete [] line;
Expand Down

0 comments on commit fee3d32

Please sign in to comment.