Following this post I managed to put together a small function to place within a bigger text body (FASTA) shorter strings determined from another file based on some conditions (e.g. 100 events from a subset of only those 400-to-500 characters in length, and selected randomly). Now, I'm pretty fine with the result; however, I wish to print for those 100 events where exactly they have been added in the bigger text body — ideally, start-end position if not too hard. I guess this could be integrated in get_retro_text() or, if easier, build as an external function, but I cannot really figure out from where to start... any help is greatly appreciated, thanks in advance! ###randomly selects 100 sequences and adds them to the FASTA def insert (source_str, insert_str, pos): return source_str[os] + insert_str + source_str[pos:] def get_retro_text(genome, all_strings): string_of_choice = [string for string in all_strings if 400 < len(string) < 500] hundred_strings = random.sample(string_of_choice, k=100) text_of_strings = [] for k in range(len(hundred_strings)): text_of_strings.append(str(hundred_strings[k].seq)) single_string = ",".join(text_of_strings) new_genome = insert(genome, single_string, random.randint(0, len(genome))) return new_genome big_genome = get_retro_text(body, s) Continue reading...