score_dock.c

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

C
2,053
字号
/*                                                                    *//*                        Copyright UCSF, 1997                        *//*                                                                    *//*Written by Todd Ewing12/96*/#include "define.h"#include "utility.h"#include "mol.h"#include "global.h"#include "dock.h"#include "search.h"#include "label.h"#include "score.h"#include "score_dock.h"#include "flex.h"#include "simplex.h"#include "io_ligand.h"#include "io_grid.h"#include "transform.h"#include "rank.h"#include "vector.h"typedef struct simplex_struct{  DOCK		*dock;  LABEL		*label;  SCORE		*score;  MOLECULE	*mol_ref;  MOLECULE	*mol_ori;  MOLECULE	*mol_score;  MOLECULE	mol_min;  MOLECULE	mol_best;  LIST		*list;  int		rigid_flag;  int		layer_inner;  int		layer_outer;  int		cycle;} SIMPLEX;/* ///////////////////////////////////////////////////////////////Subroutine to calculate and optimize the score for a ligand orientation.The best scoring orientation is updated.Return values:	TRUE	molecule orientation was scored	FALSE	molecule orientation not scored1/97 te/////////////////////////////////////////////////////////////// */int get_anchor_score(  DOCK		*dock,  LABEL		*label,  SCORE		*score,  MOLECULE	*mol_ref,  MOLECULE	*mol_init,  MOLECULE	*mol_ori,  MOLECULE	*mol_score,  LIST		*best_anchors,  int		orient_id,  int		write_flag){  int type;			/* Score type iterator *//** Read/construct scoring grids* 11/96 te*/  if (!orient_id)  {    if (score->inter_flag && !score->grid.init_flag)    {      if (score->grid.flag)        read_grids        (          &score->grid,          &score->bump,          &score->contact,          &score->chemical,          &score->energy,          &label->chemical        );      else        make_receptor_grid        (          &score->grid,          &score->energy,          label        );    }  }  else    reset_score (&mol_ori->score);/** Evaluate whether anchor orientation bumps with receptor* 12/96 te*/  if  (    (score->inter_flag == TRUE) &&    (score->bump.flag == TRUE) &&    (check_bump (&score->grid, &score->bump, label, mol_ori) >      score->bump.maximum)  )    return FALSE;  if (mol_ori->transform.flag)    mol_ori->transform.rmsd =      calc_rmsd (mol_ori, mol_init);  copy_transform (mol_score, mol_ori);  copy_score (&mol_score->score, &mol_ori->score);  copy_coords (mol_score, mol_ori);  copy_torsions (mol_score, mol_ori);  copy_segments (mol_score, mol_ori);  copy_layers (mol_score, mol_ori);/** Loop through all scoring types* 11/96 te*/  for (type = 0; type < SCORE_TOTAL; type++)  {    if (!score->type[type].flag)      continue;    mol_score->score.type = type;/**   Either minimize this orientation or just score it*   11/96 te*/    if (score->type[type].minimize && label->flex.minimize_anchor_flag)    {      minimize_ligand        (dock, label, score, mol_ref, mol_ori, mol_score, TRUE, 0, 0);      mol_score->transform.rmsd =        calc_rmsd (mol_score, mol_init);    }    else      calc_score (label, score, mol_score, 0);/**   Update the list of best anchors*   11/96 te*/    update_list (best_anchors, mol_score);/**   Write out the orientation if flagged, and if:**   1. Ligand has moved AND rmsd is within override, OR*   2. No scoring is performed, OR*   3. The score is below maximum cutoff**   3/96 te*/    if    (      write_flag &&      (        ((mol_score->transform.flag) &&          (mol_score->transform.rmsd <=            score->rmsd_override)) ||        (mol_score->score.total <= score->type[type].maximum)      )    )    {      write_ligand      (        dock,        score,        mol_score,        score->type[type].file_name,        score->type[type].file      );    }/**   Reset coordinates previous to minimization*   6/96 te*/    if (score->type[type].minimize)    {      copy_transform (mol_score, mol_ori);      copy_torsions (mol_score, mol_ori);      copy_coords (mol_score, mol_ori);    }  }  return TRUE;}/* /////////////////////////////////////////////////////////////// */void get_peripheral_score(  DOCK		*dock,  LABEL		*label,  SCORE		*score,  MOLECULE	*mol_ref,  MOLECULE	*mol_init,  MOLECULE	*mol_conf,  MOLECULE	*mol_ori,  MOLECULE	*mol_score,  LIST		*best_anchors,  LIST		*best_orients,  int		write_flag,  int		anchor){  int type;			/* Score type iterator */  int seed;			/* Seed conformation iterator */  int layer;			/* Segment layer iterator */  int segment_id;		/* Segment iterator */  int segment;			/* Segment id */  static int allocate_flag = TRUE; /* Flag for whether lists allocated */  static LIST seed_conform;	/* List of seed conformations */  static LIST best_conform;	/* List of best conformations *//** Initialize conformation storage lists* 12/96 te*/  if (allocate_flag == TRUE)  {    allocate_lists (score, &seed_conform, label->flex.max_conforms, FALSE);    allocate_flag = FALSE;  }  else    reset_lists (score, &seed_conform);  copy_lists (score, &best_conform, best_anchors);/** Loop through all scoring types* 12/96 te*/  for (type = 0; type < SCORE_TOTAL; type++)  {    if (!score->type[type].flag)      continue;/**   Loop through each shell of flexible segments*   3/97 te*/    for    (      layer = 0;      (layer < mol_conf->total.layers) &&        (best_conform.total[type] > 0);      layer++    )    {/**     Loop through all segments in current layer*     Except first layer, just do first segment and only do pruning of it*     2/98 te*/      for      (        segment_id = 0;        ((layer == 0) && (segment_id < 1)) ||        ((layer != 0) && (segment_id < mol_conf->layer[layer].segment_total))          && (best_conform.total[type] > 0);        segment_id++      )      {        if (layer > 0)        {/**         Allocate sufficient space for best conformations*         1/98 te*/          segment = mol_conf->layer[layer].segment[segment_id];          best_conform.total[type] =            seed_conform.total[type] * mol_conf->segment[segment].conform_total;          reallocate_list (&best_conform, type);          reset_list (&best_conform, type);/**         Loop through all seed conformations*         3/97 te*/          for (seed = 0; seed < seed_conform.total[type]; seed++)          {              copy_member (FALSE, mol_ori, seed_conform.member[type][seed]);              mol_ori->layer[layer].active_flag = TRUE;              mol_ori->segment[segment].active_flag = TRUE;              mol_ori->segment[segment].min_flag = TRUE;              mol_ori->segment[segment].conform_count = 0;/**             Drive through conformations of this segment*             3/97 te*/              while              (                get_segment_conformation                (                  label,                  score,                  mol_ori,                  layer,                  segment_id                ) != EOF              )              {                copy_molecule (mol_score, mol_ori);/**               Either minimize this conformation or just score it*               If minimize, allow rigid+outer layer OR outer two layers*               2/97 te*/                if (score->type[type].minimize)                  minimize_ligand                    (dock, label, score, mol_ref, mol_ori, mol_score,                    label->flex.reminimize_anchor_flag,                    MAX (0, layer - label->flex.reminimize_layers),                    layer);                else                  calc_score                    (label, score, mol_score, layer);                if (global.output_volume == 'v')                  mol_score->transform.rmsd =                    calc_rmsd (mol_score, mol_init);                mol_score->segment[segment].min_flag = FALSE;                update_list (&best_conform, mol_score);              } /* End of conformer loop */          } /* End of seed loop */        } /* End of if (layer > 0) */        if (global.output_volume == 'v')        {          fprintf (global.outfile,            "\nAnchor-first search: anchor %d, layer %d, segment %d, "            "configurations %d\n", anchor + 1,            layer + 1, segment_id + 1, best_conform.total[type]);          print_list (score, &best_conform, type, global.outfile);          fflush (global.outfile);        }/**       Write out the conformationally expanded ensemble*       2/98 te*/        if (label->flex.write_flag == TRUE)          write_periph_structures          (            dock,            score,            &best_conform,            mol_ref,            mol_ori,            type,            anchor,            layer,            segment_id,            FALSE          );/**       Identify the most different best conforms as seeds for next cycle*       2/98 te*/        shrink_list        (          &best_conform,          &seed_conform,          type,          label->flex.max_conforms        );        if (global.output_volume == 'v')        {          fprintf (global.outfile,            "\nAnchor-first search: anchor %d, layer %d, segment %d, "            "prunings %d\n", anchor + 1,            layer + 1, segment_id + 1, seed_conform.total[type]);          print_list (score, &seed_conform, type, global.outfile);          fflush (global.outfile);        }/**       Write out the pruned ensemble*       2/98 te*/        if (label->flex.write_flag == TRUE)          write_periph_structures          (            dock,            score,            &seed_conform,            mol_ref,            mol_ori,            type,            anchor,            layer,            segment_id,            TRUE          );      } /* End of segment count loop */    } /* End of layer loop *//**   Process the top scoring configurations*   2/97 te*/    if ((seed_conform.total[type] > 0)&&(best_conform.total[type] > 0))    {/**     Re-minimize the top scoring configurations*     2/97 te*/      if      (        score->type[type].minimize &&        label->flex.reminimize_ligand_flag &&        (mol_ori->total.layers > 2)      )      {        for (seed = 0; seed < seed_conform.total[type]; seed++)        {          copy_molecule (mol_score, seed_conform.member[type][seed]);          for          (            segment_id = 0;            segment_id < mol_score->total.segments;            segment_id++          )            mol_score->segment[segment_id].min_flag = TRUE;          minimize_ligand            (dock, label, score, mol_ref, seed_conform.member[type][seed],            mol_score, TRUE, 0, mol_score->total.layers - 1);          mol_score->transform.rmsd = calc_rmsd (mol_score, mol_init);          copy_molecule (seed_conform.member[type][seed], mol_score);        }        sort_list (&seed_conform, type);        if (global.output_volume == 'v')        {          fprintf (global.outfile,            "Anchor-first search: anchor %d, reminimize_ligand results\n",            anchor + 1);          print_list (score, &seed_conform, type, global.outfile);        }      }      merge_lists (score, best_orients, &seed_conform);/**     Write out the best configurations to file, if requested*     2/97 te*/      if (write_flag)      {        for (seed = 0; seed < seed_conform.total[type]; seed++)        {          if          (            ((seed_conform.member[type][seed]->transform.flag) &&              (seed_conform.member[type][seed]->transform.rmsd <=                score->rmsd_override)) ||            (seed_conform.member[type][seed]->score.total <=              score->type[type].maximum)          )          {            write_ligand            (              dock,              score,              seed_conform.member[type][seed],              score->type[type].file_name,              score->type[type].file            );          }        } /* End of seed loop */      } /* End of write IF */    } /* End of process IF */  } /* End of score type loop */}/* ////////////////////////////////////////////////////////////////// */

⌨️ 快捷键说明

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