def get_product_seq(self): seq = self.template_seq enzyme = AllEnzymes.get(self.enzyme_name) sites = enzyme.search(seq) site = -1 + one( sites, ValueError( f"{self.enzyme_name!r} does not cut {self.template_tag!r}."), ValueError( f"{self.enzyme_name!r} cuts {self.template_tag!r} {len(sites)} times." ), ) return seq[site:] + seq[:site]
os.makedirs(OUT_DIR, exist_ok=True) DEL_COORDS = (args.DEL_START, args.DEL_END) DEL_NAME = args.DEL_NAME HR_LENGTH = args.HR_LENGTH ENZYME = args.ENZYME # Check input try: genome = SeqIO.read(GENOME, "fasta") except (FileNotFoundError, ValueError): raise SystemExit("\n\terror: could not read genome file\n") if (not all([coord in range(1, len(genome)+1) for coord in DEL_COORDS]) or DEL_COORDS[0] >= DEL_COORDS[1]): raise SystemExit("\n\terror: invalid deletion coordinates\n") if ENZYME in AllEnzymes: enzyme = AllEnzymes.get(ENZYME) else: raise SystemExit("\n\terror: restriction enzyme not found\t") log = open(os.path.join(OUT_DIR, DEL_NAME + "_primer_design.txt"), "w") # Define initial regions del_region = Region(DEL_COORDS, genome) margin1_coords = (del_region.s() - MARGIN_SIZE + INTERNAL_MARGIN, del_region.s() + INTERNAL_MARGIN) margin1 = Region(margin1_coords, genome) margin2_coords = (del_region.e() - INTERNAL_MARGIN, del_region.e() + MARGIN_SIZE - INTERNAL_MARGIN) margin2 = Region(margin2_coords, genome) log.write( sep + "##### PRIMER DESIGN FOR DELETION '%s' %d - %d (%.1f kb) #####\n"