<jupyter_start><jupyter_text><jupyter_code>! pwd
%cd drive/MyDrive
! git clone https://github.com/dgoppenheimer/rama8000.git<jupyter_output>Cloning into 'rama8000'...
remote: Enumerating objects: 60, done.[K
remote: Counting objects: 100% (60/60), done.[K
remote: Compressing objects: 100% (58/58), done.[K
remote: Total 60 (delta 1), reused 56 (delta 0), pack-reused 0[K
Unpacking objects: 100% (60/60), done.<jupyter_text>Ramachandran Plotter[Ramachandran Plotter (v2.0.2)](https://github.com/Joseph-Ellaway/Ramachandran_Plotter)<jupyter_code>!pip install numpy pandas matplotlib scipy biopython matplotlib argparse opencv-python
!wget https://files.rcsb.org/download/6GVE.pdb
!git clone https://github.com/Joseph-Ellaway/Ramachandran_Plotter.git
%cd Ramachandran_Plotter
!python RamachandranPlotter.py --pdb 6GVE.pdb --plot_type 0<jupyter_output>Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/matplotlib/texmanager.py", line 306, in _run_checked_subprocess
    stderr=subprocess.STDOUT)
  File "/usr/lib/python3.7/subprocess.py", line 411, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.7/subprocess.py", line 488, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.7/subprocess.py", line 800, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.7/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'latex': 'latex'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "RamachandranPlotter.py", line 163, in <module>
    main(pdb, itmod, model_num, itchain, chain_num, plot_type, out_dir, verb, save, file_type)
  File "RamachandranPlotter.py", line 136, in main
   [...]<jupyter_text>RamachanDrawNote: this uses BioPython, which returns angles in radians. These values need to be converted to degrees before plotting.<jupyter_code>!!pip install biopython RamachanDraw
from RamachanDraw import fetch, phi_psi, plot
# PDB id to be downloaded
PDB_id = '1MBN'
# Drawing the Ramachandran plot
plot(fetch(PDB_id))

# Generating a dictionary to store the phi and psi angles
# And returning the ignored aminoacid residues
phi_psi_dict, ignored_res = phi_psi(fetch(PDB_id), return_ignored=True)
phi_psi_dict
import csv

with open('/content/1mbn-rama.csv', 'w') as csv_file:
    writer = csv.writer(csv_file)
    writer.writerow(('amino_acid', 'phi', 'psi'))
    for key, value in phi_psi_dict.items():
        writer.writerow([key, value[0], value[1]])
import plotly.graph_objects as go
import pandas as pd
import plotly.express as px

df = pd.read_csv('/content/1mbn-rama.csv')
           
df.columns
df.psi # gets the data in the specified column
df = pd.read_csv('/content/1mbn-rama.csv')
print(df.head())
import plotly.graph_objects as go
import pandas as pd
import plotly.express as px

df = pd.read_csv('/content/1mbn-rama.csv')

# The above code creates a dataframe (df) from reading a csv file.

fig = go.Figure(data=[go.Table(
    header=dict(values=list(df.columns),
                fill_color='paleturquoise',
                align='center'),
    cells=dict(values=[df.amino_acid, df.phi, df.psi],
                fill_color='lavender',
                align='left'))
])

# The above code creates a figure from the dataframe,
# and styles the header and the cells of the table.

fig.update_layout(width=500) # limits the table to a width of 500px
fig.show() # shows the figure
# fig.write_image("rmsd-core.dat.png") # make a png of the figure
figscattertest = px.scatter(df, x="phi", y="psi",
                 hover_name="amino_acid" 
                 ) # x and y are the column names
figscattertest.update_traces(marker=dict(color='white'))
#@title General Plot
import plotly.express as px
import plotly.graph_objects as go
import pandas as pd

# Create dataframes for each file
dfgenaLLowed1 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-aLLowed1.csv')
dfgenaLLowed2 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-aLLowed2.csv')
dfgenaLLowed3 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-aLLowed3.csv')
dfgenaLLowed4 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-aLLowed4.csv')
dfgenaLLowed5 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-aLLowed5.csv')
dfgenaLLowed6 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-aLLowed6.csv')

dfgenfavored1 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-favored1.csv')
dfgenfavored2 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-favored2.csv')
dfgenfavored3 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-favored3.csv')
dfgenfavored4 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-favored4.csv')
dfgenfavored5 = pd.read_csv('/content/drive/MyDrive/rama8000/generaL-favored5.csv')

# ========== your dihedral data file here ==========
# dftest = pd.read_csv('/content/drive/MyDrive/rama8000/gen-data-good.csv')
# ==================================================


# ===== create figures =====
# x and y are the column names
figgenaLLowed1 = px.line(dfgenaLLowed1, x="phi", y="psi",
                 hover_name="number"
                ) 
# add line color
figgenaLLowed1.update_traces(line=dict(
    color = 'deepskyblue',
    width=1))

figgenaLLowed2 = px.line(dfgenaLLowed2, x="phi", y="psi",
                 hover_name="number" 
                 ) 
figgenaLLowed2.update_traces(line=dict(
    color = 'deepskyblue',
    width=1))

figgenaLLowed3 = px.line(dfgenaLLowed3, x="phi", y="psi",
                 hover_name="number" 
                 ) 
figgenaLLowed3.update_traces(line=dict(
    color = 'deepskyblue',
    width=1))

figgenaLLowed4 = px.line(dfgenaLLowed4, x="phi", y="psi",
                 hover_name="number" 
                 ) 
figgenaLLowed4.update_traces(line=dict(
    color = 'deepskyblue',
    width=1))

figgenaLLowed5 = px.line(dfgenaLLowed5, x="phi", y="psi",
                 hover_name="number" 
                 )                
figgenaLLowed5.update_traces(line=dict(
    color = 'deepskyblue',
    width=1))

figgenaLLowed6 = px.line(dfgenaLLowed6, x="phi", y="psi",
                 hover_name="number") 
figgenaLLowed6.update_traces(line=dict(
    color = 'deepskyblue',
    width=1))

figgenfavored1 = px.line(dfgenfavored1, x="phi", y="psi",
                 hover_name="number") 
figgenfavored1.update_traces(line=dict(
    color = 'deepskyblue',
    width=2))

figgenfavored2 = px.line(dfgenfavored2, x="phi", y="psi",
                 hover_name="number")
figgenfavored2.update_traces(line=dict(
    color = 'deepskyblue',
    width=2)) 

figgenfavored3 = px.line(dfgenfavored3, x="phi", y="psi",
                 hover_name="number") 
figgenfavored3.update_traces(line=dict(
    color = 'deepskyblue',
    width=2))

figgenfavored4 = px.line(dfgenfavored4, x="phi", y="psi",
                 hover_name="number") 
figgenfavored4.update_traces(line=dict(
    color = 'deepskyblue',
    width=2))

figgenfavored5 = px.line(dfgenfavored5, x="phi", y="psi",
                 hover_name="number") 
figgenfavored5.update_traces(line=dict(
    color = 'deepskyblue',
    width=2))

# ======== your data as a scatter plot ========



# =============================================

# ======= construct a composite figure =======

# don't forget your scatter plot data!
figgeneral = go.Figure(data=
                    figgenaLLowed1.data
                  + figgenaLLowed2.data
                  + figgenaLLowed3.data
                  + figgenaLLowed4.data
                  + figgenaLLowed5.data
                  + figgenaLLowed6.data
                  + figgenfavored1.data
                  + figgenfavored2.data
                  + figgenfavored3.data
                  + figgenfavored4.data
                  + figgenfavored5.data
                  + figscattertest.data
                  )               

# turn off legend
# set color and size for the data points
figgeneral.update_traces(showlegend=False,
                         marker=dict(color='white',
                         size=4)
)

# change the graph width,
# add a graph title,
# add axes titles,
# set background color
figgeneral.update_layout(width=700, 
                         height=700, 
                         title_text="General",
                         # unicode for greek characters
                         xaxis=dict(title=u"\u03A6"),
                         yaxis=dict(title=u"\u03A8"),
                         plot_bgcolor="black"
                         )

# update the axes
figgeneral.update_xaxes(showline=True,
                  zeroline=True,
                  showgrid=False, 
                  range=(-180,180),
                  zerolinewidth=1,
                  zerolinecolor='grey'
)

figgeneral.update_yaxes(showline=True,
                   zeroline=True,
                   showgrid=False, 
                   range=(-180,180),
                   zerolinewidth=1,
                   zerolinecolor='grey'
)

# save an image of the graph
# fig.write_image("test1.png")

# show the graph
figgeneral.show()<jupyter_output><empty_output><jupyter_text>MDAnalysis Rama<jupyter_code>!pip install -q condacolab
import condacolab
condacolab.install()
!conda install -c conda-forge mdanalysis

import MDAnalysis as mda
from MDAnalysis.analysis.dihedrals import Dihedral
from MDAnalysis.analysis.dihedrals import Ramachandran
print(mda.__version__)
psf = mda.Universe("/content/drive/MyDrive/adk.psf")

print(psf)
u = mda.Universe("/content/drive/MyDrive/adk.psf", "/content/drive/MyDrive/adk_dims.dcd")
print(u)
print(len(u.trajectory))
u.atoms
protein = u.select_atoms('protein')
print('There are {} residues in the protein'.format(len(protein.residues)))
omegas = [res.omega_selection() for res in protein.residues[5:10]]
omegas[0].dihedral.value()
r = Ramachandran(u.select_atoms("protein"), check_protein=False).run()


from MDAnalysis.analysis.base import Results
print(r.results.angles)
import pandas as pd 
import numpy as np

# pd.DataFrame(r.results.angles)

df = r.results.angles

print(df)
print(type(df))<jupyter_output>[[[-103.52371989  129.97374003]
  [-127.41345798  131.99797348]
  [-101.22956631  139.01118182]
  ...
  [ -55.36503514  -46.15269629]
  [ -68.3059521   -35.93160727]
  [ -82.39446913  -68.29687375]]

 [[-101.140083    131.28320079]
  [-127.2286263   123.36634508]
  [-100.42295089  127.41342403]
  ...
  [ -56.43926858  -30.62061947]
  [ -81.92597937  -50.77547138]
  [ -74.45797863  -48.7247066 ]]

 [[-126.99922311  128.83294423]
  [-142.70339861  143.46664769]
  [-118.95378056  135.49073127]
  ...
  [ -58.34101648  -40.24845627]
  [ -76.22335305  -29.31211749]
  [ -92.49748988  -64.32427808]]

 ...

 [[-113.25037947  119.10505256]
  [-132.55558424  150.21343736]
  [-123.87515567  121.58839284]
  ...
  [ -36.70180796  -51.55572685]
  [ -86.72845962  -41.94075971]
  [ -72.32358177  -61.95805576]]

 [[-115.72918245  116.15395114]
  [-130.93826539  150.16488768]
  [-102.37344624  126.15339438]
  ...
  [ -64.45133991  -43.64728993]
  [ -82.69954916  -41.38594851]
  [ -74.26600997  -56.350072[...]<jupyter_text>`n_frames×n_residues×2` `numpy.ndarray` with content `[[[phi, psi], [residue 2], ...], [time step 2], ...]`.<jupyter_code>x3 = r.results.angles
print("x3 ndim: ", x3.ndim)
print("x3 shape:", x3.shape)
print("x3 size: ", x3.size)
# only 212 amino acids because first and last do not have 
# both phi and psi angles
print("x3 T:", x3.T)
# Defined x3 as the numpy.ndarray of r.results.angles 
# There are 19 time points, 212 amino acids, 2 values (phi and psi)
# Let's look at the first time point, first amino acid, second angle (psi)
print(x3[0,0,1])
# x3[:first time point, :first amino acid, :two values (both phi and psi)]

print(x3[:1, :1, :2])
# x3[:first 3 time points, :first 2 amino acids, :two values (both phi and psi)]

print(x3[:3, :2, :2])
y=output[:,0] , y=output[:,1], y=output[:,2]
import plotly.express as px
df2 = px.data.gapminder()
print(df2)
# just a test
# abridged_data = {'wandered': [[2005, 5.807135648994622e-06], [2006, 5.7273128507756315e-06], [2007, 6.7032709205293806e-06], [2008, 8.777680961941695e-06]], 'airport': [[2007, 1.0841708003745173e-05], [2008, 8.89465511574262e-06]], 'request': [[2005, 4.479519997292191e-05], [2006, 4.427159014360846e-05], [2007, 4.3048248627066294e-05], [2008, 4.081853901820637e-05]]}
# for key,value in abridged_data.items():
#     x = value[:,0]
#     y = value[:,1]
#     plt.plot(x,y,label=key)
# plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1431178103927013, 'fraction_numerical': 0.09028163427211425, 'mean_word_length': 3.2688791059939044, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '191544', 'license': 'MIT', 'n_tokens_mistral': 5347, 'n_tokens_neox': 4543, 'n_words': 893, 'path': 'to_delete.ipynb', 'repo_name': 'dgoppenheimer/Molecular-Dynamics', 'size': '12605'}