added check for irregular length sequences when calculating energy