Esempio n. 1
0
void Events::simulation() {
	bool hasError = false;
	while (lattice.coverage() < c::finalCoverage) {
		execute();
		//if (crossCheck()) {
		//	hasError = true;
		//}
	}
	crossCheck(true);
	std::cout << properties.showHead();
	std::cout << properties.show();
	if (hasError) {
		std::cout << "Error encountered through simulation" << std::endl;
	} else {
		std::cout << "OK" << std::endl;
	}
	std::cout << "Diff barrier = " << E_d << std::endl;
	countBounds();
	std::cout << std::endl;

	std::stringstream name;
	name << "double" << E_d << ".pdb";
	utils::saveFile(name.str(), lattice.gridToPdb());
	//utils::loadInJMol(name.str());
}
//main ()
int main (int argc, char *argv[]) {
//Call syntax check
    if (argc != 6) {
        printf ("Usage: %s Fasta_filename Human_interactions Yeast_interactions Negative_interactions Output_CSV_filename\n", argv[0]);
        exit (1);
    }
//Main variables
    fastaEntry *firFasta = NULL;
    FILE *inFile, *fasFile, *outFile;
//File creation and checks
    printf ("Opening initial files...\n");
    createFile (&fasFile, argv[1], 'r');
    createFile (&inFile, argv[2], 'r');
    createFile (&outFile, argv[5], 'w');
    fprintf (outFile, "Source,Protein,A,C,D,E,F,G,H,I,K,L,M,N,P,Q,R,S,T,V,W,Y,Class\n");
//Build dynamic linked list of scaf data
    printf ("Files found and created.  Compiling fasta entries...\n");
    createFastaEntry (&firFasta);
    createFastaList (firFasta, fasFile);
    fclose (fasFile);
//Find the entries from the Human interaction file
    printf ("Compiled.  Cross referencing with Human interaction profile...\n");
    crossCheck (firFasta, 'H', 'I', inFile, outFile);
    fclose (inFile);
//Find the entries from the Yeast interaction file
    printf ("Cross referenced.  Cross referencing with Yeast interaction profile...\n");
    createFile (&inFile, argv[3], 'r');
    crossCheck (firFasta, 'Y', 'I', inFile, outFile);
    fclose (inFile);
//Find the entries from the Negative interaction file
    printf ("Cross referenced.  Cross referencing with Negative interaction profile...\n");
    createFile (&inFile, argv[4], 'r');
    crossCheck (firFasta, 'N', 'N', inFile, outFile);
    fclose (inFile);
//Close everything
    printf ("Cross referenced.  Freeing memory and closing files...\n");
    fclose (outFile);
    freeFastaList (firFasta);
    printf ("Done.\n");
    return 0;
}
void hgLoadEranModules(char *database, 
	char *geneToModule, char *moduleToMotif, char *motifWeights,
	char *motifPositions, char *genePositions)
/* hgLoadEranModules - Load regulatory modules from Eran Segal. */
{
struct sqlConnection *conn = sqlConnect(database);
struct hash *positionsHash = loadGenePositions(database, conn, genePositions);
struct hash *moduleAndMotifHash = loadModuleToMotif(conn, moduleToMotif, "esRegModuleToMotif");
struct hash *geneToModuleHash = loadGeneToModule(conn, geneToModule, "esRegGeneToModule");
struct hash *motifHash = loadMotifWeights(conn, motifWeights, "esRegMotif");
loadGeneToMotif(conn, motifPositions, "esRegGeneToMotif", geneToModuleHash, moduleAndMotifHash, motifHash, positionsHash, "esRegUpstreamRegion");
crossCheck(conn, "esRegMotif", "esRegGeneToModule", "esRegGeneToMotif", "esRegModuleToMotif");
}
Esempio n. 4
0
simulationReturn Events::growthSimulation()
{
	/*std::cout << std::endl;
	for (int i = 0; i < 4; i++) {
		std::cout << evolution._rates.getRate(0, i, 0);
	}
	for (int i = 0; i < 4; i++) {
		std::cout << evolution._rates.getRate(i, 0, 0);
	}
	std::cin.ignore();*/

	int position = c::A / 2 + c::w / 3;
	//for (int n = 0; n < 6; n++) {
	//	adsorption(neigh::neigh(n,position), atomType::silicon);
	//}
	adsorption(position, atomType::silicon);

	int nShows = 10;
	double currTarget = _targetCoverage / 10;

   while (_getCoverage() < _targetCoverage) {
      if (_nEvents % 1000000 == 0) {
			std::cout << _nEvents << "\t" << _getCoverage() << std::endl;
			if (crossCheck(false) != 0) {
				crossCheck();
				std::cin.ignore();
			}
      }
		if (_getCoverage() > currTarget) {
			results.addGridState(grid._lattice);
			results.addRow(getResultVector());
			currTarget += _targetCoverage / 10;
		}
      execute();
	}
	crossCheck();
   results.addGridState(grid._lattice);
   results.addRow(getResultVector());

	/*double relaxTime = 50.0;
	double targetTime = evolution._masterTime + relaxTime;

	evolution._rates.ads = 0.0;
	evolution._rates.totalAds = 0.0;

	while (evolution._masterTime < targetTime) {
		if (_nEvents % 1000000 == 0) {
			std::cout << _nEvents << "\t" << _getCoverage() << std::endl;
			if (crossCheck(false) != 0) {
				crossCheck();
				std::cin.ignore();
			}
		}
		execute();
	}
	crossCheck();
	results.addGridState(grid._lattice);
	results.addRow(getResultVector());*/

   return simulationReturn::allright;
}