# Plotting Ramachandran Plot from more than one PDB file

I want to plot a Ramachandran Plot for around 5000 PDB files in python that is saved in a folder in my system. I am searching for a way to make it without accessing each file by hard-coding each file name. Please tell if there is a way around this.

• Is your problem only how to avoid hardcoding file names? If so, please show us your code so we can adapt it. Or do you also need help in making the plot? What do you have so far? – terdon Jul 19 '18 at 12:09
• @terdon It seems the flag for homework is missing. No homework policy yet? This is pretty standard introductory task. – Mithoron Jul 20 '18 at 17:56
• @Mithoron no, we have no homework policy. And I hope we don't get one, to be honest. Questions can be good and clear, or bad and vague irrespective of whether they're homework. But feel very free to bring this up in meta if you think we should have one! – terdon Jul 20 '18 at 18:27

You could probably use PyRAMA for that. The only problem is that by PyRAMA plots to display, while you probably would like to save to a file.

One way to get around this is to:

1. Patch PyRAMA to allow ramachandran function to accept output image filename.

def ramachandran(file_name_list, output_image=None):
...
plt.tight_layout()
if output_image is not None:
plt.savefig(output_file, dpi=300)
else:
plt.show()


If this works as expected I would really encourage you to submit a pull-request (or at least open an issue) on github.

2. Now you can write your main script:

from glob import iglob

from rama_lib.ramachandran_calc import ramachandran

for pdb_filename in iglob('/my/dir/with/pdb/', '*.pdb'):
img_filename = pdb_filename.rsplit('.', 1)[0] + '.png'
ramachandran((pdb_filename,), img_filename)


I did not test the code, but I hope you get an idea.

There are also other ways to make a ramachandran plot in python. Please check: 1, 2, 3.