Well, you can't easily do it in your original script since AFAIK you can't capture the COM position into a variable. You could write a second script that opens your structure and then adds two helium atoms at the COM positions with:
import chimera
m = chimera.openModels.list()[0]
from chimera import Point
from BuildStructure import placeHelium
placeHelium("CM1", model=m, position=Point(x1, y1, z1))
placeHelium("CM2", model=m, position=Point(x2, y2, z2))
Then save the structure as PDB.
--Eric
Thanks a lot, It simply wasn't writing the output.txt because it couldn't import saveReplyLog module. Once I commented that line it just worked by running chimera --nogui --script http://myscript.py > output.txt.I have a follow up question:I have now printed two COM coordinates to my output.txt. I want to include these coordinates into my pdb as novel atoms which I will use later on to align in VMD the two COM COM to the z-axis of a simulation box. Is there a way to write a python operation that would use the coordinates of the COMs to perform the add atom function (same as tools> structure editor > build structure)? Or is it better to do it via shell script outside chimera?Thanks for the help.ValerioIl 2024-01-30 20:47 Eric Pettersen via Chimera-users ha scritto:Hi Valerio,
If you are running in nogui, there is no reply log. The output that would normally go to the reply log should be appearing on your shell's standard output. You just redirect the output to a file using your shell's builtin redirection capabilities.
--Eric
Eric Pettersen
UCSF Computer Graphics Lab
On Jan 30, 2024, at 12:59 AM, valerio chiarini via Chimera-users <chimera-users@cgl.ucsf.edu> wrote:
Dear Responsible,
I am trying to acquaint myself with "chimera --nogui --script" mode in
order to automatize some pdb processing for a pipeline. I manage to
search for pdb, to open the file, to select residues and to calculate
COM for the selection. On the shell, I get the COM coordinates but I
would like to print or store them to write them elsewhere. So the
question is how can I print the replylog from shell to a text file,
under the --nogui mode? I have tried with saveReplyLog but it doesn't
seem to work...Any suggestions are appreciated.
This is an excerpt from what I'm writing so far:
import os
from chimera import runCommand as rc
from chimera import replyobj
from chimera import saveReplyLog
#change to the folder containing the pdb files
os.chdir("xxx/yyy/zzz/ABC.pdb")
def find_string_with_substring(string, substring):
for s in strings:
if substring in s:
return s
return None
# list_files contain only the .pdb files
list_pdb_files = [fn for fn in os.listdir(".") if fn.endswith(".pdb")]
# specify the characters 'HLA' you want the filenames contain
HLA_characters = HLA
file_pdb_HLA = fins_string_with_substring(list_pdb_files,
HLA_characters)
print(list_pdb_files)
print(file_pdb_HLA)
nome = file_pdb_HLA
replyobj.status(Processing " + nome)
rc ("open " + nome)
rc ("select :1.232")
rc("measure center sel")
saveReplyLog("~/reply-log.txt")
Thank you so much
--
Dr. Valerio Chiarini
_Senior Scientist_
Proteins & Monoclona Antibodies Department b Takis Biotech
c/o Tecnopolo
Via di Castel Romano, 100
00128 Rome, Italy
Tel.: +39 06-50576077
Fax: +39 06-50576710
Email: chiarini@takisbiotech.it
Web: http://www.takisbiotech.it 196/03_
_Le informazioni contenute in questa comunicazione e gli eventuali
documenti allegati hanno carattere confidenziale, sono tutelate dal
segreto
professionale e sono ad uso esclusivo del destinatario. Nel caso questa
comunicazione Vi sia pervenuta per errore, Vi informiamo che la sua
diffusione e riproduzione C( contraria alla legge e preghiamo di darci
prontamente avviso e di cancellare quanto ricevuto. __Grazie._
_This e-mail message and any files transmitted with it are subject to
attorney-client privilege and contain confidential information intended
only for the person(s) to whom it is addressed. If you are not the
intended
recipient, you are hereby notified that any use or distribution of this
e-mail is strictly prohibited: please notify the sender and delete the
original message. __Thank you._
_______________________________________________
Chimera-users mailing list -- chimera-users@cgl.ucsf.edu
To unsubscribe send an email to chimera-users-leave@cgl.ucsf.edu
Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimera-users@cgl.ucsf.edu/
_______________________________________________
Chimera-users mailing list -- chimera-users@cgl.ucsf.edu
To unsubscribe send an email to chimera-users-leave@cgl.ucsf.edu
Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimera-users@cgl.ucsf.edu/
-- Dr. Valerio Chiarini_Senior Scientist_Proteins & Monoclona Antibodies Department – Takis Biotechc/o TecnopoloVia di Castel Romano, 10000128 Rome, ItalyTel.: +39 06-50576077Fax: +39 06-50576710Email: chiarini@takisbiotech.itWeb: http://www.takisbiotech.itD_.lgs. 196/03__Le informazioni contenute in questa comunicazione e gli eventualidocumenti allegati hanno carattere confidenziale, sono tutelate dal segretoprofessionale e sono ad uso esclusivo del destinatario. Nel caso questacomunicazione Vi sia pervenuta per errore, Vi informiamo che la suadiffusione e riproduzione è contraria alla legge e preghiamo di darciprontamente avviso e di cancellare quanto ricevuto. __Grazie.__This e-mail message and any files transmitted with it are subject toattorney-client privilege and contain confidential information intendedonly for the person(s) to whom it is addressed. If you are not the intendedrecipient, you are hereby notified that any use or distribution of thise-mail is strictly prohibited: please notify the sender and delete theoriginal message. __Thank you._