2
$\begingroup$

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.

$\endgroup$
3
  • $\begingroup$ 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? $\endgroup$
    – terdon
    Jul 19, 2018 at 12:09
  • $\begingroup$ @terdon It seems the flag for homework is missing. No homework policy yet? This is pretty standard introductory task. $\endgroup$
    – Mithoron
    Jul 20, 2018 at 17:56
  • $\begingroup$ @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! $\endgroup$
    – terdon
    Jul 20, 2018 at 18:27

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.