def _get_mutations(seqs, standard): mutations = [] for seq in seqs: aln = global_alignment(seq, target=standard, matrix='blosum62', gap_open=-15, gap_extend=-1) mutations.extend(_parse_mutations(aln)) return mutations
def realign_germline(self, antibody, query_start=None, query_end=None): ''' Due to restrictions on the available scoring parameters in BLASTn, incorrect truncation of the v-gene alignment can occur. This function re-aligns the query sequence with the identified germline variable gene using more appropriate alignment parameters. Args: oriented_input (str): the raw input sequence, correctly oriented query_start (int): 5' position in `oriented_input` at which the sequence should be truncated prior to alignment with the germline sequence. query_end (int): 3' position in `oriented_input` at which the seqeunce should be truncated prior to alignment with the germline sequence ''' oriented_input = antibody.oriented_input germline_seq = self._get_germline_sequence_for_realignment() aln_params = self._realignment_scoring_params(self.gene_type) # if the alignment start/end positions have been annotated by the assigner, # force re-alignment using those parameters if all([ x is not None for x in [ self.query_start, self.query_end, self.germline_start, self.germline_end ] ]): query = oriented_input.sequence[self.query_start:self.query_end] germline = germline_seq[self.germline_start:self.germline_end] alignment = global_alignment(query, germline, **aln_params) # use local alignment to determine alignment start/end positions if # they haven't already been determined by the assigner else: query = oriented_input.sequence[query_start:query_end] alignment = local_alignment(query, germline_seq, **aln_params) if alignment: self._process_realignment(antibody, alignment, query_start) else: antibody.log('GERMLINE REALIGNMENT ERROR') antibody.log('REALIGNMENT QUERY SEQUENCE:', query) antibody.log('QUERY START:', query_start) antibody.log('QUERN END:', query_end)
def _align_to_reference(self): aln = global_alignment(self.sequence, self.reference, aa=True) self._aligned = aln.aligned_query self._aligned_reference = aln.aligned_target