[Tutor] how to fill zero value and join two column

amrita at iisermohali.ac.in amrita at iisermohali.ac.in
Wed Jul 22 20:03:39 CEST 2009


Hi,

I have two text file, having entries as
fileA
33 ALA H = 7.57 N = 121.52 CA = 55.58 HA = 3.89 C = 179.24
38 ALA H = 8.29 N = 120.62 CA = 54.33 HA = 4.04 C = 178.95
8 ALA H = 7.85  N = 123.95 CA = 54.67 HA =  C =
fileB
8 ALA  helix (helix_alpha, helix1)
21 ALA  helix (helix_alpha, helix2)
23 ALA  helix (helix_alpha, helix2)

now what i want that i will make another file in which the matching
entries from the two file get printed together along with zero values for 
those atoms which doesnot have nay value in fileA. so the reult will be
something like:-

fileC
8 ALA H = 7.85  N = 123.95 CA = 54.67 HA =0.00  C =0.00|8 ALA  helix
(helix_alpha, helix1)

I tried to merge these two files using commands like:-

from collections import defaultdict
>>> def merge(sources):
...   if __name__ == "__main__":
...        a = open("/home/amrita/alachems/chem100.txt")
...        c = open("/home/amrita/secstr/secstr100.txt")
...        def source(stream):
...            return (line.strip() for line in stream)
...        for m in merge([source(x) for x in [a,c]]):
...            print "|".join(c.ljust(10) for c in m)
...
but it is not giving any value.






Thanks,
Amrita Kumari
Research Fellow
IISER Mohali
Chandigarh
INDIA



More information about the Tutor mailing list