示例#1
0
文件: run.py 项目: avirshup/D3R
def blast_the_query(query, pdb_db, pdb_path, fasta, out_dir, compinchi):
    """
    Runs a blast search using the target sequence as a query
    :param query: an instance of blast.query.Query
    :param pdb_db: The absolute path to a BLASTP database
    :param pdb_path: The absolute path to a decompressed copy of the PDB
    :param fasta: A file with fasta sequences of each chain in the PDB
    :param out_dir: The path to the directory where results will be written
    :param compinchi: The absolute path to a file with InChI strings for each ligand in the PDB
    :return: query
    """
    if not Hit.pdb_dir:
        logger.debug('Hit.set_pdb_dir')
        Hit.set_pdb_dir(pdb_path)
    if not Hit.pdb_dict:
        logger.debug('Hit.set_pdb_dict')
        Hit.set_pdb_dict(fasta)
    if not Ligand.inchi_component:
        logger.debug('Ligand.set_inchi_component')
        Ligand.set_inchi_component(compinchi)
    logger.debug('query.run_blast')
    records = query.run_blast(pdb_db, out_dir)
    if records:
        logger.debug('query.set_hits')
        query.set_hits(records)
        logger.debug('query.fill_sequences')
        query.fill_sequences()
    return query
示例#2
0
 def set_ligand(self, resname, inchi, label):
     """
     Creates a d3r.blast.Ligand object entry for the ligand. If the ligand is dockable (not in in the
     d3r.filter.FilteringSets do_not_call set), the Ligand object is appended to the dock list, and the dock_count
     and ligand_count attributes are each incremented. If ligand is in the do_not_call filtering set, then the
     ligand is added to the do_not_call list, and the ligand_count attribute is incremented. Note that, no effort is
     made to check if the input ligand is unique or has not been added before. In the case of a dockable ligand, an
     attempt is made to convert the InChI to a rd mol object. If the conversion is successful, then the Target
     inchi_error attribute is set to False. If the conversion is unsuccessful, then the the inchi_error attribute is
     set to True. Non-dockable ligands are not converted to rd mol objects.
     :param resname: (string) the PDB resname of the input ligand
     :param inchi: (string) the inchi string, which uniquely identifies the ligand
     :param label: (string) set to either 'dock' or 'do_not_call'
     """
     logger.debug('In set_ligand()')
     ligand = Ligand(resname, inchi)
     #modified by sliu 08/08, set the ligand size, rot bond etc
     if label == 'dock':
         if ligand.set_rd_mol_from_inchi():
             self.inchi_error = False
         else:
             self.inchi_error = True
         ligand.set_size()
         ligand.set_heavy_size()
         ligand.set_rot()
         self.dock.append(ligand)
         self.dock_count += 1
         self.ligand_count += 1
     elif label == 'do_not_call':
         self.do_not_call.append(ligand)
         self.ligand_count += 1
     else:
         pass
示例#3
0
文件: hit.py 项目: avirshup/D3R
    def set_ligands(self, chain_id):
        """
        Creates a d3r.blast.Ligand object for each of the bound ligands found in the PDB, and appends
        this object to the appropriate list, either dock or do_not_call. If the ligand object is added
        to the dock list, the dock_count and the ligand_count is incremented. If the ligand object is added to the
        do_not_call list, then the ligand_count is incremented. No effort is made to check whether or not the
        input ligand is unique, i.e. that it hasn't been added before. Prior to calling the method, the pdb_id
        attribute must be set, and the read_pdb method must be called. For example:
            test = d3r.blast.Test()
            test.pdb_id = '1xdn'
            test.read_pdb()
            test.set_ligands()
        """
        logger.debug('In set_ligands()')
        model_list = Selection.unfold_entities(self.pdb, 'M')
        chain_list = Selection.unfold_entities(model_list[0], 'C')
        chain_format = "<Chain id=%s>"%chain_id
        chain_index = 0 
        for (index, chain_object) in enumerate(chain_list):
            if str(chain_object) == chain_format:
                chain_index = index
        #print "Chain index", chain_index
        res_list = Selection.unfold_entities(chain_list[chain_index], 'R')
        hetero_list = [res for res in res_list if 'H_' in res.id[0] and res.id[0] != 'H_MSE']
        #modified by sliu 08/04, add chain info for ligand
        for hetero in hetero_list:
            assigned = []
            for l in self.dock:
                ligand_info = (l.resname, l.chain)
                assigned.append(ligand_info)
            for l in self.do_not_call:
                ligand_info = (l.resname, l.chain)
                assigned.append(ligand_info)

            resname = hetero.resname.strip()
            if (resname, chain_id) in assigned:
                #the resname, chain id info is already in stored
                continue
            ligand = Ligand()
            ligand.resname = resname
            ligand.chain = chain_id
            if resname in filtering_sets.do_not_call:
                ligand.label = 'do_not_call'
                self.do_not_call.append(ligand)
                self.ligand_count += 1
            else:
                ligand.label = 'dock'
                ligand.set_rd_mol_from_resname(resname)
                #modified by sliu 08/08
                ligand.set_size()
                ligand.set_heavy_size()
                self.dock.append(ligand)
                self.dock_count += 1
                self.ligand_count += 1