221 def multi_align(self, chainDict, chainConfig, lengthOfChainConfigs):
225 alignment_grps = chainDict[
'alignmentGroups']
228 if not set(alignment_grps).issubset(self.sets_to_align):
229 log.error(
" one of the alignmentGroups in %s is not available in the sets to align dictionary!", alignment_grps)
230 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
231 elif len(
set([tuple(self.sets_to_align[x])
for x
in alignment_grps])) != 1:
232 log.error(
" the alignmentGroups %s point to different sets in the sets to align dictionary", alignment_grps)
233 for x
in alignment_grps:
234 log.error(
" Set: %s, group %s", self.sets_to_align[x] , x)
235 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
238 if len(self.sets_to_align[alignment_grps[0]]) == 2:
248 max_length_firstgrp = self.length_of_configs[self.sets_to_align[alignment_grps[0]][0]]
250 for config_length,config_grp
in lengthOfChainConfigs:
251 if config_grp == self.sets_to_align[alignment_grps[0]][0]:
252 length_firstgrp = config_length
254 if length_firstgrp < max_length_firstgrp:
256 needed_steps = max_length_firstgrp - length_firstgrp
257 chainConfig.insertEmptySteps(
'Empty'+self.sets_to_align[alignment_grps[0]][0]+
'Align',needed_steps,length_firstgrp)
259 elif length_firstgrp > max_length_firstgrp:
260 log.error(
"%s first signature length %d is greater than the max calculated, %d",chainDict.name,length_firstgrp, max_length_firstgrp)
261 raise Exception(
"Probably something went wrong in GenerateMenuMT.generateChains()!")
265 elif len(self.sets_to_align[alignment_grps[0]]) > 2:
266 if not set(alignment_grps).issubset(self.sets_to_align):
267 log.error(
" one of the alignmentGroups in %s is not available in the sets to align dictionary!", alignment_grps)
268 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
269 elif len(
set([tuple(self.sets_to_align[x])
for x
in alignment_grps])) != 1:
270 log.error(
" the alignmentGroups %s point to different sets in the sets to align dictionary", alignment_grps)
271 for x
in alignment_grps:
272 log.error(
" Set: %s, group %s", self.sets_to_align[x] , x)
273 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
283 alignment_grps_ordered = [x
for x
in alignment_grp_ordering
if x
in alignment_grps]
290 aligngroups_set = self.get_groups_to_align(alignment_grps_ordered[-1])
291 aligngroups_set.reverse()
292 grp_masks = [x
in alignment_grps_ordered
for x
in aligngroups_set]
294 for align_grp,grp_in_chain
in zip(aligngroups_set,grp_masks):
296 for config_length,config_grp
in lengthOfChainConfigs:
297 if config_grp == align_grp:
298 grp_lengths += [config_length]
302 for istep,(align_grp,grp_in_chain,length_in_chain)
in enumerate(zip(aligngroups_set,grp_masks,grp_lengths)):
305 n_steps_before_grp = 0
306 if istep < len(grp_lengths)-1:
307 n_steps_before_grp =
sum(grp_lengths[istep+1:])
308 max_length_grp = self.length_of_configs[align_grp]
310 if length_in_chain < max_length_grp:
312 needed_steps = max_length_grp - length_in_chain
313 start_step = n_steps_before_grp + length_in_chain
314 chainConfig.insertEmptySteps(
'Empty'+align_grp+
'Align',needed_steps,start_step)
318 chainConfig.insertEmptySteps(
'Empty'+align_grp+
'Align',self.length_of_configs[align_grp],n_steps_before_grp)
320 log.error(
"Should never reach this point. Ordered alignmentGroups: %s, sets_to_align: %s",alignment_grps_ordered,self.sets_to_align)
321 raise Exception(
"MenuAlignment.multi_align() needs checking, this should never happen.")
323 log.debug(
"Finished with retrieving chain configuration for chain %s", chainDict[
'chainName'])
324 chainConfig.numberAllSteps()