107 for comb_pair
in list(itertools.combinations(comb,2)):
111 _,eigenvecs = np.linalg.eig(the_matrix)
115 eigenvecs = np.transpose(eigenvecs)
118 pre_unique_sets = list(
set([tuple(np.nonzero(eigenvec)[0])
for eigenvec
in eigenvecs]))
123 for aset
in pre_unique_sets:
124 if len(unique_sets) == 0 :
128 for ibset,bset
in enumerate(unique_sets):
132 elif set(aset).issubset(
set(bset)):
135 elif set(bset).issubset(
set(aset)):
136 unique_sets.pop(ibset)
137 unique_sets += [aset]
146 unique_by_sig = [[ self.
inverse_sig_dict[sig_int]
for sig_int
in setlist ]
for setlist
in unique_sets]
150 for aset
in unique_by_sig:
152 sig_to_set[sig] = aset
187 if len(
set(chainDict[
'alignmentGroups'])) != 1:
188 log.error(
"Cannot call single_align on chain %s with alignment groups %s",
189 chainDict[
'chainName'],
",".join(chainDict[
'alignmentGroups']))
190 raise Exception(
"Will not proceed, the chain is not suitable for single alignment.")
192 alignment_grp = chainDict[
'alignmentGroups'][0]
195 log.debug(
"Finished with retrieving chain configuration for chain %s", chainDict[
'chainName'])
196 chainConfig.numberAllSteps()
200 log.debug(
"Finished with retrieving chain configuration for chain %s", chainDict[
'chainName'])
201 chainConfig.numberAllSteps()
206 aligngroups_set.reverse()
208 for align_grp_to_align
in aligngroups_set:
209 chainConfig.insertEmptySteps(
'Empty'+align_grp_to_align+
'Align',self.
length_of_configs[align_grp_to_align],0)
210 log.debug(
"Finished with retrieving chain configuration for chain %s", chainDict[
'chainName'])
211 chainConfig.numberAllSteps()
215 def multi_align(self, chainDict, chainConfig, lengthOfChainConfigs):
219 alignment_grps = chainDict[
'alignmentGroups']
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.")
226 log.error(
" the alignmentGroups %s point to different sets in the sets to align dictionary", alignment_grps)
227 for x
in alignment_grps:
229 raise Exception(
"MenuAlignment.analyse_combinations() needs checking, this should never happen.")
244 for config_length,config_grp
in lengthOfChainConfigs:
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()!")
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.")
264 log.error(
" the alignmentGroups %s point to different sets in the sets to align dictionary", alignment_grps)
265 for x
in alignment_grps:
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]
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:])
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()