Re: [COOT] coot scripting

2023-10-16 Thread Paul Emsley


On 14/10/2023 23:34, Zhu JiaPeng wrote:


Dear all,

I am currently working with a protein containing multiple subunits. 
For each subunit, I need Coot to perform rigid body fitting followed 
by real-space refinement. Manually inputting the Python commands 
rigid_body_refine_zone(reso_start, resno_end, chain_id, imol) and 
refine_zone(imol, chain_id, resno1, resno2, altconf) and then pressing 
"accept" for each chain has proven to be quite tedious.


Is there a way to combine these commands into a single script for 
automation?



# Yes, indeed.


imol_model = read_pdb("tutorial-modern-chain-tweak.pdb")
imol_map   = make_and_draw_map("rnasa-1.8-all_refmac1.mtz", "FWT", 
"PHWT", "W", 0, 0)


set_refinement_immediate_replacement(1)
set_imol_refinement_map(imol_map)

for ch_id in chain_ids(imol_model):
    rigid_body_refine_zone(1, 93, ch_id, imol_model)
    accept_moving_atoms()
    residues = residues_in_chain(imol_model, ch_id)
    refine_residues(imol_model, residues)
    accept_moving_atoms()



# (Future) Coot 1 users should know this is not how the python API works 
now.



Paul.




To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


[COOT] coot scripting

2023-10-14 Thread Zhu JiaPeng
Dear all,

I am currently working with a protein containing multiple subunits. For each 
subunit, I need Coot to perform rigid body fitting followed by real-space 
refinement. Manually inputting the Python commands 
rigid_body_refine_zone(reso_start, resno_end, chain_id, imol) and 
refine_zone(imol, chain_id, resno1, resno2, altconf) and then pressing "accept" 
for each chain has proven to be quite tedious.

Is there a way to combine these commands into a single script for automation?

Best wishes,
Jiapeng
















To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [COOT] coot scripting question

2021-11-29 Thread Artem Evdokimov
Dear Cooters,

Thanks to the helpful advice of Paul, Clemens, Eddie, Mark, Marcin, and
Xavier I was able to put together a satisfactory solution to the problem at
hand. Because I am lazy I put it together in PERL, which is close to
useless to anyone with a modern approach to programming. However here's the
basic process outlined enough such that someone else should have no issues
writing their own in any language they choose :)

Step 1: create a scheme file 'coot.scm' which contains all relevant Coot
operations that lead to the creation of the Raster3D file for later
rendering. This file can contain all sorts of settings and procedures that
make your image pleasing to the eye - for Fo-Fc map+some residues it should
also contain the following commands:

(set-map-sampling-rate 1.3)
(handle-read-draw-molecule "Results/pL305-xzz
_pipedream/postrefine-pL305-xzz_ligand.restraints/refine.pdb")
(make-and-draw-map
"Results/pL305-xzz_pipedream/postrefine-pL305-xzz_ligand.restraints/refine.mtz"
"FOFCWT" "PHFOFCWT" "" 0 1)
(set-last-map-contour-level-by-sigma 2.8)
(set-go-to-atom-molecule 0)
(set-zoom 30)
(set-go-to-atom-chain-residue-atom-name "A" 910 " CE1")
(set-view-quaternion 0.573595106601715 -0.248451888561249 0.373379826545715
0.685456037521362)
(graphics-draw)
(raster3d "coot_his910.r3d")

An astute reader will note the lowering of sampling rate from default 1.8
because standard compilation of Raster3D has a relatively low polygon
limit, and maps tend to have a lot of polygons. Also at this point it is
fairly clear that I am processing multiple Pipedream (Global Phasing)
datasets :) My lazy way of dealing with multiple datasets is to
programmatically replace 'zz' with the actual dataset name.


Step 2: create a script that cycles through all the datasets (we have 700
or so) and runs

... # fix up the script file so the right files are being read
open my $in,  '<',  $file  or die "Can't read old file: $!";
   open my $out, '>', "$file.new" or die "Can't write new file: $!";

   while( <$in> )
 {
  s/zz/$index3/g;
  print $out $_;
 }
...
print `coot --no-graphics --no-startup --no-state-script --script
$scriptfile`; # this runs coot in background, without graphics
...
print `render < coot_his910e.r3d > coot_his910e.png`; # runs Raster3D with
default parameters, making a PNG file
...
print `mv coot_his910e.png $imgdir`; # moves PNG to where it should be

Step 3: Party! (actually in my case I aggregate the PNG files for viewing
all together, to see what our fragment screen caught)

Hope it helps someone do this next time the need comes up :)

Artem

- Cosmic Cats approve of this message


On Tue, Nov 23, 2021 at 3:03 PM Artem Evdokimov 
wrote:

> Dear Cooters!
>
> I am new to this list, but would love to get a little bit of help
> scripting Coot to do something for me, like this:
>
> 1. read one PDB and one MTZ file
> 2. center on a particular location (ideally defined as e.g. a residue)
> 3. orient in a particular way (defined as a matrix or however convenient)
> 4. contour a map (difference or other) at a particular level
> 5. output a snapshot
>
> (all of this without invoking graphical output as such because I need this
> to happen a few hundred times, for a few hundred PDB-MTZ pairs.
>
> Is it doable? Could someone recommend at least a barebones script for this?
>
> Many thanks :)
>
> Artem
>
> - Cosmic Cats approve of this message
>



To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [COOT] coot scripting question

2021-11-24 Thread Artem Evdokimov
Thank you again :)

Artem

- Cosmic Cats approve of this message


On Wed, Nov 24, 2021 at 5:27 PM Paul Emsley 
wrote:

>
> On 24/11/2021 18:22, Artem Evdokimov wrote:
>
> Thank you Paul
>
> And many thanks to several kind folks who answered privately!
>
> It is always exciting to hear from the coot-master himself :)
>
> Sounds like I may have to cheat the graphics somehow or use pymol or
> raster3d.
>
> Artem
>
> On Wed, Nov 24, 2021, 10:01 AM Paul Emsley 
> wrote:
>
>> On 23/11/2021 20:03, Artem Evdokimov wrote:
>> > Dear Cooters!
>> >
>> > I am new to this list, but would love to get a little bit of help
>> > scripting Coot to do something for me, like this:
>> >
>> > 1. read one PDB and one MTZ file
>> > 2. center on a particular location (ideally defined as e.g. a residue)
>> > 3. orient in a particular way (defined as a matrix or however
>> convenient)
>> > 4. contour a map (difference or other) at a particular level
>> > 5. output a snapshot
>> >
>> > (all of this without invoking graphical output as such because I need
>> > this to happen a few hundred times, for a few hundred PDB-MTZ pairs.
>> >
>> > Is it doable?
>>
>>
>> I think so.
>>
>>
>> > Could someone recommend at least a barebones script for this?
>>
>> Do this interactively for one case and then save the state. Then look at
>> 0-coot.state.py or 0-coot.state.scm. That should give you some clues.
>>
>> As for the graphical output screenshot, I have not worked out how to do
>> that without invoking X11, so the alternative is to use raster3d.  There
>> are some parameters to tweak the raster3d representation if you don't
>> like the default.
>>
>>
> The python interface to raster3d:
>
> raster3d("raster3d-example-ligand.r3d")
>
> Then (after) in the shell, run
>
> $ render < raster3d-example-ligand.r3d > raster3d-example-ligand.png
>
> Obviously if you have 100s of them you'd given them different files names
> and batch translate them in a script.
>
> Alternatively,
>
> raster_screen_shot()
>
> will run raster3d/render for you and produce "coot.png"
>
> You will then need to use your python file-system functions skills to
> rename that to something meaningful.
>
> (Ethan Merritt is the author of Raster3D.)
>
> Paul.
>
>
>
> --
>
> To unsubscribe from the COOT list, click the following link:
> https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1
>



To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [COOT] coot scripting question

2021-11-24 Thread Paul Emsley


On 24/11/2021 18:22, Artem Evdokimov wrote:

Thank you Paul

And many thanks to several kind folks who answered privately!

It is always exciting to hear from the coot-master himself :)

Sounds like I may have to cheat the graphics somehow or use pymol or 
raster3d.


Artem

On Wed, Nov 24, 2021, 10:01 AM Paul Emsley > wrote:


On 23/11/2021 20:03, Artem Evdokimov wrote:
> Dear Cooters!
>
> I am new to this list, but would love to get a little bit of help
> scripting Coot to do something for me, like this:
>
> 1. read one PDB and one MTZ file
> 2. center on a particular location (ideally defined as e.g. a
residue)
> 3. orient in a particular way (defined as a matrix or however
convenient)
> 4. contour a map (difference or other) at a particular level
> 5. output a snapshot
>
> (all of this without invoking graphical output as such because I
need
> this to happen a few hundred times, for a few hundred PDB-MTZ pairs.
>
> Is it doable?


I think so.


> Could someone recommend at least a barebones script for this?

Do this interactively for one case and then save the state. Then
look at
0-coot.state.py  or 0-coot.state.scm. That
should give you some clues.

As for the graphical output screenshot, I have not worked out how
to do
that without invoking X11, so the alternative is to use raster3d. 
There
are some parameters to tweak the raster3d representation if you don't
like the default.



The python interface to raster3d:

raster3d("raster3d-example-ligand.r3d")

Then (after) in the shell, run

$ render < raster3d-example-ligand.r3d > raster3d-example-ligand.png

Obviously if you have 100s of them you'd given them different files 
names and batch translate them in a script.


Alternatively,

raster_screen_shot()

will run raster3d/render for you and produce "coot.png"

You will then need to use your python file-system functions skills to 
rename that to something meaningful.


(Ethan Merritt is the author of Raster3D.)

Paul.





To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [COOT] coot scripting question

2021-11-24 Thread Artem Evdokimov
Thank you Paul

And many thanks to several kind folks who answered privately!

It is always exciting to hear from the coot-master himself :)

Sounds like I may have to cheat the graphics somehow or use pymol or
raster3d.

Artem

On Wed, Nov 24, 2021, 10:01 AM Paul Emsley 
wrote:

> On 23/11/2021 20:03, Artem Evdokimov wrote:
> > Dear Cooters!
> >
> > I am new to this list, but would love to get a little bit of help
> > scripting Coot to do something for me, like this:
> >
> > 1. read one PDB and one MTZ file
> > 2. center on a particular location (ideally defined as e.g. a residue)
> > 3. orient in a particular way (defined as a matrix or however convenient)
> > 4. contour a map (difference or other) at a particular level
> > 5. output a snapshot
> >
> > (all of this without invoking graphical output as such because I need
> > this to happen a few hundred times, for a few hundred PDB-MTZ pairs.
> >
> > Is it doable?
>
>
> I think so.
>
>
> > Could someone recommend at least a barebones script for this?
>
> Do this interactively for one case and then save the state. Then look at
> 0-coot.state.py or 0-coot.state.scm. That should give you some clues.
>
> As for the graphical output screenshot, I have not worked out how to do
> that without invoking X11, so the alternative is to use raster3d.  There
> are some parameters to tweak the raster3d representation if you don't
> like the default.
>
> Paul.
>
> 
>
> To unsubscribe from the COOT list, click the following link:
> https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1
>
> This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing
> list hosted by www.jiscmail.ac.uk, terms & conditions are available at
> https://www.jiscmail.ac.uk/policyandsecurity/
>



To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [COOT] coot scripting question

2021-11-24 Thread Marcin Wojdyr
Several years ago I needed a similar script. I don't remember the
details, but it still works, so perhaps you'll find it useful:
https://github.com/ccp4/dimple/blob/master/coots.py
The function basic_script there outputs a script that loads the data,
r3d_script outputs a script that generates input for Raster3D.

Marcin

On Tue, 23 Nov 2021 at 21:13, Artem Evdokimov  wrote:
>
> Dear Cooters!
>
> I am new to this list, but would love to get a little bit of help scripting 
> Coot to do something for me, like this:
>
> 1. read one PDB and one MTZ file
> 2. center on a particular location (ideally defined as e.g. a residue)
> 3. orient in a particular way (defined as a matrix or however convenient)
> 4. contour a map (difference or other) at a particular level
> 5. output a snapshot
>
> (all of this without invoking graphical output as such because I need this to 
> happen a few hundred times, for a few hundred PDB-MTZ pairs.
>
> Is it doable? Could someone recommend at least a barebones script for this?
>
> Many thanks :)
>
> Artem
>
> - Cosmic Cats approve of this message
>
> 
>
> To unsubscribe from the COOT list, click the following link:
> https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1



To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [COOT] coot scripting question

2021-11-24 Thread Paul Emsley

On 23/11/2021 20:03, Artem Evdokimov wrote:

Dear Cooters!

I am new to this list, but would love to get a little bit of help 
scripting Coot to do something for me, like this:


1. read one PDB and one MTZ file
2. center on a particular location (ideally defined as e.g. a residue)
3. orient in a particular way (defined as a matrix or however convenient)
4. contour a map (difference or other) at a particular level
5. output a snapshot

(all of this without invoking graphical output as such because I need 
this to happen a few hundred times, for a few hundred PDB-MTZ pairs.


Is it doable?



I think so.



Could someone recommend at least a barebones script for this?


Do this interactively for one case and then save the state. Then look at 
0-coot.state.py or 0-coot.state.scm. That should give you some clues.


As for the graphical output screenshot, I have not worked out how to do 
that without invoking X11, so the alternative is to use raster3d.  There 
are some parameters to tweak the raster3d representation if you don't 
like the default.


Paul.



To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


[COOT] coot scripting question

2021-11-23 Thread Artem Evdokimov
Dear Cooters!

I am new to this list, but would love to get a little bit of help scripting
Coot to do something for me, like this:

1. read one PDB and one MTZ file
2. center on a particular location (ideally defined as e.g. a residue)
3. orient in a particular way (defined as a matrix or however convenient)
4. contour a map (difference or other) at a particular level
5. output a snapshot

(all of this without invoking graphical output as such because I need this
to happen a few hundred times, for a few hundred PDB-MTZ pairs.

Is it doable? Could someone recommend at least a barebones script for this?

Many thanks :)

Artem

- Cosmic Cats approve of this message



To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


Re: [COOT] Coot scripting get imol number

2020-11-12 Thread Paul Emsley

On 12/11/2020 11:16, Luise Kandler wrote:

Dear Coot Users,

I was wondering if there is a python/scheme scripting command to catch/get the imol number of a certain map, 
that was opened in Coot. So far I could not find a suitable command in the Coot User Manual...




imol = handle_read_ccp4_map("test.map")



To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/


[COOT] Coot scripting get imol number

2020-11-12 Thread Luise Kandler

Dear Coot Users,

I was wondering if there is a python/scheme scripting command to  
catch/get the imol number of a certain map, that was opened in Coot.  
So far I could not find a suitable command in the Coot User Manual...


I would be really glad to get some feedback, thank you!

Cheers, Luise



To unsubscribe from the COOT list, click the following link:
https://www.jiscmail.ac.uk/cgi-bin/WA-JISC.exe?SUBED1=COOT=1

This message was issued to members of www.jiscmail.ac.uk/COOT, a mailing list 
hosted by www.jiscmail.ac.uk, terms & conditions are available at 
https://www.jiscmail.ac.uk/policyandsecurity/