public Data_line_class Deep_copy() { Data_line_class copy = (Data_line_class)this.MemberwiseClone(); copy.NCBI_official_symbol = (string)this.NCBI_official_symbol.Clone(); copy.Columns = Deep_copy_columns(); return(copy); }
public void Order_columns_in_standard_way() { int[] old_new_index = ColChar.Order_columns_in_standard_way_and_get_old_new_index_array(); int data_length = Data.Length; int columns_length = ColChar.Columns_length; Data_line_class[] ordered_data = new Data_line_class[data_length]; Data_line_class data_line; for (int indexD = 0; indexD < data_length; indexD++) { data_line = Data[indexD]; data_line.Rearrange_columns(old_new_index); } ColChar.Column_rearrangements_adopted = true; }
public void Sum_values_to_this_in_consideration_of_empty_entry(Data_line_class other) { int columns_length = Columns_length; for (int indexC = 0; indexC < columns_length; indexC++) { if ((this.Columns[indexC] != Empty_entry) && (other.Columns[indexC] != Empty_entry)) { this.Columns[indexC] += other.Columns[indexC]; } else if (other.Columns[indexC] != Empty_entry) { this.Columns[indexC] = other.Columns[indexC]; } } }
public void Add_to_data_instance(IAdd_to_data[] add_data) { int old_columns_length = ColChar.Columns_length; int add_data_length = add_data.Length; IAdd_to_data add_data_interface_line; #region Analyze, if new columns needed and add to colChar add_data = add_data.OrderBy(l => l.EntryType_for_data).ThenBy(l => l.Timepoint_for_data).ThenBy(l => l.SampleName_for_data).ToArray(); List <Colchar_column_line_class> colChar_column_list = new List <Colchar_column_line_class>(); Colchar_column_line_class colChar_column_line; for (int indexAdd = 0; indexAdd < add_data_length; indexAdd++) { add_data_interface_line = add_data[indexAdd]; if ((indexAdd == 0) || (!add_data_interface_line.EntryType_for_data.Equals(add_data[indexAdd - 1].EntryType_for_data)) || (!add_data_interface_line.Timepoint_for_data.Equals(add_data[indexAdd - 1].Timepoint_for_data)) || (!add_data_interface_line.SampleName_for_data.Equals(add_data[indexAdd - 1].SampleName_for_data))) { colChar_column_line = new Colchar_column_line_class(); colChar_column_line.EntryType = add_data_interface_line.EntryType_for_data; colChar_column_line.Timepoint = add_data_interface_line.Timepoint_for_data; colChar_column_line.SampleName = (string)add_data_interface_line.SampleName_for_data.Clone(); colChar_column_list.Add(colChar_column_line); } } ColChar.Identify_new_columns_and_add_at_right_site(colChar_column_list.ToArray()); int new_columns_length = ColChar.Columns.Length; #endregion int data_length = this.Data_length; Data_line_class data_line; #region Extend data lines by adding zero values at right site float[] new_columns; for (int indexD = 0; indexD < data_length; indexD++) { data_line = this.Data[indexD]; new_columns = new float[new_columns_length]; for (int indexOld = 0; indexOld < old_columns_length; indexOld++) { new_columns[indexOld] = data_line.Columns[indexOld]; } data_line.Columns = new_columns.ToArray(); } #endregion #region Add to data and generate ordered data add lines to data add_data = add_data.OrderBy(l => l.NCBI_official_symbol_for_data).ThenBy(l => l.EntryType_for_data).ThenBy(l => l.SampleName_for_data).ToArray(); int indexColumn; int indexData = 0; int stringCompare; Data_line_class new_data_line; List <Data_line_class> add_lines_to_data_list = new List <Data_line_class>(); int indexCol = -1; for (int indexAdd = 0; indexAdd < add_data_length; indexAdd++) { add_data_interface_line = add_data[indexAdd]; indexColumn = ColChar.Get_columnIndex(add_data_interface_line); stringCompare = -2; while ((indexData < data_length) && (stringCompare < 0)) { data_line = Data[indexData]; stringCompare = data_line.NCBI_official_symbol.CompareTo(add_data_interface_line.NCBI_official_symbol_for_data); if (stringCompare < 0) { indexData++; } else if (stringCompare == 0) { indexCol = ColChar.Get_columnIndex(add_data_interface_line); data_line.Add_to_this_line_after_checking_if_this_line_has_empty_entry(add_data_interface_line, indexCol); } } if (stringCompare != 0) { new_data_line = new Data_line_class(add_data_interface_line.NCBI_official_symbol_for_data, new_columns_length); new_data_line.Columns[indexColumn] = add_data_interface_line.Value_for_data; add_lines_to_data_list.Add(new_data_line); } } Data_line_class[] add_lines_to_data = add_lines_to_data_list.OrderBy(l => l.NCBI_official_symbol).ToArray(); #endregion #region Combine add_lines_to_data to generate final add_data_lines int add_lines_length = add_lines_to_data.Length; int firstIndex_same_rowName = -1; Data_line_class add_data_line; Data_line_class inner_add_data_line; List <Data_line_class> final_add_data_list = new List <Data_line_class>(); for (int indexAL = 0; indexAL < add_lines_length; indexAL++) { add_data_line = add_lines_to_data[indexAL]; if ((indexAL == 0) || (!add_data_line.NCBI_official_symbol.Equals(add_lines_to_data[indexAL - 1].NCBI_official_symbol))) { firstIndex_same_rowName = indexAL; } if ((indexAL == add_lines_length - 1) || (!add_data_line.NCBI_official_symbol.Equals(add_lines_to_data[indexAL + 1].NCBI_official_symbol))) { for (int indexInner = firstIndex_same_rowName; indexInner < indexAL; indexInner++) { inner_add_data_line = add_lines_to_data[indexInner]; add_data_line.Sum_values_to_this_in_consideration_of_empty_entry(inner_add_data_line); } final_add_data_list.Add(add_data_line); } } #endregion #region Add final data line to data int final_data_length = final_add_data_list.Count; int new_data_length = final_data_length + data_length; Data_line_class[] new_data = new Data_line_class[new_data_length]; int indexNew = -1; for (int indexOld = 0; indexOld < data_length; indexOld++) { indexNew++; new_data[indexNew] = Data[indexOld]; } for (int indexFinal = 0; indexFinal < final_data_length; indexFinal++) { indexNew++; new_data[indexNew] = final_add_data_list[indexFinal]; } Data = new_data; #endregion Keep_only_lines_that_contain_at_least_one_non_zero_value(); }
public Data_class() { ColChar = new Colchar_class(); Data = new Data_line_class[0]; }