import glob def file_list(): files=[] for file in glob.glob("*.pdb"): files.append(file) files=sorted(files,key=lambda x: int(x[:-4])) return files def split_pdb(pdb_file,files_list,label1,label2): f_pdb=open(pdb_file,"r") lines=f_pdb.readlines() i=0; for line in lines: if i==12: break f_store=open(files_list[i],"a+") if label1 in line.strip(): i+=1 f_store.write(line) print "I am here" f_store.close() continue elif line.strip()==label2: continue else: f_store.write(line) if __name__=="__main__": file_lists=file_list() split_pdb("hex6-dna.pdb1",file_lists,"TER","ENDMDL")
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/8459.html