private bool CheckSinglePlateSequential(PlateInfo plateInfo, ref string errMsg) { //var cellPositions = plateInfo.BarcodeDefinitions.Keys.ToList(); var cellPositions = plateInfo.BarcodeDefinitions.Where(x => x.Value != "").Select(x => x.Key).ToList(); var wellIDs = cellPositions.Select(x => x.WellID); if (wellIDs.Count() == 0) { return(true); } HashSet <int> allIDs = new HashSet <int>(wellIDs); int minWellID = wellIDs.Min(); int maxWellID = wellIDs.Max(); for (int id = minWellID; id < maxWellID; id++) { if (!allIDs.Contains(id)) { errMsg = string.Format("位于{0}处的样品缺失!", new CellPosition(id - 1).AlphaInteger); return(false); } } return(true); }
private void lstboxPlates_SelectionChanged(object sender, SelectionChangedEventArgs e) { SetHint(""); lstAssays.SelectedIndex = -1; dataGridView.ClearSelection(); Utility.SaveDataGridView(dataGridView, curPlateInfo); curPlateInfo = (PlateInfo)lstboxPlates.SelectedItem; txtCheckDoc.DataContext = curPlateInfo; Utility.InitDataGridView(dataGridView, curPlateInfo.BarcodeDefinitions.Count); Utility.UpdateDataGridView(dataGridView, curPlateInfo); int totalWell = curPlateInfo.MaxWellID; bool bok = false; string errMsg = ""; foreach (var pair in curPlateInfo.PredefinedBarcodes) { if (pair.Key.WellID <= totalWell) { var cell = dataGridView.Rows[pair.Key.rowIndex].Cells[pair.Key.colIndex]; bok = CheckConsist(pair.Key, cell, ref errMsg); } } Trace.WriteLine(string.Format("Selection changed to plate: {0}", curPlateInfo.Name)); }
private void AddPlate() { SetHint(""); QueryName queryNameForm = new QueryName(plates.Select(x => x.Name).ToList()); var result = queryNameForm.ShowDialog(); if (!(bool)result) { return; } string newPlateName = queryNameForm.PlateName; if (AlreadyExist(newPlateName)) { SetHint(string.Format("板名为:{0}的微孔板已经存在!", newPlateName)); return; } PlateInfo newPlateInfo = new PlateInfo(newPlateName, queryNameForm.SelectedFormat, queryNameForm.PredefinedBarcodes); Trace.WriteLine(string.Format("Create new plate:{0}, assay: {1}", newPlateName, queryNameForm.SelectedFormat)); plates.Add(newPlateInfo); lstboxPlates.SelectedIndex = plates.Count - 1; }
private void ParseSample(string line, PlateInfo plateInfo) { List <string> strs = line.Split('\t').ToList(); if (strs.All(x => x == "")) { return; } string well = strs[0]; string sampleName = strs[1]; CellPosition cellPosition = new CellPosition(well); if (!plateInfo.IsWholePlate)//only 48 position { if (cellPosition.WellID > 48) { return; } } string sAssay = strs[2]; if (sAssay != "") { assayName = sAssay; } plateInfo.BarcodeDefinitions[cellPosition] = sampleName; }
static public void UpdateDataGridView(DataGridView dataGridView, PlateInfo plateInfo) { foreach (KeyValuePair <CellPosition, string> pair in plateInfo.BarcodeDefinitions) { CellPosition cellPos = pair.Key; string barcode = pair.Value; var cell = dataGridView.Rows[cellPos.rowIndex].Cells[cellPos.colIndex]; cell.Value = barcode; } }
public void MergeFrom(PlateInfo srcPlate, bool copy2FirstHalf) { for (int i = 0; i < 48; i++) { CellPosition srcCellPos = new CellPosition(i); CellPosition dstCellPos = copy2FirstHalf ? srcCellPos : new CellPosition(i + 48); if (srcPlate.BarcodeDefinitions.ContainsKey(srcCellPos)) { barcodeDefinitions[dstCellPos] = srcPlate.BarcodeDefinitions[srcCellPos]; } } }
private void ParseGeneral(string generalInfo, out PlateInfo plateInfo) { List <string> strs = generalInfo.Split('\t').ToList(); string plateName = strs[0]; bool bMerged = false; if (strs.Count == 8) { bMerged = strs[7].Contains(strings.merged); } plateInfo = new PlateInfo(plateName, null, null, bMerged); plateInfo.PlateDescription = generalInfo; }
private bool IsConsistentWithCheckDoc(PlateInfo plateInfo, ref string errMsg) { foreach (KeyValuePair <CellPosition, string> pair in plateInfo.BarcodeDefinitions) { if (plateInfo.PredefinedBarcodes.ContainsKey(pair.Key)) { if (plateInfo.PredefinedBarcodes[pair.Key] != pair.Value) { errMsg += string.Format("板子:{0}中有{1}处与预定义不一致,请检查!", plateInfo.Name, pair.Key.AlphaInteger); return(false); } } } return(true); }
private bool SecondHalfContainsValue(PlateInfo plateInfo) { if (plateInfo.PlateDescription.Contains("merged")) { return(true); } foreach (var barcodeDef in plateInfo.BarcodeDefinitions) { if (barcodeDef.Key.WellID <= 48) { continue; } if (barcodeDef.Value != "") { return(true); } } return(false); }
private void SplitPlate() { SetHint(""); if (lstboxPlates.SelectedItem == null) { SetHint("请先选中一块板子!"); return; } Utility.SaveDataGridView(dataGridView, curPlateInfo); var srcPlate = (PlateInfo)lstboxPlates.SelectedItem; FormattedHeader formattedHeader = srcPlate.FileFormat; PlateInfo firstHalf = new PlateInfo(srcPlate.Name + "_1", formattedHeader, null, false); PlateInfo secondHalf = new PlateInfo(srcPlate.Name + "_2", formattedHeader, null, false); firstHalf.SplitFrom(srcPlate, true); secondHalf.SplitFrom(srcPlate, false); plates.Add(firstHalf); plates.Add(secondHalf); SetHint("切分完成", false); }
internal void SplitFrom(PlateInfo srcPlate, bool firstHalf) { int start = 0; int end = 48; if (!firstHalf) { start = 48; end = 96; } for (int i = start; i < end; i++) { CellPosition srcCellPos = new CellPosition(i); CellPosition dstCellPos = new CellPosition(i - start); if (srcPlate.BarcodeDefinitions.ContainsKey(srcCellPos)) { barcodeDefinitions[dstCellPos] = srcPlate.BarcodeDefinitions[srcCellPos]; } } }
private void AddHalf(bool firstHalf) { if (lstSrcPlates.SelectedItem == null) { SetHint("请选中一块板子!"); return; } PlateInfo curPlateInfo = (PlateInfo)lstSrcPlates.SelectedItem; string sName = curPlateInfo.Name; if (firstHalf) { firstPlate = curPlateInfo; txtFirstHalf.Text = sName; } else { secondPlate = curPlateInfo; txtSecondHalf.Text = sName; } }
private void btnOk_Click(object sender, RoutedEventArgs e) { if (firstPlate == null || secondPlate == null) { SetHint("请选中两块板子做Merge!"); return; } if (firstPlate.SampleDescription != secondPlate.SampleDescription) { SetHint("两块板的Assay类型不一样,您可以通过颜色区分。"); return; } bool containsValSecondHalf = SecondHalfContainsValue(firstPlate); if (containsValSecondHalf) { SetHint("第一块板整版都设置过条码,不能Merge!"); return; } containsValSecondHalf = SecondHalfContainsValue(secondPlate); if (containsValSecondHalf) { SetHint("第二块板整版都设置过条码,不能Merge!"); return; } FormattedHeader formattedHeader = new FormattedHeader(firstPlate.SampleDescription); MergedPlate = new PlateInfo(firstPlate.Name + "_" + secondPlate.Name, formattedHeader, null, true); MergedPlate.MergeFrom(firstPlate, true); MergedPlate.MergeFrom(secondPlate, false); this.DialogResult = true; this.Close(); }
public void Write(string sFile, PlateInfo plateInfo) { List <string> allLines = new List <string>(); allLines.AddRange(fileHeader); allLines.Add(plateInfo.PlateDescription); allLines.Add(""); allLines.Add(sampleHeader); plateInfo.BarcodeDefinitions = plateInfo.BarcodeDefinitions.OrderBy(x => Convert(x.Key)).ToDictionary(x => x.Key, x => x.Value); string defaultText = "\t\t\t\t\t" + plateInfo.DefaultComment; for (int i = 0; i < 96; i++) { CellPosition cellPos = new CellPosition(i); if (plateInfo.BarcodeDefinitions.ContainsKey(cellPos)) { string barcode = plateInfo.BarcodeDefinitions[cellPos]; string well = cellPos.AlphaInteger + "\t"; string sampleType = GetSampleType(barcode); string line = well; if (barcode != "") { line += barcode + "\t" + plateInfo.SampleDescription + "\t" + sampleType; } else { line = GetDefault(cellPos, defaultText); } allLines.Add(line); } else { allLines.Add(GetDefault(cellPos, defaultText)); } } File.WriteAllLines(sFile, allLines); }
static public void SaveDataGridView(DataGridView dataGridView, PlateInfo curPlateInfo) { if (curPlateInfo == null) { return; } foreach (DataGridViewRow row in dataGridView.Rows) { foreach (DataGridViewCell cell in row.Cells) { CellPosition cellPos = new CellPosition(cell.ColumnIndex, cell.RowIndex); if (!curPlateInfo.IsWholePlate) { if (cellPos.WellID > 48) { continue; } } string sBarcode = cell.Value.ToString(); curPlateInfo.BarcodeDefinitions[cellPos] = sBarcode; } } }