清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
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")