<snip>
My mistakes, the first generated-data has some problems:
the newly uploaded
tar.gz one is:
https://docs.google.com/open?id=0B93SVRfpVVg3Mjk0YjYzYTMtNzgzZS00NDk4LWI1M2QtNGE5OGZlMjYyNmM5
zip one is
https://docs.google.com/open?id=0B93SVRfpVVg3MDYwZWMzYzItYmI4ZC00MmIxLTg0NmMtMzM5MzZkZTAxZjJl
The below code generated those data has problems in appending parts
(reading mulitiple files), I don't know which parts was wrong:
#!/usr/bin/python3
import os.path
from itertools import groupby
DICTIONARYFILE="dictionary.pdb"
INFILEEXT=".out"
OUTFILEEXT=".txt"
mapping={}
def generate_dict(dictionarysourcefile):
for line in open(dictionarysourcefile,"r"):
parts=line.strip().split()
mapping[parts[2]]=parts[0]
def fetchonefiledata(dictionary,infilename):
with open(infilename,"r") as f:
residues=[]
residueID=[]
residues=[dictionary[line.split()[2]] for line in f]
print(residues)
for i in range(len(residues)):
residueID.append(residues[i][:-3])
remove_coming_dup(residueID)
def remove_coming_dup(a_list):
b_list=a_list[0:1]
for x in a_list[1:]:
if x != b_list[-1]:
b_list.append(x)
with open(base+OUTFILEEXT,"w") as f:
for index, b in enumerate([b_list]):
print(b,file=f)
if __name__=="__main__":
generate_dict(DICTIONARYFILE)
for filename in os.listdir("."):
base, ext = os.path.splitext(filename)
if ext == INFILEEXT:
fetchonefiledata(mapping,filename)