📄 main_link.c
字号:
# include "link.h"
// global variables used in this program
Parameter *parm=NULL; // paramters from the index file
ForceField *ff=NULL; // force field
FragLibrary *fraglib=NULL; // building block library
FragLibrary *forbidlib=NULL; // forbidden substructure library
FragLibrary *toxiclib=NULL; // toxic substructure library
Pocket *pok=NULL; // binding pocket
int main(int argc,char *argv[])
{
extern Parameter *parm;
extern ForceField *ff;
extern FragLibrary *fraglib;
extern FragLibrary *forbidlib;
extern FragLibrary *toxiclib;
extern Pocket *pok;
if(argc!=2)
{
printf("\n");
puts("Error: no index file is given for LINK.");
puts("The correct usage is: link index_file");
exit(1);
}
printf("\nLigBuilder/Link starts to run ... ");
printf("%s\n",Get_Time());
Set_Random_Number();
printf("Now reading parameters from '%s' ... \n", argv[1]);
Parameter parameter(argv[1]); parm=¶meter;
// parameter.Show_Content();
Pocket pocket; pok=&pocket;
printf("Now reading the binding pocket grids from '%s' ...\n",parm->grid_file);
pocket.Read_Grids(parm->grid_file);
printf("Now reading the binding pocket atoms from '%s' ...\n",parm->pocket_file);
pocket.Read_Atoms(parm->pocket_file);
// pocket.Show_Content();
printf("Now reading force field parameters from '%s' ...\n", parm->parameter_dir);
ForceField forcefield(parm->parameter_dir); ff=&forcefield;
// forcefield.Show_Content();
printf("Now reading the building block library from '%s' ... \n", parm->fraglib_dir);
FragLibrary fraglibrary; fraglib=&fraglibrary;
fraglibrary.Read_Library(parm->fraglib_dir);
fraglibrary.Assign_Parameters();
// fraglibrary.Show_Content();
FragLibrary forbidlibrary; forbidlib=&forbidlibrary;
if(!strcmp(parm->apply_forbidden_check,"YES"))
{
printf("Now reading the forbidden structure library from '%s' ... \n", parm->forbidlib_dir);
forbidlibrary.Read_Library(parm->forbidlib_dir);
forbidlibrary.Assign_Parameters();
// forbidlibrary.Show_Content();
}
FragLibrary toxiclibrary; toxiclib=&toxiclibrary;
if(!strcmp(parm->apply_toxicity_check,"YES"))
{
printf("Now reading the toxic structure library from '%s' ... \n", parm->toxiclib_dir);
toxiclibrary.Read_Library(parm->toxiclib_dir);
toxiclibrary.Assign_Parameters();
// toxiclibrary.Show_Content();
}
Population population;
Ligand seed;
int i,j;
printf("\nNow starting the Genetic Algorithm procedure ... ");
printf("%s\n",Get_Time());
if(parm->ga_starting_mode==1) // from a seed ligand
{
printf("Now reading the seed structure from '%s' ...\n", parm->seed_file);
seed.Read_From_Mol2(parm->seed_file);
seed.Detect_Connections();
seed.Seed_Structure_Check();
seed.Assign_Atom_Parameters();
seed.Get_Molecular_Properties();
seed.Calculate_Binding_Score();
seed.Calculate_Chemical_Score();
printf("Now generating the initial population ...\n");
population.Initialize(seed);
population.Statistics();
population.Count_Wins();
}
else // from current population
{
printf("Now reading the population from '%s' ...\n", parm->seed_file);
population.Read_From_Lig(parm->seed_file);
population.Statistics();
population.Count_Wins();
}
// GA procedure in steady-state mode
int mother_id;
Ligand result[24];
for(i=1;i<=parm->num_generation;i++)
{
mother_id=population.Select_A_Mother_Molecule();
if(mother_id!=FALSE)
{
if(population.Growing_On_Molecule(mother_id,result))
{
// add the new molecules to the population
for(j=0;j<24;j++)
{
if(result[j].valid==0) continue;
else if(population.Add_A_Molecule_To_Result(result[j])==TRUE)
{
result[j].valid=0;
continue;
}
else population.Add_A_Molecule_To_Population(result[j]);
}
}
}
if((i%parm->max_population)==0)
{
printf("\nStatistics of generation %d: ", i);
printf("%s",Get_Time());
population.Statistics();
}
}
// now clean up everything
printf("\nNow saving the final population in '%s' ...\n", parm->population_file);
population.Write_Out_Lig(parm->population_file);
printf("\nLigBuilder/Link has done the job successfully ... ");
printf("%s\n",Get_Time());
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -