Exemple #1
0
def split_protein_molecule_complex_manual(st_path,root_dir = 'processed_data_protein_molecule'):
    """
    @params:complex structure file path
    @return receptor,small molecule
    """
    complex_id,_ = fileutils.splitext(os.path.basename(st_path))
    root_dir
    if not os.path.exists(root_dir):
        os.mkdir(root_dir)

    result_save_path = os.path.join(root_dir,complex_id)

    if not os.path.exists(result_save_path):
        os.mkdir(result_save_path)

    rec_fname = '%s/%s_receptor.pdb' %(result_save_path,complex_id)
    bind_fname = '%s/%s_binder.pdb' %(result_save_path,complex_id)
    with open(rec_fname,'w') as rec:
        with open( bind_fname,'w') as bind:
            with open(st_path) as f:
                for line in f.readlines():
                    if start_with_atom(line):
                        rec.write(line)
                    elif belongs_to_molecule(line):
                        bind.write(line)
    rec_id,_ = fileutils.splitext(os.path.basename(rec_fname))
    bind_id,_ = fileutils.splitext(os.path.basename(bind_fname))

    rec = structure.StructureReader(rec_fname).next()
    rec.title = rec_id

    bind = structure.StructureReader(bind_fname).next()
    bind.title = bind_id

    return rec,bind
Exemple #2
0
def split_protein_protein_complex_manual(st_path,root_dir):
    """
    @params:complex structure file path
    @return antibody structure, antigen structure
    """
    complex_id,_ = fileutils.splitext(os.path.basename(st_path))

    if not os.path.exists(root_dir):
        os.mkdir(root_dir)
    result_save_path = os.path.join(root_dir,complex_id)
    if not os.path.exists(result_save_path):
        os.mkdir(result_save_path)

    ab_fname = '%s/%s_antibody.pdb' %(result_save_path,complex_id)
    ag_fname = '%s/%s_antigen.pdb' %(result_save_path,complex_id)
    with open(ab_fname,'w') as ab_f:
        with open( ag_fname,'w') as ag_f:
            with open(st_path) as f:
                for line in f.readlines():
                    if start_with_atom(line):
                        if belongs_to_antibody(line):
                            ab_f.write(line)
                        else:
                            ag_f.write(line)

    antibody_id,_ = fileutils.splitext(os.path.basename(ab_fname))
    antigen_id,_ = fileutils.splitext(os.path.basename(ag_fname))

    antibody = structure.StructureReader(ab_fname).next()
    antibody.title = antibody_id

    antigen = structure.StructureReader(ag_fname).next()
    antigen.title = antigen_id

    return antibody,antigen
def split_protein_protein_complex_manual(complex_path='',antigen_path='',antibody_path=''):
    """
    @params:complex structure file path,to be saved antigen path,to be saved antibody path
    @return antibody structure, antigen structure
    """

    with open(antibody_path,'w') as ab_f:
        with open(antigen_path,'w') as ag_f:
            with open(complex_path) as f:
                for line in f.readlines():
                    if start_with_atom(line):
                        if belongs_to_antibody(line):
                            ab_f.write(line[:60]+'\n')
                        else:
                            ag_f.write(line[:60]+'\n')

    antibody_id,_ = fileutils.splitext(os.path.basename(antibody_path))
    antigen_id,_ = fileutils.splitext(os.path.basename(antigen_path))

    antibody = structure.StructureReader(antibody_path).next()
    antibody.title = antibody_id

    antigen = structure.StructureReader(antigen_path).next()
    antigen.title = antigen_id

    return antibody,antigen
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
    with open(fp_path,  'w') as out_fp:
        for key in rec_tree.fingerprints.sifts.keys():
            rec_tree.fingerprints.fill_missing_zeros(rec_tree.min_res,  rec_tree.max_res,  key)
            fp_string = rec_tree.fingerprints.get_sift_string(key)
            out_fp.write(rec_tree.receptor.title + ':' + key + ':' + str(rec_tree.min_res) + ':' + fp_string + '\n')

    print 'saved to',fp_path

    return fp_path

if __name__ == "__main__":
    rec_file = 'protein2protein/1A2Y_antigen.pdb'
    bind_file = 'protein2protein/1A2Y_antibody.pdb'

    basename,  ext = fileutils.splitext(os.path.basename(rec_file))

    rec_tree = distance_tree()

    #receptor data
    rec = structure.StructureReader(rec_file).next()

    if rec.title == "":
        rec.title = basename

    rec_tree.set_receptor_structure(rec)
    rec_tree.parse_receptor()

    #bind data
    basename,  ext = fileutils.splitext(os.path.basename(rec_file))
    bind = structure.StructureReader(bind_file).next()