215 def multi_align(self, chainDict, chainConfig, lengthOfChainConfigs):
219 alignment_grps = chainDict[
'alignmentGroups']
222 if not set(alignment_grps).issubset(self.sets_to_align):
223 log.error(
" one of the alignmentGroups in %s is not available in the sets to align dictionary!", alignment_grps)
224 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
225 elif len(
set([tuple(self.sets_to_align[x])
for x
in alignment_grps])) != 1:
226 log.error(
" the alignmentGroups %s point to different sets in the sets to align dictionary", alignment_grps)
227 for x
in alignment_grps:
228 log.error(
" Set: %s, group %s", self.sets_to_align[x] , x)
229 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
232 if len(self.sets_to_align[alignment_grps[0]]) == 2:
242 max_length_firstgrp = self.length_of_configs[self.sets_to_align[alignment_grps[0]][0]]
244 for config_length,config_grp
in lengthOfChainConfigs:
245 if config_grp == self.sets_to_align[alignment_grps[0]][0]:
246 length_firstgrp = config_length
248 if length_firstgrp < max_length_firstgrp:
250 needed_steps = max_length_firstgrp - length_firstgrp
251 chainConfig.insertEmptySteps(
'Empty'+self.sets_to_align[alignment_grps[0]][0]+
'Align',needed_steps,length_firstgrp)
253 elif length_firstgrp > max_length_firstgrp:
254 log.error(
"%s first signature length %d is greater than the max calculated, %d",chainDict.name,length_firstgrp, max_length_firstgrp)
255 raise Exception(
"Probably something went wrong in GenerateMenuMT.generateChains()!")
259 elif len(self.sets_to_align[alignment_grps[0]]) > 2:
260 if not set(alignment_grps).issubset(self.sets_to_align):
261 log.error(
" one of the alignmentGroups in %s is not available in the sets to align dictionary!", alignment_grps)
262 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
263 elif len(
set([tuple(self.sets_to_align[x])
for x
in alignment_grps])) != 1:
264 log.error(
" the alignmentGroups %s point to different sets in the sets to align dictionary", alignment_grps)
265 for x
in alignment_grps:
266 log.error(
" Set: %s, group %s", self.sets_to_align[x] , x)
267 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
277 alignment_grps_ordered = [x
for x
in alignment_grp_ordering
if x
in alignment_grps]
284 aligngroups_set = self.get_groups_to_align(alignment_grps_ordered[-1])
285 aligngroups_set.reverse()
286 grp_masks = [x
in alignment_grps_ordered
for x
in aligngroups_set]
288 for align_grp,grp_in_chain
in zip(aligngroups_set,grp_masks):
290 for config_length,config_grp
in lengthOfChainConfigs:
291 if config_grp == align_grp:
292 grp_lengths += [config_length]
296 for istep,(align_grp,grp_in_chain,length_in_chain)
in enumerate(zip(aligngroups_set,grp_masks,grp_lengths)):
299 n_steps_before_grp = 0
300 if istep < len(grp_lengths)-1:
301 n_steps_before_grp =
sum(grp_lengths[istep+1:])
302 max_length_grp = self.length_of_configs[align_grp]
304 if length_in_chain < max_length_grp:
306 needed_steps = max_length_grp - length_in_chain
307 start_step = n_steps_before_grp + length_in_chain
308 chainConfig.insertEmptySteps(
'Empty'+align_grp+
'Align',needed_steps,start_step)
312 chainConfig.insertEmptySteps(
'Empty'+align_grp+
'Align',self.length_of_configs[align_grp],n_steps_before_grp)
314 log.error(
"Should never reach this point. Ordered alignmentGroups: %s, sets_to_align: %s",alignment_grps_ordered,self.sets_to_align)
315 raise Exception(
"MenuAlignment.multi_align() needs checking, this should never happen.")
317 log.debug(
"Finished with retrieving chain configuration for chain %s", chainDict[
'chainName'])
318 chainConfig.numberAllSteps()