main_grow.c

来自「药物开发中的基于结构的从头设计代码」· C语言 代码 · 共 141 行

C
141
字号
# include "grow.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 GROW.");
		 puts("The correct usage is: grow index_file");
		 exit(1);
		}

        printf("\nLigBuilder/Grow 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=&parameter;
	// 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;

	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 generational replacement mode 

	for(i=1;i<=parm->num_generation;i++)
		{
		 printf("\nGeneration %d: ", i);
		 printf("%s",Get_Time());

		 printf("Now selecting molecules into the mating pool ...\n");
		 population.Select_Parents(parm->num_parent);
		 // printf("%s\n",Get_Time());

		 printf("Now selecting elites from the old population ...\n");
		 population.Select_Elites(parm->elitism_ratio,i);
		 // printf("%s\n",Get_Time());

		 printf("Now generating the new population ...\n"); 
		 population.Growing_On_Population(i);
		 // printf("%s\n",Get_Time());

		 population.Statistics(); population.Count_Wins();

		 printf("Now collecting new molecules into %s ...\n", parm->ligands_file); 
		 population.Record_Results(parm->ligands_file);
		 // printf("%s\n",Get_Time());
		}

	// 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/Grow has done the job successfully ... ");
        printf("%s\n",Get_Time());

	return 0;
}

⌨️ 快捷键说明

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