Answers.Body: <p>You could probably use <a href="https://github.com/gerdos/PyRAMA" rel="nofollow noreferrer">PyRAMA</a> for that. The only problem is that by PyRAMA plots to display, while you probably would like to save to a file.</p>
  
  <p>One way to get around this is to:</p>
  
  <ol>
  <li><p>Patch PyRAMA to allow <code>ramachandran</code> function to accept output image filename.</p>
  
  <pre><code>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()
  </code></pre>
  
  <p>If this works as expected I would really <strong>encourage</strong> you to submit a <strong>pull-request</strong> (or at least open an issue) on github.</p></li>
  <li><p>Now you can write your main script:</p>
  
  <pre><code>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)
  </code></pre></li>
  </ol>
  
  <p>I did not test the code, but I hope you get an idea.</p>
  
  <p>There are also other ways to make a ramachandran plot in python. Please check: <a href="https://warwick.ac.uk/fac/sci/moac/people/students/peter_cock/python/ramachandran/drawing/" rel="nofollow noreferrer">1</a>, <a href="http://azevedolab.net/resources/rama_plot_py.pdf" rel="nofollow noreferrer">2</a>, <a href="http://mdtraj.org/latest/examples/ramachandran-plot.html" rel="nofollow noreferrer">3</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-07-19T11:31:45.933Z
Answers.LastActivityDate: 2018-07-19T11:31:45.933Z
Answers.UserDisplayName: Iakov Davydov
Body: <p>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.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-19T12:09:23.613Z
Comments.Text: 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?
Comments.UserDisplayName: terdon
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-20T17:56:24.443Z
Comments.Text: @terdon It seems the flag for homework is missing. No homework policy yet? This is pretty standard introductory task.
Comments.UserDisplayName: Mithoron
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-07-20T18:27:20.477Z
Comments.Text: @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!
Comments.UserDisplayName: terdon
Tags: <python><file-formats><pdb>
Title: Plotting Ramachandran Plot from more than one PDB file
ThreadText: # Plotting Ramachandran Plot from more than one PDB file
  
  (Asked by: username_0 on 2018-07-19)
  
  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.
  
  **Tags:** python, file-formats, pdb
  
  > **Comments:**
  > **username_1**: 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?  
  > **username_2**: @username_1 It seems the flag for homework is missing. No homework policy yet? This is pretty standard introductory task.  
  > **username_1**: @username_2 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!  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2018-07-19. Score: 2
  
  You could probably use [PyRAMA](https://github.com/gerdos/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](https://warwick.ac.uk/fac/sci/moac/people/students/peter_cock/python/ramachandran/drawing/), [2](http://azevedolab.net/resources/rama_plot_py.pdf), [3](http://mdtraj.org/latest/examples/ramachandran-plot.html).
  
  
  ---
  
  