private void AddNewMols_Click(object sender, EventArgs e) { var stopWatch = new Stopwatch(); stopWatch.Start(); string xmapFilePath = XMAP_path_txtbox.Text; string bnxFilePath = BNX_path_txtbox.Text; string[] runRootDirs = runs_paths_txtbx.Text.Split('\n'); int alignmentLabelChannel = int.Parse(mol_upload_alignment_ch_txtbx.Text); if (String.IsNullOrEmpty(xmapFilePath)) { MessageBox.Show("Must provide path to XMAP file", "Missing file path"); return; } if (String.IsNullOrEmpty(bnxFilePath)) { MessageBox.Show("Must provide path to BNX file", "Missing file path"); return; } if (String.IsNullOrEmpty(runRootDirs[0])) { MessageBox.Show("Must provide path to root directory of run files", "Missing file path"); return; } int totalALignedMolecules = XMAPParser.ParseXmap(xmapFilePath); if (totalALignedMolecules == -1) { MessageBox.Show("Can't open specified XMAP file", "Error opening file"); return; } int totalMolecules = BNXParser.ParseBNX(bnxFilePath, projectID, alignmentLabelChannel, runRootDirs); if (totalMolecules == -1) { MessageBox.Show("Can't open specified BNX file", "Error opening file"); return; } MessageBox.Show(String.Format("time elapsed: {0}", stopWatch.Elapsed.ToString())); XMAPParser.moleculeData.Clear(); }
public static void FitMoleculeToRef(Molecule molecule, bool saveChannel1Intensities, bool saveChannel2Intensities, string outputDir) { List <Tuple <int, int> > labelIdAlignmentPositions = XMAPParser.ParseAlignmentString(molecule.AlignmentString); //in each tuple item1 = ref, item2 = molecule string[] molAlignmentLabelPositions = molecule.AlignmentChannelLabelPositions.Split('\t'); List <double> refPositions = new List <double>(); List <double> molPositions = new List <double>(); //Dictionary<int, double> molFitPixelPositions = new Dictionary<int, double>(); double currRefPosition, currMolPosition; foreach (Tuple <int, int> labelIdAlignment in labelIdAlignmentPositions) { currRefPosition = rCmapPositions[molecule.ChromId][labelIdAlignment.Item1 - 1]; //position along chromosome in bp currMolPosition = double.Parse(molAlignmentLabelPositions[labelIdAlignment.Item2 - 1]) / bpPerPixel; //position along molecule in pixels if (!refPositions.Contains(currRefPosition) && !molPositions.Contains(currMolPosition)) { refPositions.Add(currRefPosition); molPositions.Add(currMolPosition); } } if (molecule.Orientation == "-") { refPositions.Reverse(); molPositions.Reverse(); } IInterpolation linearInterpolation = Interpolate.Linear(molPositions, refPositions); if (saveChannel1Intensities) { SaveMoleculePixelsToFile(linearInterpolation, molecule, 1, outputDir); } if (saveChannel2Intensities) { SaveMoleculePixelsToFile(linearInterpolation, molecule, 2, outputDir); } }