def permuted_copy(self): lengths, names = zip(*[(rec.seqlength, rec.name) for rec in self.records]) concat = concatenate(self.records) concat.shuffle() new_records = concat.split_by_lengths(lengths, names) return self.__class__(new_records)
def concatenate(self, index_list): """ NB: had a version of this which used a reduce construct to concatenate the alignments - reduce(lambda x,y: x+y, records_list) - but this led to problems of the original object being modified. Deepcopying the first record, ensuring a new memory address for the concatenation, seems more robust. """ member_records = self.members(index_list) concat = concatenate(member_records) concat.name = '-'.join(str(x) for x in index_list) return concat