#!/usr/bin/python # Count charge of polypeptide as in [1] # (c) 2008 Tobias Abenius, licence: GPL # 1. Yu Shi, Coreceptor Usage and Sensitivity to Neutralization of HIV-1 & HIV-2 from sys import argv, stderr, exit def count(cond,l): return sum(map(cond,l)) def charge(seq): seq = seq.lower() positive = lambda c: c in 'rk' negative = lambda c: c in 'ed' return count(positive,seq) - count(negative,seq) if __name__ == "__main__": if len(argv) != 2: stderr.write("Syntax: %s " % argv[0]) exit(1) stderr.write("Reading sequences separated by newline from file '%s'\n" % argv[1]) for row in file(argv[1]).readlines(): print charge(row)