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.
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:
Patch PyRAMA to allow
ramachandranfunction 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.
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) + '.png' ramachandran((pdb_filename,), img_filename)
I did not test the code, but I hope you get an idea.