def align(self, degappify=False): """align(degappify=False) : Align all EntryGroups in a multiple sequence alignment, using the master entries. If degappify==True, will first remove all gaps from sequences before realigning. Calls gappify() on all EntryGroups after performing the alignment. """ from prosci.util.seq import align as seqalign if degappify: self.remove_gaps() aligned = Ali(seqalign(self.toFastaString()), fasta_mode=True) for eg_self, eg_aligned in zip(self, aligned): assert deGappify(eg_aligned.master.seq) == deGappify(eg_self.master.seq) eg_self.master.seq = eg_aligned.master.seq eg_self.gappify()
def align(self, other, degappify=False): """align(other, degappify=False) : Align this Entry to another using a sequence alignment. If degappify==True, will first remove all gaps from sequences before realigning. """ from prosci.util.seq import align as seqalign assert self.code != other.code if degappify: self.seq = deGappify(self.seq) other.seq = deGappify(other.seq) aligned = Ali(seqalign(self.toFastaString()+other.toFastaString()), fasta_mode=True) assert len(aligned) == 2 assert deGappify(aligned[self.code].master.seq) == deGappify(self.seq) assert deGappify(aligned[other.code].master.seq) == deGappify(other.seq) self.seq = aligned[self.code].master.seq other.seq = aligned[other.code].master.seq