By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,587 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,587 IT Pros & Developers. It's quick & easy.

how to write a python script to count number of residues in a 'pdb' file

P: 6
import sys
import os
for line in f1:
if line.startswith('ATOM') or line.startswith('HETATM'):
if res_number not in residue and line[17-20]!='HOH' and line[17-20]!='WAT':
if res_total>=50 and res_total<=1000:

# please can anyone explain me what's wrong with this codes. as the output i want to know number of residues in this pdb file
Mar 6 '17 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 621
Your question is really to vague to answer; i.e we do not know what the input is and if you really are counting "residues" or something else in the file. Also, there are no code tags (see How to Ask a Question at so it would be a waste of time to try and guess as to the indentations. So the only helpful information is to add some print statements to see what is happening
Expand|Select|Wrap|Line Numbers
  1. res_number=line[22-26]
  2. print("res_number =", res_number)
  3. if res_number not in residue and line[17-20]!='HOH' and line[17-20]!='WAT':
  4.     print("res_number not in")
  5. else:
  6.     print("res_number else")
  7. ##  etc. 
Mar 6 '17 #2

P: 6
thank you very much for your kind explanation. I will proceed with this.
Mar 7 '17 #3

Post your reply

Sign in to post your reply or Sign up for a free account.