Esempio n. 1
0
DIError DiskEditDialog::OpenFile(const WCHAR* fileName, bool openRsrc,
    A2File** ppFile, A2FileDescr** ppOpenFile)
{
    A2File* pFile;
    A2FileDescr* pOpenFile = NULL;

    LOGI(" OpenFile '%ls' rsrc=%d", fileName, openRsrc);
    CStringA fileNameA(fileName);
    pFile = fpDiskFS->GetFileByName(fileNameA);
    if (pFile == NULL) {
        CString msg, failed;

        msg.Format(IDS_DEFILE_FIND_FAILED, fileName);
        failed.LoadString(IDS_FAILED);
        MessageBox(msg, failed, MB_OK | MB_ICONSTOP);
        return kDIErrFileNotFound;
    }

    DIError dierr;
    dierr = pFile->Open(&pOpenFile, true, openRsrc);
    if (dierr != kDIErrNone) {
        CString msg, failed;

        msg.Format(IDS_DEFILE_OPEN_FAILED, fileName,
            DiskImgLib::DIStrError(dierr));
        failed.LoadString(IDS_FAILED);
        MessageBox(msg, failed, MB_OK | MB_ICONSTOP);
        return dierr;
    }

    *ppFile = pFile;
    *ppOpenFile = pOpenFile;

    return kDIErrNone;
}
Esempio n. 2
0
int
testVdwGA(){
	//--------------------- protein -------------------------------------
	string							fileNameA ( "/mnt/2t/xushutan/project/gold_dock/1a9u_diverse500/1A9U_protein.mol2" ) ;
	Molecular						molA( fileNameA );
	molA = readMolecularFile( fileNameA ).front();
	mol = molA;

	bindingAtomVec = getBindingSiteAtoms( mol, bindingCenter, bindingDiameter );
	if(1){
		cout<<"binding site atoms:"<<bindingAtomVec.size()<<endl;
		for( size_t i=0; i<bindingAtomVec.size(); i++ ){
			bindingAtomVec[i].print();
		}
	}
	vector<Atom>			protHbAcceptorAtoms = goldPar.getHydrogenBondAcceptorAtoms( bindingAtomVec );
	vector<Atom>			protHbDonorAtoms = goldPar.getHydrogenBondDonorAtoms( bindingAtomVec );

	if(0){
		cout<<"prot acceptor:"<<protHbAcceptorAtoms.size()<<endl;
		for( size_t i=0; i<protHbAcceptorAtoms.size(); i++ ){
			protHbAcceptorAtoms[i].print();
		}
		cout<<"prot donor:"<<protHbDonorAtoms.size()<<endl;
		for( size_t i=0; i<protHbDonorAtoms.size(); i++ ){
			protHbDonorAtoms[i].print();
		}
	}

	//---------------------------- ligand -----------------------------------
	string							fileNameB = "/mnt/2t/xushutan/project/gold_dock/1a9u_diverse500/ligand_corina.mol2";
	Molecular						molB;
	molB = readMolecularFile( fileNameB ).front();

	vector<Atom>			ligHbAcceptorAtoms = goldPar.getHydrogenBondAcceptorAtoms( molB.get_atomVec() );
	vector<Atom>			ligHbDonorAtoms = goldPar.getHydrogenBondDonorAtoms( molB.get_atomVec() );

	if(0){
		cout<<"lig acceptor:"<<ligHbAcceptorAtoms.size()<<endl;
		for( size_t i=0; i<ligHbAcceptorAtoms.size(); i++ ){
			ligHbAcceptorAtoms[i].print();
		}
		cout<<"lig donor:"<<ligHbDonorAtoms.size()<<endl;
		for( size_t i=0; i<ligHbDonorAtoms.size(); i++ ){
			ligHbDonorAtoms[i].print();
		}
		cout<<"-----------"<<endl;
	}

	Coord							ligand_N25( 0.1835,    0.8981,    0.1207 );
	Coord							standardLigand_NC3(  3.576,  15.169,  28.381 );

	Coord							direction = standardLigand_NC3 - ligand_N25 ;
	double						distance = getCoordDis( standardLigand_NC3, ligand_N25 );
	ligand = translateMol( molB, direction, distance );
	ligand.print();

	rotableBondVec = getRotableBonds( molB );

	if(1){
		cout<<"rotableBondNum:"<<rotableBondVec.size()<<endl;
		for( size_t i=0; i<rotableBondVec.size(); i++ ){
			rotableBondVec[i].print();
		}
	}

	population *pop=NULL;	/* The population of solutions. */

	int 	chromoLength = 7 + rotableBondVec.size();
	cout<<"chromolength:"<<  rotableBondVec.size()<<endl;;
	random_seed( 10000 );
	pop = ga_genesis_double(
			6,												// population size
			1, 												// num_chromo: ligand position, rotation and bond rotation
			7 + rotableBondVec.size(),			// chromo length, here 7 is position 3 + rotation 3 + translate distance 1
			NULL,
			NULL,
			NULL,
			NULL,
			docking_score,
//			ga_seed_printable_random,
			initialChromo,
			NULL,
			ga_select_one_sus,        /* GAselect_one           select_one */
			ga_select_two_sus,        /* GAselect_two           select_two */
			ga_mutate_double_multipoint, /* GAmutate  mutate */
			ga_crossover_double_mean, /* GAcrossover     crossover */
			NULL,                     /* GAreplace              replace */
			NULL                      /* void *                 userdata */
			);
	ga_population_set_parameters(
			pop,                     /* population              *pop */
			GA_SCHEME_DARWIN,        /* const ga_class_type     class */
			GA_ELITISM_PARENTS_DIE,  /* const ga_elitism_type   elitism */
			0.9,                     /* double                  crossover */
			0.2,                     /* double                  mutation */
			0.0                      /* double                  migration */
	);
	ga_evolution(
			pop,                     /* population              *pop */
			int(2)                    /* const int               max_generations */
	);
	printf( "Fitness score = %f\n", ga_get_entity_from_rank(pop,0)->fitness);
	ga_extinction(pop);	/* Deallocates all memory associated with  the population and it's entities. */
	exit(EXIT_SUCCESS);

}