Exemplo n.º 1
0
    def load_pdb_pocket(self, pdb, pdb_dir="/data/databases/pdb/"):
        utils = PDBs(pdb_dir)
        if not os.path.exists(utils.pdb_pockets_path(pdb)):
            utils.update_pdb(pdb)
            fpocket = FPocket(utils.pdb_path(pdb))
            result = fpocket.hunt_pockets()
            mkdir(os.path.dirname(utils.pdb_pockets_path(pdb)))
            result.save(utils.pdb_pockets_path(pdb))
        with open(utils.pdb_pockets_path(pdb)) as h:
            result = json.load(h)

        self.pdb_data[pdb]["pockets"] = result
        return self.pdb_data[pdb]["pockets"]
Exemplo n.º 2
0
    def handle(self, *args, **options):

        tmp = os.path.abspath(options['tmp'])
        if not os.path.exists(tmp):
            os.makedirs(tmp)
        qs = PDB.objects.filter(code=options["pdb"]) if options["pdb"] else PDB.objects.all()
        total = qs.count()
        utils = PDBs(options["pdbs_dir"])

        with tqdm(qs, total=total) as pbar:
            for pdb in pbar:
                pbar.set_description(pdb.code)

                try:
                    fpocket2sql = FPocket2SQL()
                    fpocket2sql.create_or_get_pocket_properties()
                    fpocket2sql.load_pdb(pdb.code)
                    fpocket2sql.run_fpocket(options['tmp'],pdb_path=utils.pdb_path(pdb.code),
                                            pockets_path=utils.pdb_pockets_path(pdb.code),
                                            force=options["force"])
                    fpocket2sql.load_pockets()
                    # res.delete_dir()


                except IOError as ex:
                    traceback.print_exc()
                    self.stderr.write("error processing pockets from %s: %s" % (pdb.code, str(ex)))

                except Exception as ex:
                    traceback.print_exc()
                    raise CommandError(ex)
Exemplo n.º 3
0
    def handle(self, *args, **options):

        if options["verbose"] == 1:
            import logging
            logging.basicConfig(level=logging.DEBUG)

        pdbs = PDBs(options["pdbs_dir"])
        pdbs.url_pdb_entries = options["entries_url"]
        if not os.path.exists(options["entries_path"]):
            pdbs.download_pdb_entries()

        pdbio = PDBIO(options['pdbs_dir'] + "/", options['entries_path'],
                      options['tmp'])
        pdbio.init()

        try:
            pdbs.update_pdb(options['code'])
            pdbio.process_pdb(options['code'],
                              force=options['force'],
                              pocket_path=pdbs.pdb_pockets_path(
                                  options['code']),
                              pdb_path=pdbs.pdb_path(options['code']))

        except IOError as ex:
            traceback.print_exc()
            self.stderr.write("error processing pockets from %s: %s" %
                              (options['code'], str(ex)))
        except Exception as ex:
            traceback.print_exc()
            raise CommandError(ex)