239 def multi_align(self, chainDict, chainConfig, lengthOfChainConfigs):
243 alignment_grps = chainDict[
'alignmentGroups']
246 if not set(alignment_grps).issubset(self.sets_to_align):
247 log.error(
" one of the alignmentGroups in %s is not available in the sets to align dictionary!", alignment_grps)
248 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
249 elif len(
set([tuple(self.sets_to_align[x])
for x
in alignment_grps])) != 1:
250 log.error(
" the alignmentGroups %s point to different sets in the sets to align dictionary", alignment_grps)
251 for x
in alignment_grps:
252 log.error(
" Set: %s, group %s", self.sets_to_align[x] , x)
253 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
256 if len(self.sets_to_align[alignment_grps[0]]) == 2:
266 max_length_firstgrp = self.length_of_configs[self.sets_to_align[alignment_grps[0]][0]]
268 for config_length,config_grp
in lengthOfChainConfigs:
269 if config_grp == self.sets_to_align[alignment_grps[0]][0]:
270 length_firstgrp = config_length
272 if length_firstgrp < max_length_firstgrp:
274 needed_steps = max_length_firstgrp - length_firstgrp
275 chainConfig.insertEmptySteps(
'Empty'+self.sets_to_align[alignment_grps[0]][0]+
'Align',needed_steps,length_firstgrp)
277 elif length_firstgrp > max_length_firstgrp:
278 log.error(
"%s first signature length %d is greater than the max calculated, %d",chainDict.name,length_firstgrp, max_length_firstgrp)
279 raise Exception(
"Probably something went wrong in GenerateMenuMT.generateChains()!")
283 elif len(self.sets_to_align[alignment_grps[0]]) > 2:
284 if not set(alignment_grps).issubset(self.sets_to_align):
285 log.error(
" one of the alignmentGroups in %s is not available in the sets to align dictionary!", alignment_grps)
286 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
287 elif len(
set([tuple(self.sets_to_align[x])
for x
in alignment_grps])) != 1:
288 log.error(
" the alignmentGroups %s point to different sets in the sets to align dictionary", alignment_grps)
289 for x
in alignment_grps:
290 log.error(
" Set: %s, group %s", self.sets_to_align[x] , x)
291 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
301 alignment_grps_ordered = [x
for x
in alignment_grp_ordering
if x
in alignment_grps]
308 aligngroups_set = self.get_groups_to_align(alignment_grps_ordered[-1])
309 aligngroups_set.reverse()
310 grp_masks = [x
in alignment_grps_ordered
for x
in aligngroups_set]
312 for align_grp,grp_in_chain
in zip(aligngroups_set,grp_masks):
314 for config_length,config_grp
in lengthOfChainConfigs:
315 if config_grp == align_grp:
316 grp_lengths += [config_length]
320 for istep,(align_grp,grp_in_chain,length_in_chain)
in enumerate(zip(aligngroups_set,grp_masks,grp_lengths)):
323 n_steps_before_grp = 0
324 if istep < len(grp_lengths)-1:
325 n_steps_before_grp =
sum(grp_lengths[istep+1:])
326 max_length_grp = self.length_of_configs[align_grp]
328 if length_in_chain < max_length_grp:
330 needed_steps = max_length_grp - length_in_chain
331 start_step = n_steps_before_grp + length_in_chain
332 chainConfig.insertEmptySteps(
'Empty'+align_grp+
'Align',needed_steps,start_step)
336 chainConfig.insertEmptySteps(
'Empty'+align_grp+
'Align',self.length_of_configs[align_grp],n_steps_before_grp)
338 log.error(
"Should never reach this point. Ordered alignmentGroups: %s, sets_to_align: %s",alignment_grps_ordered,self.sets_to_align)
339 raise Exception(
"MenuAlignment.multi_align() needs checking, this should never happen.")
341 log.debug(
"Finished with retrieving chain configuration for chain %s", chainDict[
'chainName'])
342 chainConfig.numberAllSteps()