match.c

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

C
2,459
字号
/*                                                                    *//*                        Copyright UCSF, 1997                        *//*                                                                    *//*Written by Todd Ewing10/95*/#include "define.h"#include "utility.h"#include "mol.h"#include "global.h"#include "dock.h"#include "search.h"#include "label.h"#include "screen.h"#include "match.h"#include "io.h"#include "mol_prep.h"#include "rotrans.h"/* ////////////////////////////////////////////////////////////// Routine to manage matching procedure3/96 te////////////////////////////////////////////////////////////// */int get_match(  DOCK		*dock,  MATCH		*match,  LABEL		*label,  MOLECULE      *mol_conf,  int           conformation_id,  int           orientation_id){  if (orientation_id == 0)  {    match->total = 0;    match->max = 0;    match->cycle = 0;    match->chiral_flag = TRUE;    if (!match->init_flag)      init_match_site (match, label);    if (!match->centers_flag)      get_ligand_centers (match, mol_conf);    if (conformation_id == 0)      init_match_ligand (match, label);  }  if (match->auto_flag)  {    while (match->total >= match->max)    {      match->cycle++;      initialize_adjacency (match, label);      if (compute_matches (match) == EOF)        return EOF;      match->total = 0;    }    copy_clique (&match->clique, &match->clique_sort[match->total]);    match->total++;    return TRUE;  }  else  {    if (orientation_id == 0)    {      match->cycle++;      initialize_adjacency (match, label);    }    if (match_distance (match) != EOF)    {      match->total++;      return TRUE;    }       else    {      if (!dock->multiple_ligands || !dock->multiple_conforms)        output_match_info (match);      return EOF;    }  }}/* ////////////////////////////////////////////////////////////// Routine to free matching arrays5/97 te////////////////////////////////////////////////////////////// */void free_matches(  LABEL		*label,  MATCH		*match){  free_clique_list (match);  free_clique_link (match);  free_match (match);  free_match_site (match, label);  free_ligand_centers (match);}/* ////////////////////////////////////////////////////////////// Routine to allocate space for matching arrays3/96 te////////////////////////////////////////////////////////////// */void init_match_site(  MATCH		*match,  LABEL		*label){/** Construct match table* 11/96 te*/  if (match->chemical_flag && !label->chemical.match_table)    get_table    (      &label->chemical,      label->chemical.match_file_name,      &label->chemical.match_table    );/** Read in site points for matching* 8/96 te*/  get_site (match, label);  get_centers (match, label);/** Update the critical cluster identifiers of the site points* 7/95 te*/  id_site_points (match);/** Reorder site points so that critical clusters come first* 7/95 te*/  if (match->critical_flag)    order_site_points (match);/** Allocate memory for the critical cluster filters* 7/95 te*/  ecalloc  (    (void **) &match->critical_filter,    match->cluster_total + 1,    sizeof (char *),    "matching filter",    global.outfile  );/** Construct distance matrix for receptor site points* 6/95 te*/  match->bin_length =    calculate_distances    (      &match->receptor_site,      &match->receptor_distances,      &match->receptor_distance_size    );/** Make keys for pharmacophore search* 1/97 te*/  if (label->chemical.screen.pharmaco_flag)  {    if (label->chemical.screen.fold_flag)    {      update_folded_keys (&label->chemical, &match->receptor_site, 0);      return;    }    else      update_unfolded_keys (&label->chemical, &match->receptor_site, 0);  }  ecalloc  (    (void **) &match->clique_adjacency_total,    match->clique_size_max + 1,    sizeof (int),    "clique adjacency list total",    global.outfile  );  ecalloc  (    (void **) &match->clique_adjacency_list,    match->clique_size_max + 1,    sizeof (EDGE *),    "clique adjacency list",    global.outfile  );  ecalloc  (    (void **) &match->adjacent,    match->clique_size_max + 1,    sizeof (int),    "adjacent iterator list",    global.outfile  );  match->clique.edge_max = match->clique_size_max;  allocate_clique (&match->clique);  ecalloc  (    (void **) &match->degenerate,    match->clique_size_max,    sizeof (int),    "degenerate clique list",    global.outfile  );  emalloc  (    (void **) &match->histogram,    match->clique_size_max * sizeof (int),    "clique histogram",    global.outfile  );/** Construct matrix needed to calculate chirality* 10/95 te*/  calculate_vectors  (    &match->receptor_site,    &match->receptor_vectors,    &match->receptor_vector_size  );/** Construct receptor distance bins* 1/97 te*/  make_distance_bins (match);  allocate_clique_atoms (match);  match->init_flag = TRUE;}/* ////////////////////////////////////////////////////////////// Routine to free space for matching arrays4/97 te////////////////////////////////////////////////////////////// */void free_match_site(  MATCH		*match,  LABEL		*label){/** Free match table* 5/97 te*/  if (match->chemical_flag && label->chemical.match_table)    free_table    (      &label->chemical,      &label->chemical.match_table    );/** Free site points for matching* 5/97 te*/  free_molecule (&match->receptor_site);  free_distances  (    &match->receptor_distances,    &match->receptor_distance_size  );  efree ((void **) &match->clique_adjacency_total);  efree ((void **) &match->clique_adjacency_list);  efree ((void **) &match->adjacent);  free_clique (&match->clique);  efree ((void **) &match->degenerate);  efree ((void **) &match->histogram);  if (match->critical_flag)    free_site_points (match);  efree ((void **) &match->critical_filter);  free_vectors  (    &match->receptor_vectors,    &match->receptor_vector_size  );  free_distance_bins (match);  free_molecule (&match->ligand_clique);  free_molecule (&match->receptor_clique);}/* ////////////////////////////////////////////////////////////// Routine to allocate space for matching arrays3/96 te////////////////////////////////////////////////////////////// */void allocate_match (MATCH *match){  int i;  ecalloc  (    (void **) &match->adjacency_total,    match->node_max,    sizeof (int),    "adjacency list total",    global.outfile  );  ecalloc  (    (void **) &match->adjacency_max,    match->node_max,    sizeof (int),    "adjacency list max",    global.outfile  );  ecalloc  (    (void **) &match->adjacency_list,    match->node_max,    sizeof (EDGE *),    "adjacency matrix",    global.outfile  );  for (i = 0; i < match->clique_size_max + 1; i++)    ecalloc    (      (void **) &match->clique_adjacency_list[i],      match->node_max,      sizeof (EDGE),      "clique adjacency matrix",      global.outfile    );  for (i = 0; i < match->node_max; i++)  {    match->clique_adjacency_list[0][i].node = i;    match->clique_adjacency_list[0][i].residual = 0;  }/** Allocate memory for and initialize the chemical matching filter* 7/95 te*/  emalloc  (    (void **) &match->chemical_filter,    match->node_max * sizeof (char),    "chemical label filter",    global.outfile  );  memset (match->chemical_filter, 1, match->node_max);/** Allocate memory for the critical cluster filters* 7/95 te*/  for (i = 0; i < match->cluster_total + 1; i++)    ecalloc    (      (void **) &match->critical_filter[i],      match->node_max,      sizeof (char),      "matching filter",      global.outfile    );}/* ////////////////////////////////////////////////////////////// Routine to reset match variables.11/96 te////////////////////////////////////////////////////////////// */void reset_match (MATCH *match){  int i;  memset (match->adjacency_total, 0, match->node_max * sizeof (int));  memset    (match->clique_adjacency_total, 0,    (match->clique_size_max + 1) * sizeof (int));  for (i = 1; i < match->clique_size_max + 1; i++)    memset      (match->clique_adjacency_list[i], 0,      match->node_max * sizeof (EDGE));  reset_clique (&match->clique);  memset (match->adjacent, 0, (match->clique_size_max + 1) * sizeof (int));  memset (match->degenerate, 0, match->clique_size_max * sizeof (int));  memset (match->histogram, 0, match->clique_size_max * sizeof (int));}/* ////////////////////////////////////////////////////////////// Routine to free match variables.11/96 te////////////////////////////////////////////////////////////// */void free_match (MATCH *match){  int i;  efree ((void **) &match->adjacency_total);  efree ((void **) &match->adjacency_max);  for (i = 0; i < match->node_max; i++)    efree ((void **) &match->adjacency_list[i]);  efree ((void **) &match->adjacency_list);  if (match->clique_adjacency_list)    for (i = 0; i < match->clique_size_max + 1; i++)      efree ((void **) &match->clique_adjacency_list[i]);  efree ((void **) &match->chemical_filter);  if (match->critical_filter)    for (i = 0; i < match->cluster_total + 1; i++)      efree ((void **) &match->critical_filter[i]);  match->node_max = 0;}/* ////////////////////////////////////////////////////////////// Routine to reallocate match variables.3/97 te////////////////////////////////////////////////////////////// */void reallocate_match (MATCH *match){  if (match->node_max < match->node_total)  {    free_match (match);    match->node_max = match->node_total;    allocate_match (match);  }}/* ///////////////////////////////////////////////////////////// */void allocate_clique_atoms (MATCH *match){  match->ligand_clique.max.atoms = match->clique_size_max;  allocate_molecule (&match->ligand_clique);  match->receptor_clique.max.atoms = match->clique_size_max;  allocate_molecule (&match->receptor_clique);}/* ////////////////////////////////////////////////////////////// */void allocate_clique (CLIQUE *clique){  if (clique->edge_max > 0)    ecalloc    (      (void **) &clique->edge,      clique->edge_max,      sizeof (EDGE),      "clique edges",      global.outfile    );}    /* ////////////////////////////////////////////////////////////// */void reallocate_clique (CLIQUE *clique){  if (clique->edge_max < clique->edge_total)  {    free_clique (clique);    clique->edge_max = clique->edge_total;    allocate_clique (clique);  }}/* ////////////////////////////////////////////////////////////// */void free_clique (CLIQUE *clique){  if (clique->edge_max > 0)    efree ((void **) &clique->edge);  clique->edge_max = 0;}/* ////////////////////////////////////////////////////////////// */void reset_clique (CLIQUE *clique){  if (clique->edge_max > 0)    memset (clique->edge, 0, clique->edge_max * sizeof (EDGE));  clique->edge_total = 0;  clique->residual = 0;  clique->reflect_flag = FALSE;}/* ////////////////////////////////////////////////////////////// */void copy_clique (CLIQUE *copy, CLIQUE *original){  int i;  copy->edge_total = original->edge_total;  reallocate_clique (copy);  for (i = 0; i < original->edge_total; i++)    copy->edge[i] = original->edge[i];  copy->residual = original->residual;  copy->reflect_flag = original->reflect_flag;}/* ////////////////////////////////////////////////////////////// Routine to set up arrays used during matching.7/95 te////////////////////////////////////////////////////////////// */int init_match_ligand(  MATCH		*match,  LABEL		*label){  match->node_total =    match->ligand_center.total.atoms * match->receptor_site.total.atoms;  reallocate_match (match);/** If chemical matching is performed, construct new chemical filter* 7/95 te*/  if (match->chemical_flag)    make_chemical_filter (&label->chemical, match);/** If critical cluster matching is performed, construct new filter* to guide matching* 6/95 te*/  if (match->critical_flag)    make_critical_filter (match);  return TRUE;}/* ////////////////////////////////////////////////////////////// 

⌨️ 快捷键说明

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