Beispiel #1
0
        public Main()
        {
            InitializeComponent();

            _currentId = -1;
            _ms        = new MemorySearch();

            _ms.setProgressEvent(progressUpdate);
        }
Beispiel #2
0
        private void searchSearch_Click(object sender, EventArgs e)
        {
            // create a MemorySearch object for structure search
            ms = new MemorySearch();

            // load database or sdf file
            if (searchSdf.Text.EndsWith(".molengine"))
                ms.Read(searchSdf.Text);
            else if (searchSdf.Text.EndsWith(".sdf"))
                ms.AddSdf(searchSdf.Text);
            else
            {
                MessageBox.Show("Unknown file format");
                return;
            }

            // prepare query structure
            string smiles = null;
            if (searchSmiles.Text != "")
                smiles = searchSmiles.Text;
            else
            {
                Molecule m = Molecule.ReadFile(searchQuery.Text);
                smiles = m == null ? null : m.SMILES;
            }

            if (string.IsNullOrEmpty(smiles))
            {
                MessageBox.Show("No query is read");
                return;
            }

            // search type
            double cutoff = 0.6;
            MemorySearch.SearchMode mode = MemorySearch.SearchMode.Substructure;
            switch (searchType.Text)
            {
                case "Full-structure":
                    mode = MemorySearch.SearchMode.FullStructure;
                    break;
                case "Exact":
                    mode = MemorySearch.SearchMode.ExactFullStructure;
                    break;
                case "Similarity 60%":
                    mode = MemorySearch.SearchMode.Similarity;
                    cutoff = 0.6;
                    break;
                case "Similarity 90%":
                    mode = MemorySearch.SearchMode.Similarity;
                    cutoff = 0.9;
                    break;
            }

            // highlight query structures
            ms.Highlighting = Color.Red;

            // search ...
            searchResults = ms.Search(Molecule.ReadSMILES(smiles), mode, 200, cutoff);

            // browse to the first hit
            searchIndex = 0;
            searchNext_Click(null, EventArgs.Empty);
        }