⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mutate.c

📁 药物开发中的基于结构的从头设计代码
💻 C
📖 第 1 页 / 共 2 页
字号:
# include "link.h"

void Ligand::Rational_Mutate()
{
	extern Pocket *pok;
	int i,tmp,mark,num_candidate;
	char grid,*candidate;

	// first, make the list of all the possible mutations 

	candidate=new char[num_atom];
	if(candidate==NULL) Memory_Allocation_Error();

	for(i=0;i<num_atom;i++) candidate[i]='V';

	for(i=0;i<num_atom;i++)
		{
                 if(atom[i].type[0]=='H') continue;

		 grid=pok->Get_Grid_Property(atom[i].coor);

		 if(grid=='E') candidate[i]='E';
		 else if(grid=='H')
			{
			 if(!strcmp(atom[i].hb,"DA")||
			    !strcmp(atom[i].hb,"A")||
			    !strcmp(atom[i].hb,"D")) candidate[i]='H';
			}
		 else if(grid=='D')
			{
			 if(!strcmp(atom[i].hb,"N")||
			    !strcmp(atom[i].hb,"A")) candidate[i]='D';
			}
		 else if(grid=='A')
			{
			 if(!strcmp(atom[i].hb,"N")||
                            !strcmp(atom[i].hb,"D")) candidate[i]='A';
			}
		}

	// then, mutate each of the candidate until no candidate is available 
	
	Ligand tmp_lig;
	Ligand tmp_result(this->num_atom+100,this->num_bond+100);

	tmp_lig=*this;

	mark=0;

	while(1)
	{
	 num_candidate=0;

	 for(i=0;i<num_atom;i++)
		{
		 if(candidate[i]!='V') num_candidate++;
		 else continue;
		}

	 if(num_candidate==0) break;

	 tmp_result<=tmp_lig;	// notice!

	 for(i=0;i<num_atom;i++)
		{
		 if(candidate[i]=='V') continue;

		 tmp=tmp_result.Mutate_An_Atom(atom[i].id,candidate[i]);

		 if(tmp==FALSE) 
			{
			 candidate[i]='V'; break;
			}
		 else if(tmp_result.Mutation_Viability_Check(atom[i].id)==FALSE)
			{
			 candidate[i]='V'; break;
			}
		 else
			{
			 // printf("Mutation happened! atom %d\n", atom[i].id);
			 candidate[i]='V';
			 tmp_lig=tmp_result;
			 mark++;
			 break;
			}
		}
	}

	delete [] candidate;

	if(mark!=0)
		{
		 tmp_lig.valid=tmp_lig.Arrange_IDs(); 
		 if(tmp_lig.valid!=0) *this=tmp_lig;
		}

	return;
}

int Ligand::Mutate_An_Atom(int atom_id, char grid)
// atom_id is the ID of the atom
// grid is the target property 
{
	int mark,tmp;
	Group group;

	mark=FALSE;

	if(grid=='E') 
		{
		 mark=Mutate_An_Atom_To_H(atom_id);
		}
	else if(grid=='H')
		{
		 if(!strcmp(atom[atom_id-1].type,"N.4")||
		    !strcmp(atom[atom_id-1].type,"N.3")||
		    !strcmp(atom[atom_id-1].type,"O.3")||
		    !strcmp(atom[atom_id-1].type,"N.am"))
			{
			 mark=Mutate_An_Atom_To_C3(atom_id);
			}
		 else if(!strcmp(atom[atom_id-1].type,"N.2"))
			{
			 mark=Mutate_An_Atom_To_C2(atom_id);
			}
		 else if(!strcmp(atom[atom_id-1].type,"N.ar"))
			{
			 mark=Mutate_An_Atom_To_Car(atom_id);
			}
		}
	else if(grid=='A')
		{
		 if(!strcmp(atom[atom_id-1].type,"C.3")||
		    !strcmp(atom[atom_id-1].type,"N.4")||
		    !strcmp(atom[atom_id-1].type,"N.3")||
		    !strcmp(atom[atom_id-1].type,"N.am")||
		    !strcmp(atom[atom_id-1].type,"N.pl3"))
			{
			 mark=Mutate_An_Atom_To_O3(atom_id);
			}
		 else if(!strcmp(atom[atom_id-1].type,"C.2"))
			{
			 mark=Mutate_An_Atom_To_N2(atom_id);
			}
		 else if(!strcmp(atom[atom_id-1].type,"C.ar"))
			{
			 mark=Mutate_An_Atom_To_Nar(atom_id);
			}
		}
	else if(grid=='D')
		{
		 group=Find_A_Group(atom_id);
		 tmp=CO_Connection_Check(group);

		 if(tmp==0)
			{
			 if(!strcmp(atom[atom_id-1].type,"C.3"))
				{
				 if(group.num_nonh==1)
					mark=Mutate_An_Atom_To_O3(atom_id);
				 else mark=Mutate_An_Atom_To_N4(atom_id);
				}
		     	else if(!strcmp(atom[atom_id-1].type,"O.3")&&
				 group.num_nonh==2)
				{
				 if(group.num_pi==2&&atom[atom_id-1].ring!=0)
					mark=Mutate_An_Atom_To_Npl3(atom_id);
				 else mark=Mutate_An_Atom_To_N4(atom_id);
				} 
			}
		 else
			{
			 if(!strcmp(atom[atom_id-1].type,"C.3")||
			    !strcmp(atom[atom_id-1].type,"O.3"))
				{
				 mark=Mutate_An_Atom_To_Nam(atom_id);
				}
			}
		}

	return mark;
}

int Ligand::Mutate_An_Atom_To_C3(int atom_id)
{
	char tmp_type[10];
	strcpy(tmp_type,atom[atom_id-1].type);

	Group group;
	group=Find_A_Group(atom_id);

	if(!strcmp(tmp_type,"N.4")||!strcmp(tmp_type,"N.3")) 
		{
		 // simply change the atom
		 strcpy(atom[atom_id-1].name,"C");
		 strcpy(atom[atom_id-1].type,"C.3");
		 atom[atom_id-1].weight=12;
		 return TRUE;
		}
	else if(!strcmp(tmp_type,"N.am")&&(group.num_neib==3))
		{
         	 int bond_id;
         	 if(group.num_nonh==0) return FALSE;      // N.am.3h!
         	 else if(group.num_nonh<=2)               // N.am.2h & N.am.h
                	{
                 	 Delete_An_Atom(group.neib[2].id);
		 	 bond_id=CO_Connection_Check(group);
                 	 if(bond_id>0) strcpy(bond[bond_id-1].type,"1");
                	}
         	 else return FALSE;                       // N.am
		}
	else if(!strcmp(tmp_type,"O.3")&&(group.num_neib==2)) {}
	else return FALSE;

	// add two sp3 hydrogens and change the atom

	strcpy(group.center.name,"C");
	strcpy(group.center.type,"C.3");
	group.center.weight=12;

	extern ForceField *ff;
	int i;
	float v1[3],v2[3];
	float length;
	Atom h1,h2;
	Bond b1,b2;

	for(i=0;i<3;i++)
		{
		 v1[i]=group.neib[0].coor[i]-group.center.coor[i];
		 v2[i]=group.neib[1].coor[i]-group.center.coor[i];
		}	

	Unify_Vector(v1); Unify_Vector(v2);

	Get_Sp3_Coordinates(v1,v2,h1.coor,h2.coor);

	length=ff->Get_Bond_Length("C.3","H","1");

	for(i=0;i<3;i++)
		{
		 h1.coor[i]=group.center.coor[i]+length*h1.coor[i];
		 h2.coor[i]=group.center.coor[i]+length*h2.coor[i];
		}

	h1.id=num_atom+1; h1.valid=group.center.valid; 
	strcpy(h1.name,"H"); strcpy(h1.type,"H.spc");
	h1.weight=1;

	h2.id=num_atom+2; h2.valid=group.center.valid;
	strcpy(h2.name,"H"); strcpy(h2.type,"H.spc");
	h2.weight=1;

	b1.id=num_bond+1; b1.valid=1;
	b1.atom_1=group.center.id; b1.atom_2=h1.id; 
	strcpy(b1.type,"1");
	
	b2.id=num_bond+2; b2.valid=1;
	b2.atom_1=group.center.id; b2.atom_2=h2.id;
	strcpy(b2.type,"1");
	
	atom[atom_id-1]=group.center;
	atom[num_atom]=h1; atom[num_atom+1]=h2;
	bond[num_bond]=b1; bond[num_bond+1]=b2;	

	num_atom+=2; num_bond+=2;

	return TRUE;
}

int Ligand::Mutate_An_Atom_To_N4(int atom_id)
{
	char tmp_type[10];
	strcpy(tmp_type,atom[atom_id-1].type);

	Group group;
	group=Find_A_Group(atom_id);

	// first, check whether it is possible to make a mutation

	if(CO_Connection_Check(group)>0) return FALSE;
	else if(!strcmp(tmp_type,"C.3")&&(group.num_nonh<=3)) 
		{
		 // simply change the atom
		 strcpy(atom[atom_id-1].name,"N");
		 strcpy(atom[atom_id-1].type,"N.4");
		 atom[atom_id-1].weight=14;
		 return TRUE;
		}
	else if(!strcmp(tmp_type,"O.3")&&(group.num_neib==2)) {}
	else return FALSE;

	// add two sp3 hydrogens and change the atom

	strcpy(group.center.name,"N");
	strcpy(group.center.type,"N.4");
	group.center.weight=14;

	extern ForceField *ff;
	int i;
	float v1[3],v2[3];
	float length;
	Atom h1,h2;
	Bond b1,b2;

	for(i=0;i<3;i++)
		{
		 v1[i]=group.neib[0].coor[i]-group.center.coor[i];
		 v2[i]=group.neib[1].coor[i]-group.center.coor[i];
		}	

	Unify_Vector(v1); Unify_Vector(v2);

	Get_Sp3_Coordinates(v1,v2,h1.coor,h2.coor);

	length=ff->Get_Bond_Length("N.4","H","1");

	for(i=0;i<3;i++)
		{
		 h1.coor[i]=group.center.coor[i]+length*h1.coor[i];
		 h2.coor[i]=group.center.coor[i]+length*h2.coor[i];
		}

	h1.id=num_atom+1; h1.valid=group.center.valid; 
	strcpy(h1.name,"H"); strcpy(h1.type,"H.spc");
	h1.weight=1;

	h2.id=num_atom+2; h2.valid=group.center.valid;
	strcpy(h2.name,"H"); strcpy(h2.type,"H.spc");
	h2.weight=1;

	b1.id=num_bond+1; b1.valid=1;
	b1.atom_1=group.center.id; b1.atom_2=h1.id; 
	strcpy(b1.type,"1");
	
	b2.id=num_bond+2; b2.valid=1;
	b2.atom_1=group.center.id; b2.atom_2=h2.id;
	strcpy(b2.type,"1");
	
	atom[atom_id-1]=group.center;
	atom[num_atom]=h1; atom[num_atom+1]=h2;
	bond[num_bond]=b1; bond[num_bond+1]=b2;	

	num_atom+=2; num_bond+=2;

	return TRUE;
}

int Ligand::Mutate_An_Atom_To_O3(int atom_id)
{
	Group group;
	group=Find_A_Group(atom_id);

	int bond_id;

	if(group.num_nonh==0) return FALSE;
	else if(group.num_nonh<=2&&(group.num_neib<=4))
		{
	 	 strcpy(atom[atom_id-1].name,"O");
	 	 strcpy(atom[atom_id-1].type,"O.3");
		 atom[atom_id-1].weight=16;

		 if(!strcmp(group.center.type,"N.am"))
			{
		 	 bond_id=CO_Connection_Check(group);
			 if(bond_id>0) strcpy(bond[bond_id-1].type,"1");
			}

	 	 if(group.num_nonh==2&&group.num_neib==3)
			{
		 	 Delete_An_Atom(group.neib[2].id);
			}
		 else if(group.num_nonh==1&&group.num_neib==3)
			{
			 Delete_An_Atom(group.neib[1].id);
			}
	 	 else if(group.num_nonh==2&&group.num_neib==4)
			{
		 	 Delete_An_Atom(group.neib[2].id);
		 	 Delete_An_Atom(group.neib[3].id);
			}
		 else if(group.num_nonh==1&&group.num_neib==4)
			{
			 Delete_An_Atom(group.neib[1].id);
		 	 Delete_An_Atom(group.neib[3].id);
			}
		 else return FALSE;
		}
	else return FALSE;

⌨️ 快捷键说明

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