215 def multi_align(self, chainDict, chainConfig, lengthOfChainConfigs):
216
218
219 alignment_grps = chainDict['alignmentGroups']
220
221
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.")
230
231
232 if len(self.sets_to_align[alignment_grps[0]]) == 2:
233
234
235
236
237
238
239
240
241 length_firstgrp = 0
242 max_length_firstgrp = self.length_of_configs[self.sets_to_align[alignment_grps[0]][0]]
243
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
247
248 if length_firstgrp < max_length_firstgrp:
249
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)
252
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()!")
256
257
258
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.")
268
269
270
271
272
273
274
275
276 alignment_grp_ordering = get_alignment_group_ordering()
277 alignment_grps_ordered = [x for x in alignment_grp_ordering if x in alignment_grps]
278
279
280
281
282
283
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]
287 grp_lengths = []
288 for align_grp,grp_in_chain in zip(aligngroups_set,grp_masks):
289 if grp_in_chain:
290 for config_length,config_grp in lengthOfChainConfigs:
291 if config_grp == align_grp:
292 grp_lengths += [config_length]
293 else:
294 grp_lengths += [0]
295
296 for istep,(align_grp,grp_in_chain,length_in_chain) in enumerate(zip(aligngroups_set,grp_masks,grp_lengths)):
297
298
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]
303 if grp_in_chain:
304 if length_in_chain < max_length_grp:
305
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)
309 else:
310
311
312 chainConfig.insertEmptySteps('Empty'+align_grp+'Align',self.length_of_configs[align_grp],n_steps_before_grp)
313 else:
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.")
316
317 log.debug("Finished with retrieving chain configuration for chain %s", chainDict['chainName'])
318 chainConfig.numberAllSteps()
319
320 return chainConfig
void remove_duplicates(std::vector< T > &vec)