from __future__ import with_statement
import os, glob
mypath = '/home/sb/bioinfo/test/'
AACharge = {"C":-.045,"D":-.999,"E":-.998,
for x in glob.glob(mypath+'*.fas'):
    with open(os.path.join(mypath,x),'U') as fh:
        name = fh.readline()[1:-1]
        seq = ""
        for line in fh:
            seq += line[:-1].upper()
    charge = -0.002
    for aa in seq:
        charge += AACharge.get(aa,0)
    with open(os.path.join(mypath,'netvalue.txt'),'a') as fh:

This code is part of the book "Python for Bioinformatics", by Sebastian Bassi ( Return to home page.