Skip to content

Commit

Permalink
Merge pull request #479 from acesnik/master
Browse files Browse the repository at this point in the history
Bug fixes and nice notifications.
  • Loading branch information
Anthony authored Dec 15, 2017
2 parents bd5545f + 8011fa3 commit 32e1928
Show file tree
Hide file tree
Showing 17 changed files with 1,907 additions and 94 deletions.
4 changes: 3 additions & 1 deletion ProteoformSuiteGUI/DisplayObjects/DisplayGoTermNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace ProteoformSuiteGUI
{
public class DisplayGoTermNumber : DisplayObject
{

#region Public Constructors

public DisplayGoTermNumber(GoTermNumber g)
Expand Down Expand Up @@ -48,7 +49,7 @@ public string ID

public double p_value
{
get { return gtn.by; }
get { return gtn.p_value; }
}

public double by //benjamini yekutieli calculated after all p-values are calculated
Expand Down Expand Up @@ -138,5 +139,6 @@ private static string number_format(string property_name)
}

#endregion Private Methods

}
}
10 changes: 10 additions & 0 deletions ProteoformSuiteGUI/DisplayUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@ public static DataTable FormatTable(List<DisplayObject> display_objects, IEnumer
return dt;
}

public static bool CheckForProteinFastas(ComboBox cmb, IEnumerable<string> files)
{
if (Lollipop.file_filters[cmb.SelectedIndex].Contains(".fasta") && files.Any(x => x.Contains(".fasta")))
{
MessageBox.Show("Usage of protein fasta files is not yet enabled. Please use a protein XML file for now, e.g. from UniProt. (See this site for more information, and let us know there if this is an issue for you: https://github.com/smith-chem-wisc/ProteoformSuite/issues/477.)", "Load Files Message");
return true;
}
return false;
}

#endregion Public Methods

}
Expand Down
2 changes: 2 additions & 0 deletions ProteoformSuiteGUI/LoadDeconvolutionResults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ private void dgv_quantResults_DragEnter(object sender, DragEventArgs e)
private void drag_drop(DragEventArgs e, ComboBox cmb, DataGridView dgv)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (DisplayUtility.CheckForProteinFastas(cmb, files)) return; // todo: implement protein fasta usage
Sweet.lollipop.enter_input_files(files, Lollipop.acceptable_extensions[cmb.SelectedIndex], Lollipop.file_types[cmb.SelectedIndex], Sweet.lollipop.input_files, true);
match_files();
DisplayUtility.FillDataGridView(dgv, Sweet.lollipop.get_files(Sweet.lollipop.input_files, Lollipop.file_types[cmb.SelectedIndex]).Select(f => new DisplayInputFile(f)));
Expand Down Expand Up @@ -295,6 +296,7 @@ private void add_files(ComboBox cmb, DataGridView dgv)
DialogResult dr = openFileDialog.ShowDialog();
if (dr == DialogResult.OK)
{
if (DisplayUtility.CheckForProteinFastas(cmb, openFileDialog.FileNames)) return; // todo: implement protein fasta usage
Sweet.lollipop.enter_input_files(openFileDialog.FileNames, Lollipop.acceptable_extensions[cmb.SelectedIndex], Lollipop.file_types[cmb.SelectedIndex], Sweet.lollipop.input_files, true);
match_files();
}
Expand Down
53 changes: 25 additions & 28 deletions ProteoformSuiteGUI/ProteoformFamilies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ public partial class ProteoformFamilies : Form, ISweetForm
public ProteoformFamilies()
{
InitializeComponent();

//Initialize display options
cmbx_colorScheme.Items.AddRange(CytoscapeScript.color_scheme_names);
cmbx_nodeLayout.Items.AddRange(Lollipop.node_positioning);
cmbx_nodeLabelPositioning.Items.AddRange(CytoscapeScript.node_label_positions);
cmbx_edgeLabel.Items.AddRange(Lollipop.edge_labels);
cmbx_nodeLabel.Items.AddRange(Lollipop.node_labels);
cmbx_geneLabel.Items.AddRange(Lollipop.gene_name_labels.ToArray());
cmbx_tableSelector.Items.AddRange(table_names);

cmbx_colorScheme.SelectedIndex = 1;
cmbx_nodeLayout.SelectedIndex = 1;
cmbx_nodeLabelPositioning.SelectedIndex = 0;
cmbx_edgeLabel.SelectedIndex = 1;
cmbx_nodeLabel.SelectedIndex = 1;
cmbx_geneLabel.SelectedIndex = 1;

InitializeParameterSet();
this.AutoScroll = true;
this.AutoScrollMinSize = this.ClientSize;
Expand Down Expand Up @@ -43,21 +60,6 @@ public void initialize_every_time()

public void InitializeParameterSet()
{
//Initialize display options
cmbx_colorScheme.Items.AddRange(CytoscapeScript.color_scheme_names);
cmbx_nodeLayout.Items.AddRange(Lollipop.node_positioning);
cmbx_nodeLabelPositioning.Items.AddRange(CytoscapeScript.node_label_positions);
cmbx_edgeLabel.Items.AddRange(Lollipop.edge_labels);
cmbx_nodeLabel.Items.AddRange(Lollipop.node_labels);
cmbx_geneLabel.Items.AddRange(Lollipop.gene_name_labels.ToArray());
cmbx_tableSelector.Items.AddRange(table_names);

cmbx_colorScheme.SelectedIndex = 1;
cmbx_nodeLayout.SelectedIndex = 1;
cmbx_nodeLabelPositioning.SelectedIndex = 0;
cmbx_edgeLabel.SelectedIndex = 1;
cmbx_nodeLabel.SelectedIndex = 1;
cmbx_geneLabel.SelectedIndex = 1;
Lollipop.preferred_gene_label = cmbx_geneLabel.SelectedItem.ToString();
Lollipop.gene_centric_families = cb_geneCentric.Checked;

Expand Down Expand Up @@ -123,22 +125,17 @@ public void ClearListsTablesFigures(bool clear_following)
}
}

/// <summary>
/// generate report and change selected table names based on # decoy communities
/// </summary>
public void update_figures_of_merit()
{
rtb_proteoformFamilyResults.Text = ResultsSummaryGenerator.proteoform_families_report();

//change selected table names based on # decoy communities
int decoy_communities = Sweet.lollipop.decoy_proteoform_communities.Count;
for(int i = 0; i < decoy_communities; i++)
{
if (!cmbx_tableSelector.Items.Contains("Decoy Community " + i)) cmbx_tableSelector.Items.Add("Decoy Community " + i);
}

//if more items than decoy databases, remove later ones //FIX
while(cmbx_tableSelector.Items.Count - 5 - decoy_communities > 0)
{
cmbx_tableSelector.Items.RemoveAt(5 + decoy_communities);
}
int selection = cmbx_tableSelector.SelectedIndex;
cmbx_tableSelector.Items.Clear();
cmbx_tableSelector.Items.AddRange(table_names);
cmbx_tableSelector.Items.AddRange(Enumerable.Range(0, Sweet.lollipop.decoy_proteoform_communities.Count).Select(i => "Decoy Community " + i).ToArray());
cmbx_tableSelector.SelectedIndex = selection < cmbx_tableSelector.Items.Count ? selection : 0;
}

#endregion Public Methods
Expand Down
8 changes: 4 additions & 4 deletions ProteoformSuiteGUI/ProteoformSweet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private bool load_method()
string method_filename = methodFileOpen.FileName;
DialogResult d4 = MessageBox.Show("Add files at the listed paths if they still exist?", "Full Run", MessageBoxButtons.YesNoCancel);
if (d4 == DialogResult.Cancel) return false;
if (!open_method(File.ReadAllLines(method_filename), d4 == DialogResult.Yes))
if (!open_method(method_filename, File.ReadAllLines(method_filename), d4 == DialogResult.Yes))
{
MessageBox.Show("Method file was not loaded succesffully.");
return false;
Expand All @@ -223,9 +223,9 @@ private bool load_method()
return false;
}

public bool open_method(string[] lines, bool add_files)
public bool open_method(string methodFilePath, string[] lines, bool add_files)
{
bool method_file_success = Sweet.open_method(String.Join(Environment.NewLine, lines), add_files, out string warning);
bool method_file_success = Sweet.open_method(methodFilePath, String.Join(Environment.NewLine, lines), add_files, out string warning);
if (warning.Length > 0 && MessageBox.Show("WARNING" + Environment.NewLine + Environment.NewLine + warning, "Open Method", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
return false;
foreach (ISweetForm form in forms) form.InitializeParameterSet();
Expand All @@ -246,7 +246,7 @@ public Stopwatch full_run()
DialogResult d4 = MessageBox.Show("Add files at the listed paths if they still exist?", "Full Run", MessageBoxButtons.YesNoCancel);
if (d4 == DialogResult.Cancel) return null;

if (!open_method(File.ReadAllLines(filepath), d4 == DialogResult.Yes))
if (!open_method(filepath, File.ReadAllLines(filepath), d4 == DialogResult.Yes))
{
MessageBox.Show("Error in method file. Generate a new method file.");
return null;
Expand Down
38 changes: 19 additions & 19 deletions ProteoformSuiteGUI/Quantification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ public Quantification()
InitializeComponent();
this.AutoScroll = true;
this.AutoScrollMinSize = this.ClientSize;

//Initialize display options
cmbx_volcanoChartSelection.Items.AddRange(volcano_selections);
cmbx_colorScheme.Items.AddRange(CytoscapeScript.color_scheme_names);
cmbx_nodeLayout.Items.AddRange(Lollipop.node_positioning);
cmbx_nodeLabelPositioning.Items.AddRange(CytoscapeScript.node_label_positions);
cmbx_edgeLabel.Items.AddRange(Lollipop.edge_labels.ToArray());
cmbx_nodeLabel.Items.AddRange(Lollipop.node_labels.ToArray());
cmbx_geneLabel.Items.AddRange(Lollipop.gene_name_labels.ToArray());
cb_redBorder.Checked = true;
cb_boldLabel.Checked = true;

cmbx_volcanoChartSelection.SelectedIndex = 0;
cmbx_colorScheme.SelectedIndex = 1;
cmbx_nodeLayout.SelectedIndex = 1;
cmbx_nodeLabelPositioning.SelectedIndex = 0;
cmbx_geneLabel.SelectedIndex = 1;
cmbx_nodeLabel.SelectedIndex = 1;
cmbx_edgeLabel.SelectedIndex = 1;
}

#endregion Constructor
Expand Down Expand Up @@ -201,29 +220,10 @@ public void InitializeConditionsParameters()
Sweet.lollipop.numerator_condition = cmbx_ratioNumerator.SelectedItem.ToString();
Sweet.lollipop.denominator_condition = cmbx_ratioDenominator.SelectedItem.ToString();
Sweet.lollipop.induced_condition = cmbx_inducedCondition.SelectedItem.ToString();
cmbx_edgeLabel.Items.AddRange(Lollipop.edge_labels);
}

public void InitializeParameterSet()
{
//Initialize display options
cmbx_volcanoChartSelection.Items.AddRange(volcano_selections);
cmbx_colorScheme.Items.AddRange(CytoscapeScript.color_scheme_names);
cmbx_nodeLayout.Items.AddRange(Lollipop.node_positioning);
cmbx_nodeLabelPositioning.Items.AddRange(CytoscapeScript.node_label_positions);
cmbx_edgeLabel.Items.AddRange(Lollipop.edge_labels.ToArray());
cmbx_nodeLabel.Items.AddRange(Lollipop.node_labels.ToArray());
cmbx_geneLabel.Items.AddRange(Lollipop.gene_name_labels.ToArray());
cb_redBorder.Checked = true;
cb_boldLabel.Checked = true;

cmbx_volcanoChartSelection.SelectedIndex = 0;
cmbx_colorScheme.SelectedIndex = 1;
cmbx_nodeLayout.SelectedIndex = 1;
cmbx_nodeLabelPositioning.SelectedIndex = 0;
cmbx_geneLabel.SelectedIndex = 1;
cmbx_nodeLabel.SelectedIndex = 1;
cmbx_edgeLabel.SelectedIndex = 1;
Lollipop.preferred_gene_label = cmbx_geneLabel.SelectedItem.ToString();
Lollipop.gene_centric_families = cb_geneCentric.Checked;

Expand Down
25 changes: 20 additions & 5 deletions ProteoformSuiteGUI/TheoreticalDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@ private void TheoreticalDatabase_Load(object sender, EventArgs e)
initial_load = false;
}

private void set_Make_Database_Button()
private bool SetMakeDatabaseButton()
{
bool ready_to_run = ReadyToRunTheGamut();
btn_downloadUniProtPtmList.Enabled = !ready_to_run && Sweet.lollipop.get_files(Sweet.lollipop.input_files, Purpose.PtmList).Count() == 0;
btn_Make_Databases.Enabled = ready_to_run;
return ready_to_run;
}

private void btn_Make_Databases_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -278,7 +279,10 @@ private void cb_limitLargePtmSets_CheckedChanged(object sender, EventArgs e)
private void dgv_loadFiles_DragDrop(object sender, DragEventArgs e)
{
drag_drop(e, cmb_loadTable, dgv_loadFiles);
set_Make_Database_Button();
if (!SetMakeDatabaseButton() && Sweet.lollipop.get_files(Sweet.lollipop.input_files, Purpose.ProteinDatabase).Count() > 0)
{
MessageBox.Show("You still need a PTM list. Please use the \"Donwload UniProt PTM List\" button.", "Enabling Make Database Button");
}
}

private void dgv_loadFiles_DragEnter(object sender, DragEventArgs e)
Expand All @@ -289,6 +293,7 @@ private void dgv_loadFiles_DragEnter(object sender, DragEventArgs e)
private void drag_drop(DragEventArgs e, ComboBox cmb, DataGridView dgv)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
if (DisplayUtility.CheckForProteinFastas(cmb, files)) return; // todo: implement protein fasta usage
Sweet.lollipop.enter_input_files(files, Lollipop.acceptable_extensions[cmb.SelectedIndex], Lollipop.file_types[cmb.SelectedIndex], Sweet.lollipop.input_files, true);
DisplayUtility.FillDataGridView(dgv, Sweet.lollipop.get_files(Sweet.lollipop.input_files, Lollipop.file_types[cmb.SelectedIndex]).Select(f => new DisplayInputFile(f)));
DisplayInputFile.FormatInputFileTable(dgv, Lollipop.file_types[cmb.SelectedIndex]);
Expand All @@ -302,7 +307,10 @@ public void reload_database_list()
DisplayUtility.FillDataGridView(dgv_loadFiles, Sweet.lollipop.get_files(Sweet.lollipop.input_files, Lollipop.file_types[cmb_loadTable.SelectedIndex]).Select(f => new DisplayInputFile(f)));
DisplayInputFile.FormatInputFileTable(dgv_loadFiles, Lollipop.file_types[cmb_loadTable.SelectedIndex]);
initialize_table_bindinglist();
set_Make_Database_Button();
if (!SetMakeDatabaseButton() && Sweet.lollipop.get_files(Sweet.lollipop.input_files, Purpose.ProteinDatabase).Count() > 0)
{
MessageBox.Show("You still need a PTM list. Please use the \"Donwload UniProt PTM List\" button.", "Enabling Make Database Button");
}
}

private void tb_tableFilter_TextChanged(object sender, EventArgs e)
Expand All @@ -326,6 +334,7 @@ private void btn_downloadUniProtPtmList_Click(object sender, EventArgs e)
DisplayUtility.FillDataGridView(dgv_loadFiles, Sweet.lollipop.get_files(Sweet.lollipop.input_files, Lollipop.file_types[cmb_loadTable.SelectedIndex]).Select(f => new DisplayInputFile(f)));
DisplayInputFile.FormatInputFileTable(dgv_loadFiles, Lollipop.file_types[cmb_loadTable.SelectedIndex]);
btn_downloadUniProtPtmList.Enabled = false;
SetMakeDatabaseButton();
}

#endregion LOAD DATABASES GRID VIEW Private Methods
Expand All @@ -341,11 +350,17 @@ private void btn_addFiles_Click(object sender, EventArgs e)

DialogResult dr = openFileDialog.ShowDialog();
if (dr == DialogResult.OK)
{
if (DisplayUtility.CheckForProteinFastas(cmb_loadTable, openFileDialog.FileNames)) return; // todo: implement protein fasta usage
Sweet.lollipop.enter_input_files(openFileDialog.FileNames, Lollipop.acceptable_extensions[cmb_loadTable.SelectedIndex], Lollipop.file_types[cmb_loadTable.SelectedIndex], Sweet.lollipop.input_files, true);
}

DisplayUtility.FillDataGridView(dgv_loadFiles, Sweet.lollipop.get_files(Sweet.lollipop.input_files, Lollipop.file_types[cmb_loadTable.SelectedIndex]).Select(f => new DisplayInputFile(f)));
DisplayInputFile.FormatInputFileTable(dgv_loadFiles, Lollipop.file_types[cmb_loadTable.SelectedIndex]);
set_Make_Database_Button();
if (!SetMakeDatabaseButton() && Sweet.lollipop.get_files(Sweet.lollipop.input_files, Purpose.ProteinDatabase).Count() > 0)
{
MessageBox.Show("You still need a PTM list. Please use the \"Donwload UniProt PTM List\" button.", "Enabling Make Database Button");
}
}

private void btn_clearFiles_Click(object sender, EventArgs e)
Expand All @@ -355,7 +370,7 @@ private void btn_clearFiles_Click(object sender, EventArgs e)
Sweet.lollipop.input_files = Sweet.lollipop.input_files.Except(files_to_remove).ToList();
DisplayUtility.FillDataGridView(dgv_loadFiles, Sweet.lollipop.get_files(Sweet.lollipop.input_files, Lollipop.file_types[cmb_loadTable.SelectedIndex]).Select(f => new DisplayInputFile(f)));
DisplayInputFile.FormatInputFileTable(dgv_loadFiles, Lollipop.file_types[cmb_loadTable.SelectedIndex]);
set_Make_Database_Button();
SetMakeDatabaseButton();
}

#endregion ADD/CLEAR Private Methods
Expand Down
10 changes: 8 additions & 2 deletions ProteoformSuiteInternal/ComponentReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ public List<Component> remove_monoisotopic_duplicates_harmonics_from_same_scan(L
foreach (double missedMonoMass in possibleMissedMonoisotopicsList)
{
double massTolerance = missedMonoMass / 1000000d * Sweet.lollipop.raw_component_mass_tolerance;
List<Component> missedMonoisotopics = scanComps.Where(cp => !removeThese.Contains(cp) && cp.weighted_monoisotopic_mass >= (missedMonoMass - massTolerance) && cp.weighted_monoisotopic_mass <= (missedMonoMass + massTolerance)).ToList(); // this is a list of harmonics to hc
List<Component> missedMonoisotopics = scanComps.Where(cp =>
!removeThese.Contains(cp)
&& cp.weighted_monoisotopic_mass >= (missedMonoMass - massTolerance)
&& cp.weighted_monoisotopic_mass <= (missedMonoMass + massTolerance)).ToList(); // this is a list of harmonics to hc

foreach (Component c in missedMonoisotopics.Where(m => m.id != sc.id).ToList())
{
Expand Down Expand Up @@ -164,7 +167,10 @@ public List<Component> remove_monoisotopic_duplicates_harmonics_from_same_scan(L
foreach (double harmonicMass in possibleHarmonicList)
{
double massTolerance = harmonicMass / 1000000d * Sweet.lollipop.raw_component_mass_tolerance;
List<Component> harmonics = scanComps.Where(cp => !removeThese.Contains(cp) && cp.weighted_monoisotopic_mass >= (harmonicMass - massTolerance) && cp.weighted_monoisotopic_mass <= (harmonicMass + massTolerance)).ToList(); // this is a list of harmonics to hc
List<Component> harmonics = scanComps.Where(cp =>
!removeThese.Contains(cp)
&& cp.weighted_monoisotopic_mass >= (harmonicMass - massTolerance)
&& cp.weighted_monoisotopic_mass <= (harmonicMass + massTolerance)).ToList(); // this is a list of harmonics to hc
List<Component> someHarmonics = harmonics.Where(harmonicComponent => harmonicComponent.id != hc.id).ToList();
foreach (Component h in someHarmonics) // now that we have a list of harmonics to hc, we have to figure out what to do with them
{
Expand Down
2 changes: 1 addition & 1 deletion ProteoformSuiteInternal/CytoscapeScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ public static void write_styles(List<ProteoformFamily> all_families, string styl
writer.WriteEndElement();

//NODE PROPERTIES
double max_total_intensity = quantitative != null ?
double max_total_intensity = all_families.Count == 0 ? 0 : quantitative != null ?
(double)all_families.SelectMany(f => f.experimental_proteoforms).Max(p => p.quant.intensitySum) :
all_families.SelectMany(f => f.experimental_proteoforms).Max(p => p.agg_intensity);
writer.WriteStartElement("node");
Expand Down
Loading

0 comments on commit 32e1928

Please sign in to comment.