Exemplo n.º 1
0
    def run(self):
        curated_pdb = self.input().path
        proasis_hit = ProasisHits.objects.get(crystal_name_id=self.crystal_id, refinement_id=self.refinement_id)
        ligand_list = eval(proasis_hit.ligand_list)
        ligand_list = proasis_api_funcs.get_lig_strings(ligand_list)
        crystal_name = proasis_hit.crystal_name.crystal_name
        target_name = proasis_hit.crystal_name.target.target_name.upper()

        pdb_file = open(curated_pdb, 'r')
        ligid = 0
        for l in ligand_list:
            ligid += 1
            for line in pdb_file:
                if any(lig in line for lig in ligand_list):
                    continue
                else:
                    with open(os.path.join(self.hit_directory, target_name,
                                           crystal_name, str(crystal_name + '_' + str(ligid)),
                                           str(crystal_name + '_apo_' + str(ligid) + '.pdb')), 'a') as f:
                        f.write(line)

            out_entry = ProasisOut.objects.filter(proasis=proasis_hit, ligid=ligid)

            out_entry.apo = str(crystal_name + '_apo_' + str(ligid) + '.pdb')
            out_entry.save()
Exemplo n.º 2
0
    def run(self):
        proasis_hit = ProasisHits.objects.get(crystal_name_id=self.crystal_id, refinement_id=self.refinement_id)
        strucid = proasis_hit.strucid
        ligands = eval(proasis_hit.ligand_list)
        ligand_list = proasis_api_funcs.get_lig_strings(ligands)
        crystal_name = proasis_hit.crystal_name.crystal_name
        target_name = proasis_hit.crystal_name.target.target_name

        ligid = 0
        for lig in ligand_list:
            ligid += 1

            curated_pdb = proasis_api_funcs.get_struc_file(strucid,
                                                           os.path.join(
                                                               self.hit_directory, target_name.upper(), str(crystal_name +
                                                                                                        '_' +
                                                                                                        str(ligid)),
                                                               str(crystal_name + str('_' + str(ligid) + '.pdb'))),
                                                           'curatedpdb')

            proasis_out = ProasisOut.objects.get_or_create(proasis=proasis_hit,
                                                           crystal=proasis_hit.crystal_name,
                                                           ligand=lig,
                                                           ligid=ligid,
                                                           root=os.path.join(self.hit_directory,
                                                                             proasis_hit.crystal_name.target.target_name.upper()),
                                                           start=str(proasis_hit.crystal_name.crystal_name + '/' +
                                                                     proasis_hit.crystal_name.crystal_name + '_' +
                                                                     ligid),
                                                           curated=curated_pdb.split('/')[-1]
                                                           )
            proasis_out[0].save()
Exemplo n.º 3
0
    def output(self):
        proasis_hit = ProasisHits.objects.get(crystal_name_id=self.crystal_id, refinement_id=self.refinement_id)
        crystal_name = proasis_hit.crystal_name.crystal_name
        target_name = proasis_hit.crystal_name.target.target_name.upper()
        ligands = eval(proasis_hit.ligand_list)
        ligand_list = proasis_api_funcs.get_lig_strings(ligands)

        return [luigi.LocalTarget(os.path.join(
            self.hit_directory, target_name, crystal_name, str(crystal_name + str(i)), str(crystal_name + '_apo_' + str(i) + '.pdb')))
            for i in range(1, len(ligand_list)+1)]
Exemplo n.º 4
0
    def run(self):
        self.ligands = eval(self.ligands)
        print((len(self.ligands)))
        # if len(list(self.ligands))>1:
        # raise Exception('Structures containing more than 1 ligand are currently unsupported')
        conn, c = dbf.connectDB()
        c.execute('SELECT curated_name from proasis_out WHERE strucid=%s',
                  (self.strucid, ))
        rows = c.fetchall()
        print((len(rows)))
        if len(rows) > 1:
            raise Exception('Multiple files where found for this structure: ' +
                            str(rows))
        if len(rows) > 0 and len(rows[0]) == 0:
            # raise Exception('No entries found for this strucid... check the datasource!')
            c.execute('DELETE from proasis_out WHERE curated_name=%s',
                      (str(self.crystal + '_' + 'curated.pdb'), ))
            conn.commit()
            shutil.rmtree(os.path.join(self.root_dir, self.docking_dir))
            raise Exception(
                'DB problem... resetting the datasource and files for this crystal'
            )

        for row in rows:
            curated_pdb = str(row[0])
        try:
            print(curated_pdb)
        except:
            c.execute('DELETE from proasis_out WHERE curated_name=%s',
                      (str(self.crystal + '_' + 'curated.pdb'), ))
            conn.commit()
            shutil.rmtree(os.path.join(self.root_dir, self.docking_dir))
            raise Exception(
                'DB problem... resetting the datasource and files for this crystal'
            )

        ligand_string = paf.get_lig_strings(self.ligands)

        working_dir = os.getcwd()
        os.chdir(os.path.join(self.root_dir, self.docking_dir))
        try:
            pdb_file = open(curated_pdb, 'r')
        except:
            raise Exception(str(rows))
        for line in pdb_file:
            if any(lig in line for lig in ligand_string):
                continue
            else:
                with open(self.output().path, 'a') as f:
                    f.write(line)
        os.chdir(working_dir)