public Size RenderTip(Graphics g, Size sizeMax, bool draw) { var table = new TableDesc(); using (var rt = new RenderTools()) { if (_row.Peptide != null) { table.AddDetailRow(Helpers.PeptideToMoleculeTextMapper.Translate(GroupComparisonStrings.FoldChangeRowTipProvider_RenderTip_Peptide, _row.Peptide.IsSmallMolecule()), _row.Peptide.ModifiedSequence == null ? _row.Peptide.ToString() : _row.Peptide.ModifiedSequence.ToString(), rt); } if (_row.Protein != null) { table.AddDetailRow(Helpers.PeptideToMoleculeTextMapper.Translate(GroupComparisonStrings.FoldChangeRowTipProvider_RenderTip_Protein, _row.Protein.IsNonProteomic()), ProteinMetadataManager.ProteinModalDisplayText(_row.Protein.DocNode), rt); } table.AddDetailRow(GroupComparisonStrings.FoldChangeRowTipProvider_RenderTip_Fold_Change, _row.FoldChangeResult.FoldChange.ToString(Formats.FoldChange, CultureInfo.CurrentCulture), rt); table.AddDetailRow(GroupComparisonStrings.FoldChange_Log2_Fold_Change_, _row.FoldChangeResult.Log2FoldChange.ToString(Formats.FoldChange, CultureInfo.CurrentCulture), rt); table.AddDetailRow(GroupComparisonStrings.FoldChangeRowTipProvider_RenderTip_P_Value, _row.FoldChangeResult.AdjustedPValue.ToString(Formats.PValue, CultureInfo.CurrentCulture), rt); table.AddDetailRow(GroupComparisonStrings.FoldChange__Log10_P_Value_, (-Math.Log10(_row.FoldChangeResult.AdjustedPValue)).ToString(Formats.PValue, CultureInfo.CurrentCulture), rt); var size = table.CalcDimensions(g); if (draw) { table.Draw(g); } return(new Size((int)size.Width + 2, (int)size.Height + 2)); } }
/// <summary> /// 初始化<see cref="TableDescContext"/>实例 /// </summary> /// <param name="tableHtml">数据表HTML</param> public TableDescContext(string tableHtml) { this._tableHtml = tableHtml; //默认初始化,避免为null时操作 _table = new TableDesc(); }
public void AddLine(string description, string data) { if (_table == null) { _table = new TableDesc(); } _table.AddDetailRow(description, data, _rt); }
public static Size RenderTip(TransitionDocNode nodeTran, Graphics g, Size sizeMax, bool draw) { var table = new TableDesc(); using (RenderTools rt = new RenderTools()) { table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Ion, nodeTran.Transition.FragmentIonName, rt); table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Charge, nodeTran.Transition.Adduct.AdductCharge.ToString(LocalizationHelper.CurrentCulture), rt); table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Product_m_z, string.Format(@"{0:F04}", nodeTran.Mz), rt); int?decoyMassShift = nodeTran.Transition.DecoyMassShift; if (decoyMassShift.HasValue) { table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Decoy_Mass_Shift, decoyMassShift.Value.ToString(LocalizationHelper.CurrentCulture), rt); } if (nodeTran.HasLoss) { // If there is only one loss, show its full description var losses = nodeTran.Losses; if (losses.Losses.Count == 1) { table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Loss, losses.ToStrings()[0], rt); } // Otherwise, just show the total mass for multiple losses // followed by individual losses else { table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Loss, string.Format(@"{0:F04}", losses.Mass), rt); table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Losses, TextUtil.LineSeparate(losses.ToStrings()), rt); } } if (nodeTran.HasLibInfo) { table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Library_rank, nodeTran.LibInfo.Rank.ToString(LocalizationHelper.CurrentCulture), rt); float intensity = nodeTran.LibInfo.Intensity; table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Library_intensity, MathEx.RoundAboveZero(intensity, (intensity < 10 ? 1 : 0), 4).ToString(LocalizationHelper.CurrentCulture), rt); } if (nodeTran.Transition.IsCustom() && !string.IsNullOrEmpty(nodeTran.Transition.CustomIon.Formula)) { table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodeTran.Transition.CustomIon.Formula + nodeTran.Transition.Adduct.AdductFormula.ToString(LocalizationHelper.CurrentCulture), rt); } SizeF size = table.CalcDimensions(g); if (draw) { table.Draw(g); } return(new Size((int)size.Width + 2, (int)size.Height + 2)); } }
public FeatureInformations GetIdentifyFeatureInfos(MapObjects2.Point mousePosition, AxMapObjects2.AxMap mapControl, MapProject.MapStruct mapInfosCollection) { FeatureInformations oFeatureInfos = null; foreach (ILayerStruct oLayerInfos in mapInfosCollection.Layers) { if (oLayerInfos.LayerType != (short)LayerTypeConstants.moMapLayer) { continue; } MapUtil.MapOperation oMapOper = new MapOperation(); MapObjects2.MapLayer oMapLayer = oMapOper.GetLayerByName(mapControl, oLayerInfos.AliasName) as MapObjects2.MapLayer; if (oMapLayer.Visible == false) { continue; } Recordset oSelectedRecords = oMapLayer.SearchShape(mousePosition, SearchMethodConstants.moAreaIntersect, ""); if (oSelectedRecords.EOF) { continue; } oSelectedRecords.MoveFirst(); oFeatureInfos = new FeatureInformations(); oFeatureInfos.CurrentLayerInfos = oLayerInfos; oFeatureInfos.Geometry = oSelectedRecords.Fields.Item("shape").Value; TableDesc oTableDesc = oSelectedRecords.TableDesc; oFeatureInfos.FieldsAndValuesCollection = new Dictionary <string, string>(); int iFieldsCount = oTableDesc.FieldCount; string sFieldName = ""; string sValue = ""; for (short i = 0; i < iFieldsCount; i++) { sFieldName = oTableDesc.get_FieldName(i); sValue = oSelectedRecords.Fields.Item(sFieldName).ValueAsString; oFeatureInfos.FieldsAndValuesCollection.Add(sFieldName, sValue); } break; } return(oFeatureInfos); }
private void RecreateTable <T>(TableDesc tableDesc, IEnumerable <T> data, Func <T, object[]> getColumnValues) { database.CreateTable(tableDesc.tableName, tableDesc.columns); database.BulkCopy(tableDesc.tableName, tableDesc.columns, data.Select(delegate(T x) { var columnValues = getColumnValues(x); if (columnValues.Length != tableDesc.columns.Length) { const string messageFormat = "invalid values, expected length [{0}], actual length [{1}]"; throw new InvalidOperationException(string.Format(messageFormat, tableDesc.columns.Length, columnValues.Length)); } return(columnValues); })); database.ExecuteNonQuery(tableDesc.createIndexesSql); }
private static string DoMinTableName(ExpressionSqlBuilder builder, ITableSource parent, TableClause tc1) { TableDesc td1 = (TableDesc)tc1.Table; var arr = parent.GetTables(); bool find = false; bool findDubName = false; bool findDubSchema = false; foreach (var tc in arr) { if (tc == tc1) { find = true; } else if (string.IsNullOrEmpty(tc.Alias) && (tc.Table is TableDesc) ) { TableDesc td = (TableDesc)tc.Table; if (td.PhysicalTableName.ToLower() == td1.PhysicalTableName.ToLower()) { findDubName = true; if (td.PhysicalSchema.ToLower() == td1.PhysicalSchema.ToLower()) { findDubSchema = true; } } } } if (!find) { return(null); } if (!findDubName) { return(builder.EncodeTable(td1.PhysicalTableName)); } if (!findDubSchema) { return(builder.EncodeTable(td1.PhysicalSchema) + "." + builder.EncodeTable(td1.PhysicalTableName)); } throw new Exception("Not unique table " + builder.EncodeTable(td1.PhysicalSchema) + "." + builder.EncodeTable(td1.PhysicalTableName)); }
public Size RenderTip(Graphics g, Size sizeMax, bool draw) { var table = new TableDesc(); using (var rt = new RenderTools()) { table.AddDetailRow(Resources.PeptideRegressionTipProvider_RenderTip_Peptide, DocNode.ModifiedSequence, rt); table.AddDetailRow(XLabel, Point.X.ToString(CultureInfo.CurrentCulture), rt); table.AddDetailRow(YLabel, Point.Y.ToString(CultureInfo.CurrentCulture), rt); var size = table.CalcDimensions(g); if (draw) { table.Draw(g); } return(new Size((int)size.Width + 2, (int)size.Height + 2)); } }
public static Size RenderTip(PeptideDocNode nodePep, TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTranSelected, SrmSettings settings, Graphics g, Size sizeMax, bool draw) { if (nodeGroup.TransitionGroup.IsCustomIon) { var customTable = new TableDesc(); using (RenderTools rt = new RenderTools()) { customTable.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Molecule, nodeGroup.CustomIon.Name, rt); customTable.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_charge, nodeGroup.TransitionGroup.PrecursorCharge.ToString(LocalizationHelper.CurrentCulture), rt); customTable.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_mz, string.Format("{0:F04}", nodeGroup.PrecursorMz), rt); // Not L10N if (nodeGroup.CustomIon.Formula != null) { customTable.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodeGroup.CustomIon.Formula, rt); } SizeF size = customTable.CalcDimensions(g); customTable.Draw(g); return new Size((int) size.Width + 2, (int) size.Height + 2); } } ExplicitMods mods = (nodePep != null ? nodePep.ExplicitMods : null); IEnumerable<DocNode> choices = GetChoices(nodeGroup, settings, mods, true).ToArray(); HashSet<DocNode> chosen = new HashSet<DocNode>(nodeGroup.Children); // Make sure all chosen peptides get listed HashSet<DocNode> setChoices = new HashSet<DocNode>(choices); setChoices.UnionWith(chosen); choices = setChoices.ToArray(); Transition tranSelected = (nodeTranSelected != null ? nodeTranSelected.Transition : null); IFragmentMassCalc calc = settings.GetFragmentCalc(nodeGroup.TransitionGroup.LabelType, mods); string aa = nodeGroup.TransitionGroup.Peptide.Sequence; // We handled custom ions above, and returned double[,] masses = calc.GetFragmentIonMasses(aa); var filter = settings.TransitionSettings.Filter; // Get charges and type pairs, making sure all chosen charges are included HashSet<int> setCharges = new HashSet<int>(filter.ProductCharges.Where(charge => Math.Abs(charge) <= Math.Abs(nodeGroup.TransitionGroup.PrecursorCharge) && Math.Sign(charge) == Math.Sign(nodeGroup.TransitionGroup.PrecursorCharge))); HashSet<IonType> setTypes = new HashSet<IonType>(filter.IonTypes); foreach (TransitionDocNode nodTran in chosen) { var type = nodTran.Transition.IonType; if (type == IonType.precursor) continue; setCharges.Add(nodTran.Transition.Charge); setTypes.Add(type); } setTypes.Remove(IonType.precursor); int[] charges = setCharges.ToArray(); Array.Sort(charges); IonType[] types = Transition.GetTypePairs(setTypes); var tableDetails = new TableDesc(); var table = new TableDesc(); using (RenderTools rt = new RenderTools()) { string seqModified = GetModifiedSequence(nodePep, nodeGroup, settings); if (!Equals(seqModified, nodeGroup.TransitionGroup.Peptide.Sequence)) tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Modified, seqModified, rt); var precursorCharge = nodeGroup.TransitionGroup.PrecursorCharge; var precursorMz = nodeGroup.PrecursorMz; tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_charge, precursorCharge.ToString(LocalizationHelper.CurrentCulture), rt); tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_mz, string.Format("{0:F04}", precursorMz), rt); // Not L10N tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_mh, string.Format("{0:F04}", nodeGroup.GetPrecursorIonMass()), // Not L10N rt); int? decoyMassShift = nodeGroup.TransitionGroup.DecoyMassShift; if (decoyMassShift.HasValue) { tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Decoy_Mass_Shift, decoyMassShift.Value.ToString(LocalizationHelper.CurrentCulture), rt); } if (nodeGroup.HasLibInfo) { foreach (KeyValuePair<PeptideRankId, string> pair in nodeGroup.LibInfo.RankValues) tableDetails.AddDetailRow(pair.Key.Label, pair.Value, rt); } if (charges.Length > 0 && types.Length > 0) { var headers = new RowDesc { CreateHead("#", rt), // Not L10N CreateHead("AA", rt), // Not L10N CreateHead("#", rt) // Not L10N }; foreach (int charge in charges) { string plusSub = Transition.GetChargeIndicator(charge); foreach (IonType type in types) { CellDesc cell = CreateHead(type.ToString().ToLower() + plusSub, rt); if (Transition.IsNTerminal(type)) headers.Insert(0, cell); else headers.Add(cell); } } table.Add(headers); int len = aa.Length; for (int i = 0; i < len; i++) { CellDesc cellAA = CreateRowLabel(aa.Substring(i, 1), rt); cellAA.Align = StringAlignment.Center; var row = new RowDesc { CreateRowLabel(i == len - 1 ? string.Empty : (i + 1).ToString(CultureInfo.InvariantCulture), rt), cellAA, CreateRowLabel(i == 0 ? string.Empty : (len - i).ToString(CultureInfo.InvariantCulture), rt) }; foreach (int charge in charges) { foreach (IonType type in types) { CellDesc cell; if (Transition.IsNTerminal(type)) { if (i == len - 1) cell = CreateData(string.Empty, rt); else { double massH = masses[(int)type, i]; cell = CreateIon(type, i + 1, massH, charge, choices, chosen, tranSelected, rt); } row.Insert(0, cell); } else { if (i == 0) cell = CreateData(string.Empty, rt); else { double massH = masses[(int)type, i - 1]; cell = CreateIon(type, len - i, massH, charge, choices, chosen, tranSelected, rt); } row.Add(cell); } } } table.Add(row); } } SizeF sizeDetails = tableDetails.CalcDimensions(g); sizeDetails.Height += TableDesc.TABLE_SPACING; // Spacing between details and fragments SizeF size = table.CalcDimensions(g); if (draw) { tableDetails.Draw(g); g.TranslateTransform(0, sizeDetails.Height); table.Draw(g); g.TranslateTransform(0, -sizeDetails.Height); } int width = (int) Math.Round(Math.Max(sizeDetails.Width, size.Width)); int height = (int) Math.Round(sizeDetails.Height + size.Height); return new Size(width + 2, height + 2); } }
public override Size RenderTip(Graphics g, Size sizeMax, bool draw) { var sizeInitial = base.RenderTip(g, sizeMax, draw); if (ShowAnnotationTipOnly) { return(sizeInitial); } g.TranslateTransform(0, sizeInitial.Height); FastaSequence fastaSeq = DocNode.Id as FastaSequence; var tableDetails = new TableDesc(); using (RenderTools rt = new RenderTools()) { SizeF sizeX80 = g.MeasureString(X80, rt.FontNormal); float widthLine = sizeX80.Width; float heightLine = sizeX80.Height; float heightMax = sizeMax.Height; tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Name, DocNode.Name, rt); // If current name isn't the original, show that. if (DocNode.PeptideGroup.Name != null && !Equals(DocNode.Name, DocNode.PeptideGroup.Name)) { tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Original_Name, DocNode.OriginalName, rt); } if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Accession)) { tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Accession, DocNode.ProteinMetadata.Accession, rt); } if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.PreferredName)) { tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Preferred_Name, DocNode.ProteinMetadata.PreferredName, rt); } if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Gene)) { tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Gene, DocNode.ProteinMetadata.Gene, rt); } if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Species)) { tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Species, DocNode.ProteinMetadata.Species, rt); } if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.DisplaySearchHistory())) { tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Searched, DocNode.ProteinMetadata.DisplaySearchHistory(), rt); } if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Description)) { tableDetails.AddDetailRowLineWrap(g, Resources.PeptideGroupTreeNode_RenderTip_Description, DocNode.ProteinMetadata.Description, rt); } if (DocNode.PeptideGroup.Description != null && !Equals(DocNode.Description, DocNode.PeptideGroup.Description)) { tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Original_Description, DocNode.OriginalDescription, rt); } SizeF sizeDetails = tableDetails.CalcDimensions(g); sizeDetails.Height += TableDesc.TABLE_SPACING; // Spacing between details and fragments float heightTotal = sizeDetails.Height; widthLine = Math.Max(widthLine, sizeDetails.Width); if (draw) { tableDetails.Draw(g); } if (fastaSeq != null) { IList <DocNode> peptidesChoices = GetChoices(true).ToArray(); HashSet <DocNode> peptidesChosen = new HashSet <DocNode>(Chosen); // Make sure all chosen peptides get listed HashSet <DocNode> setChoices = new HashSet <DocNode>(peptidesChoices); setChoices.UnionWith(peptidesChosen); var arrayChoices = setChoices.ToArray(); Array.Sort(arrayChoices, (choice1, choice2) => PeptideFromChoice(choice1).Order - PeptideFromChoice(choice2).Order); peptidesChoices = arrayChoices; // Get the selected peptide, if there is one PeptideTreeNode nodePepTree = SequenceTree.GetNodeOfType <PeptideTreeNode>(); Peptide peptideSelected = (nodePepTree != null ? nodePepTree.DocNode.Peptide : null); int i = 0; string aa = fastaSeq.Sequence; const bool peptideList = false; while (i < aa.Length) { // If this is not the last possible line, just render it. if (heightTotal + heightLine * 2 <= heightMax) { i = RenderAALine(aa, peptideList, i, false, draw, peptidesChoices, peptidesChosen, peptideSelected, g, rt, heightTotal, widthLine); heightTotal += heightLine; } // If not drawing, then this is the last possible line, and // it will have content. else if (!draw) { heightTotal += heightLine; break; } // Otherwise, measure first, and then re-render, with an elipsis // if the full sequence cannot be shown. else { RenderAALine(aa, peptideList, i, false, false, peptidesChoices, peptidesChosen, peptideSelected, g, rt, heightTotal, widthLine); RenderAALine(aa, peptideList, i, i < aa.Length, true, peptidesChoices, peptidesChosen, peptideSelected, g, rt, heightTotal, widthLine); heightTotal += heightLine; break; } } } return(TipSize(Math.Max(widthLine, sizeInitial.Width), heightTotal + sizeInitial.Height)); } }
public static Size RenderTip(TransitionDocNode nodeTran, Graphics g, Size sizeMax, bool draw) { var table = new TableDesc(); using (RenderTools rt = new RenderTools()) { table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Ion, nodeTran.Transition.FragmentIonName, rt); table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Charge, nodeTran.Transition.Charge.ToString(LocalizationHelper.CurrentCulture), rt); table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Product_m_z, string.Format("{0:F04}", nodeTran.Mz), rt); // Not L10N int? decoyMassShift = nodeTran.Transition.DecoyMassShift; if (decoyMassShift.HasValue) table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Decoy_Mass_Shift, decoyMassShift.Value.ToString(LocalizationHelper.CurrentCulture), rt); if (nodeTran.HasLoss) { // If there is only one loss, show its full description var losses = nodeTran.Losses; if (losses.Losses.Count == 1) table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Loss, losses.ToStrings()[0], rt); // Otherwise, just show the total mass for multiple losses // followed by individual losses else { table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Loss, string.Format("{0:F04}", losses.Mass), rt); // Not L10N table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Losses, TextUtil.LineSeparate(losses.ToStrings()), rt); } } if (nodeTran.HasLibInfo) { table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Library_rank, nodeTran.LibInfo.Rank.ToString(LocalizationHelper.CurrentCulture), rt); float intensity = nodeTran.LibInfo.Intensity; table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Library_intensity, MathEx.RoundAboveZero(intensity, (intensity < 10 ? 1 : 0), 4).ToString(LocalizationHelper.CurrentCulture), rt); } if (nodeTran.Transition.IsCustom() && !string.IsNullOrEmpty(nodeTran.Transition.CustomIon.Formula)) { table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodeTran.Transition.CustomIon.Formula, rt); } SizeF size = table.CalcDimensions(g); if (draw) table.Draw(g); return new Size((int)size.Width + 2, (int)size.Height + 2); } }
public override Size RenderTip(Graphics g, Size sizeMax, bool draw) { var sizeInitial = base.RenderTip(g, sizeMax, draw); if (ShowAnnotationTipOnly) return sizeInitial; g.TranslateTransform(0, sizeInitial.Height); FastaSequence fastaSeq = DocNode.Id as FastaSequence; var tableDetails = new TableDesc(); using (RenderTools rt = new RenderTools()) { SizeF sizeX80 = g.MeasureString(X80, rt.FontNormal); float widthLine = sizeX80.Width; float heightLine = sizeX80.Height; float heightMax = sizeMax.Height; tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Name, DocNode.Name, rt); // If current name isn't the original, show that. if (DocNode.PeptideGroup.Name != null && !Equals(DocNode.Name, DocNode.PeptideGroup.Name)) tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Original_Name, DocNode.OriginalName, rt); if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Accession)) tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Accession, DocNode.ProteinMetadata.Accession, rt); if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.PreferredName)) tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Preferred_Name, DocNode.ProteinMetadata.PreferredName, rt); if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Gene)) tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Gene, DocNode.ProteinMetadata.Gene, rt); if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Species)) tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Species, DocNode.ProteinMetadata.Species, rt); if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.DisplaySearchHistory())) tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Searched, DocNode.ProteinMetadata.DisplaySearchHistory(), rt); if (!String.IsNullOrEmpty(DocNode.ProteinMetadata.Description)) tableDetails.AddDetailRowLineWrap(g,Resources.PeptideGroupTreeNode_RenderTip_Description, DocNode.ProteinMetadata.Description, rt); if (DocNode.PeptideGroup.Description != null && !Equals(DocNode.Description, DocNode.PeptideGroup.Description)) tableDetails.AddDetailRow(Resources.PeptideGroupTreeNode_RenderTip_Original_Description, DocNode.OriginalDescription, rt); SizeF sizeDetails = tableDetails.CalcDimensions(g); sizeDetails.Height += TableDesc.TABLE_SPACING; // Spacing between details and fragments float heightTotal = sizeDetails.Height; widthLine = Math.Max(widthLine, sizeDetails.Width); if (draw) { tableDetails.Draw(g); } if (fastaSeq != null) { IList<DocNode> peptidesChoices = GetChoices(true).ToArray(); HashSet<DocNode> peptidesChosen = new HashSet<DocNode>(Chosen); // Make sure all chosen peptides get listed HashSet<DocNode> setChoices = new HashSet<DocNode>(peptidesChoices); setChoices.UnionWith(peptidesChosen); var arrayChoices = setChoices.ToArray(); Array.Sort(arrayChoices, (choice1, choice2) => PeptideFromChoice(choice1).Order - PeptideFromChoice(choice2).Order); peptidesChoices = arrayChoices; // Get the selected peptide, if there is one PeptideTreeNode nodePepTree = SequenceTree.GetNodeOfType<PeptideTreeNode>(); Peptide peptideSelected = (nodePepTree != null ? nodePepTree.DocNode.Peptide : null); int i = 0; string aa = fastaSeq.Sequence; const bool peptideList = false; while (i < aa.Length) { // If this is not the last possible line, just render it. if (heightTotal + heightLine * 2 <= heightMax) { i = RenderAALine(aa, peptideList, i, false, draw, peptidesChoices, peptidesChosen, peptideSelected, g, rt, heightTotal, widthLine); heightTotal += heightLine; } // If not drawing, then this is the last possible line, and // it will have content. else if (!draw) { heightTotal += heightLine; break; } // Otherwise, measure first, and then re-render, with an elipsis // if the full sequence cannot be shown. else { RenderAALine(aa, peptideList, i, false, false, peptidesChoices, peptidesChosen, peptideSelected, g, rt, heightTotal, widthLine); RenderAALine(aa, peptideList, i, i < aa.Length, true, peptidesChoices, peptidesChosen, peptideSelected, g, rt, heightTotal, widthLine); heightTotal += heightLine; break; } } } return TipSize(Math.Max(widthLine, sizeInitial.Width), heightTotal + sizeInitial.Height); } }
public override ITableDesc GetTableByName(string[] names, bool useCache) { if (useCache) { var t = Get(names); if (t != null) { return(t); } } string tn; string sh; if (names.Length == 2) { sh = names[0]; tn = names[1]; } else if (names.Length == 1) { sh = DefaultSchema(); tn = names[0]; } else { throw new Exception("Incorrect table name"); } using (var con = GetConnection()) { con.Open(); string sql = @"SELECT EXISTS ( SELECT 1 FROM pg_catalog.pg_class c JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE n.nspname = @schema AND c.relname = @name );"; DbCommand cmd = con.CreateCommand(); cmd.CommandText = sql; ParserDbUtils.AddParam(cmd, "@schema", sh); ParserDbUtils.AddParam(cmd, "@name", tn); using (var reader = cmd.ExecuteReader()) { if (!reader.Read()) { throw new Exception("Table " + string.Join(".", names) + " is not found"); } } } using (var con = GetConnection()) { con.Open(); string sql = @"SELECT attname AS column_name , atttypid::regtype AS data_type -- more attributes? FROM pg_attribute WHERE attrelid = @schemaTable::regclass -- table name, optionally schema-qualified AND attnum > 0 AND NOT attisdropped ORDER BY attnum"; DbCommand cmd = con.CreateCommand(); cmd.CommandText = sql; string st = ""; if (!string.IsNullOrEmpty(sh)) { st += "\"" + sh + "\""; } if (!string.IsNullOrEmpty(tn)) { if (st != "") { st += "."; } st += "\"" + tn + "\""; } ParserDbUtils.AddParam(cmd, "@schemaTable", st); TableDesc td = new TableDesc(); td.PhysicalTableName = tn; td.LogicalTableName = tn; td.PhysicalSchema = sh; td.LogicalSchema = sh; //td.DbDriver = Driver; td.TableColumns = new List <Column>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { Column ci = new Column( reader.GetString(reader.GetOrdinal("column_name")), ColumnSqlTypeToSimpleType(reader.GetString(reader.GetOrdinal("data_type"))) ); td.TableColumns.Add(ci); } } Set(names, td); return(td); } }
public static Size RenderTip(PeptideDocNode nodePep, TransitionGroupDocNode nodeGroup, TransitionDocNode nodeTranSelected, SrmSettings settings, Graphics g, Size sizeMax, bool draw) { if (nodeGroup.TransitionGroup.IsCustomIon) // TODO(bspratt) this seems to leave out a lot of detail { var customTable = new TableDesc(); using (RenderTools rt = new RenderTools()) { customTable.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Molecule, nodeGroup.CustomMolecule.Name, rt); customTable.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_charge, nodeGroup.TransitionGroup.PrecursorAdduct.AdductCharge.ToString(LocalizationHelper.CurrentCulture), rt); customTable.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_mz, string.Format(@"{0:F04}", nodeGroup.PrecursorMz), rt); if (nodeGroup.CustomMolecule.Formula != null) { customTable.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodeGroup.CustomMolecule.Formula + nodeGroup.TransitionGroup.PrecursorAdduct.AdductFormula.ToString(LocalizationHelper.CurrentCulture), rt); } SizeF size = customTable.CalcDimensions(g); customTable.Draw(g); return(new Size((int)size.Width + 2, (int)size.Height + 2)); } } ExplicitMods mods = (nodePep != null ? nodePep.ExplicitMods : null); IEnumerable <DocNode> choices = nodeGroup.GetPrecursorChoices(settings, mods, true).ToArray(); HashSet <DocNode> chosen = new HashSet <DocNode>(nodeGroup.Children); // Make sure all chosen peptides get listed HashSet <DocNode> setChoices = new HashSet <DocNode>(choices); setChoices.UnionWith(chosen); choices = setChoices.ToArray(); Transition tranSelected = (nodeTranSelected != null ? nodeTranSelected.Transition : null); IFragmentMassCalc calc = settings.GetFragmentCalc(nodeGroup.TransitionGroup.LabelType, mods); var aa = nodeGroup.TransitionGroup.Peptide.Target.Sequence; // We handled custom ions above, and returned var masses = calc.GetFragmentIonMasses(nodeGroup.TransitionGroup.Peptide.Target); var filter = settings.TransitionSettings.Filter; // Get charges and type pairs, making sure all chosen charges are included var setCharges = new HashSet <Adduct>(filter.PeptideProductCharges.Where(charge => Math.Abs(charge.AdductCharge) <= Math.Abs(nodeGroup.TransitionGroup.PrecursorCharge) && Math.Sign(charge.AdductCharge) == Math.Sign(nodeGroup.TransitionGroup.PrecursorCharge))); HashSet <IonType> setTypes = new HashSet <IonType>(filter.PeptideIonTypes); foreach (TransitionDocNode nodTran in chosen) { var type = nodTran.Transition.IonType; if (!Transition.IsPeptideFragment(type)) { continue; } setCharges.Add(nodTran.Transition.Adduct); setTypes.Add(type); } setTypes.RemoveWhere(t => !Transition.IsPeptideFragment(t)); var charges = setCharges.Where(c => c.IsProteomic).ToArray(); Array.Sort(charges); IonType[] types = Transition.GetTypePairs(setTypes); var tableDetails = new TableDesc(); var table = new TableDesc(); using (RenderTools rt = new RenderTools()) { var seqModified = GetModifiedSequence(nodePep, nodeGroup, settings); if (!Equals(seqModified, nodeGroup.TransitionGroup.Peptide.Target)) { tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Modified, seqModified.Sequence, rt); } var precursorCharge = nodeGroup.TransitionGroup.PrecursorAdduct; var precursorMz = nodeGroup.PrecursorMz; tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_charge, precursorCharge.AdductCharge.ToString(LocalizationHelper.CurrentCulture), rt); tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_mz, string.Format(@"{0:F04}", precursorMz), rt); tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Precursor_mh, string.Format(@"{0:F04}", nodeGroup.GetPrecursorIonMass()), rt); int?decoyMassShift = nodeGroup.TransitionGroup.DecoyMassShift; if (decoyMassShift.HasValue) { tableDetails.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Decoy_Mass_Shift, decoyMassShift.Value.ToString(LocalizationHelper.CurrentCulture), rt); } if (nodeGroup.HasLibInfo) { foreach (KeyValuePair <PeptideRankId, string> pair in nodeGroup.LibInfo.RankValues) { tableDetails.AddDetailRow(pair.Key.Label, pair.Value, rt); } } if (charges.Length > 0 && types.Length > 0) { var headers = new RowDesc { CreateHead(@"#", rt), CreateHead(@"AA", rt), CreateHead(@"#", rt) }; foreach (var charge in charges) { string plusSub = Transition.GetChargeIndicator(charge); foreach (IonType type in types) { CellDesc cell = CreateHead(type.ToString().ToLower() + plusSub, rt); if (Transition.IsNTerminal(type)) { headers.Insert(0, cell); } else { headers.Add(cell); } } } table.Add(headers); int len = aa.Length; for (int i = 0; i < len; i++) { CellDesc cellAA = CreateRowLabel(aa.Substring(i, 1), rt); cellAA.Align = StringAlignment.Center; var row = new RowDesc { CreateRowLabel(i == len - 1 ? string.Empty : (i + 1).ToString(CultureInfo.InvariantCulture), rt), cellAA, CreateRowLabel(i == 0 ? string.Empty : (len - i).ToString(CultureInfo.InvariantCulture), rt) }; foreach (var charge in charges) { foreach (IonType type in types) { CellDesc cell; if (Transition.IsNTerminal(type)) { if (i == len - 1) { cell = CreateData(string.Empty, rt); } else { var massH = masses[type, i]; cell = CreateIon(type, i + 1, massH, charge, choices, chosen, tranSelected, rt); } row.Insert(0, cell); } else { if (i == 0) { cell = CreateData(string.Empty, rt); } else { var massH = masses[type, i - 1]; cell = CreateIon(type, len - i, massH, charge, choices, chosen, tranSelected, rt); } row.Add(cell); } } } table.Add(row); } } SizeF sizeDetails = tableDetails.CalcDimensions(g); sizeDetails.Height += TableDesc.TABLE_SPACING; // Spacing between details and fragments SizeF size = table.CalcDimensions(g); if (draw) { tableDetails.Draw(g); g.TranslateTransform(0, sizeDetails.Height); table.Draw(g); g.TranslateTransform(0, -sizeDetails.Height); } int width = (int)Math.Round(Math.Max(sizeDetails.Width, size.Width)); int height = (int)Math.Round(sizeDetails.Height + size.Height); return(new Size(width + 2, height + 2)); } }
public static Size RenderTip(PeptideDocNode nodePep, TransitionDocNode nodeTranSelected, SrmSettings settings, Graphics g, Size sizeMax, bool draw) { var table = new TableDesc(); using (RenderTools rt = new RenderTools()) { Peptide peptide = nodePep.Peptide; SizeF size; if (peptide.IsCustomIon) { table.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Molecule, nodePep.CustomIon.Name, rt); table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodePep.CustomIon.Formula, rt); table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Neutral_Mass, nodePep.CustomIon.GetMass(settings.TransitionSettings.Prediction.PrecursorMassType).ToString(LocalizationHelper.CurrentCulture), rt); size = table.CalcDimensions(g); table.Draw(g); return new Size((int)Math.Round(size.Width + 2), (int)Math.Round(size.Height + 2)); } if (nodePep.Children.Count > 1) { foreach (var typedModSequence in GetTypedModifiedSequences(nodePep, settings)) table.AddDetailRow(typedModSequence.Key.Title, typedModSequence.Value, rt); } if (peptide.Begin.HasValue) { // Add a spacing row, if anything was added if (table.Count > 0) table.AddDetailRow(" ", " ", rt); // Not L10N table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Previous, peptide.PrevAA.ToString(CultureInfo.InvariantCulture), rt); table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_First, peptide.Begin.Value.ToString(LocalizationHelper.CurrentCulture), rt); table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Last, ((peptide.End ?? 1) - 1).ToString(LocalizationHelper.CurrentCulture), rt); table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Next, peptide.NextAA.ToString(CultureInfo.InvariantCulture), rt); } if (nodePep.Rank.HasValue) table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Rank, nodePep.Rank.Value.ToString(LocalizationHelper.CurrentCulture), rt); size = table.CalcDimensions(g); if (draw) table.Draw(g); // Render group tip, if there is only one, and this node is collapsed if (nodePep.Children.Count == 1) { var nodeGroup = (TransitionGroupDocNode)nodePep.Children[0]; if (size.Height > 0) size.Height += TableDesc.TABLE_SPACING; if (draw) g.TranslateTransform(0, size.Height); Size sizeMaxGroup = new Size(sizeMax.Width, sizeMax.Height - (int)size.Height); SizeF sizeGroup = TransitionGroupTreeNode.RenderTip(nodePep, nodeGroup, nodeTranSelected, settings, g, sizeMaxGroup, draw); if (draw) g.TranslateTransform(0, -size.Height); size.Width = Math.Max(size.Width, sizeGroup.Width); size.Height += sizeGroup.Height; } return new Size((int)Math.Round(size.Width + 2), (int)Math.Round(size.Height + 2)); } }
/// <summary> /// 实始化<see cref="MappingResolveContext"/>实例 /// </summary> /// <param name="template">Mapping类文件模板</param> /// <param name="table">数据表</param> public MappingResolveContext(string template, TableDesc table) { this._output = template; this._table = table; }
public static Size RenderTip(PeptideDocNode nodePep, TransitionDocNode nodeTranSelected, SrmSettings settings, Graphics g, Size sizeMax, bool draw) { var table = new TableDesc(); using (RenderTools rt = new RenderTools()) { Peptide peptide = nodePep.Peptide; SizeF size; if (peptide.IsCustomMolecule) { table.AddDetailRow(Resources.TransitionGroupTreeNode_RenderTip_Molecule, nodePep.CustomMolecule.Name, rt); table.AddDetailRow(Resources.TransitionTreeNode_RenderTip_Formula, nodePep.CustomMolecule.Formula, rt); table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Neutral_Mass, nodePep.CustomMolecule.GetMass(settings.TransitionSettings.Prediction.PrecursorMassType).ToString(LocalizationHelper.CurrentCulture), rt); foreach (var id in nodePep.CustomMolecule.AccessionNumbers.AccessionNumbers) { table.AddDetailRow(id.Key, id.Value, rt); // Show InChiKey etc as available } size = table.CalcDimensions(g); table.Draw(g); return(new Size((int)Math.Round(size.Width + 2), (int)Math.Round(size.Height + 2))); } if (peptide.IsDecoy) { string sourceText = nodePep.SourceTextId .Replace(@".0]", @"]") .Replace(@".", LocalizationHelper.CurrentCulture.NumberFormat.NumberDecimalSeparator); table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Source, sourceText, rt); } if (nodePep.Children.Count > 1) { foreach (var typedModSequence in GetTypedModifiedSequences(nodePep, settings)) { table.AddDetailRow(typedModSequence.Key.Title, typedModSequence.Value, rt); } } if (peptide.Begin.HasValue) { // Add a spacing row, if anything was added if (table.Count > 0) { table.AddDetailRow(@" ", @" ", rt); } table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Previous, peptide.PrevAA.ToString(CultureInfo.InvariantCulture), rt); table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_First, peptide.Begin.Value.ToString(LocalizationHelper.CurrentCulture), rt); table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Last, ((peptide.End ?? 1) - 1).ToString(LocalizationHelper.CurrentCulture), rt); table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Next, peptide.NextAA.ToString(CultureInfo.InvariantCulture), rt); } if (nodePep.Rank.HasValue) { table.AddDetailRow(Resources.PeptideTreeNode_RenderTip_Rank, nodePep.Rank.Value.ToString(LocalizationHelper.CurrentCulture), rt); } size = table.CalcDimensions(g); if (draw) { table.Draw(g); } // Render group tip, if there is only one, and this node is collapsed if (nodePep.Children.Count == 1) { var nodeGroup = (TransitionGroupDocNode)nodePep.Children[0]; if (size.Height > 0) { size.Height += TableDesc.TABLE_SPACING; } if (draw) { g.TranslateTransform(0, size.Height); } Size sizeMaxGroup = new Size(sizeMax.Width, sizeMax.Height - (int)size.Height); SizeF sizeGroup = TransitionGroupTreeNode.RenderTip(nodePep, nodeGroup, nodeTranSelected, settings, g, sizeMaxGroup, draw); if (draw) { g.TranslateTransform(0, -size.Height); } size.Width = Math.Max(size.Width, sizeGroup.Width); size.Height += sizeGroup.Height; } return(new Size((int)Math.Round(size.Width + 2), (int)Math.Round(size.Height + 2))); } }
/// <summary> /// 初始化<see cref="EntityClassResolverContext"/>实例 /// </summary> /// <param name="entityTemplate">实体类文件模板</param> /// <param name="tableDesc">数据表描述对象</param> public EntityClassResolveContext(string entityTemplate, TableDesc tableDesc) { this._outputEntityClassContent = entityTemplate; this._tableDesc = tableDesc; }
public override ITableDesc GetTableByName(string[] names, bool useCache) { if (useCache) { var t = Get(names); if (t != null) { return(t); } } string tn; string sh; if (names.Length == 2) { sh = names[0]; tn = names[1]; } else if (names.Length == 1) { sh = DefaultSchema(); tn = names[0]; } else { throw new Exception("Incorrect table name"); } using (var con = GetConnection()) { con.Open(); string sql = "select TABLE_SCHEMA, TABLE_NAME from INFORMATION_SCHEMA.TABLES where TABLE_SCHEMA = @schema and TABLE_NAME = @name"; DbCommand cmd = con.CreateCommand(); cmd.CommandText = sql; ParserDbUtils.AddParam(cmd, "@schema", sh); ParserDbUtils.AddParam(cmd, "@name", tn); using (var reader = cmd.ExecuteReader()) { if (!reader.Read()) { throw new Exception("Table " + string.Join(".", names) + " is not found"); } } } using (var con = GetConnection()) { con.Open(); string sql = @"select COLUMN_NAME, DATA_TYPE from INFORMATION_SCHEMA.COLUMNS where TABLE_SCHEMA = @schema and TABLE_NAME = @name"; DbCommand cmd = con.CreateCommand(); cmd.CommandText = sql; ParserDbUtils.AddParam(cmd, "@schema", sh); ParserDbUtils.AddParam(cmd, "@name", tn); TableDesc td = new TableDesc(); td.PhysicalTableName = tn; td.LogicalTableName = tn; td.PhysicalSchema = sh; td.LogicalSchema = sh; td.TableColumns = new List <Column>(); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) { Column ci = new Column( reader.GetString(reader.GetOrdinal("COLUMN_NAME")), ColumnSqlTypeToSimpleType(reader.GetString(reader.GetOrdinal("DATA_TYPE")))); td.TableColumns.Add(ci); } } Set(names, td); return(td); } }