Пример #1
0
    def convert_function(self, item):
        id_pattern = '\/(?P<id>\w{4}_\d+)_'

        #dockDestPath = os.path.join(self.dockingFolderPath)

        receptor = item['receptor']
        ligand_box = item['ligand_box']
        ligand = item['ligand']

        cry_id = re.search('\/(?P<id>\w{4}_\d+)_',
                           ligand_box).groupdict()['id']
        cry_rec = cry_id.split('_')[0]
        #print ligand
        dec_id = re.search('\/(?P<id>[a-zA-Z0-9]+_decoys_\d+).pdb',
                           ligand).groupdict()['id']

        destFileName = cry_id + '_' + dec_id + '.pdb'
        dest_ligand = os.path.join(self.dockingFolderPath, cry_rec,
                                   destFileName)
        try_create_chain_parent_folder(dest_ligand)
        cmd = "{} -r {} -l {} --autobox_ligand {} -o {} --num_modes=1000 --energy_range=1000 --cpu=1 ".format(
            FLAGS.smina, receptor, ligand, ligand_box, dest_ligand)

        print cmd
        if not os.path.exists(dest_ligand):

            os.system(cmd)
Пример #2
0
def convert(fast_file_path):

    fast_name = os.path.basename(fast_file_path)
    mix_name = fast_name.replace('ligand_fast', 'ligand_mix')
    mix_name = mix_name.replace('.pdb', '.av4')
    receptor = fast_name.split('_')[0]

    crystalFolder = os.path.join(FLAGS.crystalPath, receptor)
    similar_crystal = get_similar_crystal_file(crystalFolder, fast_file_path)

    ligand_coords, ligand_atom_type, ligand_afinity = parseLigand(
        fast_file_path)

    print 'parsed {} , shape'.format(fast_name)
    print ligand_coords.shape

    filtered_coords, filtered_affinity = overlap_filter(
        similar_crystal, ligand_coords, ligand_afinity)

    mix_dest_path = os.path.join(FLAGS.mix_path, receptor, mix_name)

    try_create_chain_parent_folder(mix_dest_path)

    save_av4(mix_dest_path, filtered_affinity, ligand_atom_type,
             filtered_coords)
Пример #3
0
def convert():
    source = '/home/ubuntu/xiao/data/overlap/crystal_ligands'
    dest = '/home/ubuntu/xiao/data/overlap/crystal'
    for sourcePath in glob(os.path.join(source,'*','*.pdb')):
        destPath = re.sub(source,dest,sourcePath)
        cmd = 'obabel -ipdb {} -opdb {}'.format(sourcePath,destPath)
        try_create_chain_parent_folder(destPath)
        os.system(cmd)
Пример #4
0
    def convert_function(self, item):
        dockDestPath = os.path.join(self.dockingFolderPath)
        receptor = item['receptor']
        ligand_box = item['ligand_box']
        ligand = item['ligand']
        dest_ligand = ligand.replace(FLAGS.dockSourcePath, dockDestPath)
        try_create_chain_parent_folder(dest_ligand)
        cmd = "{} -r {} -l {} --autobox_ligand {} -o {} --num_modes=1000 --energy_range=1000 --cpu=1 ".format(
            FLAGS.smina, receptor, ligand, ligand_box, dest_ligand)

        if not os.path.exists(dest_ligand):
            print cmd
            os.system(cmd)
Пример #5
0
def convert(offset=None):
    files = glob(os.path.join(sourcePath, '*.pdb'))
    index = range(offset - 1, len(files),
                  FLAGS.orchestra_jobsize) if offset else range(0, len(files))
    for i in index:
        sourceFilePath = files[i]
        destFilePath = sourceFilePath.replace(sourcePath, destPath)
        destFilePath = destFilePath.replace('.pdb', '.mol2')
        try_create_chain_parent_folder(destFilePath)
        cmd = 'obabel -ipdb {} -omol2 -O {}'.format(sourceFilePath,
                                                    destFilePath)
        os.popen(cmd)
        print cmd
Пример #6
0
def select(index=None):
    count = 0
    ligand_list = glob(os.path.join(FLAGS.sourcePath, '*', '*.pdb'))
    if index:
        segment = len(ligand_list) / 1000
        indexes = range((index - 1) * segment, index * segment)
    else:
        indexes = range(len(ligand_list))
    for ind in indexes:
        ligand = ligand_list[ind]
        count += 1
        print count
        dest_ligand = ligand.replace(FLAGS.sourcePath, FLAGS.destPath)
        dest_ligand = dest_ligand.replace('.', '_1.')
        try_create_chain_parent_folder(dest_ligand)
        cmd = 'obabel -ipdb {} -f 1 -l 1 -opdb -O {}'.format(
            ligand, dest_ligand)
        if not os.path.exists(dest_ligand):
            os.system(cmd)
Пример #7
0
def convert(fast_path):
    file_name = os.path.basename(fast_path)

    dest_name = file_name.replace('.pdb', '.av4')
    file_id = re.search('(^[a-zA-Z0-9]{4}_\d+)', file_name).group()
    receptor = file_name.split('_')[0]

    crystalFolder = os.path.join(FLAGS.crystalPath, receptor)
    similar_crystal = get_similar_crystal_file(crystalFolder, fast_path)
    lig_coords, lig_elements, lig_affinity = parsePDB()

    filtered_coords, filtered_affinity = overlap_filter(
        similar_crystal, lig_coords, lig_affinity)

    av4_dest_path = os.path.join(FLAGS.super_dest_path, receptor, dest_name)

    try_create_chain_parent_folder(av4_dest_path)

    save_av4(av4_dest_path, filtered_affinity, lig_elements, filtered_coords)
Пример #8
0
    def downloads(self,item):
        download_address = self.get_address(item)
        if os.path.exists(os.path.join(FLAGS.rowdata_folder,item+'.pdb')):
            print item," exists"
            return None
        print 'download ',item
        os.system('wget -P {}  {}'.format(FLAGS.rowdata_folder,download_address))

        pdbname = item.lower()
        ligand_folder = os.path.join(FLAGS.splited_ligand_folder,pdbname)
        try_create_chain_folder(ligand_folder)

        try:
            parsed = prody.parsePDB(os.path.join(FLAGS.rowdata_folder,item+'.pdb'))
        except:
            self.error_log('can not parse {}.\n'.format(item))
            return None
        
        hetero = parsed.select('(hetero and not water) or resname ATP or resname ADP or sesname AMP or resname GTP or resname GDP or resname GMP')
        receptor = parsed.select('protein or nucleic')
        if receptor is None:
            self.error_log("{} doesn't have receptor.\n".format(item))
            return None
        if hetero is None:
            self.error_log("{} doesn't have ligand.\n".format(item))
            return None
        ligand_flags = False
        for each in prody.HierView(hetero).iterResidues():
            if each.numAtoms() <= 10:
                continue
            else:
                ligand_flags = True
                ResId = each.getResindex()
                ligand_path = os.path.join(FLAGS.splited_ligand_folder,pdbname,"{}_{}_ligand.pdb".format(pdbname,ResId))
                try_create_chain_parent_folder(ligand_path)
                prody.writePDB(ligand_path,each)

        if ligand_flags:
            receptor_path = os.path.join(FLAGS.splited_receptor_folder,pdbname+'.pdb')
            prody.writePDB(receptor_path,receptor)
        else:
            self.error_log("{} doesn't convert, not ligand have more than 10 atoms.\n".format(item))
Пример #9
0
    def entry_convert(self, item, coded):
        '''
        original pdb file contains multiple frames
        use obabel for select one frame from it

        :param item: row of dataframe
        :param coded: bool
        :return:
        '''
        source_file_path = item["SourcePath"]
        if coded:
            dest_file_path = item['code_destpath']
        else:
            dest_file_path = item['DestPath']
        Id = item['FrameId']

        cmd = 'obabel -ipdb {} -f {} -l {} -opdb -O {}'.format(source_file_path, Id, Id, dest_file_path)


        try_create_chain_parent_folder(dest_file_path)

        if not os.path.exists(dest_file_path):
            os.popen(cmd)
Пример #10
0
    def convert_function(self, item):
        destPath = os.path.join(self.dockingFolderPath, 'fast',
                                'decked_ligands')

        sourceFileName = item['Id'] + '_ligand_fast.pdb'

        destFileName = item['Id'] + '_ligand_fast_.pdb'

        sourceFilePath = os.path.join(FLAGS.sourcePath, item['PDBname'],
                                      sourceFileName)

        destFilePath = os.path.join(destPath, item['PDBname'], destFileName)

        try_create_chain_parent_folder(destFilePath)

        cmd = 'obabel -ipdb {} -opdb -O {} -m'.format(sourceFilePath,
                                                      destFilePath)

        receptor_folder = os.path.join(self.dockingFolderPath, 'fast',
                                       'receptors')
        receptor_source = os.path.join(FLAGS.receptor_source, item['PDBname'],
                                       item['PDBname'] + '.pdb')
        receptor_dest = os.path.join(receptor_folder, item['PDBname'],
                                     item['PDBname'] + '.pdb')

        if not os.path.exists(receptor_dest):
            try_create_chain_parent_folder(receptor_dest)
            os.system('cp {} {}'.format(receptor_source, receptor_dest))

        crystal_folder = os.path.join(self.dockingFolderPath, 'fast',
                                      'crystal_ligands')
        crystal_source = os.path.join(FLAGS.crystal_source, item['PDBname'],
                                      item['Id'] + '_ligand.pdb')
        crystal_dest = os.path.join(crystal_folder, item['PDBname'],
                                    item['Id'] + '_ligand.pdb')

        if not os.path.exists(crystal_dest):
            try_create_chain_parent_folder(crystal_dest)
            os.system('cp {} {}'.format(crystal_source, crystal_dest))

        #print cmd
        os.system(cmd)