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

How to add multiple lists to a script to count number of residues

P: 6
import os
print path
list_of_filenames=os.listdir(os.path.join(path, 'newfiles'))
print list_of_filenames
for f in list_of_filenames:
f1=open(os.path.join(path, 'newfiles', f)).readlines()
for line in f1:
if line.startswith('ATOM'):
if res_number not in residue and line[17:20]!='HOH':

Herewith I attach a txt file of my sample input.
in that file
column 1 represents ATOM or HETATM
column 2 represents atom number
column 3 represents atom type
column 4 represents name of the residue
column 5 represents the type of the chain
column 6 represents residue number

My question is how many residues are in this file?

It's complicated to find it because of even atom number changes in every line, residue number stands as a constant. Because in one residue there are different atoms.
Another thing is both in chain A and chain B, ALA is residue 542, but in chain A there is no 543rd residue, but in chain B there is 543rd residue. Therefore newly addition from chain B is only 543rd residue, otherwise values will be repeated.
I want to count number of residues of the file except water (HOH) molecules ?

So how can I count number of residues in this file?
Mar 15 '17 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 619
Didn't you already do this, i.e. count all in all files, in a previous post that asked how to count each file individually?
Mar 15 '17 #2

P: 6
@dwblas yes I got some answers. but they are unbelievable. So I think there is a problem with my codes. i.e repetition of values when counting.
So I need to know how to modify these codes. Please if you know the method can you help me ?
Mar 16 '17 #3

Post your reply

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