private void mnuRemove_Click(object sender, EventArgs e) { BioSeqRemove frm = new BioSeqRemove(); DialogResult rc = frm.ShowDialog(); if (rc == DialogResult.OK) // then the config has the specs { Cursor.Current = Cursors.WaitCursor; //int ret = SeqDBHelper.RemoveSample(); // Parameters are in appsettings. WSLProxyResponse WSLResponse = ServiceCallHelper.RemoveSample(AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig()); // Parameters are in appsettings. ServiceCallHelper.LoadConfig(AppConfigHelper.LoggedOnUser); // To retrieve StandardOutput and LastError. Cursor.Current = Cursors.Default; if (WSLResponse.ExitCode == 0) { MessageBox.Show(AppConfigHelper.RemoveSampleID() + " successfully removed.", "Success", MessageBoxButtons.OK); AppConfigHelper.RemoveSample(string.Empty); // So we don't prompt for it again. ReloadSampleIDs(); // Reload list without sample ID. } else { MessageBox.Show("Remove completed with error code " + WSLResponse.ExitCode.ToString() + "." + Environment.NewLine + Environment.NewLine + AppConfigHelper.StandardOutput + Environment.NewLine + AppConfigHelper.LastError, "Error", MessageBoxButtons.OK); } } }
private void mnuInsert_Click(object sender, EventArgs e) { BioSeqInsert frm = new BioSeqInsert(lstSampleIDs.Items); DialogResult rc = frm.ShowDialog(); if (rc == DialogResult.OK) // then the config has the specs { Cursor.Current = Cursors.WaitCursor; int ret; string function = "Replace"; // If the InsertInputPath is local, copy it to UserFolder on the server. if (AppConfigHelper.InsertInputPath().StartsWith("[L]")) { DirectoryHelper.FileCopy(AppConfigHelper.InsertInputPath(), "[S]" + AppConfigHelper.UserFolder(), true); } WSLProxyResponse WSLResponse; if (AppConfigHelper.InsertSampleReplace) { WSLResponse = ServiceCallHelper.ReplaceSample(AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig()); // Parameters are in appsettings. } else // Go ahead without prompting. { function = "Insert"; WSLResponse = ServiceCallHelper.InsertSample(AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig()); // Parameters are in appsettings. } ServiceCallHelper.LoadConfig(AppConfigHelper.LoggedOnUser); // To retrieve StandardOutput and LastError. Cursor.Current = Cursors.Default; if (WSLResponse.ExitCode == 0) { MessageBox.Show(AppConfigHelper.StandardOutput + Environment.NewLine + function + " completed successfully.", "Success", MessageBoxButtons.OK); ReloadSampleIDs(); // Reload list with new sample ID. } else { MessageBox.Show(function + " completed with error code " + WSLResponse.ExitCode.ToString() + "." + Environment.NewLine + Environment.NewLine + AppConfigHelper.StandardOutput + Environment.NewLine + AppConfigHelper.LastError, "Error", MessageBoxButtons.OK); } } }
private static void InitConfig() { ServiceCallHelper.LoadConfig(string.Empty); // Loads the global appsettings.json. //// Start by copying the local copy of <loggedOnUser>_appsettings.json to the server. //DirectoryHelper.FileCopy("[L]" + AppConfigHelper.executablePath + "\\" + AppConfigHelper.LoggedOnUser + "_appsettings.json", // "[S]" + AppConfigHelper.PathToServerAppsettings, true); if (!IsServiceClass.IsService) { if (!File.Exists(DirectoryHelper.CleanPath(AppConfigHelper.NormalizePathToWindows(AppConfigHelper.PathToWSL())))) { // Learned that wsl.exe cannot run from \Windows\System32 (file not found). MessageBox.Show(DirectoryHelper.CleanPath(AppConfigHelper.PathToWSL()) + " (" + DirectoryHelper.CleanPath(AppConfigHelper.NormalizePathToWindows(AppConfigHelper.PathToWSL())) + ") does not exist. Correct PathToWSL in appsettings.json before continuing.", "ERROR", MessageBoxButtons.OK); } string path = DirectoryHelper.CleanPath(AppConfigHelper.NormalizePathToWindows(AppConfigHelper.PathToSeqDB())); if (!File.Exists(path)) { // Learned that although Ubuntu prefix is \\wsl on my machine, it is \\wsl$ on WIMMER. MessageBox.Show(DirectoryHelper.CleanPath(AppConfigHelper.PathToSeqDB()) + " (" + DirectoryHelper.CleanPath(AppConfigHelper.NormalizePathToWindows(AppConfigHelper.PathToSeqDB())) + ") does not exist. " + Environment.NewLine + "Correct PathToSeqDB in appsettings.json before continuing, or" + Environment.NewLine + "issue 'wsl --shutdown' in PowerShell.", "ERROR", MessageBoxButtons.OK); } } else // IsService { try { AppConfigHelper.seqdbConfigGlobal.ServerDriveList = ServiceCallHelper.DriveList(); ServiceCallHelper.SaveConfigGlobal(); } catch (Exception ex) { MessageBox.Show("Unable to obtain the drive list from the server." + Environment.NewLine + ex.ToString(), "ERROR", MessageBoxButtons.OK); } } }
private void mnuRestore_Click(object sender, EventArgs e) { BioSeqRestore frm = new BioSeqRestore(txtVersions.Text.Trim()); DialogResult rc = frm.ShowDialog(); if (rc == DialogResult.OK) // then the config has the specs { Cursor.Current = Cursors.WaitCursor; WSLProxyResponse WSLResponse = ServiceCallHelper.RestoreDatabase(AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig()); // Parameters are in appsettings. ServiceCallHelper.LoadConfig(AppConfigHelper.LoggedOnUser); // To retrieve StandardOutput and LastError. Cursor.Current = Cursors.Default; if (WSLResponse.ExitCode == 0) { ReloadSampleIDs(); // Reload list without sample ID. MessageBox.Show(AppConfigHelper.StandardOutput + Environment.NewLine + "Restore successfully completed.", "Success", MessageBoxButtons.OK); } else { MessageBox.Show("Restore completed with error code " + WSLResponse.ExitCode.ToString() + "." + Environment.NewLine + Environment.NewLine + AppConfigHelper.StandardOutput + Environment.NewLine + AppConfigHelper.LastError, "Error", MessageBoxButtons.OK); } } }
private void btnDeleteDB_Click(object sender, EventArgs e) { // Delete the currently selected database and associated archive database. ConfirmDBDelete.MainInstruction = "You are about to completely delete " + txtDB.Text + " in " + txtPath.Text; if (txtVersions.Text.Length > 0) { ConfirmDBDelete.MainInstruction = ConfirmDBDelete.MainInstruction + ", as well as the associated archival database"; } ConfirmDBDelete.MainInstruction = ConfirmDBDelete.MainInstruction + ". Do you want to continue?"; TaskDialogButton button = ConfirmDBDelete.ShowDialog(this); if (button == btnDeleteDBNo) { return; } Cursor.Current = Cursors.WaitCursor; int rc = ServiceCallHelper.DeleteDB(AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig()); if (rc == 0) { MessageBox.Show("Database successfully deleted.", "Success", MessageBoxButtons.OK); } else { MessageBox.Show("Failed to delete database. Error code " + rc.ToString(), "ERROR", MessageBoxButtons.OK); } cmbUser.SelectedIndexChanged -= cmbUser_SelectedIndexChanged; ServiceCallHelper.LoadConfig(string.Empty); ServiceCallHelper.LoadConfig(AppConfigHelper.LoggedOnUser); AppConfigHelper.seqdbConfig.LastDBSelected = string.Empty; Initialize(); cmbUser.SelectedIndexChanged += cmbUser_SelectedIndexChanged; Cursor.Current = Cursors.Default; }
private void mnuBackup_Click(object sender, EventArgs e) { BioSeqBackup frm = new BioSeqBackup(); DialogResult rc = frm.ShowDialog(); if (rc == DialogResult.OK) // then the config has the specs { Cursor.Current = Cursors.WaitCursor; WSLProxyResponse WSLResponse = ServiceCallHelper.BackupDatabase(AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig()); // Parameters are in appsettings. ServiceCallHelper.LoadConfig(AppConfigHelper.LoggedOnUser); // To retrieve StandardOutput and LastError. Cursor.Current = Cursors.Default; if (WSLResponse.ExitCode == 0) { RefreshVersionInformation(AppConfigHelper.seqdbConfig.seqDBs[AppConfigHelper.seqdbConfig.LastDBSelected]); MessageBox.Show(AppConfigHelper.StandardOutput + Environment.NewLine + "Backup successfully completed.", "Success", MessageBoxButtons.OK); // Refresh backup version display. } else { MessageBox.Show("Backup completed with error code " + WSLResponse.ExitCode.ToString() + "." + Environment.NewLine + Environment.NewLine + AppConfigHelper.StandardOutput + Environment.NewLine + AppConfigHelper.LastError, "Error", MessageBoxButtons.OK); } } }
private void mnuExtract_Click(object sender, EventArgs e) { BioSeqExtract frm = new BioSeqExtract(); DialogResult rc = frm.ShowDialog(); if (rc == DialogResult.OK) // then the config has the specs { Cursor.Current = Cursors.WaitCursor; // Parameters are in appsettings. WSLProxyResponse WSLResponse = ServiceCallHelper.Extract(AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig()); // Parameters are in appsettings. ServiceCallHelper.LoadConfig(AppConfigHelper.LoggedOnUser); // To retrieve StandardOutput and LastError. Cursor.Current = Cursors.Default; if (WSLResponse.ExitCode == 0) { MessageBox.Show(AppConfigHelper.StandardOutput + Environment.NewLine + "Extract completed successfully. Result is in " + AppConfigHelper.ExtractOutputPath() + "\\" + AppConfigHelper.ExtractSampleID() + ".fasta", "Success", MessageBoxButtons.OK); } else { MessageBox.Show("Extract completed with error code " + WSLResponse.ExitCode.ToString() + "." + Environment.NewLine + Environment.NewLine + AppConfigHelper.StandardOutput + Environment.NewLine + AppConfigHelper.LastError, "Error", MessageBoxButtons.OK); } } }
private void cmbSeqDB_SelectedIndexChanged(object sender, EventArgs e) { if (cmbSeqDB.SelectedIndex == 0) // empty = none = reset { menuStrip1.Enabled = false; btnDeleteDB.Enabled = false; txtDB.Text = txtPath.Text = txtVersions.Text = AppConfigHelper.seqdbConfig.LastDBSelected = string.Empty; lblKipper.Visible = false; lstSampleIDs.Items.Clear(); chkDetailSamples.Enabled = false; lstSampleIDs.Enabled = false; AppConfigHelper.SaveConfig(); } else if (cmbSeqDB.SelectedIndex == 1) // New { BioSeqNewDB frmNewDB = new BioSeqNewDB(); DialogResult rc = frmNewDB.ShowDialog(); if (rc == DialogResult.OK) // then the config has the specs for the new db to select. { Cursor.Current = Cursors.WaitCursor; // If necessary, copy local files to server. string fastaPath = AppConfigHelper.Build_DBInput(); if (IsServiceClass.IsService && !string.IsNullOrEmpty(fastaPath)) { if (fastaPath.StartsWith("[L]") || !fastaPath.StartsWith("[")) { ServiceCallHelper.ResetFastaFolder(AppConfigHelper.LoggedOnUser); string[] folders = Directory.GetDirectories(DirectoryHelper.CleanPath(fastaPath)); foreach (string folder in folders) { string[] files = Directory.GetFiles(folder, "*.fasta", SearchOption.TopDirectoryOnly); foreach (string file in files) { DirectoryHelper.FileCopy("[L]" + file, "[S]" + AppConfigHelper.UserFolder() + "FastaFiles", true); } files = Directory.GetFiles(folder, "*.fna", SearchOption.TopDirectoryOnly); foreach (string file in files) { DirectoryHelper.FileCopy("[L]" + file, "[S]" + AppConfigHelper.UserFolder() + "FastaFiles", true); } files = Directory.GetFiles(folder, "*.fa", SearchOption.TopDirectoryOnly); foreach (string file in files) { DirectoryHelper.FileCopy("[L]" + file, "[S]" + AppConfigHelper.UserFolder() + "FastaFiles", true); } } } } if (!string.IsNullOrEmpty(AppConfigHelper.BuildTreeWildReference())) // This is the standard genome for the new database. { // Wherever it is, store it temporarily in the UserFolder. DirectoryHelper.FileCopy(AppConfigHelper.BuildTreeWildReference(), "[S]" + AppConfigHelper.UserFolder(), true); } /////////// Call Build_DB in SeqDB. try { ServiceCallHelper.Build_DB(AppConfigHelper.LoggedOnUser, AppConfigHelper.JsonConfig()); } catch (Exception ex) { Cursor.Current = Cursors.Default; MessageBox.Show("Error: " + ex.ToString(), "ERROR", MessageBoxButtons.OK); return; } if (AppConfigHelper.LastError.Length > 0) { Cursor.Current = Cursors.Default; MessageBox.Show("Error: " + AppConfigHelper.LastError, "ERROR", MessageBoxButtons.OK); return; } if (string.IsNullOrEmpty(AppConfigHelper.BuildTreeDomesticReference)) { AppConfigHelper.BuildTreeDomesticReference = AppConfigHelper.BuildTreeWildReference(); AppConfigHelper.SaveConfig(); } ServiceCallHelper.LoadConfig(AppConfigHelper.LoggedOnUser); PopulateDBDropdownAndSelect(); Cursor.Current = Cursors.Default; } } else // a database is selected. { Cursor.Current = Cursors.WaitCursor; AppConfigHelper.seqdbConfig.LastDBSelected = cmbSeqDB.SelectedItem.ToString(); AppConfigHelper.SaveConfig(); menuStrip1.Enabled = true; btnDeleteDB.Enabled = true; chkDetailSamples.Enabled = true; lstSampleIDs.Enabled = true; txtVersions.Text = string.Empty; lstSampleIDs.Items.Clear(); SeqDB db = AppConfigHelper.seqdbConfig.seqDBs[AppConfigHelper.seqdbConfig.LastDBSelected]; txtDB.Text = db.DBName; txtPath.Text = db.DBPath; AppConfigHelper.LastError = string.Empty; if (SampleIDsBusyFlag || VersionsBusyFlag) { MessageBox.Show("Version information and sample IDs are being loaded for previous database. Please select " + db.DBName + " again.", "Warning", MessageBoxButtons.OK); return; } // Version information comes from the global config. RefreshVersionInformation(AppConfigHelper.seqdbConfigGlobal.seqDBs[AppConfigHelper.seqdbConfig.LastDBSelected]); // Also get sample IDs into listbox. ReloadSampleIDs(); Cursor.Current = Cursors.Default; if (AppConfigHelper.LastError.Length > 0) { MessageBox.Show("Error: " + AppConfigHelper.LastError, "ERROR", MessageBoxButtons.OK); } } }
private void btnPushTask_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; BioSeqTask task = AppConfigHelper.TaskOfIndex(lstTasks.SelectedIndex); Cursor.Current = Cursors.Default; if (task == null || task.LastExitCode == -999) { MessageBox.Show("Task output is no longer available but may have completed.", "Warning", MessageBoxButtons.OK); return; } AppConfigHelper.LastCommand = task.TaskCommand; switch (task.TaskType) { case "VFabricate": TaskCompletion(task, "VFabricate", "VFabricate completed."); Cursor.Current = Cursors.Default; if (task.LastExitCode == 0) { string sampleName = string.Empty; if (AppConfigHelper.SampleChecked("VFabricate")) { sampleName = AppConfigHelper.SampleID("VFabricate"); } string destination = AppConfigHelper.CopyResultFromServer(AppConfigHelper.OutputPath("VFabricate"), new string[] { sampleName + ".VFList.tsv" }); MessageBox.Show(task.StandardOutput + Environment.NewLine + "VFabricate completed successfully. Result is in " + destination + "\\" + sampleName + ".VFList.tsv", "Success", MessageBoxButtons.OK); destination = DirectoryHelper.CleanPath(destination); Process.Start(destination + "\\" + sampleName + ".VFList.tsv"); } break; case "Quast": TaskCompletion(task, "Quast", "Quast completed."); Cursor.Current = Cursors.Default; if (task.LastExitCode == 0) { string sampleName = string.Empty; if (AppConfigHelper.SampleChecked("Quast")) { sampleName = AppConfigHelper.SampleID("Quast"); } string destination = AppConfigHelper.CopyResultFromServer(AppConfigHelper.OutputPath("Quast"), new string[] { "\\Quast" + sampleName }, false); // folder copy //destination = DirectoryHelper.CleanPath(destination); MessageBox.Show(task.StandardOutput + Environment.NewLine + "Quast completed successfully. Result is in the " + destination + " folder.", "Success", MessageBoxButtons.OK); } break; case "Kraken2": TaskCompletion(task, "Kraken2", "Kraken2 completed."); Cursor.Current = Cursors.Default; if (task.LastExitCode == 0) { MessageBox.Show(task.StandardOutput + Environment.NewLine + "Kraken2 completed successfully. Result is in " + AppConfigHelper.OutputPath("Kraken2") + ".", "Success", MessageBoxButtons.OK); if (AppConfigHelper.OutputPath("Kraken2").StartsWith("[L]")) { string destination = DirectoryHelper.CleanPath(AppConfigHelper.OutputPath("Kraken2")) + "\\"; if (File.Exists(destination + "kraken.aggregates.txt")) { File.Delete(destination + "kraken.aggregates.txt"); } if (File.Exists(destination + "kraken.txt")) { File.Delete(destination + "kraken.txt"); } if (File.Exists(destination + "RefseqIdent.txt")) { File.Delete(destination + "RefseqIdent.txt"); } AppConfigHelper.CopyResultFromServer(AppConfigHelper.OutputPath("Kraken2"), new string[] { "kraken.aggregates.txt", "kraken.txt", "RefseqIdent.txt" }); if (File.Exists(destination + "kraken.aggregates.txt")) { Process.Start(destination + "kraken.aggregates.txt"); } if (File.Exists(destination + "kraken.txt")) { Process.Start(destination + "kraken.txt"); } if (File.Exists(destination + "RefseqIdent.txt")) { Process.Start(destination + "RefseqIdent.txt"); } } } break; case "BBMap": TaskCompletion(task, "BBMap", "BBMap completed."); if (task.LastExitCode == 0) { string destination = AppConfigHelper.CopyResultFromServer(AppConfigHelper.OutputPath("BBMap"), new string[] { "covhist.txt", "covstats.txt", "bincov.txt", "basecov.txt", "RefseqIdent.txt" }); destination = DirectoryHelper.CleanPath(destination); MessageBox.Show(task.StandardOutput + Environment.NewLine + "BBMap completed successfully. Result is in " + destination + ".", "Success", MessageBoxButtons.OK); if (File.Exists(destination + "covhist.txt")) { Process.Start(destination + "covhist.txt"); } if (File.Exists(destination + "covstats.txt")) { Process.Start(destination + "covstats.txt"); } if (File.Exists(destination + "bincov.txt")) { Process.Start(destination + "bincov.txt"); } if (File.Exists(destination + "basecov.txt")) { Process.Start(destination + "basecov.txt"); } if (File.Exists(destination + "RefseqIdent.txt")) { Process.Start(destination + "RefseqIdent.txt"); } } break; case "Search": TaskCompletion(task, "Search", "Search completed."); Cursor.Current = Cursors.WaitCursor; ServiceCallHelper.LoadConfig(AppConfigHelper.LoggedOnUser); // To retrieve StandardOutput and LastError. Cursor.Current = Cursors.Default; if (task.LastExitCode == 0) { string filename = AppConfigHelper.OutputPath("Search") + "\\" + AppConfigHelper.SearchOutputSampleName() + ".txt"; MessageBox.Show(task.StandardOutput + Environment.NewLine + "Search completed successfully. Close this dialog to open the result file in " + filename + ".", "Success", MessageBoxButtons.OK); // If the output path is on the server, we need to copy it to the local Temp folder to display the results. // If the output path is on the local machine, we need to copy from the user folder on the server to the local destination. string destination = AppConfigHelper.CopyResultFromServer(AppConfigHelper.OutputPath("Search"), new string[] { AppConfigHelper.SearchOutputSampleName() + ".txt" }); Process.Start(DirectoryHelper.CleanPath(destination) + AppConfigHelper.SearchOutputSampleName() + ".txt"); } break; case "Assemble": TaskCompletion(task, "Assembly", "Assembly completed. If there are no errors, the results including the contig files are in the E:/data/staging folder on the server."); break; case "InfluenzaA": TaskCompletion(task, "InfluenzaA", "InfluenzaA completed."); Cursor.Current = Cursors.Default; if (task.LastExitCode == 0) { //MessageBox.Show(task.StandardOutput + Environment.NewLine + "InfluenzaA completed successfully. Result is in the " + // AppConfigHelper.InfluenzaAOutputPath + " folder.", "Success", MessageBoxButtons.OK); if (IsServiceClass.IsService) { if (AppConfigHelper.InfluenzaAOutputPath.StartsWith("[L]")) // Output was created on server, to be stored on client. [L] { // For each sample that was processed, there is a subfolder in the UserFolder on the server named after the sample name. // That subfolder needs to be copied to the local output folder. Note that we only copy the <sample>\consensus contents. foreach (string sampleName in AppConfigHelper.InfluenzaASamplesList.Keys) { if (AppConfigHelper.InfluenzaASamplesList[sampleName].Substring(0, 1) == "1") { string sourceFolderName = "[S]" + AppConfigHelper.UserFolder() + sampleName + "\\consensus\\"; Directory.CreateDirectory(DirectoryHelper.CleanPath(AppConfigHelper.InfluenzaAOutputPath) + "\\" + sampleName + "\\"); //Logger.Log.Debug("Copy from " + sourceFolderName + " to " + AppConfigHelper.InfluenzaAOutputPath + "\\"); DirectoryHelper.FolderCopy(sourceFolderName, AppConfigHelper.InfluenzaAOutputPath + "\\" + sampleName + "\\"); } } } MessageBox.Show(task.StandardOutput + Environment.NewLine + "Influenza A pipeline completed successfully. Results copied to " + AppConfigHelper.InfluenzaAOutputPath + "\\, including consensus fasta files in sample name subfolder[s].", "Files copied", MessageBoxButtons.OK); } } break; case "Centrifuge": TaskCompletion(task, "Centrifuge", "Centrifuge completed."); Cursor.Current = Cursors.Default; if (task.LastExitCode == 0) { if (IsServiceClass.IsService) { if (AppConfigHelper.CentrifugeOutputPath.StartsWith("[L]")) // Output was created on server, to be stored on client. [L] { if (AppConfigHelper.CentrifugeOutputPath.StartsWith("[L]")) { string destination = DirectoryHelper.CleanPath(AppConfigHelper.CentrifugeOutputPath) + "\\"; if (File.Exists(destination + "centrifuge_res.tsv")) { File.Delete(destination + "centrifuge_res.tsv"); } if (File.Exists(destination + "centrifuge_report.tsv")) { File.Delete(destination + "centrifuge_report.tsv"); } AppConfigHelper.CopyResultFromServer(AppConfigHelper.CentrifugeOutputPath, new string[] { "centrifuge_res.tsv", "centrifuge_report.tsv" }); if (File.Exists(destination + "centrifuge_report.tsv")) { Process.Start(destination + "centrifuge_report.tsv"); } } } MessageBox.Show(task.StandardOutput + Environment.NewLine + "Centrifuge pipeline completed successfully. Results copied to " + AppConfigHelper.CentrifugeOutputPath + ".", "Files copied", MessageBoxButtons.OK); } } break; case "Salmonella": TaskCompletion(task, "Salmonella", "Salmonella serotyping completed."); Cursor.Current = Cursors.Default; if (task.LastExitCode == 0) { MessageBox.Show(task.StandardOutput + Environment.NewLine + "Salmonella serotyping completed successfully. Result is in " + AppConfigHelper.SalmonellaOutputPath, "Success", MessageBoxButtons.OK); if (IsServiceClass.IsService) { if (AppConfigHelper.SalmonellaOutputPath.StartsWith("[L]")) // Output was created on server, to be stored on client. [L] { string sourceFolderName = "[S]" + AppConfigHelper.UserFolder() + "\\sistr_res_aggregate.csv"; string destinationFolderName = AppConfigHelper.SalmonellaOutputPath; DirectoryHelper.FileCopy(sourceFolderName, destinationFolderName, true); File.Move(DirectoryHelper.CleanPath(destinationFolderName) + "\\sistr_res_aggregate.csv", DirectoryHelper.CleanPath(destinationFolderName) + "\\sistr_res_aggregate" + DateTime.Now.ToString("yyMMddHHmmss") + ".csv"); // Rename Process.Start(DirectoryHelper.CleanPath(destinationFolderName) + "\\sistr_res_aggregate" + DateTime.Now.ToString("yyMMddHHmmss") + ".csv"); } else // Rename on server. { DirectoryHelper.FileMove(AppConfigHelper.SalmonellaOutputPath + "\\sistr_res_aggregate.csv", AppConfigHelper.SalmonellaOutputPath + "\\sistr_res_aggregate" + DateTime.Now.ToString("yyMMddHHmmss") + ".csv"); } } } break; case "Nextstrain": TaskCompletion(task, "Nextstrain", "Nextstrain phylogenetic processing completed."); Cursor.Current = Cursors.Default; if (task.LastExitCode == 0) { //NextstrainProfile nextstrainProfile = AppConfigHelper.GetNextstrainProfile(); // for current database. MessageBox.Show(task.StandardOutput + Environment.NewLine + "Nextstrain completed successfully.", "Success", MessageBoxButtons.OK); if (IsServiceClass.IsService) { //string browser = string.Empty; //RegistryKey key = null; //try //{ // key = Registry.ClassesRoot.OpenSubKey(@"HTTP\shell\open\command"); // if (key != null) // { // // Get default Browser // browser = key.GetValue(null).ToString().ToLower().Trim(new[] { '"' }); // } // if (!browser.EndsWith("exe")) // { // //Remove all after the ".exe" // browser = browser.Substring(0, browser.LastIndexOf(".exe", StringComparison.InvariantCultureIgnoreCase) + 4); // } //} //finally //{ // if (key != null) // { // key.Close(); // } //} // Open the browser. // See documentation for this approach: // https://docs.nextstrain.org/en/latest/guides/share/community-builds.html // The GitHub repository file structure must be: // nextstrain/auspice/nextstrain.json // The BioSeqDB service will have already pushed the updated files to Github. Process proc = Process.Start("https://nextstrain.org/community/ArnieBerg/nextstrain@main"); //if (nextstrainProfile.OuputPath.StartsWith("[L]")) // Output was created on server, to be stored on client. [L] //{ // string sourceFolderName = "[S]" + AppConfigHelper.UserFolder() + "\\ncov_global.json"; // string destinationFolderName = nextstrainProfile.OuputPath; // DirectoryHelper.FileCopy(sourceFolderName, destinationFolderName, true); // File.Move(DirectoryHelper.CleanPath(destinationFolderName) + "\\ncov_global.json", // DirectoryHelper.CleanPath(destinationFolderName) + "\\sistr_res_aggregate" + DateTime.Now.ToString("yyMMddHHmmss") + ".csv"); // Rename // Process.Start(DirectoryHelper.CleanPath(destinationFolderName) + "\\sistr_res_aggregate" + DateTime.Now.ToString("yyMMddHHmmss") + ".csv"); //} //else // Rename on server. //{ // DirectoryHelper.FileMove(nextstrainProfile.OuputPath + "\\sistr_res_aggregate.csv", // nextstrainProfile.OuputPath + "\\sistr_res_aggregate" + DateTime.Now.ToString("yyMMddHHmmss") + ".csv"); //} } } break; case "BuildTree": TaskCompletion(task, "BuildTree", "BuildTree completed. Close this dialog to open the result file."); //Logger.Log.Debug("ExitCode=" + task.LastExitCode.ToString() + @" Write to c:\temp\commandline.txt: open file='" + // AppConfigHelper.BuildTreeOutputPath() + "\\tree.nwk';" + Environment.NewLine); if (!Directory.Exists("C:\\Temp")) { Directory.CreateDirectory("C:\\Temp"); } string dendroscopePath = @"C:\Temp\"; if (IsServiceClass.IsService) { // For service, copy the tree.nwk from wherever it was stored to C:\Temp. If it is on the server, call the service to copy it. // If it is on the local machine, do a File.Copy. string sourceFolderName = "[S]" + AppConfigHelper.UserFolder(); string destinationFolderName = AppConfigHelper.BuildTreeOutputPath() + "\\"; Logger.Log.Debug("btnPushTask: FileCopy " + sourceFolderName + "tree.nwk to " + destinationFolderName); Logger.Log.Debug("btnPushTask: DirectoryHelper destination: " + AppConfigHelper.GetDirectoryName(DirectoryHelper.CleanPath(destinationFolderName + "\\")) + "\\" + Path.GetFileName(DirectoryHelper.CleanPath(sourceFolderName)) + "tree.nwk"); if (destinationFolderName.StartsWith("[L]")) // Buildtree output was created on server, to be stored on client. [L] { DirectoryHelper.FileCopy(sourceFolderName + "tree.nwk", destinationFolderName, true); DirectoryHelper.FileCopy(sourceFolderName + "metadata_microreact.csv", destinationFolderName, true); dendroscopePath = DirectoryHelper.CleanPath(destinationFolderName); Logger.Log.Debug("btnPushTask: dendroscopePath: " + dendroscopePath); } else // Buildtree output was created on server, to be stored on server. [S] { DirectoryHelper.FileCopy(sourceFolderName + "tree.nwk", destinationFolderName, true); DirectoryHelper.FileCopy(sourceFolderName + "metadata_microreact.csv", destinationFolderName, true); // Also copy to local Temp folder for Dendroscope to pick up. DirectoryHelper.FileCopy(sourceFolderName + "tree.nwk", @"[L]C:\Temp\", true); DirectoryHelper.FileCopy(sourceFolderName + "metadata_microreact.csv", @"[L]C:\Temp\", true); } } else { if (DirectoryHelper.CleanPath(AppConfigHelper.BuildTreeOutputPath()) != @"C:\Temp") { if (File.Exists(@"C:\Temp\tree.nwk")) { File.Delete(@"C:\Temp\tree.nwk"); } File.Copy(DirectoryHelper.CleanPath(AppConfigHelper.BuildTreeOutputPath() + "\\tree.nwk"), @"C:\Temp\tree.nwk", true); } if (File.Exists(@"C:\Temp\metadata_microreact.csv")) { File.Delete(@"C:\Temp\metadata_microreact.csv"); } File.Copy(DirectoryHelper.CleanPath(AppConfigHelper.BuildTreeOutputPath() + "\\metadata_microreact.csv"), @"C:\Temp\metadata_microreact.csv", true); } File.WriteAllText("C:\\Temp\\commandline.txt", @"open file='" + dendroscopePath + "tree.nwk';" + Environment.NewLine); if (task.LastExitCode == 0) { // Invoke Dendroscope to visualize tree. c:\\Temp\\commandine.txt contains the line: // open file='C:\Temp\Save\tree.nwk'; try { Cursor.Current = Cursors.WaitCursor; Process.Start(AppConfigHelper.PathToDendroscope(), "-g -c c:\\Temp\\commandline.txt"); Cursor.Current = Cursors.Default; } catch (Exception ex) { MessageBox.Show("Dendroscope needs to be installed to view the result. Check path " + AppConfigHelper.PathToDendroscope() + Environment.NewLine + Environment.NewLine + ex.ToString(), "INSTALL DENDROSCOPE", MessageBoxButtons.OK); } } break; } UIThreadRefresh(sender, e); }