Exemplo n.º 1
0
int main(int argc, char *argv[])
{
    GlobalStartup();
    DoApplicationSettings ();

    char    curWd[4096],
            dirSlash = GetPlatformDirectoryChar ();
    getcwd (curWd,4096);

    _String baseDir (curWd);

    if (baseDir.getChar (baseDir.sLength-1) != dirSlash) {
        baseDir=baseDir & dirSlash;
    }

    _String libDir (_HYPHY_LIBDIRECTORY_);

    if (libDir.getChar (libDir.sLength-1) != dirSlash) {
        libDir=libDir & dirSlash;
    }

    pathNames&& &libDir;

    libDirectory  = libDir;
    libArgDir     = libDirectory;
    baseDirectory = baseDir;
    baseArgDir    = baseDirectory;


    QApplication app(argc, argv);
    HyphyMain mainWindow;
    ReadInTemplateFiles     ();

    _hyPrimaryConsoleWindow = & mainWindow;

    /*mainWindow.setGeometry(
    QStyle::alignedRect(
        Qt::LeftToRight,
        Qt::AlignCenter,
        mainWindow.size(),
        qApp->desktop()->availableGeometry()
    ));*/

    mainWindow.show();
    mainWindow.raise();
    return app.exec();
}
Exemplo n.º 2
0
//__________________________________________________________________________________
long	DisplayListOfChoices (void)
{
	ReadInTemplateFiles();
	
	if (!availableTemplateFiles.lLength) 
		return -1;
	
	long 		choice = -1;
	char 		buffer[2048];
	_String 	fileAbbr, 
				*thisLine;
	_SimpleList categoryDelimiters;
	_List		categoryHeadings;
	
	for (choice = 0; choice< availableTemplateFiles.lLength; choice++)
	{
		thisLine = (_String*)(*(_List*)availableTemplateFiles(choice))(2);
		if (thisLine->sData[0]=='!')
		{
			categoryDelimiters<<choice;
			fileAbbr = *thisLine;
			fileAbbr.Trim (1,-1);
			categoryHeadings && &fileAbbr;
		}
	}
	
	choice = -1;
	if (categoryDelimiters.lLength==0)
	{
		while (choice == -1)
		{
			for (choice = 0; choice<availableTemplateFiles.lLength; choice++)
			{
				printf ("\n\t(%s):%s",((_String*)(*(_List*)availableTemplateFiles(choice))(0))->getStr(),
									  ((_String*)(*(_List*)availableTemplateFiles(choice))(1))->getStr());
			}
			printf ("\n\n Please type in the abbreviation for the file you want to use (or press ENTER to process custom batch file):");
			fgets (buffer,2048,stdin);
			fgets (buffer,2048,stdin);
			fileAbbr = buffer;
			if (fileAbbr.FirstNonSpaceIndex()<0)
				 return -1;
			fileAbbr.UpCase();
			for (choice = 0; choice<availableTemplateFiles.lLength; choice++)
			{
				if (fileAbbr.Equal((_String*)(*(_List*)availableTemplateFiles(choice))(0)))
					break;							  
			}
			if (choice==availableTemplateFiles.lLength) choice=-1;
		}	
	}
	else
	{
		long categNumber = -1;
		while (choice==-1)
		{
			if (categNumber<0)
			{
				_String   header ("***************** TYPES OF STANDARD ANALYSES *****************"),
						  verString (GetVersionString().getStr());
						  
				if (verString.sLength<header.sLength-2)
				{
					_String padder (128,true);
					long    poop = (header.sLength-2-verString.sLength)/2;
					if (!poop) poop = 1;
					for (choice=0; choice<poop; choice++)
						padder << ' ';
					padder.Finalize();
					verString = padder & '/' & verString & "\\" & padder;
				}
						  
				printf ("\n\033[2J\033[H%s\n%s\n\n",verString.getStr(), header.getStr());
				for (choice = 0; choice<categoryHeadings.lLength; choice++)
					printf ("\n\t(%ld) %s",choice+1,((_String*)categoryHeadings(choice))->getStr());

				printf ("\n\n Please select type of analyses you want to list (or press ENTER to process custom batch file):");
				
				
				fgets (buffer,2048,stdin);
				fileAbbr = buffer;
				
				if (logInputMode)
					loggedUserInputs && & fileAbbr;
		
				if (fileAbbr.FirstNonSpaceIndex()<0)
					 return -1;
				
				choice = fileAbbr.toNum();
				
				if ( choice>0 && choice<=categoryHeadings.lLength)
					categNumber = choice-1;
			}
			else
			{
				printf ("\n\033[2J\033[H ***************** FILES IN '%s' ***************** \n\n",((_String*)categoryHeadings(categNumber))->getStr());
				long start = categoryDelimiters.lData[categNumber]+1,
					 end = categNumber==categoryDelimiters.lLength-1?availableTemplateFiles.lLength:categoryDelimiters.lData[categNumber+1];
				
				for (choice = start; choice<end; choice++)
					printf ("\n\t(%ld) %s",choice-start+1,((_String*)(*(_List*)availableTemplateFiles(choice))(1))->getStr());

				printf ("\n\n Please select the file you want to use (or press ENTER to return to the list of analysis types):");
				
				fileAbbr = *StringFromConsole ();
				
				if (logInputMode)
					loggedUserInputs && & fileAbbr;
				
				if (fileAbbr.FirstNonSpaceIndex()<0)
					 categNumber = -1;
				else
				{
					choice = fileAbbr.toNum();
					if ((choice>0 && choice<=end-start))
						return start+choice-1;
				}
					
			}
			choice = -1;
		}
	}
	return choice;
}
Exemplo n.º 3
0
int main( int   argc, char *argv[] )
{

	#ifdef	__HYPHYMPI__
		  int 		   rank, 
		  			   size;
		  			   			   			 
		  MPI_Init	   (&argc, &argv);
		  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
		  MPI_Comm_size(MPI_COMM_WORLD, &size);
		  
		  _hy_mpi_node_rank = rank;
		  
		  setParameter  (mpiNodeID, (_Parameter)rank);
		  setParameter	(mpiNodeCount, (_Parameter)size);
		  
		  if (rank == 0)
	#endif
   
	gtk_init (&argc, &argv);

	/* set up globals */
	
	char curWd[4096];
	getcwd (curWd,4096);

	_String baseDir (curWd);
	baseDir=baseDir&'/';

	pathNames&& &baseDir;
	baseDirectory = baseDir;
	for (long i=1; i<argc;i++)
	{
		_String thisArg (argv[i]);
		if (thisArg.beginswith ("BASEPATH="))
		{
			baseDirectory = thisArg.Cut(9,-1);
			if (baseDirectory.sLength)
			{
				if (baseDirectory.sData[baseDirectory.sLength-1]!='/')
					baseDirectory = baseDirectory&"/";
			}
		}
		else
			if (thisArg.beginswith ("USEPATH="))
			{
				_String		baseArgDir 			(thisArg,8,-1);
				errorFileName					= baseArgDir & errorFileName;
				messageFileName					= baseArgDir & messageFileName;
				pathNames.Delete				(0);
				pathNames&&						&baseDir;
			}
			else
				if (thisArg.beginswith ("CPU="))
				{
					#ifdef __MP__
					_String cpus = thisArg.Cut(4,-1);
					systemCPUCount = cpus.toNum();
					if (systemCPUCount<1)
						systemCPUCount = 1;
					#ifdef __MP2__
						pthread_setconcurrency (systemCPUCount+1);
					#endif
					#endif
				}
				#ifdef	__HYPHYMPI__
					else
						if (thisArg == _String("MPIOPTIMIZER"))
						{
							mpiParallelOptimizer = true;
							setParameter	(mpiNodeCount, 0.0);
						}
						else
							if (thisArg == _String("MPIPARTITIONS"))
							{
								mpiPartitionOptimizer = true;
								setParameter	(mpiNodeCount, 0.0);
							}
				#endif
	}
	
	#ifdef	__HYPHYMPI__
	if (rank == 0)
	#endif
	{
		baseDir = baseDirectory & "GTKResources";
		_List scanRes;
		ScanDirectoryForFileNames(baseDir,scanRes,false);
		if (scanRes.lLength == 0)
		{
			GtkWidget * noRez = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "HYPHY_GTK was unable to find a required GTKResources directory in %s. Please use BASEPATH= command line option to specify where the installation directory of HyPhy can be found.", baseDirectory.sData);
			gtk_dialog_run (GTK_DIALOG (noRez));
			gtk_widget_destroy (noRez);
			return 1;
		}
		_String rcPath = baseDir & "/theme/theme.rc";
		//printf ("Loading res files from %s\n", rcPath.sData);
		gtk_rc_parse (rcPath.sData);
	}
	
 	GlobalStartup();

	#ifdef	__HYPHYMPI__
	if (rank == 0)
	{
	#endif
	GdkDisplay * defDisplay = gdk_screen_get_display (gdk_screen_get_default());
	hSizeCursor = gdk_cursor_new_for_display (defDisplay,GDK_SB_H_DOUBLE_ARROW);
	pickUpCursor = gdk_cursor_new_for_display (defDisplay,GDK_TARGET);
	dropOffCursor = gdk_cursor_new_for_display (defDisplay,GDK_TCROSS);
	
	screenPContext = gdk_pango_context_get_for_screen (gdk_screen_get_default());
	tablePDMenuIcon = (GdkPixbuf*)ProcureIconResource(4020);
		
	/*{
		GdkScreen * defD = gdk_screen_get_default();
		fontConversionFactor = 72.27 / (gdk_screen_get_height (defD) *25.4 / gdk_screen_get_height_mm(defD)); 
		printf ("Pango conversion factor computed at: %g\n", fontConversionFactor);
	}*/

		
	ReadInTemplateFiles ();
		
	hyphyConsoleWindow = new _HYConsoleWindow ("HYPHY Console");
	ReadPreferences		();
	SetStatusLine ("None","Idle","00:00:00");
	while (gtk_events_pending())
		gtk_main_iteration();

	SetPreferences		();
	ReadGeneticCodes	();	
	ReadModelTemplates	();
	ReadTreeProcessors ();
	MoveConsoleWindow  (consolePositionRectangle);
	StringToConsole (hyphyCiteString);
	hyphyConsoleWindow->BringToFront();

	#ifdef __HYPHYMPI__ 
	{
		char statBuffer[1024];
		sprintf (statBuffer,"MPI version of HyPhy running on %d nodes (a master and %d compute nodes) in %s mode\n",
							 size, 
							 size-1,
							 mpiPartitionOptimizer?"partition":(mpiParallelOptimizer?"rate heterogeneity":"normal"));
		BufferToConsole (statBuffer);
	}
	#endif
		
	g_timeout_add  (100,GlobalQueueTimer,nil);
	g_timeout_add  (1000,progressTimerFunction,nil);
	gtk_main ();

	WritePreferences();
	#ifdef	__HYPHYMPI__
	}
	else // slave node
	{
		if (mpiParallelOptimizer || mpiPartitionOptimizer)
			mpiOptimizerLoop (rank, size);
		else
			mpiNormalLoop (rank, size, baseDir);
	}
	#endif

	GlobalShutdown();
    return 0;
}