加入收藏 | 设为首页 | 会员中心 | 我要投稿 安卓应用网 (https://www.0791zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

用pytho写的分割pdb文件一个脚本

发布时间:2020-05-24 23:44:44 所属栏目:Python 来源:互联网
导读:用pytho写的分割pdb文件一个脚本

下面是脚本之家 jb51.cc 通过网络收集整理的代码片段。

脚本之家小编现在分享给大家,也给大家做个参考。

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")

以上是脚本之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得脚本之家网站内容还不错,欢迎将脚本之家网站推荐给程序员好友。

(编辑:安卓应用网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读