Exemple #1
0
        private static void ProcessRunTiffs(int projectId, string[] runsDirectoryPaths, int runId, Scan[] runMoleculesByScanByCol, UpdateBox updateBox)
        {
            BackgroundFOV[] allChannelsBackgroundFOVs;

            string[] runNameMonth = DatabaseManager.GetRunNameMonth(runId);
            int      rootDirIdx   = UserInputParser.GetRunRootDir(runsDirectoryPaths, runNameMonth[1], runNameMonth[0]);

            if (rootDirIdx >= 0)
            {
                string runDir             = Path.Combine(runsDirectoryPaths[rootDirIdx], runNameMonth[1], runNameMonth[0]);
                string backgroundTiffPath = Path.Combine(runDir, runNameMonth[0] + "_Scan001.tiff");
                using (Tiff backgroundTiff = Tiff.Open(backgroundTiffPath, "r"))
                {
                    FieldValue[] width  = backgroundTiff.GetField(TiffTag.IMAGEWIDTH);
                    FieldValue[] height = backgroundTiff.GetField(TiffTag.IMAGELENGTH);
                    imageLength  = height[0].ToInt();
                    imageWidth   = width[0].ToInt();
                    scanlineSize = backgroundTiff.ScanlineSize();
                    allChannelsBackgroundFOVs = GetAllChannelsBackgroundFOVs(backgroundTiff, projectId, runId);
                }

                Parallel.ForEach(runMoleculesByScanByCol.Where(scan => scan != null), scan =>
                {
                    ProcessScanTiff(runDir, runNameMonth[0], scan, allChannelsBackgroundFOVs, updateBox);
                });
            }
        }
Exemple #2
0
        static int GenomeAlignmentFromCmd(string[] args)
        {
            string keyFilePath             = args[0];
            string rCmapFilePath           = args[1];
            string outputDirPath           = args[2];
            int    projectId               = int.Parse(args[3]);
            float  lengthFilter            = float.Parse(args[4]) * 1000;
            float  confidenceFilter        = float.Parse(args[5]);
            float  alignedLenPercentFilter = float.Parse(args[6]);
            string queryLocation           = args[7];
            bool   saveChannel1            = int.Parse(args[8]) == 1 ? true : false;
            bool   saveChannel2            = int.Parse(args[9]) == 1 ? true : false;

            int readKeyChroms = CMAPParser.ReadKeyFile(keyFilePath);
            Tuple <List <int>, List <Tuple <int, int, int> > > locations = UserInputParser.getLocations(queryLocation, null);
            List <int> chromIdsFilter = locations.Item1;
            List <Tuple <int, int, int> > chromStartEndFilter = locations.Item2;

            CMAPParser.rCmapPositions = CMAPParser.ParseCmap(rCmapFilePath, 1);

            List <Molecule> selectedMolecules = DatabaseManager.SelectMoleculesForGenomeAlignment(projectId, lengthFilter, confidenceFilter, alignedLenPercentFilter, null, chromIdsFilter,
                                                                                                  chromStartEndFilter);

            foreach (Molecule molecule in selectedMolecules)
            {
                CMAPParser.FitMoleculeToRef(molecule, saveChannel1, saveChannel2, outputDirPath);
            }

            return(0);
        }
Exemple #3
0
        private void filterMolecules_Click(object sender, EventArgs e)
        {
            alignmentFilter         = aligned_filter_ckbx.Checked ? 1 : 0;
            lengthFilter            = String.IsNullOrEmpty(min_len_txtbx.Text) ? 0 : float.Parse(min_len_txtbx.Text) * 1000;
            confidenceFilter        = String.IsNullOrEmpty(min_conf_txtbx.Text) ? 0 : float.Parse(min_conf_txtbx.Text);
            alignedLenPercentFilter = String.IsNullOrEmpty(min_aligned_len_txtbx.Text) ? 0 : float.Parse(min_aligned_len_txtbx.Text);
            molIdsFilterArray       = null;
            chromIdsFilter          = null;
            chromStartEndFilter     = null;

            if (!String.IsNullOrEmpty(mols_ids_txtbx.Text) && !String.IsNullOrEmpty(mol_ids_file_path_txtbx.Text))
            {
                MessageBox.Show("For molecule IDs filter either input into the text box, or upload a file, but not both", "Error parsing filter options");
                return;
            }

            if (!String.IsNullOrEmpty(mols_ids_txtbx.Text) || !String.IsNullOrEmpty(mol_ids_file_path_txtbx.Text))
            {
                molIdsFilterArray = UserInputParser.getMolIds(mols_ids_txtbx.Text, mol_ids_file_path_txtbx.Text);
                if (molIdsFilterArray == null)
                {
                    MessageBox.Show("Can't open molecule IDs file", "Error parsing filter options");
                    return;
                }
            }

            if (!String.IsNullOrEmpty(mol_locations_txtbx.Text) && !String.IsNullOrEmpty(mol_locations_file_path_txtbx.Text))
            {
                MessageBox.Show("For molecule locations filter either input into the text box, or upload a file, but not both", "Error parsing filter options");
                return;
            }

            if (!String.IsNullOrEmpty(mol_locations_txtbx.Text) || !String.IsNullOrEmpty(mol_locations_file_path_txtbx.Text))
            {
                if (String.IsNullOrEmpty(key_file_path_txtbx.Text))
                {
                    MessageBox.Show("For molecule locations filter you must supply a key file", "Error parsing filter options");
                    return;
                }
                else //file and lines are present, parse the input
                {
                    int readKeyChroms = CMAPParser.ReadKeyFile(key_file_path_txtbx.Text); //reading the key file to translate chromosome names to IDs, becaues chromosomes are saved as IDs in DB
                    if (readKeyChroms == -1)
                    {
                        MessageBox.Show("Can't open specified key file", "Error opening file");
                        return;
                    }
                    else
                    {
                        //get the locations from user input
                        Tuple <List <int>, List <Tuple <int, int, int> > > locations = UserInputParser.getLocations(mol_locations_txtbx.Text, mol_locations_file_path_txtbx.Text);
                        chromIdsFilter      = locations.Item1;
                        chromStartEndFilter = locations.Item2;
                    }
                }
            }
        }