From ea11d8cdcd8effb84691943a59551be37115f207 Mon Sep 17 00:00:00 2001 From: Dominik Kopczynski Date: Thu, 2 Nov 2023 12:53:46 +0100 Subject: [PATCH] added functional group tables for phospohlipids --- LipidCreator/CreatorGUI.Designer.cs | 274 +++++++--------- LipidCreator/CreatorGUI.cs | 489 ++++++++++++++++++---------- LipidCreator/FattyAcid.cs | 5 +- LipidCreator/FattyAcidGroup.cs | 77 +++-- LipidCreator/Tutorial.cs | 4 +- 5 files changed, 493 insertions(+), 356 deletions(-) diff --git a/LipidCreator/CreatorGUI.Designer.cs b/LipidCreator/CreatorGUI.Designer.cs index c22e464..78cf71f 100644 --- a/LipidCreator/CreatorGUI.Designer.cs +++ b/LipidCreator/CreatorGUI.Designer.cs @@ -736,21 +736,6 @@ partial class CreatorGUI public TextBox slDB2Textbox; [NonSerialized] public TextBox stDBTextbox; - - [NonSerialized] - public TextBox clHydroxyl3Textbox; - [NonSerialized] - public TextBox clHydroxyl4Textbox; - [NonSerialized] - public TextBox glHydroxyl1Textbox; - [NonSerialized] - public TextBox glHydroxyl2Textbox; - [NonSerialized] - public TextBox glHydroxyl3Textbox; - [NonSerialized] - public TextBox plHydroxyl1Textbox; - [NonSerialized] - public TextBox plHydroxyl2Textbox; [NonSerialized] public TextBox stHydroxylTextbox; @@ -802,20 +787,6 @@ partial class CreatorGUI [NonSerialized] Label slFAHydroxyLabel; [NonSerialized] - Label clHydroxyl3Label; - [NonSerialized] - Label clHydroxyl4Label; - [NonSerialized] - Label glHydroxyl1Label; - [NonSerialized] - Label glHydroxyl2Label; - [NonSerialized] - Label glHydroxyl3Label; - [NonSerialized] - Label plHydroxyl1Label; - [NonSerialized] - Label plHydroxyl2Label; - [NonSerialized] Label stFAHydroxyLabel; @@ -911,7 +882,19 @@ partial class CreatorGUI [NonSerialized] - DataGridView glFA1FuncGroups; + public DataGridView glFA1FuncGroups; + [NonSerialized] + public DataGridView glFA2FuncGroups; + [NonSerialized] + public DataGridView glFA3FuncGroups; + [NonSerialized] + public DataGridView plFA1FuncGroups; + [NonSerialized] + public DataGridView plFA2FuncGroups; + [NonSerialized] + public DataGridView plFA3FuncGroups; + [NonSerialized] + public DataGridView plFA4FuncGroups; @@ -933,6 +916,72 @@ partial class CreatorGUI public int mediatorMiddleHeight = 164; public long easterEggMilliseconds; + public delegate void MouseMovedEvent(); + + public class GlobalMouseHandler : IMessageFilter + { + private const int WM_MOUSEMOVE = 0x0200; + + public event MouseMovedEvent TheMouseMoved; + + #region IMessageFilter Members + + public bool PreFilterMessage(ref Message m) + { + if (m.Msg == WM_MOUSEMOVE) + { + if (TheMouseMoved != null) TheMouseMoved(); + } + return false; + } + + #endregion + } + + public List[] functionalGroupGridViews = new List[7]{new List(), new List(), new List(), new List(), new List(), new List(), new List()}; + public DataGridView expandedView = null; + + + private void setupFGDataGridView(DataGridView view, int left, int top, int tabIndex) + { + DataGridViewComboBoxColumn funcGroupCol = new DataGridViewComboBoxColumn(); + funcGroupCol.DataSource = Lipid.FUNCTIONAL_GROUP_NAMES; + funcGroupCol.HeaderText = "Func. group"; + funcGroupCol.DataPropertyName = "Func. group"; + funcGroupCol.SortMode = DataGridViewColumnSortMode.NotSortable; + + DataGridViewTextBoxColumn rangeCol = new DataGridViewTextBoxColumn(); + rangeCol.HeaderText = "Range"; + rangeCol.DataPropertyName = "Range"; + rangeCol.SortMode = DataGridViewColumnSortMode.NotSortable; + + view.Location = new Point(left, top); + view.Size = new Size(180, 40); + view.BringToFront(); + view.Columns.AddRange(funcGroupCol, rangeCol); + view.DefaultCellStyle.WrapMode = DataGridViewTriState.True; + view.AllowUserToResizeColumns = false; + view.AllowUserToAddRows = false; + view.AllowUserToResizeRows = false; + view.MultiSelect = false; + view.RowTemplate.Height = 20; + view.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + view.RowHeadersVisible = false; + view.ScrollBars = ScrollBars.Vertical; + view.DefaultCellStyle.Font = new Font("Arial", 8); + view.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing; + view.EnableHeadersVisualStyles = false; + view.ColumnHeadersHeight = 20; + view.DataBindingComplete += functionalGroupComplete; + view.CellValueChanged += functionalGroupCellValueChanged; + functionalGroupGridViews[tabIndex].Add(view); + + ContextMenu cm = new ContextMenu(); + cm.MenuItems.Add(new FMenuItem("Add functional group", new EventHandler(addFunctionalGroup), view)); + cm.MenuItems.Add(new FMenuItem("Remove functional group", new EventHandler(removeFunctionalGroup), view)); + view.ContextMenu = cm; + } + public Image ScaleImage(Image image, int maxWidth, int maxHeight) { @@ -962,6 +1011,10 @@ private void InitializeComponent() this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; this.Text = "LipidCreator"; + GlobalMouseHandler gmh = new GlobalMouseHandler(); + gmh.TheMouseMoved += new MouseMovedEvent(gmh_TheMouseMoved); + Application.AddMessageFilter(gmh); + this.timerEasterEgg = new System.Timers.Timer(15); this.timerEasterEgg.Elapsed += this.timerEasterEggTick; @@ -1139,7 +1192,7 @@ private void InitializeComponent() String dbText = "No. DB"; String hydroxylText = "No. Hydroxy"; - int dbLength = 70; + int dbLength = 60; int sep = 15; int sepText = 20; int faLength = 150; @@ -1255,10 +1308,6 @@ private void InitializeComponent() clFA4Combobox.Items.Add("Fatty acyl chain - even"); clDB3Textbox = new TextBox(); clDB4Textbox = new TextBox(); - clHydroxyl3Textbox = new TextBox(); - clHydroxyl4Textbox = new TextBox(); - clHydroxyl3Label = new Label(); - clHydroxyl4Label = new Label(); clDB3Label = new Label(); clDB4Label = new Label(); glFA1Textbox = new TextBox(); @@ -1279,16 +1328,10 @@ private void InitializeComponent() glDB1Textbox = new TextBox(); glDB2Textbox = new TextBox(); glDB3Textbox = new TextBox(); - glHydroxyl1Textbox = new TextBox(); - glHydroxyl2Textbox = new TextBox(); - glHydroxyl3Textbox = new TextBox(); glDB1Label = new Label(); glDB2Label = new Label(); glDB3Label = new Label(); glHGLabel = new Label(); - glHydroxyl1Label = new Label(); - glHydroxyl2Label = new Label(); - glHydroxyl3Label = new Label(); plFA1Textbox = new TextBox(); plFA2Textbox = new TextBox(); plFA1Combobox = new ComboBox(); @@ -1301,12 +1344,8 @@ private void InitializeComponent() plFA2Combobox.Items.Add("Fatty acyl chain - even"); plDB1Textbox = new TextBox(); plDB2Textbox = new TextBox(); - plHydroxyl1Textbox = new TextBox(); - plHydroxyl2Textbox = new TextBox(); plDB1Label = new Label(); plDB2Label = new Label(); - plHydroxyl1Label = new Label(); - plHydroxyl2Label = new Label(); plHGLabel = new Label(); slLCBTextbox = new TextBox(); slFATextbox = new TextBox(); @@ -1388,6 +1427,12 @@ private void InitializeComponent() medNegativeAdduct = new GroupBox(); glFA1FuncGroups = new DataGridView(); + glFA2FuncGroups = new DataGridView(); + glFA3FuncGroups = new DataGridView(); + plFA1FuncGroups = new DataGridView(); + plFA2FuncGroups = new DataGridView(); + plFA3FuncGroups = new DataGridView(); + plFA4FuncGroups = new DataGridView(); glStep1 = new GroupBox(); plStep1 = new GroupBox(); @@ -1451,7 +1496,7 @@ private void InitializeComponent() string formattingFA = "Comma seperated single entries or intervals. Example formatting: 2, 3, 5-6, 13-20"; string formattingDB = "Comma seperated single entries or intervals. Example formatting: 2, 3-4, 6"; - string formattingHydroxyl = "Comma seperated single entries or intervals. Example formatting: 2-4, 10, 12"; + string formattingHydroxyl = "Comma seperated single entries or intervals. Example formatting: 0-2, 4"; string FApInformation = "Plasmenyl fatty acids need at least one double bond"; string repFAText = "All fatty acyl parameters will be copied from the first FA to all remaining FAs"; @@ -1492,14 +1537,10 @@ private void InitializeComponent() plStep1.Controls.Add(clFA4Textbox); plStep1.Controls.Add(clDB3Textbox); plStep1.Controls.Add(clDB4Textbox); - plStep1.Controls.Add(clHydroxyl3Textbox); - plStep1.Controls.Add(clHydroxyl4Textbox); plStep1.Controls.Add(clFA3Combobox); plStep1.Controls.Add(clFA4Combobox); plStep1.Controls.Add(clDB3Label); plStep1.Controls.Add(clDB4Label); - plStep1.Controls.Add(clHydroxyl3Label); - plStep1.Controls.Add(clHydroxyl4Label); phospholipidsTab.Font = Font; @@ -1507,14 +1548,12 @@ private void InitializeComponent() clFA4Textbox.Visible = false; clDB3Textbox.Visible = false; clDB4Textbox.Visible = false; - clHydroxyl3Textbox.Visible = false; - clHydroxyl4Textbox.Visible = false; clFA3Combobox.Visible = false; clFA4Combobox.Visible = false; clDB3Label.Visible = false; clDB4Label.Visible = false; - clHydroxyl3Label.Visible = false; - clHydroxyl4Label.Visible = false; + plFA3FuncGroups.Visible = false; + plFA4FuncGroups.Visible = false; @@ -1535,13 +1574,8 @@ private void InitializeComponent() clDB3Label.Location = new Point(clDB3Textbox.Left, clDB3Textbox.Top - sep); clDB3Label.Width = dbLength; clDB3Label.Text = dbText; - clHydroxyl3Textbox.Width = dbLength; - clHydroxyl3Textbox.Location = new Point(clDB3Textbox.Left + clDB3Textbox.Width + sep, clDB3Textbox.Top); - clHydroxyl3Textbox.TextChanged += delegate(object s, EventArgs e){ updateHydroxyl(s, new FattyAcidEventArgs( ((Phospholipid)currentLipid).fag3, FattyAcidType.Ester )); }; - toolTip.SetToolTip(clHydroxyl3Textbox, formattingHydroxyl); - clHydroxyl3Label.Width = dbLength; - clHydroxyl3Label.Location = new Point(clHydroxyl3Textbox.Left, clHydroxyl3Textbox.Top - sep); - clHydroxyl3Label.Text = hydroxylText; + setupFGDataGridView(plFA3FuncGroups, clDB3Textbox.Left + sep + dbLength, clFA3Combobox.Top, 2); + toolTip.SetToolTip(plFA3FuncGroups, formattingHydroxyl); clFA3Checkbox3.Location = new Point(clFA3Textbox.Left + 90, clFA3Textbox.Top + clFA3Textbox.Height); @@ -1580,13 +1614,8 @@ private void InitializeComponent() clDB4Label.Location = new Point(clDB4Textbox.Left, clDB4Textbox.Top - sep); clDB4Label.Width = dbLength; clDB4Label.Text = dbText; - clHydroxyl4Textbox.Width = dbLength; - clHydroxyl4Textbox.Location = new Point(clDB4Textbox.Left + clDB4Textbox.Width + sep, clDB4Textbox.Top); - clHydroxyl4Textbox.TextChanged += delegate(object s, EventArgs e){ updateHydroxyl(s, new FattyAcidEventArgs( ((Phospholipid)currentLipid).fag4, FattyAcidType.Ester )); }; - toolTip.SetToolTip(clHydroxyl4Textbox, formattingHydroxyl); - clHydroxyl4Label.Width = dbLength; - clHydroxyl4Label.Location = new Point(clHydroxyl4Textbox.Left, clHydroxyl4Textbox.Top - sep); - clHydroxyl4Label.Text = hydroxylText; + setupFGDataGridView(plFA4FuncGroups, clDB4Textbox.Left + sep + dbLength, clFA4Combobox.Top, 2); + toolTip.SetToolTip(plFA4FuncGroups, formattingHydroxyl); clFA4Checkbox3.Location = new Point(clFA4Textbox.Left + 90, clFA4Textbox.Top + clFA4Textbox.Height); clFA4Checkbox3.Text = "FA O"; @@ -1625,9 +1654,6 @@ private void InitializeComponent() glStep1.Controls.Add(glDB1Textbox); glStep1.Controls.Add(glDB2Textbox); glStep1.Controls.Add(glDB3Textbox); - glStep1.Controls.Add(glHydroxyl1Textbox); - glStep1.Controls.Add(glHydroxyl2Textbox); - glStep1.Controls.Add(glHydroxyl3Textbox); glStep1.Controls.Add(glFA1Combobox); glStep1.Controls.Add(glFA2Combobox); glStep1.Controls.Add(glFA3Combobox); @@ -1637,12 +1663,12 @@ private void InitializeComponent() glStep1.Controls.Add(glDB1Label); glStep1.Controls.Add(glDB2Label); glStep1.Controls.Add(glDB3Label); - glStep1.Controls.Add(glHydroxyl1Label); - glStep1.Controls.Add(glHydroxyl2Label); - glStep1.Controls.Add(glHydroxyl3Label); glStep1.Controls.Add(glRepresentativeFA); glStep1.Controls.Add(glPositiveAdduct); glStep1.Controls.Add(glNegativeAdduct); + glStep1.Controls.Add(glFA1FuncGroups); + glStep1.Controls.Add(glFA2FuncGroups); + glStep1.Controls.Add(glFA3FuncGroups); glycerolipidsTab.Parent = tabControl; glycerolipidsTab.Text = "Glycerolipids"; //glycerolipidsTab.ToolTipText = "Glycerolipids"; @@ -1660,7 +1686,6 @@ private void InitializeComponent() glStep1.Text = "Step 1: Precursor selection"; - glFA1Combobox.BringToFront(); glFA1Textbox.BringToFront(); @@ -1682,13 +1707,10 @@ private void InitializeComponent() glDB1Label.Location = new Point(glDB1Textbox.Left, glDB1Textbox.Top - sep); glDB1Label.Width = dbLength; glDB1Label.Text = dbText; - glHydroxyl1Textbox.Width = dbLength; - glHydroxyl1Textbox.Location = new Point(glDB1Textbox.Left + glDB1Textbox.Width + sep, glDB1Textbox.Top); - glHydroxyl1Textbox.TextChanged += delegate(object s, EventArgs e){ updateHydroxyl(s, new FattyAcidEventArgs( ((Glycerolipid)currentLipid).fag1, FattyAcidType.Ester )); updateGLRepresentative(); }; - toolTip.SetToolTip(glHydroxyl1Textbox, formattingHydroxyl); - glHydroxyl1Label.Width = dbLength; - glHydroxyl1Label.Location = new Point(glHydroxyl1Textbox.Left, glHydroxyl1Textbox.Top - sep); - glHydroxyl1Label.Text = hydroxylText; + setupFGDataGridView(glFA1FuncGroups, glDB1Textbox.Left + sep + dbLength, glFA1Combobox.Top, 1); + toolTip.SetToolTip(glFA1FuncGroups, formattingHydroxyl); + + glFA1Checkbox3.Location = new Point(glFA1Textbox.Left + 90, glFA1Textbox.Top + glFA1Textbox.Height); glFA1Checkbox3.Text = "FA O"; @@ -1705,6 +1727,10 @@ private void InitializeComponent() glFA1Checkbox1.Text = "FA"; glFA1Checkbox1.Checked = true; glFA1Checkbox1.CheckedChanged += delegate(object s, EventArgs e){ FattyAcidCheckboxCheckChanged(s, new FattyAcidEventArgs( ((Glycerolipid)currentLipid).fag1, FattyAcidType.Ester )); updateGLRepresentative(); }; + + + + glFA2Combobox.BringToFront(); glFA2Textbox.BringToFront(); @@ -1726,13 +1752,9 @@ private void InitializeComponent() glDB2Label.Location = new Point(glDB2Textbox.Left, glDB2Textbox.Top - sep); glDB2Label.Width = dbLength; glDB2Label.Text = dbText; - glHydroxyl2Textbox.Width = dbLength; - glHydroxyl2Textbox.Location = new Point(glDB2Textbox.Left + glDB2Textbox.Width + sep, glDB2Textbox.Top); - glHydroxyl2Textbox.TextChanged += delegate(object s, EventArgs e){ updateHydroxyl(s, new FattyAcidEventArgs( ((Glycerolipid)currentLipid).fag2, FattyAcidType.Ester )); }; - toolTip.SetToolTip(glHydroxyl2Textbox, formattingHydroxyl); - glHydroxyl2Label.Width = dbLength; - glHydroxyl2Label.Location = new Point(glHydroxyl2Textbox.Left, glHydroxyl2Textbox.Top - sep); - glHydroxyl2Label.Text = hydroxylText; + setupFGDataGridView(glFA2FuncGroups, glDB2Textbox.Left + sep + dbLength, glFA2Combobox.Top, 1); + toolTip.SetToolTip(glFA2FuncGroups, formattingHydroxyl); + glFA2Checkbox3.Location = new Point(glFA2Textbox.Left + 90, glFA2Textbox.Top + glFA2Textbox.Height); glFA2Checkbox3.Text = "FA O"; @@ -1771,13 +1793,8 @@ private void InitializeComponent() glDB3Label.Location = new Point(glDB3Textbox.Left, glDB3Textbox.Top - sep); glDB3Label.Width = dbLength; glDB3Label.Text = dbText; - glHydroxyl3Textbox.Width = dbLength; - glHydroxyl3Textbox.Location = new Point(glDB3Textbox.Left + glDB3Textbox.Width + sep, glDB3Textbox.Top); - glHydroxyl3Textbox.TextChanged += delegate(object s, EventArgs e){ updateHydroxyl(s, new FattyAcidEventArgs( ((Glycerolipid)currentLipid).fag3, FattyAcidType.Ester )); }; - toolTip.SetToolTip(glHydroxyl3Textbox, formattingHydroxyl); - glHydroxyl3Label.Width = dbLength; - glHydroxyl3Label.Location = new Point(glHydroxyl3Textbox.Left, glHydroxyl3Textbox.Top - sep); - glHydroxyl3Label.Text = hydroxylText; + setupFGDataGridView(glFA3FuncGroups, glDB3Textbox.Left + sep + dbLength, glFA3Combobox.Top, 1); + toolTip.SetToolTip(glFA3FuncGroups, formattingHydroxyl); glFA3Checkbox3.Location = new Point(glFA3Textbox.Left + 90, glFA3Textbox.Top + glFA3Textbox.Height); glFA3Checkbox3.Text = "FA O"; @@ -1872,7 +1889,7 @@ private void InitializeComponent() glContainsSugar.BringToFront(); - glRepresentativeFA.Location = new Point(glHydroxyl1Textbox.Left + glHydroxyl1Textbox.Width + sep, glHydroxyl1Textbox.Top); + glRepresentativeFA.Location = new Point(glFA1FuncGroups.Left + glFA1FuncGroups.Width + sep, glFA1Textbox.Top); glRepresentativeFA.Width = 150; glRepresentativeFA.Text = "First FA representative"; toolTip.SetToolTip(glRepresentativeFA, repFAText); @@ -1887,42 +1904,9 @@ private void InitializeComponent() - DataGridViewComboBoxColumn funcGroupCol = new DataGridViewComboBoxColumn(); - funcGroupCol.DataSource = Lipid.FUNCTIONAL_GROUP_NAMES; - funcGroupCol.HeaderText = "Func. group"; - funcGroupCol.DataPropertyName = "Func. group"; - - DataGridViewTextBoxColumn rangeCol = new DataGridViewTextBoxColumn(); - rangeCol.HeaderText = "Range"; - rangeCol.DataPropertyName = "Range"; - glStep1.Controls.Add(glFA1FuncGroups); - glFA1FuncGroups.Location = new Point(glFA1Combobox.Left + glFA1Combobox.Width + 2 * sep + glDB1Textbox.Width, glFA1Combobox.Top); - glFA1FuncGroups.Size = new Size(340, 360); - glFA1FuncGroups.BringToFront(); - glFA1FuncGroups.Columns.AddRange(funcGroupCol, rangeCol); - glFA1FuncGroups.DefaultCellStyle.WrapMode = DataGridViewTriState.True; - glFA1FuncGroups.AllowUserToResizeColumns = false; - glFA1FuncGroups.AllowUserToAddRows = false; - glFA1FuncGroups.AllowUserToResizeRows = false; - glFA1FuncGroups.MultiSelect = false; - glFA1FuncGroups.RowTemplate.Height = 20; - glFA1FuncGroups.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - glFA1FuncGroups.RowHeadersVisible = false; - glFA1FuncGroups.ScrollBars = ScrollBars.Vertical; - glFA1FuncGroups.DefaultCellStyle.Font = new Font("Arial", 8); - glFA1FuncGroups.RowHeadersWidthSizeMode = - DataGridViewRowHeadersWidthSizeMode.DisableResizing; - glFA1FuncGroups.EnableHeadersVisualStyles = false; - glFA1FuncGroups.ColumnHeadersHeight = 20; - glFA1FuncGroups.DataBindingComplete += functionalGroupComplete; - glFA1FuncGroups.CellValueChanged += functionalGroupCellValueChanged; - ContextMenu cm = new ContextMenu(); - cm.MenuItems.Add(new FMenuItem("Add functional group", new EventHandler(addFunctionalGroup), glFA1FuncGroups)); - cm.MenuItems.Add(new FMenuItem("Remove functional group", new EventHandler(removeFunctionalGroup), glFA1FuncGroups)); - glFA1FuncGroups.ContextMenu = cm; @@ -1942,20 +1926,20 @@ private void InitializeComponent() plStep1.Controls.Add(plFA2Textbox); plStep1.Controls.Add(plDB1Textbox); plStep1.Controls.Add(plDB2Textbox); - plStep1.Controls.Add(plHydroxyl1Textbox); - plStep1.Controls.Add(plHydroxyl2Textbox); plStep1.Controls.Add(plFA1Combobox); plStep1.Controls.Add(plFA2Combobox); plStep1.Controls.Add(plDB1Label); plStep1.Controls.Add(plDB2Label); - plStep1.Controls.Add(plHydroxyl1Label); - plStep1.Controls.Add(plHydroxyl2Label); plStep1.Controls.Add(plHgListbox); plStep1.Controls.Add(plHGLabel); plStep1.Controls.Add(plRepresentativeFA); plStep1.Controls.Add(plPositiveAdduct); plStep1.Controls.Add(plNegativeAdduct); plStep1.Controls.Add(easterText); + plStep1.Controls.Add(plFA1FuncGroups); + plStep1.Controls.Add(plFA2FuncGroups); + plStep1.Controls.Add(plFA3FuncGroups); + plStep1.Controls.Add(plFA4FuncGroups); phospholipidsTab.Parent = tabControl; phospholipidsTab.Text = " Glycero-\nphospholipids"; //phospholipidsTab.ToolTipText = "Glycerophospholipids"; @@ -1991,13 +1975,8 @@ private void InitializeComponent() plDB1Label.Location = new Point(plDB1Textbox.Left, plDB1Textbox.Top - sep); plDB1Label.Width = dbLength; plDB1Label.Text = dbText; - plHydroxyl1Textbox.Width = dbLength; - plHydroxyl1Textbox.Location = new Point(plDB1Textbox.Left + plDB1Textbox.Width + sep, plDB1Textbox.Top); - plHydroxyl1Textbox.TextChanged += delegate(object s, EventArgs e){ updateHydroxyl(s, new FattyAcidEventArgs( ((Phospholipid)currentLipid).fag1, FattyAcidType.Ester )); updatePLRepresentative(); }; - toolTip.SetToolTip(plHydroxyl1Textbox, formattingHydroxyl); - plHydroxyl1Label.Width = dbLength; - plHydroxyl1Label.Location = new Point(plHydroxyl1Textbox.Left, plHydroxyl1Textbox.Top - sep); - plHydroxyl1Label.Text = hydroxylText; + setupFGDataGridView(plFA1FuncGroups, plDB1Textbox.Left + sep + dbLength, plFA1Combobox.Top, 2); + toolTip.SetToolTip(plFA1FuncGroups, formattingHydroxyl); plFA1Checkbox3.Location = new Point(plFA1Textbox.Left + 90, plFA1Textbox.Top + plFA1Textbox.Height); plFA1Checkbox3.Text = "FA O"; @@ -2035,13 +2014,8 @@ private void InitializeComponent() plDB2Label.Location = new Point(plDB2Textbox.Left, plDB2Textbox.Top - sep); plDB2Label.Width = dbLength; plDB2Label.Text = dbText; - plHydroxyl2Textbox.Width = dbLength; - plHydroxyl2Textbox.Location = new Point(plDB2Textbox.Left + plDB2Textbox.Width + sep, plDB2Textbox.Top); - plHydroxyl2Textbox.TextChanged += delegate(object s, EventArgs e){ updateHydroxyl(s, new FattyAcidEventArgs( ((Phospholipid)currentLipid).fag2, FattyAcidType.Ester )); }; - toolTip.SetToolTip(plHydroxyl2Textbox, formattingHydroxyl); - plHydroxyl2Label.Width = dbLength; - plHydroxyl2Label.Location = new Point(plHydroxyl2Textbox.Left, plHydroxyl2Textbox.Top - sep); - plHydroxyl2Label.Text = hydroxylText; + setupFGDataGridView(plFA2FuncGroups, plDB2Textbox.Left + sep + dbLength, plFA2Combobox.Top, 2); + toolTip.SetToolTip(plFA2FuncGroups, formattingHydroxyl); plFA2Checkbox3.Location = new Point(plFA2Textbox.Left + 90, plFA2Textbox.Top + plFA2Textbox.Height); plFA2Checkbox3.Text = "FA O"; @@ -2153,7 +2127,7 @@ private void InitializeComponent() plPictureBox.SizeMode = PictureBoxSizeMode.AutoSize; plPictureBox.SendToBack(); - plRepresentativeFA.Location = new Point(plHydroxyl1Textbox.Left + plHydroxyl1Textbox.Width + sep, plHydroxyl1Textbox.Top); + plRepresentativeFA.Location = new Point(plFA1FuncGroups.Left + plFA1FuncGroups.Width + sep, plFA1FuncGroups.Top); plRepresentativeFA.Width = 150; plRepresentativeFA.Text = "First FA representative"; toolTip.SetToolTip(plRepresentativeFA, repFAText); @@ -2983,7 +2957,7 @@ private void InitializeComponent() this.SizeChanged += new EventHandler(windowSizeChanged); this.FormClosing += new FormClosingEventHandler(windowOnClosing); - controlElements = new ArrayList(){menuFile, menuOptions, menuHelp, addLipidButton, modifyLipidButton, MS2fragmentsLipidButton, addHeavyIsotopeButton, filtersButton, plFA1Checkbox3, plFA1Checkbox2, plFA1Checkbox1, plFA2Checkbox1, plPosAdductCheckbox2, plPosAdductCheckbox3, plIsCL, plRegular, plIsLyso, plFA1Textbox, plFA2Textbox, plDB1Textbox, plDB2Textbox, plHydroxyl1Textbox, plHydroxyl2Textbox, plFA1Combobox, plFA2Combobox, plHgListbox, plHGLabel, plRepresentativeFA, plPositiveAdduct, plNegativeAdduct, openReviewFormButton, startFirstTutorialButton, startSecondTutorialButton, startThirdTutorialButton, startFourthTutorialButton, lipidsGridview, menuTranslate, menuWizard, menuCollisionEnergy, menuCollisionEnergyOpt, menuMS2Fragments, menuIsotopes, menuClearLipidList, menuResetCategory, menuResetLipidCreator, menuStatistics, glFA1Checkbox3, glFA1Checkbox2, glFA1Checkbox1, glFA2Checkbox3, glFA2Checkbox2, glFA2Checkbox1, glFA3Checkbox3, glFA3Checkbox2, glFA3Checkbox1, glPictureBox, glArrow, glFA1Textbox, glFA2Textbox, glFA3Textbox, glDB1Textbox, glDB2Textbox, glDB3Textbox, glHydroxyl1Textbox, glHydroxyl2Textbox, glHydroxyl3Textbox, glFA1Combobox, glFA2Combobox, glFA3Combobox, glHgListbox, glHGLabel, glContainsSugar, glRepresentativeFA, glPositiveAdduct, glNegativeAdduct, plHasPlasmalogen}; + controlElements = new ArrayList(){menuFile, menuOptions, menuHelp, addLipidButton, modifyLipidButton, MS2fragmentsLipidButton, addHeavyIsotopeButton, filtersButton, plFA1Checkbox3, plFA1Checkbox2, plFA1Checkbox1, plFA2Checkbox1, plPosAdductCheckbox2, plPosAdductCheckbox3, plIsCL, plRegular, plIsLyso, plFA1Textbox, plFA2Textbox, plDB1Textbox, plDB2Textbox, plFA1Combobox, plFA2Combobox, plHgListbox, plHGLabel, plRepresentativeFA, plPositiveAdduct, plNegativeAdduct, openReviewFormButton, startFirstTutorialButton, startSecondTutorialButton, startThirdTutorialButton, startFourthTutorialButton, lipidsGridview, menuTranslate, menuWizard, menuCollisionEnergy, menuCollisionEnergyOpt, menuMS2Fragments, menuIsotopes, menuClearLipidList, menuResetCategory, menuResetLipidCreator, menuStatistics, glFA1Checkbox3, glFA1Checkbox2, glFA1Checkbox1, glFA2Checkbox3, glFA2Checkbox2, glFA2Checkbox1, glFA3Checkbox3, glFA3Checkbox2, glFA3Checkbox1, glPictureBox, glArrow, glFA1Textbox, glFA2Textbox, glFA3Textbox, glDB1Textbox, glDB2Textbox, glDB3Textbox, glFA1FuncGroups, glFA2FuncGroups, glFA3FuncGroups, glFA1Combobox, glFA2Combobox, glFA3Combobox, glHgListbox, glHGLabel, glContainsSugar, glRepresentativeFA, glPositiveAdduct, glNegativeAdduct, plHasPlasmalogen, plFA1FuncGroups, plFA2FuncGroups, plFA3FuncGroups, plFA4FuncGroups}; if (!lipidCreatorInitError) diff --git a/LipidCreator/CreatorGUI.cs b/LipidCreator/CreatorGUI.cs index a2bf5a7..c4a4312 100644 --- a/LipidCreator/CreatorGUI.cs +++ b/LipidCreator/CreatorGUI.cs @@ -81,7 +81,6 @@ public partial class CreatorGUI : Form private static readonly ILog log = LogManager.GetLogger(typeof(CreatorGUI)); public bool changingTabForced; public ArrayList lipidTabList; - public int currentTabIndex = 1; public LipidCreator lipidCreator; [NonSerialized] public AboutDialog aboutDialog; @@ -692,8 +691,8 @@ private void functionalGroupComplete(object sender, DataGridViewBindingCompleteE { if (!(sender is DataGridView)) return; DataGridView view = (DataGridView)sender; - view.Columns[0].Width = (int)Math.Floor(view.Size.Width * 0.45); - view.Columns[1].Width = (int)Math.Floor(view.Size.Width * 0.55); + view.Columns[0].Width = (int)Math.Floor(view.Size.Width * 0.6); + view.Columns[1].Width = (int)Math.Floor(view.Size.Width * 0.4); } @@ -709,6 +708,43 @@ public void addFunctionalGroup(Object sender, EventArgs e) + + public void gmh_TheMouseMoved() + { + Point cur_pos = Cursor.Position; + List hoveredViews = new List(); + bool expandedInList = false; + foreach (DataGridView view in functionalGroupGridViews[(int)currentIndex]) + { + Point view_pos = view.PointToScreen(Point.Empty); + if (view_pos.X <= cur_pos.X && cur_pos.X <= view_pos.X + view.Width && view_pos.Y <= cur_pos.Y && cur_pos.Y <= view_pos.Y + view.Height) + { + hoveredViews.Add(view); + if (expandedView == view) expandedInList = true; + } + } + if (expandedInList) + { + return; + } + + if (expandedView != null) + { + expandedView.Height = 40; + expandedView = null; + } + if (hoveredViews.Count > 0) + { + expandedView = hoveredViews[0]; + expandedView.Height = 100; + expandedView.BringToFront(); + expandedView.Update(); + } + } + + + + public void removeFunctionalGroup(Object sender, EventArgs e) { @@ -1117,7 +1153,6 @@ public void changeTabElements(int index) glFA1Textbox.Text = currentGlycerolipid.fag1.lengthInfo; glDB1Textbox.Text = currentGlycerolipid.fag1.dbInfo; - glHydroxyl1Textbox.Text = currentGlycerolipid.fag1.hydroxylInfo; glFA1Combobox.SelectedIndex = currentGlycerolipid.fag1.chainType; glFA1Checkbox1.Checked = currentGlycerolipid.fag1.faTypes[FattyAcidType.Ester]; glFA1Checkbox2.Checked = currentGlycerolipid.fag1.faTypes[FattyAcidType.Plasmenyl]; @@ -1126,19 +1161,19 @@ public void changeTabElements(int index) glFA2Textbox.Text = currentGlycerolipid.fag2.lengthInfo; glDB2Textbox.Text = currentGlycerolipid.fag2.dbInfo; - glHydroxyl2Textbox.Text = currentGlycerolipid.fag2.hydroxylInfo; glFA2Combobox.SelectedIndex = currentGlycerolipid.fag2.chainType; glFA2Checkbox1.Checked = currentGlycerolipid.fag2.faTypes[FattyAcidType.Ester]; glFA2Checkbox2.Checked = currentGlycerolipid.fag2.faTypes[FattyAcidType.Plasmenyl]; glFA2Checkbox3.Checked = currentGlycerolipid.fag2.faTypes[FattyAcidType.Plasmanyl]; + glFA2FuncGroups.DataSource = currentGlycerolipid.fag2.functionalGroups; glFA3Textbox.Text = currentGlycerolipid.fag3.lengthInfo; glDB3Textbox.Text = currentGlycerolipid.fag3.dbInfo; - glHydroxyl3Textbox.Text = currentGlycerolipid.fag3.hydroxylInfo; glFA3Combobox.SelectedIndex = currentGlycerolipid.fag3.chainType; glFA3Checkbox1.Checked = currentGlycerolipid.fag3.faTypes[FattyAcidType.Ester]; glFA3Checkbox2.Checked = currentGlycerolipid.fag3.faTypes[FattyAcidType.Plasmenyl]; glFA3Checkbox3.Checked = currentGlycerolipid.fag3.faTypes[FattyAcidType.Plasmanyl]; + glFA3FuncGroups.DataSource = currentGlycerolipid.fag3.functionalGroups; glPosAdductCheckbox1.Checked = currentGlycerolipid.adducts["+H"]; glPosAdductCheckbox2.Checked = currentGlycerolipid.adducts["+2H"]; @@ -1154,14 +1189,13 @@ public void changeTabElements(int index) updateRanges(currentGlycerolipid.fag1, glFA1Textbox, glFA1Combobox.SelectedIndex); updateRanges(currentGlycerolipid.fag1, glDB1Textbox, 3); - updateRanges(currentGlycerolipid.fag1, glHydroxyl1Textbox, 4); updateFunctionalGroupGridView(currentGlycerolipid.fag1, glFA1FuncGroups); updateRanges(currentGlycerolipid.fag2, glFA2Textbox, glFA2Combobox.SelectedIndex); updateRanges(currentGlycerolipid.fag2, glDB2Textbox, 3); - updateRanges(currentGlycerolipid.fag2, glHydroxyl2Textbox, 4); + updateFunctionalGroupGridView(currentGlycerolipid.fag2, glFA2FuncGroups); updateRanges(currentGlycerolipid.fag3, glFA3Textbox, glFA3Combobox.SelectedIndex); updateRanges(currentGlycerolipid.fag3, glDB3Textbox, 3); - updateRanges(currentGlycerolipid.fag3, glHydroxyl3Textbox, 4); + updateFunctionalGroupGridView(currentGlycerolipid.fag3, glFA3FuncGroups); glRepresentativeFA.Checked = currentGlycerolipid.representativeFA; glPictureBox.SendToBack(); @@ -1178,9 +1212,8 @@ public void changeTabElements(int index) plFA2Combobox.Visible = true; plFA2Textbox.Visible = true; plDB2Textbox.Visible = true; - plHydroxyl2Textbox.Visible = true; + plFA2FuncGroups.Visible = true; plDB2Label.Visible = true; - plHydroxyl2Label.Visible = true; @@ -1199,10 +1232,8 @@ public void changeTabElements(int index) clFA4Textbox.Visible = true; clDB3Textbox.Visible = true; clDB4Textbox.Visible = true; - clHydroxyl3Textbox.Visible = true; - clHydroxyl4Textbox.Visible = true; - clHydroxyl3Label.Visible = true; - clHydroxyl4Label.Visible = true; + plFA3FuncGroups.Visible = true; + plFA4FuncGroups.Visible = true; clFA3Combobox.Visible = true; clFA4Combobox.Visible = true; clDB3Label.Visible = true; @@ -1214,7 +1245,7 @@ public void changeTabElements(int index) plFA1Textbox.Text = currentPhospholipid.fag1.lengthInfo; plDB1Textbox.Text = currentPhospholipid.fag1.dbInfo; - plHydroxyl1Textbox.Text = currentPhospholipid.fag1.hydroxylInfo; + plFA1FuncGroups.DataSource = currentPhospholipid.fag1.functionalGroups; plFA1Combobox.SelectedIndex = currentPhospholipid.fag1.chainType; plFA1Checkbox1.Checked = currentPhospholipid.fag1.faTypes[FattyAcidType.Ester]; plFA1Checkbox2.Checked = currentPhospholipid.fag1.faTypes[FattyAcidType.Plasmenyl]; @@ -1222,7 +1253,7 @@ public void changeTabElements(int index) plFA2Textbox.Text = currentPhospholipid.fag2.lengthInfo; plDB2Textbox.Text = currentPhospholipid.fag2.dbInfo; - plHydroxyl2Textbox.Text = currentPhospholipid.fag2.hydroxylInfo; + plFA2FuncGroups.DataSource = currentPhospholipid.fag2.functionalGroups; plFA2Combobox.SelectedIndex = currentPhospholipid.fag2.chainType; plFA2Checkbox1.Checked = currentPhospholipid.fag2.faTypes[FattyAcidType.Ester]; plFA2Checkbox2.Checked = currentPhospholipid.fag2.faTypes[FattyAcidType.Plasmenyl]; @@ -1230,7 +1261,7 @@ public void changeTabElements(int index) clFA3Textbox.Text = currentPhospholipid.fag3.lengthInfo; clDB3Textbox.Text = currentPhospholipid.fag3.dbInfo; - clHydroxyl3Textbox.Text = currentPhospholipid.fag3.hydroxylInfo; + plFA3FuncGroups.DataSource = currentPhospholipid.fag3.functionalGroups; clFA3Combobox.SelectedIndex = currentPhospholipid.fag3.chainType; clFA3Checkbox1.Checked = currentPhospholipid.fag3.faTypes[FattyAcidType.Ester]; clFA3Checkbox2.Checked = currentPhospholipid.fag3.faTypes[FattyAcidType.Plasmenyl]; @@ -1238,7 +1269,7 @@ public void changeTabElements(int index) clFA4Textbox.Text = currentPhospholipid.fag4.lengthInfo; clDB4Textbox.Text = currentPhospholipid.fag4.dbInfo; - clHydroxyl4Textbox.Text = currentPhospholipid.fag4.hydroxylInfo; + plFA4FuncGroups.DataSource = currentPhospholipid.fag4.functionalGroups; clFA4Combobox.SelectedIndex = currentPhospholipid.fag4.chainType; clFA4Checkbox1.Checked = currentPhospholipid.fag4.faTypes[FattyAcidType.Ester]; clFA4Checkbox2.Checked = currentPhospholipid.fag4.faTypes[FattyAcidType.Plasmenyl]; @@ -1259,16 +1290,16 @@ public void changeTabElements(int index) updateRanges(currentPhospholipid.fag1, plFA1Textbox, plFA1Combobox.SelectedIndex); updateRanges(currentPhospholipid.fag1, plDB1Textbox, 3); - updateRanges(currentPhospholipid.fag1, plHydroxyl1Textbox, 4); + updateFunctionalGroupGridView(currentPhospholipid.fag1, plFA1FuncGroups); updateRanges(currentPhospholipid.fag2, plFA2Textbox, plFA2Combobox.SelectedIndex); updateRanges(currentPhospholipid.fag2, plDB2Textbox, 3); - updateRanges(currentPhospholipid.fag2, plHydroxyl2Textbox, 4); + updateFunctionalGroupGridView(currentPhospholipid.fag2, plFA2FuncGroups); updateRanges(currentPhospholipid.fag3, clFA3Textbox, clFA3Combobox.SelectedIndex); updateRanges(currentPhospholipid.fag3, clDB3Textbox, 3); - updateRanges(currentPhospholipid.fag3, clHydroxyl3Textbox, 4); + updateFunctionalGroupGridView(currentPhospholipid.fag3, plFA3FuncGroups); updateRanges(currentPhospholipid.fag4, clFA4Textbox, clFA4Combobox.SelectedIndex); updateRanges(currentPhospholipid.fag4, clDB4Textbox, 3); - updateRanges(currentPhospholipid.fag4, clHydroxyl4Textbox, 4); + updateFunctionalGroupGridView(currentPhospholipid.fag4, plFA4FuncGroups); plRepresentativeFA.Checked = currentPhospholipid.representativeFA; plPictureBox.Image = cardioBackboneImage; @@ -1288,10 +1319,8 @@ public void changeTabElements(int index) clFA4Textbox.Visible = false; clDB3Textbox.Visible = false; clDB4Textbox.Visible = false; - clHydroxyl3Textbox.Visible = false; - clHydroxyl4Textbox.Visible = false; - clHydroxyl3Label.Visible = false; - clHydroxyl4Label.Visible = false; + plFA3FuncGroups.Visible = false; + plFA4FuncGroups.Visible = false; clFA3Combobox.Visible = false; clFA4Combobox.Visible = false; clDB3Label.Visible = false; @@ -1331,7 +1360,7 @@ public void changeTabElements(int index) plFA1Textbox.Text = currentPhospholipid.fag1.lengthInfo; plDB1Textbox.Text = currentPhospholipid.fag1.dbInfo; - plHydroxyl1Textbox.Text = currentPhospholipid.fag1.hydroxylInfo; + plFA1FuncGroups.DataSource = currentPhospholipid.fag1.functionalGroups; plFA1Combobox.SelectedIndex = currentPhospholipid.fag1.chainType; plFA1Checkbox1.Checked = currentPhospholipid.fag1.faTypes[FattyAcidType.Ester]; plFA1Checkbox2.Checked = currentPhospholipid.fag1.faTypes[FattyAcidType.Plasmenyl]; @@ -1339,7 +1368,7 @@ public void changeTabElements(int index) plFA2Textbox.Text = currentPhospholipid.fag2.lengthInfo; plDB2Textbox.Text = currentPhospholipid.fag2.dbInfo; - plHydroxyl2Textbox.Text = currentPhospholipid.fag2.hydroxylInfo; + plFA2FuncGroups.DataSource = currentPhospholipid.fag2.functionalGroups; plFA2Combobox.SelectedIndex = currentPhospholipid.fag2.chainType; plFA2Checkbox1.Checked = currentPhospholipid.fag2.faTypes[FattyAcidType.Ester]; plFA2Checkbox2.Checked = currentPhospholipid.fag2.faTypes[FattyAcidType.Plasmenyl]; @@ -1359,12 +1388,12 @@ public void changeTabElements(int index) updateRanges(currentPhospholipid.fag1, plFA1Textbox, plFA1Combobox.SelectedIndex); updateRanges(currentPhospholipid.fag1, plDB1Textbox, 3); - updateRanges(currentPhospholipid.fag1, plHydroxyl1Textbox, 4); + updateFunctionalGroupGridView(currentPhospholipid.fag1, plFA1FuncGroups); if (!currentPhospholipid.isLyso) { updateRanges(currentPhospholipid.fag2, plFA2Textbox, plFA2Combobox.SelectedIndex); updateRanges(currentPhospholipid.fag2, plDB2Textbox, 3); - updateRanges(currentPhospholipid.fag2, plHydroxyl2Textbox, 4); + updateFunctionalGroupGridView(currentPhospholipid.fag2, plFA2FuncGroups); } plRepresentativeFA.Checked = currentPhospholipid.representativeFA; plHasPlasmalogen.Checked = currentPhospholipid.hasPlasmalogen; @@ -1640,6 +1669,11 @@ private void updateFunctionalGroupGridView(FattyAcidGroup fag, DataGridView view + + + + + public void updateCarbon(Object sender, FattyAcidEventArgs e) { e.fag.lengthInfo = ((TextBox)sender).Text; @@ -1710,8 +1744,27 @@ public void updateGLRepresentative() glFA3Textbox.Text = glFA1Textbox.Text; glDB2Textbox.Text = glDB1Textbox.Text; glDB3Textbox.Text = glDB1Textbox.Text; - glHydroxyl2Textbox.Text = glHydroxyl1Textbox.Text; - glHydroxyl3Textbox.Text = glHydroxyl1Textbox.Text; + + DataTable gl1Table = (DataTable)glFA1FuncGroups.DataSource; + DataTable gl2Table = (DataTable)glFA2FuncGroups.DataSource; + DataTable gl3Table = (DataTable)glFA3FuncGroups.DataSource; + + gl2Table.Clear(); + gl3Table.Clear(); + + foreach (DataRow dr in gl1Table.Rows) + { + DataRow gl2dr = gl2Table.NewRow(); + gl2dr[0] = dr[0]; + gl2dr[1] = dr[1]; + gl2Table.Rows.Add(gl2dr); + + DataRow gl3dr = gl3Table.NewRow(); + gl3dr[0] = dr[0]; + gl3dr[1] = dr[1]; + gl3Table.Rows.Add(gl3dr); + } + glFA2Checkbox1.Checked = glFA1Checkbox1.Checked; glFA2Checkbox2.Checked = glFA1Checkbox2.Checked; glFA2Checkbox3.Checked = glFA1Checkbox3.Checked; @@ -1737,9 +1790,6 @@ public void updatePLRepresentative() plDB2Textbox.Text = plDB1Textbox.Text; clDB3Textbox.Text = plDB1Textbox.Text; clDB4Textbox.Text = plDB1Textbox.Text; - plHydroxyl2Textbox.Text = plHydroxyl1Textbox.Text; - clHydroxyl3Textbox.Text = plHydroxyl1Textbox.Text; - clHydroxyl4Textbox.Text = plHydroxyl1Textbox.Text; plFA2Checkbox1.Checked = plFA1Checkbox1.Checked; plFA2Checkbox2.Checked = plFA1Checkbox2.Checked; plFA2Checkbox3.Checked = plFA1Checkbox3.Checked; @@ -1749,6 +1799,35 @@ public void updatePLRepresentative() clFA4Checkbox1.Checked = plFA1Checkbox1.Checked; clFA4Checkbox2.Checked = plFA1Checkbox2.Checked; clFA4Checkbox3.Checked = plFA1Checkbox3.Checked; + + + + DataTable pl1Table = (DataTable)plFA1FuncGroups.DataSource; + DataTable pl2Table = (DataTable)plFA2FuncGroups.DataSource; + DataTable pl3Table = (DataTable)plFA3FuncGroups.DataSource; + DataTable pl4Table = (DataTable)plFA4FuncGroups.DataSource; + + pl2Table.Clear(); + pl3Table.Clear(); + pl4Table.Clear(); + + foreach (DataRow dr in pl1Table.Rows) + { + DataRow pl2dr = pl2Table.NewRow(); + pl2dr[0] = dr[0]; + pl2dr[1] = dr[1]; + pl2Table.Rows.Add(pl2dr); + + DataRow pl3dr = pl3Table.NewRow(); + pl3dr[0] = dr[0]; + pl3dr[1] = dr[1]; + pl3Table.Rows.Add(pl3dr); + + DataRow pl4dr = pl4Table.NewRow(); + pl4dr[0] = dr[0]; + pl4dr[1] = dr[1]; + pl4Table.Rows.Add(pl4dr); + } } } @@ -1756,26 +1835,27 @@ public void updatePLRepresentative() public void clRepresentativeFACheckedChanged(Object sender, EventArgs e) { - ((Phospholipid)currentLipid).representativeFA = ((CheckBox)sender).Checked; - if (((Phospholipid)currentLipid).representativeFA) + Phospholipid currentPhospholipid = (Phospholipid)currentLipid; + currentPhospholipid.representativeFA = ((CheckBox)sender).Checked; + if (currentPhospholipid.representativeFA) { plFA2Textbox.Enabled = false; plDB2Textbox.Enabled = false; - plHydroxyl2Textbox.Enabled = false; + plFA2FuncGroups.Enabled = false; plFA2Combobox.Enabled = false; plFA2Checkbox1.Enabled = false; plFA2Checkbox2.Enabled = false; plFA2Checkbox3.Enabled = false; clFA3Textbox.Enabled = false; clDB3Textbox.Enabled = false; - clHydroxyl3Textbox.Enabled = false; + plFA3FuncGroups.Enabled = false; clFA3Combobox.Enabled = false; clFA3Checkbox1.Enabled = false; clFA3Checkbox2.Enabled = false; clFA3Checkbox3.Enabled = false; clFA4Textbox.Enabled = false; clDB4Textbox.Enabled = false; - clHydroxyl4Textbox.Enabled = false; + plFA4FuncGroups.Enabled = false; clFA4Combobox.Enabled = false; clFA4Checkbox1.Enabled = false; clFA4Checkbox2.Enabled = false; @@ -1787,9 +1867,34 @@ public void clRepresentativeFACheckedChanged(Object sender, EventArgs e) plDB2Textbox.Text = plDB1Textbox.Text; clDB3Textbox.Text = plDB1Textbox.Text; clDB4Textbox.Text = plDB1Textbox.Text; - plHydroxyl2Textbox.Text = plHydroxyl1Textbox.Text; - clHydroxyl3Textbox.Text = plHydroxyl1Textbox.Text; - clHydroxyl4Textbox.Text = plHydroxyl1Textbox.Text; + + DataTable pl1Table = (DataTable)plFA1FuncGroups.DataSource; + DataTable pl2Table = (DataTable)plFA2FuncGroups.DataSource; + DataTable pl3Table = (DataTable)plFA3FuncGroups.DataSource; + DataTable pl4Table = (DataTable)plFA4FuncGroups.DataSource; + + pl2Table.Clear(); + pl3Table.Clear(); + pl4Table.Clear(); + + foreach (DataRow dr in pl1Table.Rows) + { + DataRow pl2dr = pl2Table.NewRow(); + pl2dr[0] = dr[0]; + pl2dr[1] = dr[1]; + pl2Table.Rows.Add(pl2dr); + + DataRow pl3dr = pl3Table.NewRow(); + pl3dr[0] = dr[0]; + pl3dr[1] = dr[1]; + pl3Table.Rows.Add(pl3dr); + + DataRow pl4dr = pl4Table.NewRow(); + pl4dr[0] = dr[0]; + pl4dr[1] = dr[1]; + pl4Table.Rows.Add(pl4dr); + } + plFA2Combobox.Text = plFA1Combobox.Text; clFA3Combobox.Text = plFA1Combobox.Text; clFA4Combobox.Text = plFA1Combobox.Text; @@ -1807,35 +1912,36 @@ public void clRepresentativeFACheckedChanged(Object sender, EventArgs e) { plFA2Textbox.Enabled = true; plDB2Textbox.Enabled = true; - plHydroxyl2Textbox.Enabled = true; + plFA2FuncGroups.Enabled = true; plFA2Combobox.Enabled = true; plFA2Checkbox1.Enabled = true; plFA2Checkbox2.Enabled = true; plFA2Checkbox3.Enabled = true; clFA3Textbox.Enabled = true; clDB3Textbox.Enabled = true; - clHydroxyl3Textbox.Enabled = true; + plFA3FuncGroups.Enabled = true; clFA3Combobox.Enabled = true; clFA3Checkbox1.Enabled = true; clFA3Checkbox2.Enabled = true; clFA3Checkbox3.Enabled = true; clFA4Textbox.Enabled = true; clDB4Textbox.Enabled = true; - clHydroxyl4Textbox.Enabled = true; + plFA4FuncGroups.Enabled = true; clFA4Combobox.Enabled = true; clFA4Checkbox1.Enabled = true; clFA4Checkbox2.Enabled = true; clFA4Checkbox3.Enabled = true; } - updateRanges(((Phospholipid)currentLipid).fag2, plFA2Textbox, plFA2Combobox.SelectedIndex); - updateRanges(((Phospholipid)currentLipid).fag3, clFA3Textbox, clFA3Combobox.SelectedIndex); - updateRanges(((Phospholipid)currentLipid).fag4, clFA4Textbox, clFA4Combobox.SelectedIndex); - updateRanges(((Phospholipid)currentLipid).fag2, plDB2Textbox, 3); - updateRanges(((Phospholipid)currentLipid).fag3, clDB3Textbox, 3); - updateRanges(((Phospholipid)currentLipid).fag4, clDB4Textbox, 3); - updateRanges(((Phospholipid)currentLipid).fag2, plHydroxyl2Textbox, 4); - updateRanges(((Phospholipid)currentLipid).fag3, clHydroxyl3Textbox, 4); - updateRanges(((Phospholipid)currentLipid).fag4, clHydroxyl4Textbox, 4); + updateRanges(currentPhospholipid.fag2, plFA2Textbox, plFA2Combobox.SelectedIndex); + updateRanges(currentPhospholipid.fag3, clFA3Textbox, clFA3Combobox.SelectedIndex); + updateRanges(currentPhospholipid.fag4, clFA4Textbox, clFA4Combobox.SelectedIndex); + updateRanges(currentPhospholipid.fag2, plDB2Textbox, 3); + updateRanges(currentPhospholipid.fag3, clDB3Textbox, 3); + updateRanges(currentPhospholipid.fag4, clDB4Textbox, 3); + + updateFunctionalGroupGridView(currentPhospholipid.fag2, plFA2FuncGroups); + updateFunctionalGroupGridView(currentPhospholipid.fag3, plFA3FuncGroups); + updateFunctionalGroupGridView(currentPhospholipid.fag4, plFA4FuncGroups); } @@ -1895,13 +2001,12 @@ public void glContainsSugarCheckedChanged(Object sender, EventArgs e) { glFA3Textbox.Visible = false; glDB3Textbox.Visible = false; - glHydroxyl3Textbox.Visible = false; + glFA3FuncGroups.Visible = false; glFA3Combobox.Visible = false; glFA3Checkbox1.Visible = false; glFA3Checkbox2.Visible = false; glFA3Checkbox3.Visible = false; glDB3Label.Visible = false; - glHydroxyl3Label.Visible = false; glHgListbox.Visible = true; @@ -1917,13 +2022,12 @@ public void glContainsSugarCheckedChanged(Object sender, EventArgs e) { glFA3Textbox.Visible = true; glDB3Textbox.Visible = true; - glHydroxyl3Textbox.Visible = true; + glFA3FuncGroups.Visible = true; glFA3Combobox.Visible = true; glFA3Checkbox1.Visible = true; glFA3Checkbox2.Visible = true; glFA3Checkbox3.Visible = true; glDB3Label.Visible = true; - glHydroxyl3Label.Visible = true; glHgListbox.Visible = false; glHGLabel.Visible = false; @@ -1947,19 +2051,21 @@ public void glContainsSugarCheckedChanged(Object sender, EventArgs e) public void glRepresentativeFACheckedChanged(Object sender, EventArgs e) { - ((Glycerolipid)currentLipid).representativeFA = ((CheckBox)sender).Checked; - if (((Glycerolipid)currentLipid).representativeFA) + Glycerolipid currentGlycerolipid = ((Glycerolipid)currentLipid); + + currentGlycerolipid.representativeFA = ((CheckBox)sender).Checked; + if (currentGlycerolipid.representativeFA) { glFA2Textbox.Enabled = false; glDB2Textbox.Enabled = false; - glHydroxyl2Textbox.Enabled = false; + glFA2FuncGroups.Enabled = false; glFA2Combobox.Enabled = false; glFA2Checkbox1.Enabled = false; glFA2Checkbox2.Enabled = false; glFA2Checkbox3.Enabled = false; glFA3Textbox.Enabled = false; glDB3Textbox.Enabled = false; - glHydroxyl3Textbox.Enabled = false; + glFA3FuncGroups.Enabled = false; glFA3Combobox.Enabled = false; glFA3Checkbox1.Enabled = false; glFA3Checkbox2.Enabled = false; @@ -1969,16 +2075,38 @@ public void glRepresentativeFACheckedChanged(Object sender, EventArgs e) glFA3Textbox.Text = glFA1Textbox.Text; glDB2Textbox.Text = glDB1Textbox.Text; glDB3Textbox.Text = glDB1Textbox.Text; - glHydroxyl2Textbox.Text = glHydroxyl1Textbox.Text; - glHydroxyl3Textbox.Text = glHydroxyl1Textbox.Text; + + + DataTable gl1Table = (DataTable)glFA1FuncGroups.DataSource; + DataTable gl2Table = (DataTable)glFA2FuncGroups.DataSource; + DataTable gl3Table = (DataTable)glFA3FuncGroups.DataSource; + + gl2Table.Clear(); + gl3Table.Clear(); + + foreach (DataRow dr in gl1Table.Rows) + { + DataRow gl2dr = gl2Table.NewRow(); + gl2dr[0] = dr[0]; + gl2dr[1] = dr[1]; + gl2Table.Rows.Add(gl2dr); + + DataRow gl3dr = gl3Table.NewRow(); + gl3dr[0] = dr[0]; + gl3dr[1] = dr[1]; + gl3Table.Rows.Add(gl3dr); + } + + + glFA2Combobox.Text = glFA1Combobox.Text; glFA3Combobox.Text = glFA1Combobox.Text; - if (((Glycerolipid)currentLipid).fag2.anyFAChecked()) glFA2Checkbox1.Checked = glFA1Checkbox1.Checked; - if (((Glycerolipid)currentLipid).fag3.anyFAChecked()) glFA3Checkbox1.Checked = glFA1Checkbox1.Checked; - if (((Glycerolipid)currentLipid).fag2.anyFAChecked()) glFA2Checkbox2.Checked = glFA1Checkbox2.Checked; - if (((Glycerolipid)currentLipid).fag3.anyFAChecked()) glFA3Checkbox2.Checked = glFA1Checkbox2.Checked; - if (((Glycerolipid)currentLipid).fag2.anyFAChecked()) glFA2Checkbox3.Checked = glFA1Checkbox3.Checked; - if (((Glycerolipid)currentLipid).fag3.anyFAChecked()) glFA3Checkbox3.Checked = glFA1Checkbox3.Checked; + if (currentGlycerolipid.fag2.anyFAChecked()) glFA2Checkbox1.Checked = glFA1Checkbox1.Checked; + if (currentGlycerolipid.fag3.anyFAChecked()) glFA3Checkbox1.Checked = glFA1Checkbox1.Checked; + if (currentGlycerolipid.fag2.anyFAChecked()) glFA2Checkbox2.Checked = glFA1Checkbox2.Checked; + if (currentGlycerolipid.fag3.anyFAChecked()) glFA3Checkbox2.Checked = glFA1Checkbox2.Checked; + if (currentGlycerolipid.fag2.anyFAChecked()) glFA2Checkbox3.Checked = glFA1Checkbox3.Checked; + if (currentGlycerolipid.fag3.anyFAChecked()) glFA3Checkbox3.Checked = glFA1Checkbox3.Checked; } @@ -1986,25 +2114,25 @@ public void glRepresentativeFACheckedChanged(Object sender, EventArgs e) { glFA2Textbox.Enabled = true; glDB2Textbox.Enabled = true; - glHydroxyl2Textbox.Enabled = true; + glFA2FuncGroups.Enabled = true; glFA2Combobox.Enabled = true; glFA2Checkbox1.Enabled = true; glFA2Checkbox2.Enabled = true; glFA2Checkbox3.Enabled = true; glFA3Textbox.Enabled = true; glDB3Textbox.Enabled = true; - glHydroxyl3Textbox.Enabled = true; + glFA3FuncGroups.Enabled = true; glFA3Combobox.Enabled = true; glFA3Checkbox1.Enabled = true; glFA3Checkbox2.Enabled = true; glFA3Checkbox3.Enabled = true; } - updateRanges(((Glycerolipid)currentLipid).fag2, glFA2Textbox, glFA2Combobox.SelectedIndex); - updateRanges(((Glycerolipid)currentLipid).fag3, glFA3Textbox, glFA3Combobox.SelectedIndex); - updateRanges(((Glycerolipid)currentLipid).fag2, glDB2Textbox, 3); - updateRanges(((Glycerolipid)currentLipid).fag3, glDB3Textbox, 3); - updateRanges(((Glycerolipid)currentLipid).fag2, glHydroxyl2Textbox, 4); - updateRanges(((Glycerolipid)currentLipid).fag3, glHydroxyl3Textbox, 4); + updateRanges(currentGlycerolipid.fag2, glFA2Textbox, glFA2Combobox.SelectedIndex); + updateRanges(currentGlycerolipid.fag3, glFA3Textbox, glFA3Combobox.SelectedIndex); + updateRanges(currentGlycerolipid.fag2, glDB2Textbox, 3); + updateRanges(currentGlycerolipid.fag3, glDB3Textbox, 3); + updateFunctionalGroupGridView(currentGlycerolipid.fag2, glFA2FuncGroups); + updateFunctionalGroupGridView(currentGlycerolipid.fag3, glFA3FuncGroups); } @@ -2102,21 +2230,48 @@ private void ListboxSelectAll(object sender, KeyEventArgs e) public void plRepresentativeFACheckedChanged(Object sender, EventArgs e) { - ((Phospholipid)currentLipid).representativeFA = ((CheckBox)sender).Checked; - if (((Phospholipid)currentLipid).representativeFA) + Phospholipid currentPhospholipid = (Phospholipid)currentLipid; + currentPhospholipid.representativeFA = ((CheckBox)sender).Checked; + if (currentPhospholipid.representativeFA) { plFA2Textbox.Enabled = false; plDB2Textbox.Enabled = false; - plHydroxyl2Textbox.Enabled = false; + plFA4FuncGroups.Enabled = false; plFA2Combobox.Enabled = false; plFA2Checkbox1.Enabled = false; plFA2Textbox.Text = plFA1Textbox.Text; plDB2Textbox.Text = plDB1Textbox.Text; - plHydroxyl2Textbox.Text = plHydroxyl1Textbox.Text; plFA2Combobox.Text = plFA1Combobox.Text; plFA2Checkbox1.Checked = plFA1Checkbox1.Checked; + DataTable pl1Table = (DataTable)plFA1FuncGroups.DataSource; + DataTable pl2Table = (DataTable)plFA2FuncGroups.DataSource; + DataTable pl3Table = (DataTable)plFA3FuncGroups.DataSource; + DataTable pl4Table = (DataTable)plFA4FuncGroups.DataSource; + + pl2Table.Clear(); + pl3Table.Clear(); + pl4Table.Clear(); + + foreach (DataRow dr in pl1Table.Rows) + { + DataRow pl2dr = pl2Table.NewRow(); + pl2dr[0] = dr[0]; + pl2dr[1] = dr[1]; + pl2Table.Rows.Add(pl2dr); + + DataRow pl3dr = pl3Table.NewRow(); + pl3dr[0] = dr[0]; + pl3dr[1] = dr[1]; + pl3Table.Rows.Add(pl3dr); + + DataRow pl4dr = pl4Table.NewRow(); + pl4dr[0] = dr[0]; + pl4dr[1] = dr[1]; + pl4Table.Rows.Add(pl4dr); + } + if (plIsCL.Checked) { plFA2Checkbox2.Enabled = false; @@ -2126,7 +2281,7 @@ public void plRepresentativeFACheckedChanged(Object sender, EventArgs e) clFA3Textbox.Enabled = false; clDB3Textbox.Enabled = false; - clHydroxyl3Textbox.Enabled = false; + plFA4FuncGroups.Enabled = false; clFA3Combobox.Enabled = false; clFA3Checkbox1.Enabled = false; clFA3Checkbox2.Enabled = false; @@ -2134,7 +2289,6 @@ public void plRepresentativeFACheckedChanged(Object sender, EventArgs e) clFA3Textbox.Text = plFA1Textbox.Text; clDB3Textbox.Text = plDB1Textbox.Text; - clHydroxyl3Textbox.Text = plHydroxyl1Textbox.Text; clFA3Combobox.Text = plFA1Combobox.Text; clFA3Checkbox1.Checked = plFA1Checkbox1.Checked; clFA3Checkbox2.Checked = plFA1Checkbox2.Checked; @@ -2142,7 +2296,7 @@ public void plRepresentativeFACheckedChanged(Object sender, EventArgs e) clFA4Textbox.Enabled = false; clDB4Textbox.Enabled = false; - clHydroxyl4Textbox.Enabled = false; + plFA4FuncGroups.Enabled = false; clFA4Combobox.Enabled = false; clFA4Checkbox1.Enabled = false; clFA4Checkbox2.Enabled = false; @@ -2150,7 +2304,6 @@ public void plRepresentativeFACheckedChanged(Object sender, EventArgs e) clFA4Textbox.Text = plFA1Textbox.Text; clDB4Textbox.Text = plDB1Textbox.Text; - clHydroxyl4Textbox.Text = plHydroxyl1Textbox.Text; clFA4Combobox.Text = plFA1Combobox.Text; clFA4Checkbox1.Checked = plFA1Checkbox1.Checked; clFA4Checkbox2.Checked = plFA1Checkbox2.Checked; @@ -2161,7 +2314,7 @@ public void plRepresentativeFACheckedChanged(Object sender, EventArgs e) { plFA2Textbox.Enabled = true; plDB2Textbox.Enabled = true; - plHydroxyl2Textbox.Enabled = true; + plFA2FuncGroups.Enabled = true; plFA2Combobox.Enabled = true; plFA2Checkbox1.Enabled = true; @@ -2172,7 +2325,7 @@ public void plRepresentativeFACheckedChanged(Object sender, EventArgs e) clFA3Textbox.Enabled = true; clDB3Textbox.Enabled = true; - clHydroxyl3Textbox.Enabled = true; + plFA3FuncGroups.Enabled = true; clFA3Combobox.Enabled = true; clFA3Checkbox1.Enabled = true; clFA3Checkbox2.Enabled = true; @@ -2180,7 +2333,7 @@ public void plRepresentativeFACheckedChanged(Object sender, EventArgs e) clFA4Textbox.Enabled = true; clDB4Textbox.Enabled = true; - clHydroxyl4Textbox.Enabled = true; + plFA4FuncGroups.Enabled = true; clFA4Combobox.Enabled = true; clFA4Checkbox1.Enabled = true; clFA4Checkbox2.Enabled = true; @@ -2188,20 +2341,20 @@ public void plRepresentativeFACheckedChanged(Object sender, EventArgs e) } } - updateRanges(((Phospholipid)currentLipid).fag2, plFA2Textbox, plFA2Combobox.SelectedIndex); - updateRanges(((Phospholipid)currentLipid).fag2, plDB2Textbox, 3); - updateRanges(((Phospholipid)currentLipid).fag2, plHydroxyl2Textbox, 4); + updateRanges(currentPhospholipid.fag2, plFA2Textbox, plFA2Combobox.SelectedIndex); + updateRanges(currentPhospholipid.fag2, plDB2Textbox, 3); + updateFunctionalGroupGridView(currentPhospholipid.fag2, plFA2FuncGroups); if (plIsCL.Checked) { - updateRanges(((Phospholipid)currentLipid).fag3, clFA3Textbox, clFA3Combobox.SelectedIndex); - updateRanges(((Phospholipid)currentLipid).fag3, clDB3Textbox, 3); - updateRanges(((Phospholipid)currentLipid).fag3, clHydroxyl3Textbox, 4); + updateRanges(currentPhospholipid.fag3, clFA3Textbox, clFA3Combobox.SelectedIndex); + updateRanges(currentPhospholipid.fag3, clDB3Textbox, 3); + updateFunctionalGroupGridView(currentPhospholipid.fag3, plFA3FuncGroups); - updateRanges(((Phospholipid)currentLipid).fag4, clFA4Textbox, clFA4Combobox.SelectedIndex); - updateRanges(((Phospholipid)currentLipid).fag4, clDB4Textbox, 3); - updateRanges(((Phospholipid)currentLipid).fag4, clHydroxyl4Textbox, 4); + updateRanges(currentPhospholipid.fag4, clFA4Textbox, clFA4Combobox.SelectedIndex); + updateRanges(currentPhospholipid.fag4, clDB4Textbox, 3); + updateFunctionalGroupGridView(currentPhospholipid.fag4, plFA4FuncGroups); } } @@ -2297,9 +2450,8 @@ void plChangeLyso(bool lyso) plFA2Combobox.Visible = false; plFA2Textbox.Visible = false; plDB2Textbox.Visible = false; - plHydroxyl2Textbox.Visible = false; + plFA2FuncGroups.Visible = false; plDB2Label.Visible = false; - plHydroxyl2Label.Visible = false; plFA2Checkbox1.Visible = false; plRepresentativeFA.Visible = false; } @@ -2656,14 +2808,16 @@ public LipidCategory checkPropertiesValid() if (currentLipid is Glycerolipid) { - ((Glycerolipid)currentLipid).fag1.createFunctionalGroupCount(); - ((Glycerolipid)currentLipid).fag2.createFunctionalGroupCount(); - if (((Glycerolipid)currentLipid).fag1.faTypes[FattyAcidType.NoType]) + Glycerolipid currentGlycerolipid = (Glycerolipid)currentLipid; + currentGlycerolipid.fag1.createFunctionalGroupCount(); + currentGlycerolipid.fag2.createFunctionalGroupCount(); + currentGlycerolipid.fag3.createFunctionalGroupCount(); + if (currentGlycerolipid.fag1.faTypes[FattyAcidType.NoType]) { MessageBox.Show("Please always select the top fatty acyl!", "Not registrable"); return LipidCategory.NoLipid; } - else if (((Glycerolipid)currentLipid).fag2.faTypes[FattyAcidType.NoType] && !((Glycerolipid)currentLipid).fag3.faTypes[FattyAcidType.NoType]) + else if (currentGlycerolipid.fag2.faTypes[FattyAcidType.NoType] && !currentGlycerolipid.fag3.faTypes[FattyAcidType.NoType]) { MessageBox.Show("Please select the middle fatty acyl for DG!", "Not registrable"); return LipidCategory.NoLipid; @@ -2689,35 +2843,25 @@ public LipidCategory checkPropertiesValid() MessageBox.Show("Second double bond content not valid!", "Not registrable"); return LipidCategory.NoLipid; } - if (glHydroxyl1Textbox.BackColor == alertColor) - { - MessageBox.Show("First hydroxyl content not valid!", "Not registrable"); - return LipidCategory.NoLipid; - } - if (glHydroxyl2Textbox.BackColor == alertColor) - { - MessageBox.Show("Second hydroxyl content not valid!", "Not registrable"); - return LipidCategory.NoLipid; - } - if (((Glycerolipid)currentLipid).fag1.functionalGroupCounts == null) + if (currentGlycerolipid.fag1.functionalGroupCounts == null) { MessageBox.Show("A functional group content in first fatty acid is not valid!", "Not registrable"); return LipidCategory.NoLipid; } - if (((Glycerolipid)currentLipid).fag2.functionalGroupCounts == null) + if (currentGlycerolipid.fag2.functionalGroupCounts == null) { MessageBox.Show("A functional group content in second fatty acid is not valid!", "Not registrable"); return LipidCategory.NoLipid; } - if (((Glycerolipid)currentLipid).containsSugar) + if (currentGlycerolipid.containsSugar) { if (currentLipid.headGroupNames.Count == 0) { MessageBox.Show("No head group selected!", "Not registrable"); return LipidCategory.NoLipid; } - if (((Glycerolipid)currentLipid).fag1.faTypes[FattyAcidType.NoType] || ((Glycerolipid)currentLipid).fag2.faTypes[FattyAcidType.NoType]) + if (currentGlycerolipid.fag1.faTypes[FattyAcidType.NoType] || currentGlycerolipid.fag2.faTypes[FattyAcidType.NoType]) { MessageBox.Show("Both fatty acyls must be selected!", "Not registrable"); return LipidCategory.NoLipid; @@ -2725,8 +2869,7 @@ public LipidCategory checkPropertiesValid() } else { - ((Glycerolipid)currentLipid).fag3.createFunctionalGroupCount(); - if (((Glycerolipid)currentLipid).fag1.faTypes[FattyAcidType.NoType] && ((Glycerolipid)currentLipid).fag2.faTypes[FattyAcidType.NoType] && ((Glycerolipid)currentLipid).fag3.faTypes[FattyAcidType.NoType]) + if (currentGlycerolipid.fag1.faTypes[FattyAcidType.NoType] && currentGlycerolipid.fag2.faTypes[FattyAcidType.NoType] && currentGlycerolipid.fag3.faTypes[FattyAcidType.NoType]) { MessageBox.Show("No fatty acyl selected!", "Not registrable"); return LipidCategory.NoLipid; @@ -2741,12 +2884,7 @@ public LipidCategory checkPropertiesValid() MessageBox.Show("Third double bond content not valid!", "Not registrable"); return LipidCategory.NoLipid; } - if (glHydroxyl3Textbox.BackColor == alertColor) - { - MessageBox.Show("Third hydroxyl content not valid!", "Not registrable"); - return LipidCategory.NoLipid; - } - if (((Glycerolipid)currentLipid).fag3.functionalGroupCounts == null) + if (currentGlycerolipid.fag3.functionalGroupCounts == null) { MessageBox.Show("A functional group content in third fatty acid is not valid!", "Not registrable"); return LipidCategory.NoLipid; @@ -2758,9 +2896,10 @@ public LipidCategory checkPropertiesValid() else if (currentLipid is Phospholipid) { - if (((Phospholipid)currentLipid).isCL) + Phospholipid currentPhospholipid = (Phospholipid)currentLipid; + if (currentPhospholipid.isCL) { - if (((Phospholipid)currentLipid).fag1.faTypes[FattyAcidType.NoType] || ((Phospholipid)currentLipid).fag2.faTypes[FattyAcidType.NoType] || ((Phospholipid)currentLipid).fag3.faTypes[FattyAcidType.NoType]) + if (currentPhospholipid.fag1.faTypes[FattyAcidType.NoType] || currentPhospholipid.fag2.faTypes[FattyAcidType.NoType] || currentPhospholipid.fag3.faTypes[FattyAcidType.NoType]) { MessageBox.Show("At least the top three fatty acyls must be selected!", "Not registrable"); return LipidCategory.NoLipid; @@ -2805,25 +2944,25 @@ public LipidCategory checkPropertiesValid() { MessageBox.Show("Fourth double bond content not valid!", "Not registrable"); return LipidCategory.NoLipid; - } - if (plHydroxyl1Textbox.BackColor == alertColor) + } + if (currentPhospholipid.fag1.functionalGroupCounts == null) { - MessageBox.Show("First hydroxyl content not valid!", "Not registrable"); + MessageBox.Show("A functional group content in first fatty acid is not valid!", "Not registrable"); return LipidCategory.NoLipid; - } - if (plHydroxyl2Textbox.BackColor == alertColor) + } + if (currentPhospholipid.fag2.functionalGroupCounts == null) { - MessageBox.Show("Second hydroxyl content not valid!", "Not registrable"); + MessageBox.Show("A functional group content in second fatty acid is not valid!", "Not registrable"); return LipidCategory.NoLipid; - } - if (clHydroxyl3Textbox.BackColor == alertColor) + } + if (currentPhospholipid.fag3.functionalGroupCounts == null) { - MessageBox.Show("Third hydroxyl content not valid!", "Not registrable"); + MessageBox.Show("A functional group content in third fatty acid is not valid!", "Not registrable"); return LipidCategory.NoLipid; - } - if (clHydroxyl4Textbox.BackColor == alertColor) + } + if (currentPhospholipid.fag4.functionalGroupCounts == null) { - MessageBox.Show("Fourth hydroxyl content not valid!", "Not registrable"); + MessageBox.Show("A functional group content in fourth fatty acid is not valid!", "Not registrable"); return LipidCategory.NoLipid; } } @@ -2836,10 +2975,10 @@ public LipidCategory checkPropertiesValid() } - if (((Phospholipid)currentLipid).isLyso) + if (currentPhospholipid.isLyso) { bool hasOneHG = false; - bool hasPlasmalogen = ((Phospholipid)currentLipid).hasPlasmalogen; + bool hasPlasmalogen = currentPhospholipid.hasPlasmalogen; foreach (string headgroup in currentLipid.headGroupNames) { bool plasmalogenEquivalent = !(lipidCreator.headgroups[headgroup].attributes.Contains("ether") ^ hasPlasmalogen); @@ -2855,10 +2994,10 @@ public LipidCategory checkPropertiesValid() return LipidCategory.NoLipid; } } - else if (!((Phospholipid)currentLipid).isCL) + else if (!currentPhospholipid.isCL) { bool hasOneHG = false; - bool hasPlasmalogen = ((Phospholipid)currentLipid).hasPlasmalogen; + bool hasPlasmalogen = currentPhospholipid.hasPlasmalogen; foreach (string headgroup in currentLipid.headGroupNames) { bool plasmalogenEquivalent = !(lipidCreator.headgroups[headgroup].attributes.Contains("ether") ^ hasPlasmalogen); @@ -2878,7 +3017,7 @@ public LipidCategory checkPropertiesValid() - if (((Phospholipid)currentLipid).fag1.faTypes[FattyAcidType.NoType]) + if (currentPhospholipid.fag1.faTypes[FattyAcidType.NoType]) { MessageBox.Show("Please select at least the top fatty acyl!", "Not registrable"); return LipidCategory.NoLipid; @@ -2895,14 +3034,14 @@ public LipidCategory checkPropertiesValid() MessageBox.Show("First double bond content not valid!", "Not registrable"); return LipidCategory.NoLipid; } - if (plHydroxyl1Textbox.BackColor == alertColor) + if (currentPhospholipid.fag1.functionalGroupCounts == null) { - MessageBox.Show("First hydroxyl content not valid!", "Not registrable"); + MessageBox.Show("A functional group content in first fatty acid is not valid!", "Not registrable"); return LipidCategory.NoLipid; } - if (!((Phospholipid)currentLipid).isLyso) + if (!currentPhospholipid.isLyso) { if (plFA2Textbox.BackColor == alertColor) { @@ -2915,13 +3054,12 @@ public LipidCategory checkPropertiesValid() MessageBox.Show("Second double bond content not valid!", "Not registrable"); return LipidCategory.NoLipid; } - - if (plHydroxyl2Textbox.BackColor == alertColor) + + if (currentPhospholipid.fag2.functionalGroupCounts == null) { - MessageBox.Show("Second hydroxyl content not valid!", "Not registrable"); + MessageBox.Show("A functional group content in second fatty acid is not valid!", "Not registrable"); return LipidCategory.NoLipid; } - } @@ -2931,9 +3069,9 @@ public LipidCategory checkPropertiesValid() // - if ((((Phospholipid)currentLipid).fag1.faTypes[FattyAcidType.Plasmanyl] || ((Phospholipid)currentLipid).fag1.faTypes[FattyAcidType.Plasmenyl]) && !((Phospholipid)currentLipid).isCL && !((Phospholipid)currentLipid).hasPlasmalogen) + if ((currentPhospholipid.fag1.faTypes[FattyAcidType.Plasmanyl] || currentPhospholipid.fag1.faTypes[FattyAcidType.Plasmenyl]) && !currentPhospholipid.isCL && !currentPhospholipid.hasPlasmalogen) { - HashSet supposedPLs = ((Phospholipid)currentLipid).isLyso ? new HashSet(){"LPC", "LPE"} : new HashSet(){"PC", "PE"}; + HashSet supposedPLs = currentPhospholipid.isLyso ? new HashSet(){"LPC", "LPE"} : new HashSet(){"PC", "PE"}; HashSet selectedPLs = new HashSet(currentLipid.headGroupNames); @@ -2942,7 +3080,7 @@ public LipidCategory checkPropertiesValid() bool regularWarn = regularPLs.Any(); bool specialWarn = specialPLs.Any(); - bool split = (regularWarn && specialWarn) || (specialWarn && ((Phospholipid)currentLipid).fag1.faTypes[FattyAcidType.Ester]); + bool split = (regularWarn && specialWarn) || (specialWarn && currentPhospholipid.fag1.faTypes[FattyAcidType.Ester]); if (regularWarn || specialWarn) { @@ -2955,17 +3093,17 @@ public LipidCategory checkPropertiesValid() List HGs = new List(); foreach (string hg in specialPLs) { - if (((Phospholipid)currentLipid).fag1.faTypes[FattyAcidType.Plasmenyl]) HGs.Add(hg + " P"); - if (((Phospholipid)currentLipid).fag1.faTypes[FattyAcidType.Plasmanyl]) HGs.Add(hg + " O"); + if (currentPhospholipid.fag1.faTypes[FattyAcidType.Plasmenyl]) HGs.Add(hg + " P"); + if (currentPhospholipid.fag1.faTypes[FattyAcidType.Plasmanyl]) HGs.Add(hg + " O"); } if (split && regularWarn) { - Phospholipid newLipid = new Phospholipid((Phospholipid)currentLipid); + Phospholipid newLipid = new Phospholipid(currentPhospholipid); Phospholipid pureLipid = null; - if (((Phospholipid)currentLipid).fag1.faTypes[FattyAcidType.Ester]) + if (currentPhospholipid.fag1.faTypes[FattyAcidType.Ester]) { - pureLipid = new Phospholipid((Phospholipid)currentLipid); + pureLipid = new Phospholipid(currentPhospholipid); pureLipid.headGroupNames.Clear(); pureLipid.fag1.faTypes[FattyAcidType.Ester] = true; pureLipid.fag1.faTypes[FattyAcidType.Plasmanyl] = false; @@ -2985,7 +3123,7 @@ public LipidCategory checkPropertiesValid() lipidCreator.registeredLipids.Add(lipidHash); registeredLipidsDatatable.Rows.Add(createLipidsGridviewRow(newLipid)); - if (((Phospholipid)currentLipid).fag1.faTypes[FattyAcidType.Ester]) + if (currentPhospholipid.fag1.faTypes[FattyAcidType.Ester]) { lipidHash = pureLipid.getHashCode(); lipidCreator.registeredLipidDictionary.Add(lipidHash, pureLipid); @@ -3004,7 +3142,7 @@ public LipidCategory checkPropertiesValid() } else if (split && !regularWarn) { - Phospholipid newLipid = new Phospholipid((Phospholipid)currentLipid); + Phospholipid newLipid = new Phospholipid(currentPhospholipid); plFA1Checkbox1.Checked = true; plFA1Checkbox2.Checked = false; plFA1Checkbox3.Checked = false; @@ -3326,6 +3464,7 @@ public string FARepresentation(FattyAcidGroup fag) + public DataRow createLipidsGridviewRow(Lipid currentRegisteredLipid) { DataRow row = registeredLipidsDatatable.NewRow(); @@ -3339,24 +3478,24 @@ public DataRow createLipidsGridviewRow(Lipid currentRegisteredLipid) { row["Building Block 3"] = "HG: " + String.Join(", ", currentGlycerolipid.headGroupNames); headGroupNames.AddRange(currentGlycerolipid.headGroupNames); - row["Building Block 2"] = FARepresentation(currentGlycerolipid.fag2) + currentGlycerolipid.fag2.lengthInfo + "; DB: " + currentGlycerolipid.fag2.dbInfo + "; OH: " + currentGlycerolipid.fag2.hydroxylInfo; + row["Building Block 2"] = FARepresentation(currentGlycerolipid.fag2) + currentGlycerolipid.fag2.lengthInfo + "; DB: " + currentGlycerolipid.fag2.dbInfo + currentGlycerolipid.fag2.functionalGroupsInfo(); } else if (!currentGlycerolipid.fag3.faTypes[FattyAcidType.NoType]) { - row["Building Block 3"] = FARepresentation(currentGlycerolipid.fag3) + currentGlycerolipid.fag3.lengthInfo + "; DB: " + currentGlycerolipid.fag3.dbInfo + "; OH: " + currentGlycerolipid.fag3.hydroxylInfo; - row["Building Block 2"] = FARepresentation(currentGlycerolipid.fag2) + currentGlycerolipid.fag2.lengthInfo + "; DB: " + currentGlycerolipid.fag2.dbInfo + "; OH: " + currentGlycerolipid.fag2.hydroxylInfo; + row["Building Block 3"] = FARepresentation(currentGlycerolipid.fag3) + currentGlycerolipid.fag3.lengthInfo + "; DB: " + currentGlycerolipid.fag3.dbInfo + currentGlycerolipid.fag3.functionalGroupsInfo(); + row["Building Block 2"] = FARepresentation(currentGlycerolipid.fag2) + currentGlycerolipid.fag2.lengthInfo + "; DB: " + currentGlycerolipid.fag2.dbInfo + currentGlycerolipid.fag2.functionalGroupsInfo(); headGroupNames.Add("TG"); } else if (!currentGlycerolipid.fag2.faTypes[FattyAcidType.NoType]) { - row["Building Block 2"] = FARepresentation(currentGlycerolipid.fag2) + currentGlycerolipid.fag2.lengthInfo + "; DB: " + currentGlycerolipid.fag2.dbInfo + "; OH: " + currentGlycerolipid.fag2.hydroxylInfo; + row["Building Block 2"] = FARepresentation(currentGlycerolipid.fag2) + currentGlycerolipid.fag2.lengthInfo + "; DB: " + currentGlycerolipid.fag2.dbInfo + currentGlycerolipid.fag2.functionalGroupsInfo(); headGroupNames.Add("DG"); } else { headGroupNames.Add("MG"); } - row["Building Block 1"] = FARepresentation(currentGlycerolipid.fag1) + currentGlycerolipid.fag1.lengthInfo + "; DB: " + currentGlycerolipid.fag1.dbInfo + "; OH: " + currentGlycerolipid.fag1.hydroxylInfo; + row["Building Block 1"] = FARepresentation(currentGlycerolipid.fag1) + currentGlycerolipid.fag1.lengthInfo + "; DB: " + currentGlycerolipid.fag1.dbInfo + currentGlycerolipid.fag1.functionalGroupsInfo(); } else if (currentRegisteredLipid is Phospholipid) { @@ -3364,10 +3503,10 @@ public DataRow createLipidsGridviewRow(Lipid currentRegisteredLipid) if (currentPhospholipid.isCL) { row["Category"] = "Cardiolipin"; - row["Building Block 1"] = FARepresentation(currentPhospholipid.fag1) + currentPhospholipid.fag1.lengthInfo + "; DB: " + currentPhospholipid.fag1.dbInfo + "; OH: " + currentPhospholipid.fag1.hydroxylInfo; - row["Building Block 2"] = FARepresentation(currentPhospholipid.fag2) + currentPhospholipid.fag2.lengthInfo + "; DB: " + currentPhospholipid.fag2.dbInfo + "; OH: " + currentPhospholipid.fag2.hydroxylInfo; - row["Building Block 3"] = FARepresentation(currentPhospholipid.fag3) + currentPhospholipid.fag3.lengthInfo + "; DB: " + currentPhospholipid.fag3.dbInfo + "; OH: " + currentPhospholipid.fag3.hydroxylInfo; - if (!currentPhospholipid.fag4.faTypes[FattyAcidType.NoType]) row["Building Block 4"] = FARepresentation(currentPhospholipid.fag4) + currentPhospholipid.fag4.lengthInfo + "; DB: " + currentPhospholipid.fag4.dbInfo + "; OH: " + currentPhospholipid.fag4.hydroxylInfo; + row["Building Block 1"] = FARepresentation(currentPhospholipid.fag1) + currentPhospholipid.fag1.lengthInfo + "; DB: " + currentPhospholipid.fag1.dbInfo + currentPhospholipid.fag1.functionalGroupsInfo(); + row["Building Block 2"] = FARepresentation(currentPhospholipid.fag2) + currentPhospholipid.fag2.lengthInfo + "; DB: " + currentPhospholipid.fag2.dbInfo + currentPhospholipid.fag2.functionalGroupsInfo(); + row["Building Block 3"] = FARepresentation(currentPhospholipid.fag3) + currentPhospholipid.fag3.lengthInfo + "; DB: " + currentPhospholipid.fag3.dbInfo + currentPhospholipid.fag3.functionalGroupsInfo(); + if (!currentPhospholipid.fag4.faTypes[FattyAcidType.NoType]) row["Building Block 4"] = FARepresentation(currentPhospholipid.fag4) + currentPhospholipid.fag4.lengthInfo + "; DB: " + currentPhospholipid.fag4.dbInfo + currentPhospholipid.fag4.functionalGroupsInfo(); headGroupNames.Add("CL"); } else @@ -3375,8 +3514,8 @@ public DataRow createLipidsGridviewRow(Lipid currentRegisteredLipid) row["Category"] = "Glycerophospholipid"; headGroupNames.AddRange(currentPhospholipid.headGroupNames); row["Building Block 1"] = "HG: " + String.Join(", ", currentPhospholipid.headGroupNames); - row["Building Block 2"] = FARepresentation(currentPhospholipid.fag1) + currentPhospholipid.fag1.lengthInfo + "; DB: " + currentPhospholipid.fag1.dbInfo + "; OH: " + currentPhospholipid.fag1.hydroxylInfo; - if (!currentPhospholipid.isLyso) row["Building Block 3"] = FARepresentation(currentPhospholipid.fag2) + currentPhospholipid.fag2.lengthInfo + "; DB: " + currentPhospholipid.fag2.dbInfo + "; OH: " + currentPhospholipid.fag2.hydroxylInfo; + row["Building Block 2"] = FARepresentation(currentPhospholipid.fag1) + currentPhospholipid.fag1.lengthInfo + "; DB: " + currentPhospholipid.fag1.dbInfo + currentPhospholipid.fag1.functionalGroupsInfo(); + if (!currentPhospholipid.isLyso) row["Building Block 3"] = FARepresentation(currentPhospholipid.fag2) + currentPhospholipid.fag2.lengthInfo + "; DB: " + currentPhospholipid.fag2.dbInfo + currentPhospholipid.fag2.functionalGroupsInfo(); } } else if (currentRegisteredLipid is Sphingolipid) diff --git a/LipidCreator/FattyAcid.cs b/LipidCreator/FattyAcid.cs index aa55d0a..005b01a 100644 --- a/LipidCreator/FattyAcid.cs +++ b/LipidCreator/FattyAcid.cs @@ -142,7 +142,10 @@ public string ToString(bool fullFormat = true) if (hydroxyl > 0) key += ";O" + Convert.ToString(hydroxyl); } } - foreach (KeyValuePair kvp in functionalGroups) key += ";(" + Lipid.ALL_FUNCTIONAL_GROUPS[kvp.Key].abbreviation + ")" + Convert.ToString(kvp.Value); + foreach (KeyValuePair kvp in functionalGroups) + { + if (kvp.Value > 0) key += ";(" + Lipid.ALL_FUNCTIONAL_GROUPS[kvp.Key].abbreviation + ")" + Convert.ToString(kvp.Value); + } key += LipidCreator.computeHeavyIsotopeLabel(atomsCount); return key; } diff --git a/LipidCreator/FattyAcidGroup.cs b/LipidCreator/FattyAcidGroup.cs index e3bbcec..7c32224 100644 --- a/LipidCreator/FattyAcidGroup.cs +++ b/LipidCreator/FattyAcidGroup.cs @@ -232,6 +232,22 @@ public ulong getHashCode() + public string functionalGroupsInfo() + { + StringBuilder sb = new StringBuilder(); + foreach (DataRow dataRow in functionalGroups.Rows) + { + if (sb.Length > 0) sb.Append(", "); + string key = (string)dataRow[0]; + FunctionalGroupType fgt = Lipid.FUNCTIONAL_GROUP_POSITIONS[key]; + sb.Append(Lipid.ALL_FUNCTIONAL_GROUPS[fgt].abbreviation).Append(": ").Append((string)dataRow[1]); + } + string s = sb.ToString(); + return (s.Length == 0) ? "" : "; " + s; + } + + + public void import(XElement node, string importVersion) { chainType = ((string)node.Attribute("chainType") != null) ? Convert.ToInt32(node.Attribute("chainType").Value) : 0; @@ -339,42 +355,47 @@ public System.Collections.Generic.IEnumerable getFattyAcids() { // iterate for all hydroxyls if (maxDoubleBond < fattyAcidDoubleBond) continue; - foreach (int fattyAcidHydroxyl in hydroxylCounts) + foreach (KeyValuePair fattyAcidKeyValuePair in faTypes) { - // iterate for all bondings - if (fattyAcidLength <= fattyAcidHydroxyl) continue; - foreach (KeyValuePair fattyAcidKeyValuePair in faTypes) + if (!fattyAcidKeyValuePair.Value) continue; + + if (isLCB) { - if (!fattyAcidKeyValuePair.Value) continue; - - if (functionalGroupCounts == null || functionalGroupCounts.Count == 0) + foreach (int fattyAcidHydroxyl in hydroxylCounts) { + if (fattyAcidLength <= fattyAcidHydroxyl) continue; yield return new FattyAcid(fattyAcidLength, fattyAcidDoubleBond, fattyAcidHydroxyl, fattyAcidKeyValuePair.Key, isLCB); } - else + continue; + } + + if (functionalGroupCounts == null || functionalGroupCounts.Count == 0) + { + yield return new FattyAcid(fattyAcidLength, fattyAcidDoubleBond, 0, fattyAcidKeyValuePair.Key, isLCB); + } + else + { + Dictionary funcGroups = new Dictionary(); + Dictionary> funcGroupsPossibilities = new Dictionary>(); + Dictionary divisors = new Dictionary(); + + int combinations = 1; + foreach(KeyValuePair> kvp in functionalGroupCounts) + { + funcGroupsPossibilities.Add(kvp.Key, new List(kvp.Value)); + int tmp = combinations; + combinations *= kvp.Value.Count; + funcGroups.Add(kvp.Key, 0); + divisors.Add(kvp.Key, new int[]{combinations, tmp}); + } + for (int i = 0; i < combinations; ++i) { - Dictionary funcGroups = new Dictionary(); - Dictionary> funcGroupsPossibilities = new Dictionary>(); - Dictionary divisors = new Dictionary(); - - int combinations = 1; - foreach(KeyValuePair> kvp in functionalGroupCounts) - { - funcGroupsPossibilities.Add(kvp.Key, new List(kvp.Value)); - int tmp = combinations; - combinations *= kvp.Value.Count; - funcGroups.Add(kvp.Key, 0); - divisors.Add(kvp.Key, new int[]{combinations, tmp}); - } - for (int i = 0; i < combinations; ++i) + foreach (KeyValuePair> kvp in functionalGroupCounts) { - foreach (KeyValuePair> kvp in functionalGroupCounts) - { - int pos = (i % divisors[kvp.Key][0]) / divisors[kvp.Key][1]; - funcGroups[kvp.Key] = funcGroupsPossibilities[kvp.Key][pos]; - } - yield return new FattyAcid(fattyAcidLength, fattyAcidDoubleBond, fattyAcidHydroxyl, fattyAcidKeyValuePair.Key, isLCB, funcGroups); + int pos = (i % divisors[kvp.Key][0]) / divisors[kvp.Key][1]; + funcGroups[kvp.Key] = funcGroupsPossibilities[kvp.Key][pos]; } + yield return new FattyAcid(fattyAcidLength, fattyAcidDoubleBond, 0, fattyAcidKeyValuePair.Key, isLCB, funcGroups); } } } diff --git a/LipidCreator/Tutorial.cs b/LipidCreator/Tutorial.cs index 34a8629..1b41a9c 100644 --- a/LipidCreator/Tutorial.cs +++ b/LipidCreator/Tutorial.cs @@ -1167,10 +1167,10 @@ public void TutorialPRMStep() case (int)PRMSteps.MoreParameters: setTutorialControls(creatorGUI.plStep1, creatorGUI.phospholipidsTab); - TextBox plHyd1 = creatorGUI.plHydroxyl1Textbox; + DataGridView plHyd1 = creatorGUI.plFA1FuncGroups; tutorialArrow.update(new Point(plHyd1.Location.X + (plHyd1.Size.Width >> 1), plHyd1.Location.Y + plHyd1.Size.Height), "lt"); - tutorialWindow.update(new Size(540, 200), new Point(60, 200), "Click on 'Continue'", "The number of hydroxyl groups can be adjusted for each FA specification. Here, we stick with zero."); + tutorialWindow.update(new Size(540, 200), new Point(60, 200), "Click on 'Continue'", "LipidCreator offers 14 additional functional groups to be bound to a fatty acyl chain. Here, you can add the different groups along with a range."); nextEnabled = true; break;