# load SeqUtil methods sys.path.append('code') import SeqUtil importlib.reload(SeqUtil) lenTargetPeptide = len(target) lenTargetDna = lenTargetPeptide*3 foundDnas = [] # storage of target dan sequences ## search amino acids in forward direction for start in range(0,3): # loop for reading frame start curDna = dna[start:] curRna = SeqUtil.dna2rna(curDna) peptides = SeqUtil.rna2peptide(curRna, mapFile='./data/RNA_codon_table_1.txt') pepStartIndex = 0 for pep in peptides: # find positions of target in peptide targetPositions = [pos for pos in range(0, len(pep)) if pep[pos:(pos+lenTargetPeptide)]==target] # get corresponding dna sequence and save targetDnas = [curDna[(pepStartIndex+pos*3):(pepStartIndex+pos*3+lenTargetDna)] for pos in targetPositions] foundDnas.extend(targetDnas) # update pepStartIndex for the next peptide pepStartIndex = pepStartIndex + (len(pep)+1)*3 ## search amino acids in reverse direction