Ejemplo n.º 1
0
def process_test_data(protein_path = 'test_protein',ligand_path = 'test_ligand',o_path = 'test_output'):
    for ligand_file in os.listdir(ligand_path):
        
        ligand_st_path = os.path.join(ligand_path,ligand_file)#Ligand file path
        protein_st_path = os.path.join(protein_path,ligand_file)#protein file path
        
        print ligand_st_path,protein_st_path


        if not os.path.exists(protein_st_path):#protein file not exist
            #print protein_st_path,'not exist'
            continue
        else:
            ligand_st = structure.StructureReader(ligand_st_path).next()
            protein_st = structure.StructureReader(protein_st_path).next()

            complex_id=ligand_file[:4]
            try:#dangerous
                fp_gen_path = fp_gen1.gen_fp(receptor=protein_st,binder=ligand_st,complex_id=complex_id,root_path=o_path)
            except:
                print complex_id,'cannot be processed'
            sift_path = os.path.join(complex_id,'pattern.dat')
            if os.path.exists(sift_path):
                print complex_id,'is processed'
                continue
            avg_sift_path = os.path.join(o_path,sift_path)
            avg_sift.gen_avg_sift(fp_gen_path,avg_sift_path)#generate average sift
def cal_avg_sift_from_complex(complex_path='data/HL_chain/1RD8-1918/complex.1000.pdb'):
    print complex_path
    _,chain_name,complex_id,instance_name = complex_path.split('/')

    p_chain_path=os.path.join('processed_data',chain_name)
    if not os.path.exists(p_chain_path):
        os.mkdir(p_chain_path)

    p_complex_path=os.path.join(p_chain_path,complex_id)
    if not os.path.exists(p_complex_path):
        os.mkdir(p_complex_path)

    p_instance_path=os.path.join(p_complex_path,instance_name)[:-4]
    if not os.path.exists(p_instance_path):
        os.mkdir(p_instance_path)

    antigen_path = os.path.join(p_instance_path,'antigen.pdb')
    antibody_path = os.path.join(p_instance_path,'antibody.pdb')
    print antigen_path,antibody_path 
    antibody,antigen = split_protein_protein_complex_manual(complex_path = complex_path,antigen_path = antigen_path ,antibody_path=antibody_path)

    fp_path = os.path.join(p_instance_path,'fp.out')
    print antibody,antigen
    try:
        fp_gen_path = fp_gen1.gen_fp(receptor=antibody,binder = antigen,fp_path= fp_path)#get the finger print
    except:
        print 'failed\n'
        return
    else:
        print 'good\n'

    sift_path=os.path.join(p_instance_path,'avg_sift.out')
    print sift_path
    avg_sift.gen_avg_sift(fp_gen_path,sift_path)#generate average sift
Ejemplo n.º 3
0
def cal_avg_sift_from_complex(complex_path='data/HL_chain/1RD8-1918/complex.1000.pdb',output_dir="/home/xiaohan/Desktop",split_fun=globals()['split_protein_protein_complex_manual']):
    if not os.path.exists(output_dir):
        os.mkdir(output_dir);
    binder_path = os.path.join(output_dir,'binder.pdb')
    receptor_path = os.path.join(output_dir,'receptor.pdb')
    split_fun(complex_path = complex_path,binder_path = binder_path ,receptor_path=receptor_path,chain_info_file = os.path.join(os.path.dirname(complex_path),u"新建文本文档.txt"))
    fp_path = os.path.join(output_dir,'fp.out')
    fp_gen_path = fp_gen1.gen_fp(receptor_file=receptor_path,binder_file = binder_path,fp_path= fp_path)#get the finger print
    #fp_gen_path = fp_gen1.gen_fp(receptor_file = binder_path,binder_file = receptor_path,fp_path= fp_path)#get the finger print

    sift_path=os.path.join(output_dir,'avg_sift.out')
    avg_sift.gen_avg_sift(fp_gen_path,sift_path)#generate average sift
Ejemplo n.º 4
0
def gen_protein_protein_complex_avg_sift(complex_st_path,processed_data_path = 'processed_data'):
    complex_id,  ext = fileutils.splitext(os.path.basename(complex_st_path))

    sift_path = '%s/%s/%s_pattern.dat' %(processed_data_path,complex_id,complex_id)

    if os.path.exists(sift_path):
        print complex_id,'is processed'
        return


    antibody, antigen = split_protein_protein_complex_manual(complex_st_path,processed_data_path)#load complex structure and split it

    fp_gen_path = fp_gen1.gen_fp(receptor=antibody,binder = antigen,complex_id = complex_id,root_path = processed_data_path)#get the finger print
    avg_sift.gen_avg_sift(fp_gen_path,sift_path)#generate average sift
    fp_fp = "%s/fp" %data_root_fp
    avg_sift_fp = "%s/avg_sift" %data_root_fp
    ligand_fp = "%s/ligand" %data_root_fp
    binder_fp= "%s/binder" %data_root_fp
    
    #create them
    prepare_dirs([fp_fp  , avg_sift_fp , ligand_fp , binder_fp])
    
    #calculation start
    for complex_fp in glob.glob(os.path.join(pdb_fp,'*')):
        name_with_pdb = os.path.split(complex_fp)[-1]
        complex_id = os.path.split(complex_fp)[-1].split('.')[0]
    
        #init paths
        cur_binder_fp = os.path.join(binder_fp , name_with_pdb)
        cur_ligand_fp = os.path.join(ligand_fp , name_with_pdb)
        cur_avg_sift_fp = os.path.join(avg_sift_fp , "%s.sift" %complex_id)
        cur_fp_fp = os.path.join(fp_fp , "%s.fp" %complex_id)
    
        #split complex into ligand and binder
        split_complex(complex_fp , cur_binder_fp , cur_ligand_fp , has_atom_or_hetatm, ATOM_as_binder)

        
        antibody , antigen = load_structure(cur_binder_fp) , load_structure(cur_ligand_fp)
        
        #generate finger print
        fp_gen_path = gen_fp(receptor=antibody,binder = antigen,fp_path= cur_fp_fp)#get the finger print

        #generate sift
        gen_avg_sift(cur_fp_fp,cur_avg_sift_fp)#generate average sift