Skip to content

Commit

Permalink
Merge pull request #399 from acesnik/master
Browse files Browse the repository at this point in the history
Modifiable PTM ranks, used in pf assignment. CH2/HPO3 for no-mans-land calculations
  • Loading branch information
Anthony authored May 30, 2017
2 parents be550b1 + 67826ad commit 0148625
Show file tree
Hide file tree
Showing 52 changed files with 1,798 additions and 1,318 deletions.
2 changes: 1 addition & 1 deletion ProteoformSuiteGUI/AggregatedProteoforms.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 18 additions & 19 deletions ProteoformSuiteGUI/AggregatedProteoforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,14 @@ private void nUD_Missed_Ks_ValueChanged(object sender, EventArgs e)
{
SaveState.lollipop.missed_lysines = nUD_Missed_Ks.Value;
}

private void bt_aggregate_Click(object sender, EventArgs e)
{
if (SaveState.lollipop.neucode_labeled && SaveState.lollipop.raw_neucode_pairs.Count > 0 || SaveState.lollipop.raw_experimental_components.Count > 0)
if (ReadyToRunTheGamut())
{
Cursor = Cursors.WaitCursor;
RunTheGamut();
Cursor = Cursors.Default;
}
else if (SaveState.lollipop.target_proteoform_community.experimental_proteoforms.Length <= 0)
{
Expand Down Expand Up @@ -110,25 +113,16 @@ private void nUD_min_num_bioreps_ValueChanged(object sender, EventArgs e)

public bool ReadyToRunTheGamut()
{
return SaveState.lollipop.target_proteoform_community.experimental_proteoforms.Length <= 0
&& (SaveState.lollipop.neucode_labeled && SaveState.lollipop.raw_neucode_pairs.Count > 0 || SaveState.lollipop.raw_experimental_components.Count > 0);
return SaveState.lollipop.neucode_labeled && SaveState.lollipop.raw_neucode_pairs.Count > 0 || SaveState.lollipop.raw_experimental_components.Count > 0;
}

public void RunTheGamut()
{
Cursor = Cursors.WaitCursor;
ClearListsTablesFigures();
ClearListsTablesFigures(true);
SaveState.lollipop.aggregate_proteoforms(SaveState.lollipop.validate_proteoforms, SaveState.lollipop.raw_neucode_pairs, SaveState.lollipop.raw_experimental_components, SaveState.lollipop.raw_quantification_components, SaveState.lollipop.min_num_CS);
SaveState.lollipop.assign_best_components_for_manual_validation(SaveState.lollipop.target_proteoform_community.experimental_proteoforms);
FillTablesAndCharts();
if (SaveState.lollipop.neucode_labeled && SaveState.lollipop.target_proteoform_community.theoretical_proteoforms.Length > 0)
{
((ProteoformSweet)MdiParent).experimentalTheoreticalComparison.RunTheGamut();
((ProteoformSweet)MdiParent).experimentExperimentComparison.RunTheGamut();
if (((ProteoformSweet)MdiParent).quantification.ReadyToRunTheGamut()) ((ProteoformSweet)MdiParent).quantification.perform_calculations();
}

updateFiguresOfMerit();
Cursor = Cursors.Default;
}

public List<DataGridView> GetDGVs()
Expand Down Expand Up @@ -158,16 +152,21 @@ public void InitializeParameterSet()
tb_tableFilter.TextChanged += tb_tableFilter_TextChanged;
}

public void ClearListsTablesFigures()
public void ClearListsTablesFigures(bool clear_following)
{
if (clear_following)
{
for (int i = ((ProteoformSweet)MdiParent).forms.IndexOf(this) + 1; i < ((ProteoformSweet)MdiParent).forms.Count; i++)
{
ISweetForm sweet = ((ProteoformSweet)MdiParent).forms[i];
if (sweet as TheoreticalDatabase == null)
sweet.ClearListsTablesFigures(false);
}
}

SaveState.lollipop.clear_aggregation();
dgv_AcceptNeuCdLtProteoforms.DataSource = null;
dgv_AcceptNeuCdLtProteoforms.Rows.Clear();

((ProteoformSweet)MdiParent).experimentalTheoreticalComparison.ClearListsTablesFigures();
((ProteoformSweet)MdiParent).quantification.ClearListsTablesFigures();
((ProteoformSweet)MdiParent).experimentExperimentComparison.ClearListsTablesFigures();
((ProteoformSweet)MdiParent).proteoformFamilies.ClearListsTablesFigures();
}

#endregion Public Methods
Expand Down
59 changes: 40 additions & 19 deletions ProteoformSuiteGUI/DGVExcelWriter.cs
Original file line number Diff line number Diff line change
@@ -1,49 +1,70 @@
using System;
using ClosedXML.Excel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Office.Interop.Excel;
using Excel = Microsoft.Office.Interop.Excel;
using System.Windows.Forms;
using ClosedXML.Excel;
using System.Data;

using System.Windows.Forms;

namespace ProteoformSuiteInternal
{
class DGVExcelWriter
{
public void ExportToExcel(List<DataGridView> dgvs, string filename)

private XLWorkbook workbook = new XLWorkbook();

public void ExportToExcel(List<DataGridView> dgvs, string sheet_prefix)
{
var workbook = new XLWorkbook();
if (dgvs == null)
return;

foreach (DataGridView dgv in dgvs)
{
System.Data.DataTable dt = new System.Data.DataTable();
DataTable dt = new DataTable();
foreach (DataGridViewColumn col in dgv.Columns)
{
dt.Columns.Add(col.HeaderText);

}

foreach(DataGridViewRow row in dgv.Rows)
{
DataRow new_row = dt.NewRow();
foreach (DataGridViewCell cell in row.Cells)
{
if (dgv.Columns[cell.ColumnIndex].Visible) new_row[cell.ColumnIndex] = (cell.Value == null || cell.Value.ToString() == "NaN")? "" : cell.Value;
if (dgv.Columns[cell.ColumnIndex].Visible)
new_row[cell.ColumnIndex] = cell.Value == null || cell.Value.ToString() == "NaN" ? "" : cell.Value;
}
lock (dt) dt.Rows.Add(new_row);
}
foreach (DataGridViewColumn col in dgv.Columns) { if (!col.Visible) dt.Columns.Remove(col.HeaderText); }

var worksheet = workbook.Worksheets.Add(dt, dgv.Name);
foreach (var col in worksheet.Columns())
foreach (DataGridViewColumn col in dgv.Columns)
{
double is_number;
col.Cells(2, worksheet.LastRowUsed().RowNumber()).DataType = Double.TryParse(worksheet.Row(2).Cell(col.ColumnNumber()).Value.ToString(), out is_number) ? XLCellValues.Number : XLCellValues.Text;
if (!col.Visible)
dt.Columns.Remove(col.HeaderText);
}

IXLWorksheet worksheet = null;
lock (workbook)
{
worksheet = workbook.Worksheets.Add(dt, sheet_prefix.Substring(0, Math.Min(sheet_prefix.Length, 30 - dgv.Name.Length)) + "_" + dgv.Name);
}

foreach (var col in worksheet.Columns())
{
try
{
col.Cells(2, worksheet.LastRowUsed().RowNumber()).DataType = Double.TryParse(worksheet.Row(2).Cell(col.ColumnNumber()).Value.ToString(), out double is_number) ?
XLCellValues.Number :
XLCellValues.Text;
}
catch
{
col.Cells(2, worksheet.LastRowUsed().RowNumber()).DataType = XLCellValues.Text;
}
}
}
}

public void SaveToExcel(string filename)
{
workbook.SaveAs(filename);
}
}
Expand Down
32 changes: 32 additions & 0 deletions ProteoformSuiteGUI/DisplayObjects/DisplayExperimentalProteoform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace ProteoformSuiteGUI
{
public class DisplayExperimentalProteoform : DisplayObject
{

#region Public Constructors

public DisplayExperimentalProteoform(ExperimentalProteoform e)
Expand Down Expand Up @@ -63,6 +64,16 @@ public int observation_count
get { return e.aggregated_components.Count; }
}

public int light_verification_count
{
get { return e.lt_verification_components.Count; }
}

public int heavy_verification_count
{
get { return e.hv_verification_components.Count; }
}

public int light_observation_count
{
get { return e.lt_quant_components.Count; }
Expand All @@ -87,6 +98,21 @@ public string gene_name
"";
}
}

public string manual_validation_id
{
get { return e.manual_validation_id; }
}

public string manual_validation_verification
{
get { return e.manual_validation_verification; }
}

public string manual_validation_quant
{
get { return e.manual_validation_quant; }
}

#endregion Public Properties

Expand All @@ -110,17 +136,23 @@ public static void FormatAggregatesTable(DataGridView dgv)
dgv.Columns[nameof(agg_intensity)].HeaderText = "Aggregated Intensity";
dgv.Columns[nameof(agg_rt)].HeaderText = "Aggregated RT";
dgv.Columns[nameof(observation_count)].HeaderText = "Aggregated Component Count for Identification";
dgv.Columns[nameof(heavy_verification_count)].HeaderText = "Heavy Verification Component Count";
dgv.Columns[nameof(light_verification_count)].HeaderText = "Light Verification Component Count";
dgv.Columns[nameof(heavy_observation_count)].HeaderText = "Heavy Quantitative Component Count";
dgv.Columns[nameof(light_observation_count)].HeaderText = "Light Quantitative Component Count";
dgv.Columns[nameof(lysine_count)].HeaderText = "Lysine Count";
dgv.Columns[nameof(mass_shifted)].HeaderText = "Manually Shifted Mass";
dgv.Columns[nameof(ptm_description)].HeaderText = "PTM Description";
dgv.Columns[nameof(gene_name)].HeaderText = "Gene Name";
dgv.Columns[nameof(manual_validation_id)].HeaderText = "Abundant Component for Manual Validation of Identification";
dgv.Columns[nameof(manual_validation_verification)].HeaderText = "Abundant Component for Manual Validation of Identification Verification";
dgv.Columns[nameof(manual_validation_quant)].HeaderText = "Abundant Component for Manual Validation of Quantification";

//VISIBILITY
dgv.Columns[nameof(lysine_count)].Visible = SaveState.lollipop.neucode_labeled;
}

#endregion

}
}
43 changes: 42 additions & 1 deletion ProteoformSuiteGUI/DisplayObjects/DisplayProteoformRelation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,16 @@ public string accession_1
}
}

public string manual_validation_id_1
{
get
{
return connected_proteoforms[0] as ExperimentalProteoform != null ?
((ExperimentalProteoform)connected_proteoforms[0]).manual_validation_id :
"";
}
}


// For DataGridView display of proteform2
public double proteoform_mass_2
Expand Down Expand Up @@ -190,6 +200,16 @@ public string accession_2
}
}

public string manual_validation_id_2
{
get
{
return connected_proteoforms[1] as ExperimentalProteoform != null ?
((ExperimentalProteoform)connected_proteoforms[1]).manual_validation_id :
"";
}
}

public string Name
{
get
Expand Down Expand Up @@ -272,9 +292,11 @@ public static void FormatRelationsGridView(DataGridView dgv, bool mask_experimen
dgv.Columns[nameof(proteoform_mass_1)].HeaderText = "Experimental Aggregated Proteoform Mass";
dgv.Columns[nameof(agg_intensity_1)].HeaderText = "Experimental Aggregated Intensity";
dgv.Columns[nameof(agg_RT_1)].HeaderText = "Experimental Aggregated RT";
dgv.Columns[nameof(manual_validation_id_1)].HeaderText = "Abundant Exp. Component for Manual Validation";
dgv.Columns[nameof(agg_intensity_2)].Visible = false;
dgv.Columns[nameof(agg_RT_2)].Visible = false;
dgv.Columns[nameof(num_observations_2)].Visible = false;
dgv.Columns[nameof(manual_validation_id_2)].Visible = false;
dgv.Columns[nameof(RelationType)].Visible = false;
}

Expand All @@ -291,16 +313,35 @@ public static void FormatRelationsGridView(DataGridView dgv, bool mask_experimen
dgv.Columns[nameof(accession_2)].HeaderText = "Light Experimental Accession";
dgv.Columns[nameof(proteoform_mass_1)].HeaderText = "Heavy Experimental Aggregated Mass";
dgv.Columns[nameof(proteoform_mass_2)].HeaderText = "Light Experimental Aggregated Mass";
dgv.Columns[nameof(manual_validation_id_1)].HeaderText = "Heavy Abundant Exp. Component for Manual Validation";
dgv.Columns[nameof(manual_validation_id_2)].HeaderText = "Light Abundant Exp. Component for Manual Validation";
dgv.Columns[nameof(RelationType)].Visible = false;
dgv.Columns[nameof(Name)].Visible = false;
dgv.Columns[nameof(Fragment)].Visible = false;
}

//ProteoformFamilies formatting
dgv.Columns[nameof(RelationType)].HeaderText = "Relation Type";
if (!mask_experimental && !mask_theoretical)
{
dgv.Columns[nameof(num_observations_2)].HeaderText = "Number Observations #2";
dgv.Columns[nameof(num_observations_1)].HeaderText = "Number Observations #1";
dgv.Columns[nameof(agg_intensity_2)].HeaderText = "Intensity #2";
dgv.Columns[nameof(agg_intensity_1)].HeaderText = "Intensity #1";
dgv.Columns[nameof(agg_RT_1)].HeaderText = "Aggregated RT #1";
dgv.Columns[nameof(agg_RT_2)].HeaderText = "Aggregated RT #2";
dgv.Columns[nameof(accession_1)].HeaderText = "Accession #1";
dgv.Columns[nameof(accession_2)].HeaderText = "Accession #2";
dgv.Columns[nameof(proteoform_mass_1)].HeaderText = "Proteoform Mass #1";
dgv.Columns[nameof(proteoform_mass_2)].HeaderText = "Proteoform Mass #2";
dgv.Columns[nameof(manual_validation_id_1)].HeaderText = "Abundant Exp. Component for Manual Validation #1";
dgv.Columns[nameof(manual_validation_id_2)].HeaderText = "Abundant Exp. Component for Manual Validation #2";
dgv.Columns[nameof(RelationType)].HeaderText = "Relation Type";
}

//making these columns invisible
dgv.Columns[nameof(LysineCount)].Visible = SaveState.lollipop.neucode_labeled;
}
#endregion

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public decimal TestStatistic
get { return qval.testStatistic; }
}

public string manual_validation_quant
{
get { return qval.proteoform.manual_validation_quant; }
}

#endregion Public Properties

#region Public Methods
Expand Down Expand Up @@ -108,7 +113,8 @@ public static void FormatGridView(DataGridView dgv)
dgv.Columns[nameof(LogFoldChange)].HeaderText = "Log2 Fold Change";
dgv.Columns[nameof(pValue)].HeaderText = "p-value (by randomization test)";
dgv.Columns[nameof(TestStatistic)].HeaderText = "Student's t-Test Statistic";
}
dgv.Columns[nameof(manual_validation_quant)].HeaderText = "Abundant Component for Manual Validation of Quantification";
}

#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public string OriginalID
get { return m.original_modification.id; }
}

public string Mass
public double Mass
{
get { return m.mass.ToString(); }
get { return m.mass; }
}

public string ID
Expand All @@ -47,6 +47,18 @@ public int PtmCount
set { m.ptm_count = value; }
}

public bool require_proteoform_without_mod
{
get { return m.require_proteoform_without_mod; }
set { m.require_proteoform_without_mod = value; }
}

public int PtmRank
{
get { return m.ptm_rank; }
set { m.ptm_rank = value; }
}

#endregion Public Properties

#region Public Methods
Expand All @@ -61,6 +73,8 @@ public static void FormatUnlocalizedModificationTable(DataGridView dgv)
dgv.Columns[nameof(OriginalID)].HeaderText = "Original ID";
dgv.Columns[nameof(ID)].HeaderText = "New ID";
dgv.Columns[nameof(PtmCount)].HeaderText = "Num. PTMs Represented";
dgv.Columns[nameof(require_proteoform_without_mod)].HeaderText = "Require Proteoform Without This Modification";
dgv.Columns[nameof(PtmRank)].HeaderText = "Frequency-Based Rank of PTM Mass";

//EDITABILITY
dgv.Columns[nameof(OriginalID)].ReadOnly = true;
Expand Down
Loading

0 comments on commit 0148625

Please sign in to comment.