<jupyter_start><jupyter_text>Part 1: Initialize<jupyter_code>workfolder = path.join(bentna_folder, 'tests')
host = 'pnas_16mer'
bp_id_first = 3
bp_id_last = 12
s_agent = shapefourier.ShapeAgent(workfolder, host)<jupyter_output>/home/yizaochen/codes/bentdna/tests/pnas_16mer/an_folder exists<jupyter_text>Part 2: Read $l_i$ and $\theta$<jupyter_code>s_agent.read_l_modulus_theta()<jupyter_output><empty_output><jupyter_text>Part 3: Make or Read Dataframe of $a_n$<jupyter_code>n_begin = 1
n_end = 8
lastframe = 10000
# make, if need
df_an = s_agent.make_df_an(n_begin, n_end, lastframe)
# read
df_an = s_agent.read_df_an(n_begin, n_end)
df_an.head()<jupyter_output><empty_output><jupyter_text>Part 4: Set plots variables and functions<jupyter_code>workfolder = '/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis'
n_begin = 1
n_end = 8
def get_nlist_varlist(df, n_begin, n_end):
    n_list = list(range(n_begin, n_end+1))
    var_list = list()
    for n in n_list:
        var_list.append(df[str(n)].var())
    return n_list, var_list

def get_nlist_Lplist(df, L, n_begin, n_end):
    n_list = list(range(n_begin, n_end+1))
    Lp_list = list()
    for n in n_list:
        var_an = df[str(n)].var()
        Lp = np.square(L) / (np.square(n) * np.square(np.pi) * var_an)
        Lp_list.append(Lp)
    return n_list, Lp_list

def plot_var_an_mode_n_withline(ax, n_list, var_list, host, ttfz, lbfz, ymin, ymax):
    ax.plot(n_list, var_list, '-o', color='blue', label=host)
    ax.set_title(f'{host}', fontsize=ttfz)
    ax.set_xlabel(r'Mode number, $n$', fontsize=lbfz)
    ax.set_ylabel('Var($a_n$)', fontsize=lbfz)
    ax.set_ylim(ymin, ymax)
    ax.axhline(y=0.2, color='red', alpha=0.5)
    ax.axhline(y=0.05, color='red', alpha=0.5)
    
def plot_var_an_mode_n(ax, n_list, var_list, host, ttfz, lbfz):
    ax.plot(n_list, var_list, '-o', label=host)
    ax.set_title(f'{host}', fontsize=ttfz)
    ax.set_xlabel(r'Mode number, $n$', fontsize=lbfz)
    ax.set_ylabel('Var($a_n$)', fontsize=lbfz)
    ax.set_ylim(0, 0.25)
    
def plot_Lp_an_mode_n(ax, n_list, Lp_list, host, ttfz, lbfz, ymin, ymax):
    ax.plot(n_list, Lp_list, '-o', label=host)
    ax.set_xlabel(r'Mode number, $n$', fontsize=lbfz)
    ax.set_ylabel(r'$L_p$ (nm)', fontsize=lbfz)
    ax.set_ylim(ymin, ymax)<jupyter_output><empty_output><jupyter_text>Part 5: Length Effects, Var($a_n$) versus $n$<jupyter_code>hosts = ['pnas_16mer', 'yizao_model']
lbfz = 12
ttfz = 14
nrows = 1
ncols = 2
ymin = -0.005
ymax = 0.035

fig, axes = plt.subplots(ncols=ncols, nrows=nrows, figsize=(12,4))

idx = 0
for col_id in range(ncols):
    host = hosts[idx]
    ax = axes[col_id]
    s_agent = shapefourier.ShapeAgent(workfolder, host)
    df_an = s_agent.read_df_an(n_begin, n_end)
    n_list, var_list = get_nlist_varlist(df_an, n_begin, n_end)
    plot_var_an_mode_n_withline(ax, n_list, var_list, host, ttfz, lbfz, ymin, ymax)      
    idx += 1
plt.tight_layout()
#plt.savefig("length_effect.png", dpi=100)
plt.show()
lbfz = 12
ttfz = 14
nrows = 1
ncols = 1
ymin = 40
ymax = 165

fig, ax = plt.subplots(ncols=ncols, nrows=nrows, figsize=(8,4))

for host in hosts:
    s_agent = shapefourier.ShapeAgent(workfolder, host)
    df_an = s_agent.read_df_an(n_begin, n_end)
    L = s_agent.get_appr_L()
    nlist, Lplist = get_nlist_Lplist(df_an, L, n_begin, n_end)
    plot_Lp_an_mode_n(ax, nlist, Lplist, host, ttfz, lbfz, ymin, ymax)
ax.legend()
plt.tight_layout()
#plt.savefig("length_effect_lp.png", dpi=100)
plt.show()<jupyter_output>/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/pnas_16mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/yizao_model/an_folder exists<jupyter_text>Part 6: Sequence effect<jupyter_code>hosts = ['atat_21mer', 'g_tract_21mer', 'a_tract_21mer', 'gcgc_21mer', 'tgtg_21mer', 'ctct_21mer']
lbfz = 12
ttfz = 14
nrows = 2
ncols = 3
ymin = -0.005
ymax = 0.035

fig, axes = plt.subplots(ncols=ncols, nrows=nrows, figsize=(16,8))

idx = 0
for row_id in range(nrows):
    for col_id in range(ncols):
        host = hosts[idx]
        ax = axes[row_id, col_id]
        s_agent = shapefourier.ShapeAgent(workfolder, host)
        df_an = s_agent.read_df_an(n_begin, n_end)
        n_list, var_list = get_nlist_varlist(df_an, n_begin, n_end)
        plot_var_an_mode_n_withline(ax, n_list, var_list, host, ttfz, lbfz, ymin, ymax)      
        idx += 1
plt.tight_layout()
#plt.savefig("sequence_effect.png", dpi=100)
plt.show()
lbfz = 12
ttfz = 14
nrows = 1
ncols = 1
ymin = 40
ymax = 165

fig, ax = plt.subplots(ncols=ncols, nrows=nrows, figsize=(8,4))

for host in hosts:
    s_agent = shapefourier.ShapeAgent(workfolder, host)
    df_an = s_agent.read_df_an(n_begin, n_end)
    L = s_agent.get_appr_L()
    nlist, Lplist = get_nlist_Lplist(df_an, L, n_begin, n_end)
    plot_Lp_an_mode_n(ax, nlist, Lplist, host, ttfz, lbfz, ymin, ymax)
ax.legend(ncol=3)
plt.tight_layout()
#plt.savefig("sequence_effect_lp.png", dpi=100)
plt.show()<jupyter_output>/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/atat_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/g_tract_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/a_tract_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/gcgc_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/tgtg_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/ctct_21mer/an_folder exists<jupyter_text>Part 7: Ionic strength<jupyter_code>hosts = ['pnas_16mer', '500mm', 'only_cation', 'mgcl2_150mm']
lbfz = 12
ttfz = 14
nrows = 2
ncols = 2
ymin = -0.005
ymax = 0.035

fig, axes = plt.subplots(ncols=ncols, nrows=nrows, figsize=(16,8))

idx = 0
for row_id in range(nrows):
    for col_id in range(ncols):
        host = hosts[idx]
        ax = axes[row_id, col_id]
        s_agent = shapefourier.ShapeAgent(workfolder, host)
        df_an = s_agent.read_df_an(n_begin, n_end)
        n_list, var_list = get_nlist_varlist(df_an, n_begin, n_end)
        plot_var_an_mode_n_withline(ax, n_list, var_list, host, ttfz, lbfz, ymin, ymax)      
        idx += 1
plt.tight_layout()
#plt.savefig("ionic_effect.png", dpi=100)
plt.show()
lbfz = 12
ttfz = 14
nrows = 1
ncols = 1
ymin = 40
ymax = 165

fig, ax = plt.subplots(ncols=ncols, nrows=nrows, figsize=(8,4))

for host in hosts:
    s_agent = shapefourier.ShapeAgent(workfolder, host)
    df_an = s_agent.read_df_an(n_begin, n_end)
    L = s_agent.get_appr_L()
    nlist, Lplist = get_nlist_Lplist(df_an, L, n_begin, n_end)
    plot_Lp_an_mode_n(ax, nlist, Lplist, host, ttfz, lbfz, ymin, ymax)
ax.legend()
plt.tight_layout()
#plt.savefig("ionic_effect_lp.png", dpi=100)
plt.show()<jupyter_output>/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/pnas_16mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/500mm/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/only_cation/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/mgcl2_150mm/an_folder exists<jupyter_text>Addtional Part 1: Batch Calculation<jupyter_code>workfolder = '/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis'
hosts = ['atat_21mer', 'g_tract_21mer', 'a_tract_21mer', 'gcgc_21mer', 'tgtg_21mer', 'ctct_21mer',
         'yizao_model', '500mm', 'only_cation', 'mgcl2_150mm']
n_begin = 1
n_end = 8
last_frame = 10000 # 10000

for host in hosts:
    s_agent = shapefourier.ShapeAgent(workfolder, host)
    s_agent.read_l_modulus_theta()
    df_an = s_agent.make_df_an(n_begin, n_end, last_frame)<jupyter_output>/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/atat_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/g_tract_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/a_tract_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/gcgc_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/tgtg_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/ctct_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/yizao_model/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/500mm/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/only_cation/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/mgcl2_150mm/an_folder exists<jupyter_text>Addtional Part 2: Reduce Fraying effect<jupyter_code>start_end = {
    'atat_21mer': (4, 16), 'g_tract_21mer': (4, 16), 
    'a_tract_21mer': (4, 16), 'yizao_model': (4, 19), 
    'pnas_16mer': (4, 11), 'gcgc_21mer': (4, 16),
    'ctct_21mer': (4, 16), 'tgtg_21mer': (4, 16), '500mm': (4, 11),
    'only_cation': (4, 11), 'mgcl2_150mm': (4, 11)}

workfolder = '/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis'
n_begin = 0
n_end = 9
last_frame = 10000 # 10000


hosts = ['atat_21mer', 'g_tract_21mer', 'a_tract_21mer', 'gcgc_21mer', 'tgtg_21mer', 'ctct_21mer']

for host in hosts:
    bp_id_first = start_end[host][0]
    bp_id_last = start_end[host][1]
    s_agent = shapefourier.ShapeAgent(workfolder, host)
    s_agent.read_l_modulus_theta()
    df_an = s_agent.make_df_an(n_begin, n_end, last_frame)
hosts = ['atat_21mer', 'g_tract_21mer', 'a_tract_21mer', 'gcgc_21mer', 'tgtg_21mer', 'ctct_21mer']
lbfz = 12
ttfz = 14
nrows = 1
ncols = 1
ymin = 0
ymax = 20

fig, ax = plt.subplots(ncols=ncols, nrows=nrows, figsize=(8,4))

for host in hosts:
    bp_id_first = start_end[host][0]
    bp_id_last = start_end[host][1]
    s_agent = shapefourier.ShapeAgent(workfolder, host, bp_id_first, bp_id_last)
    df_an = s_agent.read_df_an(n_begin, n_end)
    L = s_agent.get_appr_L()
    nlist, Lplist = get_nlist_Lplist(df_an, L, n_begin, n_end)
    plot_Lp_an_mode_n(ax, nlist, Lplist, host, ttfz, lbfz, ymin, ymax)
ax.legend(ncol=2)
plt.tight_layout()
#plt.savefig("sequence_effect_lp_i4_j16.png", dpi=100)
plt.show()<jupyter_output>/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/atat_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/g_tract_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/a_tract_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/gcgc_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/tgtg_21mer/an_folder exists
/home/yizaochen/codes/dna_rna/length_effect/find_helical_axis/ctct_21mer/an_folder exists
{'fraction_non_alphanumeric': 0.13053656709429723, 'fraction_numerical': 0.0351156475325405, 'mean_word_length': 5.304604486422668, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '247598', 'license': 'MIT', 'n_tokens_mistral': 5101, 'n_tokens_neox': 4715, 'n_words': 721, 'path': 'notebooks/fourier_analysis.ipynb', 'repo_name': 'alayah2626517/bentdna_methyl', 'size': '10679'}