Hello,
In MS, I'd like to assign atomic charge values from external file.
The file format is first four lines should be passed and from the 5th line, the atomic charge values are listed in order of atomic number.
Is it possible to do it using script file?
Thanks for your help in advance.
Regards,
Young

Hi Young,
Yes it is possible to assign charges (and charge groups in 6.0!) in a script. To assign a charge is as simple as:
$atom->Charge = 0.15;
The challenge in your case is making sure the atoms in the structure match the atoms in the charge file. How do you intend to do that?
Best,
/Jason
Hi, Jason,
Thanks for the answer, Jason.
1. It is not clear to me that $atom->Charge = 0.15 in that atom number (atom ID) is not shown in this command.
If there are 10 atoms and I'd like to assign (maybe different) charges to them resepectively, what command should be used?
I supposed that atom ID would be given for it.
2. I'd like to read the data from the file and assign them to the charge of atoms (maybe using the command similar to the one you indicated).
I know PYTHON and can read data from the file using it. However, I am not familar to PERL and I asked the script for it which will be not so difficult for PERL experts, I guess.
3. Incidentally asking, would you let me know what' "charge groups" mean in your reply, different from normal atomic charge?
Best regards,
Young
Hi Young,
In Materials Studio there are no atom ID's. But you can reference them using a loop index. Here is an example of what you might do:
for (my $i=0; $i < $atoms->Count; $i++)
{my $charge = $textDocument->Lines($i);
$atoms->[$i]->Charge = $charge;
}
This example assumes the text file has one charge on each line and the charges are in the same order as they are in the structure document. Please consult the help manual for more information on scripting as there are many examples there of these types of scripts.
Best,
/Jason
Dear Jason,
Many thanks for your answer, Jason.
I'd like to some additional questions as follows.
1. I am not familar to using the script file in visualizer.
Let's assume that I opened two windows and one is a certain pdb file consisting of 100 atoms and the other is my target pdb file consisting of 100 atoms.
Then, how I can run pl file for the second windows?
I upload a.pl file containing the your scripts in the third window.
2. In your script, textDocument is the external file for charge data.
Then, is it right that this file should be located in the same directory of script file (a.pl)?
Thanks a lot for your reply in advance.
Regards,
Young
I will be out of office starting 02/20/12 and will not return until 02/21/12. I will respond to your message when I return. Thanks.
Hi Young,
It sounds like your question is basically "How do I run a script that does something with a structure file?" If this is your first time running a script, you should note that there are a number of examples in the Help manual, in the Examples folder and on this forum. Try consulting the section on Documents in the Help manual and note that there are also a couple of scripting tutorials there. If you have any specific questions, post them here.
Good luck!
/Jason