Hi Pablo,
It sounds like what you want to do is open a PDB file, fit it to a map, and then write out the PDB with the fitted coordinates rather than the original coordinates.  Is that right?  If so, you should look at the Very Basic Chimera Programming Primer for an example of looping through a series of data files and performing operations on them.  The key thing for your purposes is that you want to use the “write” command with the “relative” option in order to write the PDB file relative to the map — so if the map was model 0 and the PDB was model 1, then “write relative 0 1 output_file_name.pdb”.

—Eric

Eric Pettersen
UCSF Computer Graphics Lab

On Mar 12, 2018, at 1:42 AM, Pablo Solar Rodríguez <pablosolar.r@gmail.com> wrote:

Hello all!

I'm looking to the scripts (http://plato.cgl.ucsf.edu/trac/chimera/attachment/wiki/Scripts/) and can not see a simple example of how to open a PDB.

What I need to my extension is to save a PDB relative to a map and then open it to the model panel.

Copying it to the model panel does not make sense to me because I need to fix the positions of the moved PDB relative to the map.

Could it be something like this?

        # Get opened molecule (the one selected in the menu)
        m = self.object_menu.getvalue()
    
        # Make copy using the copy_molecule native functionality from Chimera
        from Molecule import copy_molecule
        mc = copy_molecule(m)
    
        # Set copy name
        mc.name = m.name.split('.')[0] + '_' + self.chosen_solution + '.pdb'
copy_path = self.cwd + mc.name

        from Midas import open, write
        write(mc, self.map_menu.volume(), self.cwd)
open(self.cwd)

Thank you in advance!
_______________________________________________
Chimera-dev mailing list
Chimera-dev@cgl.ucsf.edu
http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev