#!/usr/bin/python

def process(filename):
	"Process ATOM records in PDB file"
	f = file(filename)
	atoms = []
	for line in f:
		if not line.startswith("ATOM"):
			continue
		# ATOM records are fixed-format, so we cannot use whitespace for parsing
		if line[16] != ' ' and line[16] != 'A':	# Alternate location
			continue
		atom = (line[12:16],			# Atom name
				line[17:20],		# Residue type
				line[21],		# Chain id
				int(line[22:26]),	# Sequence number
				float(line[30:38]), float(line[38:46]), float(line[46:54]))
		atoms.append(atom)
	f.close()
	print len(atoms), "atoms in", filename

if __name__ == "__main__":
	import sys
	for filename in sys.argv[1:]:
		process(filename)
