nowadays I have the PDB file I need but I would like to get the HETNAM information automatically by running python scripts.
Please show me how to do this! thank you very much
nowadays I have the PDB file I need but I would like to get the HETNAM information automatically by running python scripts.
Please show me how to do this! thank you very much
In pseudocode, with links to the appropriate documentation:
This should work (hopefully). [?]
f_in = open('/home/pdb/filename.pdb', 'r')
for line in f_in:
# print the line when HETNAM is found
if line.startswith('HETNAM'):
print line
f_in.close() [?]
One Unix command line will do the job even quicker: [?] grep HETNAM /home/pdb/filename.pdb [?]
Mark, I advise you to read and learn a bit about common Unix tools such as grep, awk, sed...
//Open the file
file = open('/home/pdb/filename.pdb', 'w')
//print to check file is loaded or not
print file
// iterate through the file till the end of file for line in file.readline():
//check weather line is containing the Keyword
if line == 'HETNAM'
//if yes the print the line or store it in another string
print line
Sorry but the above Python code is incorrect. Indeed, // are not used for comments (# instead), never use 'file' as a variable name since it is already used by Python, use the 'r' mode to read a file (not the 'w' one), the 'if' statement must be terminated by a colon (:) and eventually indentation is mandatory in Python code.
Sorry but the above Python code is totally wrong.
f_in = open('/home/pdb/filename.pdb', 'r')
for line in f_in: # print the line when HETNAM is found if line.startswith('HETNAM'): print line
f_in.close()
One line of Unix command line will do the job even quicker: grep HETNAM /home/pdb/filename.pdb
Mark, I will advise you to read and learn a bit about common Unix tools such as grep, awk, sed...
Sorry but the above Python code is incorrect. Indeed, // are not used for comments (# instead), never use 'file' as a variable name since it is already used by Python, to read a file use the 'r' mode not the 'w' one that is used to write a file, the 'if' statement must be terminated by a colon (:) and eventually indentation is mandatory in Python code
Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
What have you tried so far?
The problem with this kind of question: it's unreasonable to expect other people to simply "write your code for you", without giving some indication that you have made an effort. And in the long run, that won't help you anyway. If your problem is that you know little/no Python, then you need to learn some, then come back when you have specific problems. If you just want some working code, search Google for "python pdb parser"; you'll find plenty of examples and useful libraries (hint: BioPython).
I only can find whether the file has HETNAM or not but i cannot extract the information within the hetnam and formul
HETNAM M3L N-TRIMETHYLLYSINE
FORMUL 3 M3L 2(C9 H21 N2 O2 1+)
FORMUL 5 HOH *63(H2 O)
this is the information I want thank you