void _HYObjectInspector::OpenObject (void) { _HYPullDown* p1 = (_HYPullDown*)GetCellObject (0,2); switch (p1->GetSelection()) { case 0: { OpenTreeFile(); break; } case 1: { OpenDataFile(); break; } case 2: { OpenModelFile(); break; } default: return; } BuildListOfObjects (p1->GetSelection()); }
bool _HYConsoleWindow::_ProcessMenuSelection (long msel) { switch (msel) { case HY_WINDOW_MENU_ID_FILE+1: SaveConsole (); return true; case 14: _DoPrint (); return true; case 16: ((_HYTextBox*)GetObject(0))->_DoUndo(true); return true; case 17: ((_HYTextBox*)GetObject(0))->_DoCut(true); return true; case 18: ((_HYTextBox*)GetObject(0))->_DoCopy(true); return true; case HY_WINDOW_MENU_ID_EDIT+5: ((_HYTextBox*)GetObject(0))->_DoSelectAll(true); return true; case 21: SetStatusLine ("Canceling"); terminateExecution = true; return true; case 22: { GtkWidget * suspendItem = gtk_item_factory_get_widget_by_action(menu_items,22); if (!isSuspended) { isSuspended = true; SetStatusLine (empty,empty,empty,-1,HY_SL_SUSPEND); gtk_label_set_text (GTK_LABEL (gtk_bin_get_child(GTK_BIN(suspendItem))), "Resume"); updateTimer = false; while (isSuspended) { gtk_main_iteration_do(true); } } else { isSuspended = false; SetStatusLine (empty,empty,empty,-1,HY_SL_RESUME); gtk_label_set_text (GTK_LABEL (gtk_bin_get_child(GTK_BIN(suspendItem))), "Suspend execution"); timerStart += clock()-lastTimer; updateTimer = true; } return true; } case 23: ShowMessagesLog(); return true; case 24: RunStandardAnalyses(); return true; case 25: displayAbout(false); return true; case HY_WINDOW_MENU_ID_EDIT+4: ((_HYTextBox*)GetObject(0))->_DoClear (true,true); return true; case 27: HandlePreferences (globalPreferencesList,"HYPHY Preferences"); return true; case 29: //WinExec ("hh HYPHY HELP.chm",SW_SHOWNORMAL); return true; case 30: if (OpenBatchFile (false)) { ExecuteBatchFile(); PopFilePath(); } return true; case 31: ((_HYTextBox*)GetObject(0))->_DoRedo(true); return true; case 15: postWindowCloseEvent (GetID()); gtk_main_quit (); return true; case 60: // expression calculator if (calculatorMode) { _HYTextBox *ib = (_HYTextBox*)hyphyConsoleWindow->GetObject(1); ib->SetText ("exit"); hyphyConsoleWindow->ProcessEvent (generateTextEditChangeEvent(ib->GetID(),2)); calculatorMode = false; //ib->SetText (empty); } else { calculatorMode = true; while(calculatorMode&&ExpressionCalculator()) {} calculatorMode = false; } return true; case 61: { // execute selection ExecuteSelection(); return true; } case 70: // New Tree NewTreeWindow(-1); return true; case 71: // New Model NewModel(nil); return true; case 72: // New Chart NewChartWindow(); return true; case 73: // New Genetic Code NewGeneticCodeTable(0); return true; case 74: // New Database NewDatabaseFile(0); return true; case 80: // Open Batch File if (OpenBatchFile()) { ExecuteBatchFile (); } return true; case 81: // Open Data File OpenDataFile(); return true; case 82: // Open Tree OpenTreeFile(); return true; case 83: // Open Text OpenTextFile(); return true; case 84: // Open Table OpenTable (); return true; case 85: // Open SQLite database OpenDatabaseFile (nil); return true; case HY_WINDOW_MENU_ID_FILE-2: ShowObjectInspector (); return true; default: { msel -= 1000; if (msel<availablePostProcessors.lLength) { ExecuteAPostProcessor (*(_String*)(*(_List*)availablePostProcessors(msel))(1)); return 0; } msel-=1000; if (msel<(long)recentPaths.lLength) { if (msel == -1) { for (long mi=0; mi<recentFiles.lLength; mi++) { GtkWidget * recFile = gtk_item_factory_get_widget_by_action(hyphyConsoleWindow->menu_items,2000+mi); if (recFile) { gtk_item_factory_delete_item(hyphyConsoleWindow->menu_items,gtk_item_factory_path_from_widget(recFile)); } } recentPaths.Clear(); recentFiles.Clear(); } else { if (argFileName) { *argFileName = *(_String*)recentPaths(msel); } else { argFileName = new _String (*(_String*)recentPaths(msel)); } if (OpenBatchFile(false)) { ExecuteBatchFile (); } } return true; } return true; } } return _HYTWindow::_ProcessMenuSelection(msel); }
int main(int argc, char **argv) { int i, j, k, treeNo, sumLength; char ch; TTree **treeSet; FILE *text_fv; clock_t totalStart; double totalSecs, scale, sum; char *ancestor; totalStart = clock(); ReadParams(argc, argv); if (rateHetero == CodonRates && invariableSites) { fprintf(stderr, "Invariable sites model cannot be used with codon rate heterogeneity.\n"); exit(4); } if (writeAncestors && fileFormat == NEXUSFormat) { fprintf(stderr, "Warning - When writing ancestral sequences, relaxed PHYLIP format is used.\n"); } if (writeAncestors && maxPartitions > 1) { fprintf(stderr, "Writing ancestral sequences can only be used for a single partition.\n"); exit(4); } if (!userSeed) randomSeed = CreateSeed(); SetSeed(randomSeed); if (!quiet) PrintTitle(); numTrees = OpenTreeFile(); /* if (!treeFile) { */ ReadFileParams(); /*} */ if ((ancestorSeq>0 && !hasAlignment) || ancestorSeq>numSequences) { fprintf(stderr, "Bad ancestral sequence number: %d (%d sequences loaded)\n", ancestorSeq, numSequences); exit(4); } if (textFile) { if ( (text_fv=fopen(textFileName, "rt"))==NULL ) { fprintf(stderr, "Error opening text file for insertion into output: '%s'\n", textFileName); exit(4); } } ancestor=NULL; if (hasAlignment) { AllocateMemory(); ReadFile(); if (numSites<0) numSites=numAlignmentSites; if (ancestorSeq>0) { if (numSites!=numAlignmentSites) { fprintf(stderr, "Ancestral sequence is of a different length to the simulated sequences (%d)\n", numAlignmentSites); exit(4); } ancestor=sequences[ancestorSeq-1]; } } else if (numSites<0) numSites=1000; SetModel(model); numTaxa=-1; scale=1.0; treeSet = (TTree **)malloc(sizeof(TTree **) * maxPartitions); if (treeSet==NULL) { fprintf(stderr, "Out of memory\n"); exit(5); } partitionLengths = (int *)malloc(sizeof(int) * maxPartitions); if (partitionLengths==NULL) { fprintf(stderr, "Out of memory\n"); exit(5); } partitionRates = (double *)malloc(sizeof(double) * maxPartitions); if (partitionRates==NULL) { fprintf(stderr, "Out of memory\n"); exit(5); } for (i = 0; i < maxPartitions; i++) { if ((treeSet[i]=NewTree())==NULL) { fprintf(stderr, "Out of memory\n"); exit(5); } } CreateRates(); treeNo=0; do { partitionLengths[0] = -1; ReadTree(tree_fv, treeSet[0], treeNo+1, 0, NULL, &partitionLengths[0], &partitionRates[0]); if (treeNo==0) { numTaxa=treeSet[0]->numTips; if (!quiet) fprintf(stderr, "Random number generator seed: %ld\n\n", randomSeed); if (fileFormat == NEXUSFormat) { fprintf(stdout, "#NEXUS\n"); fprintf(stdout, "[\nGenerated by %s %s\n\n", PROGRAM_NAME, VERSION_NUMBER); PrintVerbose(stdout); fprintf(stdout, "]\n\n"); } } else if (treeSet[0]->numTips != numTaxa) { fprintf(stderr, "All trees must have the same number of tips.\n"); exit(4); } if (maxPartitions == 1) { if (partitionLengths[0] != -1) { fprintf(stderr, "\nWARNING: The treefile contained partion lengths but only one partition\n"); fprintf(stderr, "was specified.\n"); } partitionLengths[0] = numSites; } sumLength = partitionLengths[0]; i = 1; while (sumLength < numSites && i <= maxPartitions) { if (!IsTreeAvail(tree_fv)) { fprintf(stderr, "\nA set of trees number %d had less partition length (%d) than\n", treeNo + 1, sumLength); fprintf(stderr, "was required to make a sequence of length %d.\n", numSites); exit(4); } ReadTree(tree_fv, treeSet[i], treeNo+1, treeSet[0]->numTips, treeSet[0]->names, &partitionLengths[i], &partitionRates[i]); if (treeSet[i]->numTips != numTaxa) { fprintf(stderr, "All trees must have the same number of tips.\n"); exit(4); } sumLength += partitionLengths[i]; i++; } if (i > maxPartitions) { fprintf(stderr, "\nA set of trees number %d had more partitions (%d) than\n", treeNo + 1, i); fprintf(stderr, "was specified in the user options (%d).\n", maxPartitions); } numPartitions = i; if (sumLength != numSites) { fprintf(stderr, "The sum of the partition lengths in the treefile does not equal\n"); fprintf(stderr, "the specified number of sites.\n"); exit(4); } for (i = 0; i < numPartitions; i++) CreateSequences(treeSet[i], partitionLengths[i]); if (numPartitions > 1) { sum = 0.0; for (i = 0; i < numPartitions; i++) sum += partitionRates[i] * partitionLengths[i]; for (i = 0; i < numPartitions; i++) partitionRates[i] *= numSites / sum; } if (treeNo==0 && verbose && !quiet) { PrintVerbose(stderr); InitProgressBar(numTrees*numDatasets); DrawProgressBar(); } for (i=0; i<numDatasets; i++) { SetCategories(); k = 0; for (j = 0; j < numPartitions; j++) { scale = partitionRates[j]; if (scaleTrees) { if (!treeSet[j]->rooted) { fprintf(stderr, "To scale tree length, they must be rooted and ultrametric.\n"); exit(4); } scale *= treeScale/treeSet[j]->totalLength; } else if (scaleBranches) scale *= branchScale; EvolveSequences(treeSet[j], k, partitionLengths[j], scale, ancestor); k += partitionLengths[j]; } if (writeAncestors) WriteAncestralSequences(stdout, treeSet[0]); else WriteSequences(stdout, (numTrees > 1 ? treeNo+1 : -1), (numDatasets > 1 ? i+1 : -1), treeSet, partitionLengths); if (writeRates) { WriteRates(stderr); } if (textFile) { while (!feof(text_fv)) { ch = fgetc(text_fv); if (!feof(text_fv)) fputc(ch, stdout); } fputc('\n', stdout); rewind(text_fv); } if (verbose && !quiet) ProgressBar(); } for (i = 0; i < numPartitions; i++) DisposeTree(treeSet[i]); treeNo++; } while (IsTreeAvail(tree_fv)); /* for (i = 0; i < maxPartitions; i++) FreeTree(treeSet[i]); */ if (treeFile) fclose(tree_fv); if (textFile) fclose(text_fv); totalSecs = (double)(clock() - totalStart) / CLOCKS_PER_SEC; if (!quiet) { fprintf(stderr, "Time taken: %G seconds\n", totalSecs); if (verboseMemory) fprintf(stderr, "Total memory used: %ld\n", totalMem); } return 0; }