public void InitializeSet()
        {
            RunQuery(delegate
            {
                var speciesList = SpeciesList;
                wstate.speciesList = speciesList.Select(s=>s.compactName).ToArray();

                using (var strdb = new StringDatabaseSearch())
                {
                    wstate.set = PartList.BuildInteractionSet(wstate.partList.parts.Where(p => p.enabled));

                    foreach (Protein prot in wstate.set.proteins.Values)
                        if (prot.stringID == 0)
                            strdb.UpdateProtein(prot);
                }

                Invoke(new Action(delegate {
                    comboSpecies.Items.AddRange(speciesList);
                    comboSpecies.SelectedIndex = Array.IndexOf(speciesList,
                        speciesList.FirstOrDefault(s => s.speciesId == 83333));

                    foreach (Protein prot in wstate.set.proteins.Values)
                        treeView.Nodes.Add(CreateProteinNode(prot));

                    treeView.ExpandAll();
                }));
            });
        }
        private void buttonMapInteractions_Click(object sender, EventArgs e)
        {
            var species = (StringDatabaseSearch.dbSpecies)comboSpecies.SelectedItem;
            int speciesID = species.speciesId;

            RunQuery(delegate
            {
                NativeExtend();

                List<Protein> natives = new List<Protein>();
                foreach (Protein p in wstate.set.proteins.Values)
                    if (!p.fromHomolog)
                        natives.Add(p);

                using (StringDatabaseSearch strdb = new StringDatabaseSearch())
                {
                    strdb.ExtendBestHomologs(wstate.set, natives, speciesID, 0, TreeUpdateLogCallback);
                }
            });
        }
        private void NativeExtend()
        {
            using (StringDatabaseSearch strdb = new StringDatabaseSearch())
            {
                strdb.ExtendInteractions(wstate.set, wstate.set.proteins.Values.Where(p => !p.fromHomolog).ToArray(),
                    MinInteractionScore, true, TreeUpdateLogCallback);

                // Find the interactions between the newly added nodes
            //				strdb.ExtendInteractions(wstate.set, wstate.set.proteins.Values.Where(p => !p.fromHomolog).ToArray(),
            //				MinInteractionScore, false, TreeUpdateLogCallback);
            }
        }
 private void buttonLocalExtend_Click(object sender, EventArgs e)
 {
     RunQuery(delegate
     {
         using (StringDatabaseSearch strdb = new StringDatabaseSearch())
         {
             strdb.ExtendInteractions(wstate.set, wstate.set.proteins.Values.Where(p => p.fromHomolog),
                 MinInteractionScore, true, TreeUpdateLogCallback);
         }
     });
 }