<jupyter_start><jupyter_text>pCMV-Target-ACEmax (by modification of a quine code)QUEEN script for pCMV-Target-ACEmax construction generated by editing the quine code obtained from pCMV-Target-AIDmax.gbk1. The C-terminus region of Target-AIDmax was amplified from pUC-optimized-PmCDA1-ugi using the primer pair SI1304/SI1307.2. A plasmid backbone was amplified from pCMV-ABEmax using the primer pair SI1310/SI1309.3. An ABEmax fragment was amplified from pCMV-ABEmax using the primer pair SI945/SI1305.4. The three fragments were assembled by Gibson Assembly.Process 1 and 2 were retrieved from the quine code of pCMV-Target-AIDmax.gbk.<jupyter_code>%matplotlib inline
import sys 
from QUEEN.queen import *
set_namespace(globals())
if "output" not in os.listdir("./"):
    os.mkdir("output")
QUEEN(record="output/pCMV-Target-AIDmax.gbk", product="pCMV_Target_AIDmax")  #Load pCMV-Target-AIDmax plasmid object
quine(pCMV_Target_AIDmax) #Obtain the quine code of pCMV-Target-AIDmax construnction.
#Extract the QUEEN commands to generate "fragment7" and "fragment8" from the quine code of pCMV-Target-AIDmax
QUEEN(record='https://benchling.com/s/seq-OCkN5m6U6st0I9ToyOn1', dbtype='benchling', product='pCMV_ABEmax', process_id='pCMV_Target_AIDmax-AIZUSOYZL0RT63IR4B6WXUZP', original_ids=[],  _sourcefile='pCMV_Target_AIDmax_construction')
QUEEN(record='https://benchling.com/s/seq-APwTvCrCHnd38ugWloNK', dbtype='benchling', product='opt_CDA1_ugi', process_id='pCMV_Target_AIDmax-6YJN07DOTJNIDR018CR0H7AB', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
QUEEN(seq='CCTGTCTCAGCTGGGAGGTGACGGCGGAGGAGGAACTGGAGGAGG', product='SI1304', process_id='pCMV_Target_AIDmax-BWTSS2G2TN3B1854LZ9CRHCP', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
QUEEN(seq='TCAGCGGGTTTAAACTCATTATCACAGCATTTTGATTTTGTTCTC', product='SI1307', process_id='pCMV_Target_AIDmax-4JQQHMKR3P1S4H7IHGNX696H', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
QUEEN(seq='ACCAAAGAAGAAGCGGAAAGTCGACAAGAAGTACAGCATCGGCCT', product='SI1308', process_id='pCMV_Target_AIDmax-24OSLPIY9XGP7A7Q156481YO', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
QUEEN(seq='GTCACCTCCCAGCTGAGACAGGTCG', product='SI1305', process_id='pCMV_Target_AIDmax-BNG799CQ3983A9N8ZJ6Y5N7L', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
QUEEN(seq='TGATAATGAGTTTAAACCCGCTGA', product='SI1310', process_id='pCMV_Target_AIDmax-ESC04QA1WT9H5OSE0OI7030Q', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
QUEEN(seq='GACTTTCCGCTTCTTCTTTGGTGACTCG', product='SI1309', process_id='pCMV_Target_AIDmax-755VCHGTW064BOU1F98DSE9Y', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')

process2={'name':'PCR', 'description':'2. A fragment encoding the human codon-optimized PmCDA1-UGI was amplified from the pUC-optimized-PmCDA1-ugi plasmid using the primer set SI1304/SI1307.'}
opt_CDA1_ugi.searchsequence(query=SI1304.seq[-18:], product='FW7', process_name=process2['name'], process_description=process2['description'], process_id='pCMV_Target_AIDmax-1F92NOLXKGM0DMJPEF2ZJZ4F', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
opt_CDA1_ugi.searchsequence(query=SI1307.seq[-18:], product='RV7', process_name=process2['name'], process_description=process2['description'], process_id='pCMV_Target_AIDmax-5RSVHPR0L46D7T8DJGNHMWEH', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
cropdna(opt_CDA1_ugi, start=FW7[0].end, end=RV7[0].start, product='extract7', process_name=process2['name'], process_description=process2['description'], process_id='pCMV_Target_AIDmax-320TY5U84H17BT759XF5WES8', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
modifyends(extract7, left=SI1304.seq, right=SI1307.rcseq, product='fragment7', process_name=process2['name'], process_description=process2['description'], process_id='pCMV_Target_AIDmax-BN0Z7343NEPH9BA7S3KX772G', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')

process3={'name':'PCR', 'description':'3. The backbone fragment (fragment8) was amplified from pCMV-ABEmax using SI1310/SI1309.'}
pCMV_ABEmax.searchsequence(query=SI1310.seq[-18:], product='FW8', process_name=process3['name'], process_description=process3['description'], process_id='pCMV_Target_AIDmax-11SFR17B8KDG8P1D4KST0UCV', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
pCMV_ABEmax.searchsequence(query=SI1309.seq[-18:], product='RV8', process_name=process3['name'], process_description=process3['description'], process_id='pCMV_Target_AIDmax-9ZKGPLUFNGQSA0YMW6I4WBNT', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
cropdna(pCMV_ABEmax, start=FW8[0].end, end=RV8[0].start, product='extract8', process_name=process3['name'], process_description=process3['description'], process_id='pCMV_Target_AIDmax-1OFYNP8YZOMQ84N29XKM1E15', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
modifyends(extract8, left=SI1310.seq, right=SI1309.rcseq, product='fragment8', process_name=process3['name'], process_description=process3['description'], process_id='pCMV_Target_AIDmax-3F7PEXEICKU1CT2NYKUSIKJB', original_ids=[], _sourcefile='pCMV_Target_AIDmax_construction')
processname1 = "PCR"
description1 = "3. An ABEmax fragment was amplified from pCMV-ABEmax using the primer pair SI945/SI1305."
QUEEN(seq="AGATCCGCGGCCGCTAATACGACTCACTATAGG", product="SI945", pn=processname1, pd=description1) #Create a QUEEN object for the forward primer. 
pCMV_ABEmax.searchsequence(SI945.seq[-18:], product="FW13", pn=processname1, pd=description1)     #Search for the 18-bp 3’-end sequences of the forward primer.
pCMV_ABEmax.searchsequence(SI1305.seq[-18:], product="RV13", pn=processname1, pd=description1)    #Search for the 18-bp 3’-end sequences of the reverse primer.
cropdna(pCMV_ABEmax, FW13[0].end, RV13[0].start, product="extract13", pn=processname1, pd=description1) #Crop the internal DNA sequence flanked by the primer annealing sites.
modifyends(extract13, SI945.seq, SI1305.rcseq, product="fragment13", pn=processname1, pd=description1)  #Add forward and reverse primer sequences to the both ends of the cropped fragment.
processname2 = "Gibson Assembly"
description2 = "4. The three fragments were assembled by Gibson Assembly."
modifyends(fragment7, "*{22}/-{22}", "-{24}/*{24}",  product="fragment7_mod", pn=processname2, pd=description2)                             #Generate long sticky ends on the both sides of "fragment7".
modifyends(fragment8, "*{24}/-{24}","-{103}/*{103}", product="fragment8_mod", pn=processname2, pd=description2)                             #Generate long sticky ends on the both sides of "fragment8".
modifyends(fragment13, "*{103}/-{103}","-{22}/*{22}", product="fragment13_mod", pn=processname2, pd=description2)                           #Generate long sticky ends on the both sides of "fragment13".
joindna(fragment7_mod, fragment8_mod, fragment13_mod, topology="circular", product="pCMV_Target_ACEmax", pn=processname2, pd=description2)  #Add forward and reverse primer sequences to the both ends of the cropped fragment.
pCMV_Target_ACEmax.printfeature()
def add_fragment_annotation(dna, fragment, new_feature_id, color_set):
    """
    Define seqeunce featurtes for "fragment" in "dna". 
    """
    f = dna.searchsequence(fragment.seq) #Search for "fragment" seqeunce in "dna"
    editfeature(dna, source=f, target_attribute="feature_id", operation=createattribute(new_feature_id), new_copy=False)                                                      #Define a new feature whose feature_id becomes "new_feature_id".
    editfeature(dna, key_attribute="feature_id", query=new_feature_id, target_attribute="qualifier:label", operation=createattribute(new_feature_id), new_copy=False)         #Provide a qualifier:label to the new feature.
    editfeature(dna, key_attribute="feature_id", query=new_feature_id, target_attribute="qualifier:edgecolor_queen", operation=createattribute(color_set[0]), new_copy=False) #Set a edge color for the new feature.
    editfeature(dna, key_attribute="feature_id", query=new_feature_id, target_attribute="qualifier:facecolor_queen", operation=createattribute(color_set[1]), new_copy=False) #Set a face color for the new feature.
    editfeature(dna, key_attribute="feature_id", query=new_feature_id, target_attribute="strand", operation=replaceattribute(0), new_copy=False)                              #Set a coding direction of the new feature
    
def visualization(dna):
    """
    Set the start position of "dna" and visualize its circular sequence map. 
    """
    dna.searchfeature(key_attribute="qualifier:label", query="^Cas9", product="Cas9")           #Search for the feature that represent the Cas9 gene.
    plasmid   = joindna(cutdna(dna, Cas9[0].start)[0], topology="circular")                     #Set the first nucleotide of the Cas9 gene as the start position of the plasmid.
    fragments = plasmid.searchfeature(key_attribute="qualifier:label", query="fragment-[0-9]+") #Obtain the features whose feature_id are "fragment-[0-9]+".
    fragments.sort(key=lambda x:x.qualifiers["label"][0])                                       #Sort the order of fragments according to qualifier.label.
    features  = plasmid.searchfeature(key_attribute="feature_type", query="CDS") + plasmid.searchfeature(key_attribute="feature_type", query="promoter") + plasmid.searchfeature(key_attribute="feature_type", query="rep_origin") + fragments #Select the sequence features to be visualized.
    fig        = visualizemap(plasmid, feature_list=features, map_view="circular", tick_interval=1000, title=dna.project) #Visualize the circular seqeunce map of the plasmid.
    return fig, plasmid

#Paris of color codes for gene edge and face 
color_sets = [('#E53935', '#ffcdd2'), ('#8E24AA', '#e1bee7'), ('#3949AB', '#c5cae9'), ('#1E88E5', '#bbdefb'), ('#00ACC1', '#b2ebf2'), ('#D81B60', '#f8bbd0'), ('#5E35B1', '#d1c4e9'), 
              ('#43A047', '#c8e6c9'), ('#7CB342', '#dcedc8'), ('#FDD835', '#fff9c4'), ('#FB8C00', '#ffe0b2'), ('#6D4C41', '#d7ccc8'), ('#C0CA33', '#f0f4c3'), ('#546E7A', '#cfd8dc')]

add_fragment_annotation(pCMV_Target_ACEmax, fragment7,  "fragment-7", color_sets[6])   #Add "fragment1" to .dnafeatures of "pCMV_Target_ACEmax" plasmid object.
add_fragment_annotation(pCMV_Target_ACEmax, fragment8,  "fragment-8", color_sets[7])   #Add "fragment1" to .dnafeatures of "pCMV_Target_ACEmax" plasmid object.
add_fragment_annotation(pCMV_Target_ACEmax, fragment13, "fragment-13", color_sets[12]) #Add "fragment1" to .dnafeatures of "pCMV_Target_ACEmax" plasmid object.
fig = visualization(pCMV_Target_ACEmax)
#Visualize the operational process chart of pCMV-Target-ACEmax.
flow = visualizeflow(pCMV_Target_ACEmax, alias_dict = {"fragment7":"fragment-7", "fragment8":"fragment-8", "fragment6":"fragment-6", "fragment13":"fragment-13", "pCMV_ABEmax":"pCMV-ABEmax", "pCMV_BE4max":"pCMV-BE4max", "pCMV_Target_ACEmax":"pCMV-Target-ACEmax", "pCMV_Target_AIDmax":"pCMV-Target-AIDmax", "pCMV_Target_AIDmax_construction":"pCMV-Target-AIDmax construction", "opt_CDA1_ugi":"opt-CDA1-ugi"})
flow.render("output/pCMV_Target_ACEmax_construction_v2")
flow
pCMV_Target_ACEmax.outputgbk("output/pCMV-Target-ACEmax_v2.gbk")
#Generate and execute the quine code and confirm if the cloned QUEEN_object is identical to the original one.
quine(pCMV_Target_ACEmax, execution=True)
#Extract the narrative descriptions linked to the operational processes.
quine(pCMV_Target_ACEmax, process_description=True)<jupyter_output>pCMV_Target_AIDmax construction
    2. A fragment encoding the human codon-optimized PmCDA1-UGI was amplified from the pUC-optimized-PmCDA1-ugi plasmid using the primer set SI1304/SI1307.
    3. The backbone fragment (fragment8) was amplified from pCMV-ABEmax using SI1310/SI1309.
pCMV_Target_ACEmax construction
    3. An ABEmax fragment was amplified from pCMV-ABEmax using the primer pair SI945/SI1305.
    4. The three fragments were assembled by Gibson Assembly.
{'fraction_non_alphanumeric': 0.122944662382105, 'fraction_numerical': 0.04807612052416326, 'mean_word_length': 7.297783933518006, 'pattern_counts': {'":': 10, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '407562', 'license': 'MIT', 'n_tokens_mistral': 4489, 'n_tokens_neox': 4096, 'n_words': 802, 'path': 'demo/sakata_et_al_2020/pCMV_Target_ACEmax_construction_v2.ipynb', 'repo_name': 'yachielab/QUEEN', 'size': '11981'}