private static void GenerateHtmlContent(string htmlFile, ManxcatSection config) { using (var writer = new StreamWriter(htmlFile)) { using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Manxcat.Web.template") ) { if (stream != null) { using (var reader = new StreamReader(stream)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); if (!string.IsNullOrEmpty(line)) { writer.WriteLine(!line.Contains(ManxcatConstants.Tag) ? line : ProcessTagLine(line, config)); } } } } else { throw new Exception(ManxcatErrorMessages.TemplateHtmlNotAvailable); } } } }
private static string ProcessTagLine(string line, ManxcatSection config) { int tagStartIdx = line.IndexOf(ManxcatConstants.Tag); int tagEndIdx = line.IndexOf(ManxcatConstants.Tag, tagStartIdx + ManxcatConstants.Tag.Length) + (ManxcatConstants.Tag.Length - 1); string prefix = line.Substring(0, tagStartIdx); string suffix = line.Substring(tagEndIdx + 1); string meat = line.Substring(tagStartIdx + ManxcatConstants.Tag.Length, ((tagEndIdx + 1) - (tagStartIdx + 2 * ManxcatConstants.Tag.Length))); switch (meat) { case ManxcatConstants.TagManxcatName: return(prefix + config.ManxcatRunName + suffix); case ManxcatConstants.TagManxcatDescription: return(prefix + config.ManxcatRunDescription + suffix); case ManxcatConstants.TagManxcatConfig: return(GenerateConfig(config)); case ManxcatConstants.TagManxcatLinks: return(prefix + GenerateLinks(config) + suffix); default: throw new Exception(ManxcatErrorMessages.UnidentifiedTagInHTMLGeneration); } }
public ConfigurationMgr() { _global = new GlobalSection(); _manxcat = new ManxcatSection(); _pairwise = new PairwiseSection(); _smithWaterman = new SmithWatermanSection(); _needlemanWunsch = new NeedlemanWunschSection(); _smithWatermanMS = new SmithWatermanMS(); _daVectorSpongeSection = new DAVectorSpongeSection(); }
private static string GenerateLinks(ManxcatSection config) { const string liTemplate = "<li><a href=\"{0}\">{1}</a></li>"; const string txtExt = ".txt"; string dotslash = string.IsNullOrEmpty(config.ServerUrlPrefix) ? "./" : (config.ServerUrlPrefix + "/" + config.ManxcatRunName + "/"); var sb = new StringBuilder("<ul>"); string reducedVectorFileNameTag = Path.GetFileNameWithoutExtension(config.ReducedVectorOutputFileName); string link = dotslash + ManxcatConstants.SimplePointsPrefix + reducedVectorFileNameTag + txtExt; string name = "Simple Points"; sb.AppendLine(string.Format(liTemplate, link, name)); link = dotslash + reducedVectorFileNameTag + ManxcatConstants.ColonPointsSuffix + txtExt; name = "Colon Points"; sb.AppendLine(string.Format(liTemplate, link, name)); link = dotslash + reducedVectorFileNameTag + ManxcatConstants.GroupPointsSuffix + txtExt; name = "Group Points"; sb.AppendLine(string.Format(liTemplate, link, name)); link = dotslash + Path.GetFileName(config.SummaryOutputFileName); name = "Summary File"; sb.AppendLine(string.Format(liTemplate, link, name)); link = dotslash + Path.GetFileName(config.TimingOutputFileName); name = "Timing File"; sb.AppendLine(string.Format(liTemplate, link, name)); link = dotslash + ManxcatConstants.OutFileNameTag + txtExt; name = "Manxcat Ouput"; sb.AppendLine(string.Format(liTemplate, link, name)); link = dotslash + "whole-plot.png"; name = "Density Graph"; sb.AppendLine(string.Format(liTemplate, link, name)); if (SALSAUtility.IsClustersSelected) { link = dotslash + "selected-plot.png"; name = "Density Graph for Selected Clusters (Intra Cluster Distances)"; sb.AppendLine(string.Format(liTemplate, link, name)); link = dotslash + "selected-inter-plot.png"; name = "Density Graph for Selected Clusters (Inter Cluster Distances)"; sb.AppendLine(string.Format(liTemplate, link, name)); } return(sb.ToString()); }
// End SALSAStatus // todo: saliya - Possible Improvement: handle comments in this function to use the List instead of the string // you will have to search for the places where comment is manipulated in other // places as well public static void SALSAUpdateMetaData(ManxcatSection Configuration) { string Comment = Configuration.Comment; for (int i = 0; i < CosmicOutput.Count; i++) { if (i == 0) { continue; } Comment += "\n" + CosmicOutput[i]; } Comment = Comment.Replace(':', '-'); Configuration.Comment = Comment; }
/// <summary> /// Generates a Web page linking to output files /// </summary> public static void WriteHTML() { ManxcatSection config = ManxcatCentral.Configuration; string directoryPath = Path.GetDirectoryName(config.ReducedVectorOutputFileName); directoryPath = string.IsNullOrEmpty(directoryPath) ? string.Empty : directoryPath; string stylesFile = Path.Combine(directoryPath, ManxcatConstants.StyleFileNameTag) + ".css"; CopyStylesCSS(stylesFile); string htmlFile = Path.Combine(directoryPath, ManxcatConstants.HtmlFileNameTag) + ".html"; GenerateHtmlContent(htmlFile, config); }
private static string GenerateConfig(ManxcatSection config) { var sb = new StringBuilder(); sb.AppendLine("I/O"); sb.AppendLine("\tCoordinateWriteFrequency: " + config.CoordinateWriteFrequency); sb.AppendLine("\tDistanceMatrixFile: " + config.DistanceMatrixFile); sb.AppendLine("\n\nManxcatCore"); sb.AppendLine("\tAddonforQcomputation: " + config.AddonforQcomputation); sb.AppendLine("\tCalcFixedCrossFixed: " + config.CalcFixedCrossFixed); sb.AppendLine("\tCGResidualLimit: " + config.CGResidualLimit); sb.AppendLine("\tChisqChangePerPoint: " + config.ChisqChangePerPoint); sb.AppendLine("\tChisqnorm: " + config.Chisqnorm); sb.AppendLine("\tChisqPrintConstant: " + config.ChisqPrintConstant); sb.AppendLine("\tConversionInformation: " + config.ConversionInformation); sb.AppendLine("\tConversionOption: " + config.ConversionOption); sb.AppendLine("\tDataPoints: " + config.DataPoints); sb.AppendLine("\tDerivtest: " + config.Derivtest); sb.AppendLine("\tDiskDistanceOption: " + config.DiskDistanceOption); sb.AppendLine("\tDistanceCut: " + config.DistanceCut); sb.AppendLine("\tDistanceFormula: " + config.DistanceFormula); sb.AppendLine("\tDistanceProcessingOption: " + config.DistanceProcessingOption); sb.AppendLine("\tDistanceWeigthsCuts: " + config.DistanceWeightsCuts); sb.AppendLine("\tEigenvaluechange: " + config.Eigenvaluechange); sb.AppendLine("\tEigenvectorchange: " + config.Eigenvectorchange); sb.AppendLine("\tExtraOption1: " + config.ExtraOption1); sb.AppendLine("\tExtraprecision: " + config.Extraprecision); sb.AppendLine("\tFixedPointCriterion: " + config.FixedPointCriterion); sb.AppendLine("\tFletcherRho: " + config.FletcherRho); sb.AppendLine("\tFletcherSigma: " + config.FletcherSigma); sb.AppendLine("\tFullSecondDerivativeOption: " + config.FullSecondDerivativeOption); sb.AppendLine("\tFunctionErrorCalcMultiplier: " + config.FunctionErrorCalcMultiplier); sb.AppendLine("\tHistogramBinCount " + config.HistogramBinCount); sb.AppendLine("\tInitializationLoops: " + config.InitializationLoops); sb.AppendLine("\tInitializationOption: " + config.InitializationOption); sb.AppendLine("\tInitialSteepestDescents: " + config.InitialSteepestDescents); sb.AppendLine("\tLinkCut: " + config.LinkCut); sb.AppendLine("\tLocalVectorDimension: " + config.LocalVectorDimension); sb.AppendLine("\tMaxit: " + config.Maxit); sb.AppendLine("\tMinimumDistance: " + config.MinimumDistance); sb.AppendLine("\tMPIIOStrategy: " + config.MPIIOStrategy); sb.AppendLine("\tNbadgo: " + config.Nbadgo); sb.AppendLine("\tOmega: " + config.Omega); sb.AppendLine("\tOmegaOption: " + config.OmegaOption); sb.AppendLine("\tPowerIterationLimit: " + config.PowerIterationLimit); sb.AppendLine("\tProcessingOption: " + config.ProcessingOption); sb.AppendLine("\tQgoodReductionFactor: " + config.QgoodReductionFactor); sb.AppendLine("\tQHighInitialFactor: " + config.QHighInitialFactor); sb.AppendLine("\tQLimiscalecalculationInterval: " + config.QLimitscalculationInterval); sb.AppendLine("\tRotationOption: " + config.RotationOption); sb.AppendLine("\tSelectedfixedpoints: " + config.Selectedfixedpoints); sb.AppendLine("\tSelectedvariedpoints: " + config.Selectedvariedpoints); sb.AppendLine("\tStoredDistanceOption: " + config.StoredDistanceOption); sb.AppendLine("\tTimeCutmillisec: " + config.TimeCutmillisec); sb.AppendLine("\tTransformMethod: " + config.TransformMethod); sb.AppendLine("\tTransformParameter: " + config.TransformParameter); sb.AppendLine("\tUndefindDistanceValue: " + config.UndefinedDistanceValue); sb.AppendLine("\tVariedPointCriterion: " + config.VariedPointCriterion); sb.AppendLine("\tWeightingOption: " + config.WeightingOption); sb.AppendLine("\tWrite2Das3D: " + config.Write2Das3D); sb.AppendLine("\n\nDensity"); sb.AppendLine("\tAlpha: " + config.Alpha); sb.AppendLine("\tPcutf: " + config.Pcutf); sb.AppendLine("\tSelectedClusters: " + config.SelectedClusters); sb.AppendLine("\tXmaxBound: " + config.XmaxBound); sb.AppendLine("\tXres: " + config.Xres); sb.AppendLine("\tYmaxBound: " + config.YmaxBound); sb.AppendLine("\tYres: " + config.Yres); return(sb.ToString()); }
public static void WriteRotateMDS(string fname, int OutputOption, double[][] param, double[][] perr) { int LocalVectorDimension = param[0].GetLength(0); if (LocalVectorDimension != perr[0].GetLength(0)) { SALSAUtility.SALSAError("Inconsistent Dimensions Labels " + LocalVectorDimension.ToString() + " Perr " + perr[0].GetLength(0).ToString()); } ManxcatSection Configuration = ManxcatCentral.Configuration; // set current cosmic scaling for (int LocalVectorIndex1 = 0; LocalVectorIndex1 < PointVectorDimension; LocalVectorIndex1++) { for (int LocalVectorIndex2 = 0; LocalVectorIndex2 < PointVectorDimension; LocalVectorIndex2++) { CurrentCosmicScaling[LocalVectorIndex1, LocalVectorIndex2] = SavedCosmicScaling[Hotsun.BestChisqLoop][LocalVectorIndex1, LocalVectorIndex2]; } } // Write SALSA Properties File Header if (OutputOption == 0) { int filetype = 2; if ((SALSAUtility.NumberFixedPoints > 0) || (SALSAUtility.NumberVariedPoints < SALSAUtility.NumberOriginalPoints)) { filetype = 4; } RotationFileProperties.GroupName = "MDS Run:" + Configuration.RunNumber.ToString(); RotationFileProperties.FileGenerationType = filetype; RotationFileProperties.OriginalPointStartIndex = 0; RotationFileProperties.LocalPointStartIndex = 0; // Rotation parameters RotationFileProperties.NumberRotationParameters = Hotsun.npar; RotationFileProperties.RotationParameters = ""; for (int CountRotPars = 0; CountRotPars < Hotsun.npar; CountRotPars++) { RotationFileProperties.RotationParameters += " " + param[CountRotPars][0].ToString("E4") + ","; } for (int Cosmicdiagonals = 0; Cosmicdiagonals < PointVectorDimension; Cosmicdiagonals++) { RotationFileProperties.RotationParameters += " " + CurrentCosmicScaling[Cosmicdiagonals, Cosmicdiagonals]. ToString("E4") + ","; } // Comment should have key features of Run string OldComment = RotationFileProperties.Comment; if (OldComment != "") { OldComment += "\n"; } OldComment += "MDS ROTATION Run " + Configuration.RunNumber.ToString() + " Start Time " + SALSAUtility.startTime.ToLocalTime() + " *** "; OldComment += "\n RotationOption " + Configuration.RotationOption + " First Scale " + FirstScale.ToString("E4") + " Second Scale " + SecondScale.ToString() + "\n First Mean"; for (int PointIndex = 0; PointIndex < PointVectorDimension; PointIndex++) { OldComment += " " + FirstMean[PointIndex].ToString("E4"); } OldComment += " Second Mean"; for (int PointIndex = 0; PointIndex < PointVectorDimension; PointIndex++) { OldComment += " " + SecondMean[PointIndex].ToString("E4"); } RotationFileProperties.Comment = OldComment; SALSA_Properties.WriteDataPointFile(fname, ManxcatCentral.Configuration.Write2Das3D, "all ", RotationFileProperties, RotationPointProperties, SALSAUtility.NumberOriginalPoints); return; } // Option OutputOption = 1 -- write ROTATED Second Data try { StreamWriter sw = null; if (!string.IsNullOrEmpty(fname)) { sw = new StreamWriter(fname, false, Encoding.UTF8); } if (sw != null) { double[] FullTranslation; double[,] FullRotation; SetupFinalTransforamation(param, out FullTranslation, out FullRotation); for (int UsedDataPoint = 0; UsedDataPoint < SALSAUtility.PointCount_Global; UsedDataPoint++) { var Vector = new double[PointVectorDimension]; MatrixVectorProduct(Vector, FullRotation, SecondData[UsedDataPoint]); VectorSum(Vector, FullTranslation, +1.0, Vector); string Coordinates = ""; int SingleCluster = 1; for (int LocalVectorIndex = 0; LocalVectorIndex < PointVectorDimension; LocalVectorIndex++) { Coordinates += Vector[LocalVectorIndex].ToString("E4") + "\t"; } sw.WriteLine( String.Format((UsedDataPoint + 1).ToString() + "\t" + Coordinates + SingleCluster.ToString())); } } sw.Flush(); sw.Close(); } catch (Exception e) { Console.WriteLine("Failed writing data" + e); throw (e); } }
// Write label-cluster results into a file public static void WriteMDS(string fname, int OutputOption, double[][] param, double[][] perr) { int LocalVectorDimension = param[0].GetLength(0); if (LocalVectorDimension != perr[0].GetLength(0)) { SALSAUtility.SALSAError("Inconsistent Dimensions Labels " + LocalVectorDimension.ToString() + " Perr " + perr[0].GetLength(0).ToString()); } ManxcatSection Configuration = ManxcatCentral.Configuration; // Write SALSA Properties File Header if (OutputOption == 0) { int filetype = 2; if ((SALSAUtility.NumberFixedPoints > 0) || (SALSAUtility.NumberVariedPoints < SALSAUtility.NumberOriginalPoints)) { filetype = 4; } string cleandate = SALSAUtility.startTime.ToLocalTime().ToString(); cleandate = cleandate.Replace(":", "."); cleandate = cleandate.Replace(" ", "-"); SALSAUtility.GlobalFileProperties.GroupName = "MDSasChisq-" + Configuration.RunSetLabel + "-Run" + Configuration.RunNumber.ToString() + "-Date-" + cleandate; SALSAUtility.GlobalFileProperties.FileGenerationType = filetype; SALSAUtility.GlobalFileProperties.OriginalPointStartIndex = 0; SALSAUtility.GlobalFileProperties.LocalPointStartIndex = 0; SALSAUtility.GlobalFileProperties.NumberOriginalPoints = SALSAUtility.NumberOriginalPoints; SALSAUtility.GlobalFileProperties.NumberPointsinFile = SALSAUtility.PointCount_Global; // Comment should have key features of Run string OldComment = SALSAUtility.GlobalFileProperties.Comment; if (OldComment != "") { OldComment += "\n"; } OldComment += "MDSasChisq " + Configuration.RunNumber.ToString() + " StartTime " + cleandate + " ****"; OldComment += "\n Distance Input Option " + Configuration.DistanceProcessingOption.ToString() + " Distance Formula " + Configuration.DistanceFormula.ToString() + " Weighting Option " + Configuration.Chisqnorm.ToString() + " Minimum Distance Value " + Configuration.MinimumDistance.ToString(); OldComment += "\n" + Hotsun.HotsunComment; SALSAUtility.GlobalFileProperties.Comment = OldComment; for (int GlobalPointIndex = 0; GlobalPointIndex < SALSAUtility.PointCount_Global; GlobalPointIndex++) { int OriginalPointIndex = SALSAUtility.UsedPointtoOriginalPointMap[GlobalPointIndex]; int groupnumber = -1; string grouplabel = "Ignored"; SALSAUtility.GlobalPointProperties[GlobalPointIndex].FixedorVaried = 0; if (ManxcatMDS.PointStatus[GlobalPointIndex] == -1) { groupnumber = 3; grouplabel = "Deleted"; } else { if (SALSAUtility.OriginalPointDisposition[GlobalPointIndex] <= -SALSAUtility.SALSASHIFT) { groupnumber = 2; grouplabel = "Fixed"; SALSAUtility.GlobalPointProperties[GlobalPointIndex].FixedorVaried = 2; } if (SALSAUtility.OriginalPointDisposition[GlobalPointIndex] >= SALSAUtility.SALSASHIFT) { groupnumber = 1; grouplabel = "Varied"; SALSAUtility.GlobalPointProperties[GlobalPointIndex].source = "MDSasChisq-" + Configuration.RunSetLabel + "-Run" + Configuration.RunNumber. ToString() + "-Date-" + cleandate; SALSAUtility.GlobalPointProperties[GlobalPointIndex].FixedorVaried = 1; } } SALSAUtility.GlobalPointProperties[GlobalPointIndex].group = groupnumber; SALSAUtility.GlobalPointProperties[GlobalPointIndex].grouplabel = grouplabel; SALSAUtility.GlobalPointProperties[GlobalPointIndex].OriginalPointNumber = OriginalPointIndex; SALSAUtility.GlobalPointProperties[GlobalPointIndex].LocalPointNumber = GlobalPointIndex; } for (int GlobalPointIndex = 0; GlobalPointIndex < SALSAUtility.PointCount_Global; GlobalPointIndex++) { if (ManxcatMDS.PointStatus[GlobalPointIndex] == -1) { SALSAUtility.GlobalPointProperties[GlobalPointIndex].valuesset = false; SALSAUtility.GlobalPointProperties[GlobalPointIndex].errorsset = false; continue; } SALSAUtility.GlobalPointProperties[GlobalPointIndex].x = param[GlobalPointIndex][0]; SALSAUtility.GlobalPointProperties[GlobalPointIndex].y = param[GlobalPointIndex][1]; if (LocalVectorDimension > 2) { SALSAUtility.GlobalPointProperties[GlobalPointIndex].z = param[GlobalPointIndex][2]; } SALSAUtility.GlobalPointProperties[GlobalPointIndex].xerr = perr[GlobalPointIndex][0]; SALSAUtility.GlobalPointProperties[GlobalPointIndex].yerr = perr[GlobalPointIndex][1]; if (LocalVectorDimension > 2) { SALSAUtility.GlobalPointProperties[GlobalPointIndex].zerr = perr[GlobalPointIndex][2]; } SALSAUtility.GlobalPointProperties[GlobalPointIndex].valuesset = true; SALSAUtility.GlobalPointProperties[GlobalPointIndex].errorsset = true; } if (SALSAUtility.Usedreordered) { var NaivePointProperties = new SALSADataPointProperties[SALSAUtility.PointCount_Global]; for (int GlobalPointIndex = 0; GlobalPointIndex < SALSAUtility.PointCount_Global; GlobalPointIndex++) { int NaivePointIndex = SALSAUtility.ActualtoNaiveUsedOrder[GlobalPointIndex]; NaivePointProperties[NaivePointIndex] = SALSAUtility.GlobalPointProperties[GlobalPointIndex].ShallowCopy(); } SALSA_Properties.WriteDataPointFile(fname, ManxcatCentral.Configuration.Write2Das3D, "all ", SALSAUtility.GlobalFileProperties, NaivePointProperties, SALSAUtility.PointCount_Global); return; } SALSA_Properties.WriteDataPointFile(fname, ManxcatCentral.Configuration.Write2Das3D, "all ", SALSAUtility.GlobalFileProperties, SALSAUtility.GlobalPointProperties, SALSAUtility.PointCount_Global); return; } // Option OutputOption = 1 // Simple output of Used in ORIGINAL not Loadbalanced Order try { StreamWriter sw = null; if (!string.IsNullOrEmpty(fname)) { sw = new StreamWriter(fname, false, Encoding.UTF8); } if (sw != null) { for (int GlobalPointIndex = 0; GlobalPointIndex < SALSAUtility.PointCount_Global; GlobalPointIndex++) { if (ManxcatMDS.PointStatus[GlobalPointIndex] == -1) { continue; } string Coordinates = ""; int SingleCluster = 1; int UsedPointIndex = SALSAUtility.NaivetoActualUsedOrder[GlobalPointIndex]; for (int LocalVectorIndex = 0; LocalVectorIndex < LocalVectorDimension; LocalVectorIndex++) { Coordinates += param[UsedPointIndex][LocalVectorIndex].ToString("E4") + "\t"; } sw.WriteLine( String.Format((GlobalPointIndex).ToString() + "\t" + Coordinates + SingleCluster.ToString())); } } sw.Flush(); sw.Close(); } catch (Exception e) { Console.WriteLine("Failed writing data" + e); throw (e); } }