dock.c

来自「最经典的分子对结软件」· C语言 代码 · 共 1,137 行 · 第 1/2 页

C
1,137
字号
            &mol_conf,            score.type[NONE].file_name,            score.type[NONE].file          );/**       Perform database processing functions*       1/97 te*/        if (dock.multiple_ligands)        {/**         Output list of current top scorers*         6/95 te*/          if (score.flag)            write_info            (              &dock,              &score,              &best_ligands,              lig_total + 1,              lig_proc,              lig_skip,              elapsed_time (NULL)            );/**         Check to see if this job has been requested to shut down*         6/95 te*/          if          (            (dock.rank_ligands || dock.parallel.flag) &&            (quit = fopen (dock.quit_file_name, "r"))          )          {            fclose (quit);            if (remove (dock.quit_file_name))              fprintf (global.outfile,                "WARNING main: Unable to delete %s.\n", dock.quit_file_name);          }/**         Check for a request to write current results*         6/95 te*/          if (dock.rank_ligands)          {            if (dump = fopen (dock.dump_file_name, "r"))            {              fclose (dump);              if (remove (dock.dump_file_name))                fprintf (global.outfile,                  "WARNING main: Unable to delete %s.\n", dock.dump_file_name);            }/**           Write restart information to disk*           6/95 te*/            if (dump || quit || (lig_proc % dock.restart_interval == 0))            {              fprintf (global.outfile,                "ATTENTION main: Writing restart information to disk.\n");              if (!write_restartinfo                (                  &dock,                  &score,                  &best_ligands,                  lig_total + 1,                  lig_proc,                  lig_skip,                  elapsed_time (NULL)                ))                fprintf (global.outfile,                  "WARNING main: Unable to write restart information.\n");            }            if (dump || quit)            {              fprintf (global.outfile,                "ATTENTION main: Writing current top scorers as requested.\n");              write_topscorers              (                &dock,                &score,                &best_ligands,                &mol_ref,                &mol_out              );              for (i = 0; i < SCORE_TOTAL; i++)                score.type[i].number_written = 0;            }            dump = NULL;          }          if (quit)          {            fprintf (global.outfile,              "ATTENTION main: Execution terminating as requested.\n");            fclose (dock.ligand_file);/**           Shut down parallel client processes, also, if this is a server run*           10/95 te*/            if (dock.parallel.server)            {              for (i = 0; i < dock.parallel.client_total; i++)              {                sprintf                  (dock.quit_file_name, "%s.quit",                  dock.parallel.client_name[i]);                quit = rfopen (dock.quit_file_name, "w", global.outfile);                efclose (&quit);              }            }            efclose (&global.outfile);            exit (EXIT_SUCCESS);          }        }      }/**     If no anchor was found, then record the skip*     6/97 te*/      else        lig_skip++;    }/**   If no ligand was read, then record the skip*   6/97 te*/    else      lig_skip++;/**   Skip set of molecules for each interval*   9/95 te*/    for (i = 0; i < dock.interval_skip; i++)    {      if (get_ligand        (          &dock, &score, &label,          &mol_ref, &mol_init,          FALSE, FALSE, FALSE        ) != EOF)      {        lig_total++;        lig_skip++;      }      else        break;    }  }  dock.read_time += elapsed_time (NULL);/** Finished reading ligands in from disk, make sure at least one was read* 6/95 te*/  if (lig_total == 0)  {    fprintf (global.outfile,      "Unable to read anything from ligand coordinate file.\n");    exit (EXIT_FAILURE);  }/** Shut down client processes, if this is a server run* 10/95 te*/  if (dock.parallel.server)  {    for (i = 0; i < dock.parallel.client_total; i++)    {      sprintf (dock.quit_file_name, "%s.quit", dock.parallel.client_name[i]);      quit = rfopen (dock.quit_file_name, "w", global.outfile);      fclose (quit);    }  }/** Write out final results (in rank_ligands mode)* 6/95 te*/  if (dock.rank_ligands)  {    if (lig_proc % dock.restart_interval)    {      fprintf (global.outfile, "Writing restart information to disk.\n");      if (!write_restartinfo        (          &dock,          &score,          &best_ligands,          lig_total,          lig_proc,          lig_skip,          elapsed_time (NULL)        ))          fprintf (global.outfile,            "WARNING main: Unable to write restart information.\n");    }    fprintf (global.outfile, "Writing top scoring molecules to disk.\n");    write_topscorers    (      &dock,      &score,      &best_ligands,      &mol_ref,      &mol_out    );  }/** Close ligand output files* 6/95 te*/  else    for (i = 0; i < SCORE_TOTAL; i++)      if (score.type[i].flag)        fclose (score.type[i].file);/** Close ligand input files* 5/97 te*/  fclose (dock.ligand_file);  if (check_file_extension (dock.ligand_file_name, FALSE) == Ptr)    read_molecule (NULL, NULL, dock.ligand_file_name, NULL, 0);/** Free molecule structures* 5/97 te*/  free_molecule (&mol_ref);  free_molecule (&mol_init);  free_molecule (&mol_conf);  free_molecule (&mol_ori);  free_molecule (&mol_score);  free_molecule (&mol_out);/** Free top score lists* 5/97 te*/  free_lists (&score, &best_anchors);  free_lists (&score, &best_orients);  free_lists (&score, &best_ligands);/** Free all other arrays* 5/97 te*/  if (label.chemical.screen.flag)    free_screen (&orient.match, &label);  if (orient.flag)    free_orients (&label, &orient);  free_scores (&label, &score);  free_labels (&label);/** Report performance* 1/97 te*/  dock.total_time += elapsed_time (NULL);  if (dock.performance_flag)    report_performance (&dock, &score, lig_proc);  fprintf (global.outfile,    "\nFinished processing molecule%s in %.6g seconds.\n",    lig_total > 1 ? "s" : "", dock.total_time);  fclose (global.outfile);  return (EXIT_SUCCESS);}/* //////////////////////////////////////////////////////////////////Evaluate how much time has elapsed (with checking for wrap-around)6/95 te////////////////////////////////////////////////////////////////// */float elapsed_time (float *reset_value){  static long clock_previous = 0;  static long clock_current = 0;  static float time;  if (reset_value)    time = *reset_value;  clock_previous = clock_current;  clock_current = clock ();  if (clock_current < clock_previous)  {    time +=      ((float) (LONG_MAX - clock_previous))      / ((float) CLOCKS_PER_SEC);    time +=      ((float) (clock_current - LONG_MIN))      / ((float) CLOCKS_PER_SEC);  }  else    time +=      ((float) (clock_current - clock_previous))      / ((float) CLOCKS_PER_SEC);  return time;}/* ////////////////////////////////////////////////////////////////// */void write_program_header (void){  if (global.outfile != stdout)    fprintf (global.outfile, "\n"      "      UUUUUUUUU     CCCCCCC     SSSSSSS    FF/   FFF/ \n"      "      UU/    UU/  CC/    CC/  SS/    SS/  FF/ FFF/    \n"      "     UU/    UU/  CC/    CC/  SS/         FFFFF/       \n"      "    UU/    UU/  CC/    CC/  SS/         FF/ FF\\       \n"      "   UU/    UU/  CC/    CC/  SS/    SS/  FF/   FF\\      \n"      " UUUUUUUUU/    CCCCCCC/    SSSSSSS/   FF/     FF\\     \n\n\n");  else    fprintf (global.outfile, "\n\n"      "      UUUUUUUUU     CCCCCCC     SSSSSSS    FF/   FFF/ \n"      "      UU/    UU/  CC/    CC/  SS/    SS/  FF/ FFF/    \n"      "     UU/    UU/  CC/    CC/  SS/         FFFFF/       \n"      "    UU/    UU/  CC/    CC/  SS/         FF/ FF\\       \n"      "   UU/    UU/  CC/    CC/  SS/    SS/  FF/   FF\\      \n"      " UUUUUUUUU/    CCCCCCC/    SSSSSSS/   FF/     FF\\     \n\n\n");  fprintf (global.outfile,    "University of California at San Francisco, DOCK %s\n", DOCK_VERSION);  fflush (global.outfile);}/* ////////////////////////////////////////////////////////////////// */void initialize_performance (DOCK *dock, SCORE *score){  dock->total_time = 0;  dock->read_time = 0;  dock->screen_time = 0;  dock->conform_time = 0;  dock->periph_time = 0;  dock->orient_time = 0;  dock->score_time = 0;  score->time = 0;  score->minimize.call_total = 0;  score->minimize.call_sub_total = 0;  score->minimize.call_min = INT_MAX;  score->minimize.call_max = INT_MIN;  score->minimize.vertex_total = 0;  score->minimize.vertex_min = INT_MAX;  score->minimize.vertex_max = INT_MIN;  score->minimize.iteration_total = 0;  score->minimize.iteration_min = INT_MAX;  score->minimize.iteration_max = INT_MIN;  score->minimize.cycle_total = 0;  score->minimize.cycle_min = INT_MAX;  score->minimize.cycle_max = INT_MIN;  score->minimize.delta_total = 0;  score->minimize.delta_min = FLT_MAX;  score->minimize.delta_max = FLT_MIN;}/* ////////////////////////////////////////////////////////////////// */void report_performance (DOCK *dock, SCORE *score, int mol_total){  fprintf (global.outfile,    "\n______________________Docking_Performance______________________\n");  dock->other_time = dock->total_time - dock->read_time;  dock->read_time -= dock->screen_time + dock->conform_time;  dock->conform_time -= dock->orient_time;  dock->orient_time -= dock->score_time;  fprintf  (    global.outfile,    "\n%-45s %8s %8s\n",    "Procedure timings",    "time (s)",    "percent"  );  fprintf  (    global.outfile,    "%-45s %8.2f %8.0f\n",    "Read",    dock->read_time,    dock->read_time / dock->total_time * 100.0  );  fprintf  (    global.outfile,    "%-45s %8.2f %8.0f\n",    "Screen",    dock->screen_time,    dock->screen_time / dock->total_time * 100.0  );  fprintf  (    global.outfile,    "%-45s %8.2f %8.0f\n",    "Orientation Search",    dock->orient_time,    dock->orient_time / dock->total_time * 100.0  );  fprintf  (    global.outfile,    "%-45s %8.2f %8.0f\n",    "Orientation Score",    dock->score_time,    dock->score_time / dock->total_time * 100.0  );  fprintf  (    global.outfile,    "%-45s %8.2f %8.0f\n",    "Conformation Anchor",    dock->conform_time - dock->periph_time,    (dock->conform_time  - dock->periph_time) / dock->total_time * 100.0  );  fprintf  (    global.outfile,    "%-45s %8.2f %8.0f\n",    "Conformation Peripheral",    dock->periph_time,    dock->periph_time / dock->total_time * 100.0  );  fprintf  (    global.outfile,    "%-45s %8.2f %8.0f\n",    "Other",    dock->other_time,    dock->other_time / dock->total_time * 100.0  );  fprintf  (    global.outfile,    "%-45s %8.2f %8.0f\n",    "Total",    dock->total_time,    100.0  );  fprintf ( global.outfile, "\n");  if (score->minimize.flag == TRUE)  {    fprintf    (      global.outfile,      "%-36s %8s %8s %8s\n",      "Minimizer usage",      "minimum",      "average",      "maximum"    );    fprintf    (      global.outfile,      "%-36s %8d %8d %8d\n",      "Calls per molecule",      score->minimize.call_min,      NINT ((float) score->minimize.call_total /        (float) mol_total),      score->minimize.call_max    );    fprintf    (      global.outfile,      "%-36s %8.2g %8.2g %8.2g\n",      "Score improvement per call",      score->minimize.delta_min,      (float) score->minimize.delta_total /        (float) score->minimize.call_total,      score->minimize.delta_max    );    fprintf    (      global.outfile,      "%-36s %8d %8d %8d\n",      "Vertices per call",      score->minimize.vertex_min,      NINT ((float) score->minimize.vertex_total /        (float) score->minimize.call_total),      score->minimize.vertex_max    );    fprintf    (      global.outfile,      "%-36s %8d %8d %8d\n",      "Cycles per call",      score->minimize.cycle_min,      NINT ((float) score->minimize.cycle_total /        (float) score->minimize.call_total),      score->minimize.cycle_max    );    fprintf    (      global.outfile,      "%-36s %8d %8d %8d\n",      "Iterations per cycle",      score->minimize.iteration_min,      NINT ((float) score->minimize.iteration_total /        (float) score->minimize.cycle_total),      score->minimize.iteration_max    );  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?