Beispiel #1
0
        public List <INPUTMODE> GetModes()
        {
            Dictionary <INPUTMODE, int> dic   = new Dictionary <INPUTMODE, int>();
            List <INPUTMODE>            modes = new List <INPUTMODE>();

            foreach (var item in masterNode)
            {
                profileNode n = InternalProfilesManager.GetNode(item.Value.internalName);
                if (n == null)
                {
                    return(null);
                }
                Type t = Type.GetType(InternalProfilesManager.internalList[n]);
                InternalProfileBase c = Activator.CreateInstance(t) as InternalProfileBase;
                foreach (var it in c.destination)
                {
                    if (!dic.ContainsKey(it))
                    {
                        dic.Add(it, 1);
                    }
                    else
                    {
                        dic[it]++;
                    }
                }
            }
            foreach (var item in dic)
            {
                if (item.Value == masterNode.Keys.Count)
                {
                    modes.Add(item.Key);
                }
            }
            return(modes);
        }
Beispiel #2
0
        private void setingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SetSettings(true);

            Settings setCheck = new Settings();

            setCheck.Load();
            InternalProfilesManager.RemoveProfilesFile();
            foreach (var item in profiles)
            {
                item.ClearProfiles();
                item.LoadProfiles();
                if (item.GetMode().Contains(setCheck.mode))
                {
                    item.AddInternalProfiles();
                }
            }
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            bool   errors            = false;
            bool   times             = false;
            bool   binary            = false;
            bool   progress          = false;
            bool   automaticProfiles = false;
            string configFileName    = "";

            Options    opt        = new Options();
            ClusterVis clusterOut = new ClusterVis();

            try
            {
                InternalProfilesManager.InitProfiles();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Some of the profiles are not available: ", ex.Message);
            }
            //Console.WriteLine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            /*foreach(var item in InternalProfilesManager.internalList)
             * {
             *  Console.WriteLine("profile=" + item);
             * }*/
            if (args.Length == 0)
            {
                Console.WriteLine("Following argument is required:");
                Console.WriteLine("-f configuration_file");

                Console.WriteLine("Following options may be specified");
                Console.WriteLine("-e \n\t show all errors");
                Console.WriteLine("-m \n\t set the input mode\n\tRNA or PROTEIN [default PROTEIN]");
                Console.WriteLine("-n \n\t number of cores to be used");
                Console.WriteLine("-t \n\tshow time information");
                Console.WriteLine("-a \n\tgenerate automatic profiles (can be used only when aligned profile is set in configuration file)");
                Console.WriteLine("-b \n\tSave results to binary file (readable by GUI version)");
                Console.WriteLine("-p \n\tShow progres bar");
                return;
            }
            Settings set = new Settings();

            set.Load();
            if (set.profilesDir == null || set.profilesDir.Length == 0)
            {
                set.profilesDir = "generatedProfiles";
                //    set.Save();
            }
            set.mode = INPUTMODE.PROTEIN;
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-f":
                    if (i + 1 >= args.Length)
                    {
                        Console.WriteLine("After -f option you have to provide configuration file");
                        return;
                    }
                    if (!File.Exists(args[i + 1]))
                    {
                        Console.WriteLine("File " + args[i + 1] + " does not exist");
                        return;
                    }
                    configFileName = args[i + 1];
                    i++;
                    break;

                case "-b":
                    binary = true;
                    break;

                case "-n":
                    if (args.Length > i)
                    {
                        int num;
                        try
                        {
                            num = Convert.ToInt32(args[++i]);
                            set.numberOfCores = num;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Wrong definition of number of cores: " + ex.Message);
                            return;
                        }
                    }
                    else
                    {
                        Console.WriteLine("Number of cores has been not provided");
                    }
                    break;

                case "-m":
                    if (args.Length > i)
                    {
                        set.Load();
                        i++;
                        if (args[i] == "PROTEIN")
                        {
                            set.mode = INPUTMODE.PROTEIN;
                        }
                        else
                        if (args[i] == "RNA")
                        {
                            set.mode = INPUTMODE.RNA;
                        }
                        else
                        if (args[i] == "USER")
                        {
                            set.mode = INPUTMODE.USER_DEFINED;
                        }
                        else
                        {
                            Console.WriteLine("Incorrect mode:" + args[i]);
                            return;
                        }
                    }
                    else
                    {
                        Console.WriteLine("No mode specified");
                    }

                    break;

                case "-e":
                    errors = true;
                    break;

                case "-t":
                    times = true;
                    break;

                case "-a":
                    automaticProfiles = true;
                    break;

                case "-p":
                    progress = true;
                    break;

                default:
                    if (args[i].Contains("-"))
                    {
                        Console.WriteLine("Unknown option " + args[i]);
                    }
                    break;
                }
            }
            set.Save();
            if (configFileName.Length == 0)
            {
                Console.WriteLine("Configurarion file has been not provided!");
                return;
            }

            string[] aux = null;
            try
            {
                Console.WriteLine("Configuration file " + configFileName);
                opt.ReadOptionFile(configFileName);
                if (automaticProfiles)
                {
                    opt.GenerateAutomaticProfiles(null);
                }
                aux             = args[0].Split('.');
                manager.opt     = opt;
                manager.message = ErrorMessage;
                if (progress)
                {
                    TimeIntervalTerminal.InitTimer(UpdateProgress);
                    TimeIntervalTerminal.Start();
                }
                manager.RunJob("");
                manager.WaitAllNotFinished();
                UpdateProgress(null, null);

                if (progress)
                {
                    TimeIntervalTerminal.Stop();
                }
                Console.Write("\r                                                                     ");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception : " + ex.Message);
            }
            if (manager.clOutput.Count > 0)
            {
                foreach (var item in manager.clOutput.Keys)
                {
                    clusterOut.output = manager.clOutput[item];
                    string clustName = manager.clOutput[item].clusterType;
                    if (clustName.Contains(":"))
                    {
                        clustName = clustName.Replace(':', '-');
                    }
                    clusterOut.output.SaveTxt(clustName + "_" + opt.outputFile);
                    //clusterOut.SCluster(clustName+"_"+opt.outputFile);
                    if (binary)
                    {
                        string       fileName = opt.outputFile + "_" + item + ".cres";
                        StreamWriter file     = new StreamWriter(fileName);

                        file.Close();
                        ClusterOutput.Save(opt.outputFile + "_" + item + ".cres0", clusterOut.output);
                    }
                }
            }
            if (times)
            {
                foreach (var item in manager.clOutput)
                {
                    Console.WriteLine(item.Value.dirName + " " + item.Value.measure + " " + item.Value.time);
                }
            }
            if (errors)
            {
                foreach (var item in ErrorBase.GetErrors())
                {
                    Console.WriteLine(item);
                }
            }
            Console.WriteLine();
        }
Beispiel #4
0
 public ProfileTree()//(string profileFile)
 {
     mgr            = new InternalProfilesManager();
     progressObject = mgr;
     set.Load();
 }
Beispiel #5
0
        public int GenerateActiveProfiles(Dictionary <string, profileNode> node, DCDFile dcd = null)
        {
            int activeProfiles = 0;

            if (node == null)
            {
                node = masterNode;
            }

            if (profiles == null)
            {
                profiles = new Dictionary <string, Dictionary <string, protInfo> >();
            }

            DebugClass.WriteMessage("Profiling started");

            foreach (var item in node.Values)
            {
                if (item.active)
                {
                    Dictionary <string, protInfo> profString;
                    mgr.ResetProgress();
                    if (item.GetNumberofStates() == 0)
                    {
                        if (item.profProgram.Length > 0)
                        {
                            if (!profiles.ContainsKey(item.profName))
                            {
                                activeProfiles++;
                                if (File.Exists(item.OutFileName))
                                {
                                    File.Delete(item.OutFileName);
                                }
                                GenerateProfile(item);
                                FileInfo f = new FileInfo(item.OutFileName);
                                if (!File.Exists(item.OutFileName) || f == null || f.Length == 0)
                                {
                                    throw new Exception("Error: profile " + item.profName + " did not generate output " + item.OutFileName);
                                }
                            }
                        }
                    }
                    else
                    {
                        DebugClass.WriteMessage("Run profiling");
                        if (dcd == null)
                        {
                            mgr.RunProfile(item.internalName, listFile);
                        }
                        else
                        {
                            mgr.RunProfile(item.internalName, dcd);
                        }
                        activeProfiles++;
                    }

                    if (item.childrens.Count > 0)
                    {
                        activeProfiles += GenerateActiveProfiles(item.childrens);
                    }
                    else
                    {
                        if (!profiles.ContainsKey(item.profName))
                        {
                            if (item.GetNumberofStates() == 0)
                            {
                                profString = ReadProfile(item);
                            }
                            else
                            {
                                if (dcd == null)
                                {
                                    profString = mgr.GetProfile(item, listFile);
                                }
                                else
                                {
                                    profString = InternalProfilesManager.GetProfile(item, dcd);
                                }
                            }
                            if (profString != null && profString.Count > 0)
                            {
                                profiles.Add(item.profName, profString);
                            }
                            else
                            {
                                throw new Exception("For profile " + item.profName + " profiles has not been generated!");
                            }
                        }
                    }
                    profilesProgress.Add(mgr.ProgressUpdate());
                }
            }
            progressObject = null;
            return(activeProfiles);
        }
Beispiel #6
0
        private void EditProfile(string Path, bool edit, profileType type)
        {
            ProfileDefinitionForm profDef     = null;
            InternalProfileForm   internalDef = null;
            profileNode           node        = null;
            profileNode           newNode     = null;
            DialogResult          res         = DialogResult.Cancel;

            if (edit)
            {
                node = treeProfiles.FindNode(Path);
                if (node.internalName != null)
                {
                    internalDef = new InternalProfileForm(node, filter);
                    res         = internalDef.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        newNode                  = internalDef.localNode;
                        toolSave.Enabled         = true;
                        toolStripButton6.Enabled = true;
                    }
                }
                else
                {
                    profDef = new ProfileDefinitionForm(node);
                    res     = profDef.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        newNode                  = profDef.profile;
                        toolSave.Enabled         = true;
                        toolStripButton6.Enabled = true;
                    }
                }
            }
            else
            {
                if (Path == null)
                {
                    Path = "Profiles";
                }
                if (type == profileType.EXTERNAL)
                {
                    profDef = new ProfileDefinitionForm();
                    res     = profDef.ShowDialog();
                    if (res == DialogResult.OK)
                    {
                        node = profDef.profile;
                        node.internalName        = null;
                        toolSave.Enabled         = true;
                        toolStripButton6.Enabled = true;
                    }
                }
                else
                {
                    Settings set = new Settings();
                    set.Load();
                    InternalProfilesManager manager       = new InternalProfilesManager();
                    List <profileNode>      validProfiles = new List <profileNode>();
                    foreach (var item in InternalProfilesManager.internalList.Keys)
                    {
                        if (manager.CheckAccessibility(item, set.mode))
                        {
                            validProfiles.Add(item);
                        }
                    }

                    ListInternal intr = new ListInternal(validProfiles);

                    res = intr.ShowDialog();

                    if (res == DialogResult.OK)
                    {
                        InternalProfileForm intForm;
                        profileNode         localNode = InternalProfilesManager.GetNode(intr.selectedProfile);
                        if (localNode.profName.Contains("Load"))
                        {
                            intForm = new InternalProfileForm(localNode, filter, false);
                        }
                        else
                        {
                            intForm = new InternalProfileForm(localNode, filter);
                        }

                        res = intForm.ShowDialog();
                        if (res == DialogResult.OK)
                        {
                            node                     = intForm.localNode;
                            node.profProgram         = intr.selectedProfile;
                            newNode                  = node;
                            toolSave.Enabled         = true;
                            toolStripButton6.Enabled = true;
                        }
                    }
                }
            }

            if (res == DialogResult.OK)
            {
                if (node != null && File.Exists(node.OutFileName))
                {
                    File.Delete(node.OutFileName);
                }
                //profChanged = true;

                if (!edit)
                {
                    //profChanged = true;
                    Regex exp = new Regex("^/");

                    TreeNode nodeT;//= new TreeNode(profDef.profile.profName);

                    string nPath = "";
                    if (Path != null)
                    {
                        nPath = exp.Replace(Path, "");
                    }
                    if (profilesView.SelectedNode == null)
                    {
                        nodeT = profilesView.Nodes[0].Nodes.Add(node.profName);
                        profilesView.Nodes[0].Expand();
                    }
                    else
                    {
                        nodeT = profilesView.SelectedNode.Nodes.Add(node.profName);
                        profilesView.SelectedNode.Expand();
                    }
                    nodeT.Tag = newNode;
                    Regex exp2 = new Regex("^Profiles");
                    Path = exp2.Replace(Path, "");
                    treeProfiles.AdddNode(Path, node);
                }
                else
                {
                    profilesView.SelectedNode.Text = node.profName;
                    treeProfiles.RemoveNode(Path);
                    Regex exp2 = new Regex("^Profiles");
                    Path = exp2.Replace(Path, "");
                    treeProfiles.AdddNode(ParentPath(Path), newNode);
                    node.CopyNode(newNode);
                    ShowTree();
                }
            }
        }
Beispiel #7
0
        public AdvancedVersion(Form parent = null)
        {
            InitializeComponent();
            this.parent = parent;
            InternalProfilesManager.RemoveProfilesFile();
            System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();

            System.OperatingSystem osinfo = System.Environment.OSVersion;
            DebugClass.WriteMessage("system: " + osinfo.VersionString + " " + Environment.Is64BitOperatingSystem);
            profiles = InternalProfilesManager.InitProfiles();

            manager.beginJob  = AddItemToList;
            manager.updateJob = UpdateListBox;
            manager.message   = ErrorMessage;


            TimeInterval.InitTimer(UpdateProgress);

/*            this.toolsToolStripMenuItem.DropDownItems.Remove(this.best5ToolStripMenuItem);
 *          this.toolsToolStripMenuItem.DropDownItems.Remove(this.compareBest5ToolStripMenuItem);
 *          this.toolsToolStripMenuItem.DropDownItems.Remove(this.best5RmsdCenterToolStripMenuItem);*/


            /*string[] dirs = Directory.GetDirectories("Y:\\casp10","T065*");
             * foreach (var item in dirs)
             * {
             *  string[] Files = Directory.GetFiles(item);
             *  List<string> ddd = new List<string>(Files);
             *
             *
             *  Rmsd rmsd = new Rmsd(ddd, "", false, PDB.PDBMODE.ONLY_CA);
             *  List <string> kk =new List<string>();
             *  foreach(var nn in Files)
             *  {
             *      string[] aux = nn.Split(Path.DirectorySeparatorChar);
             *      kk.Add(aux[aux.Length - 1]);
             *  }
             *  string []aa=item.Split(Path.DirectorySeparatorChar);
             *  rmsd.DistStat(kk,aa[aa.Length-1]);
             * }*/
            /* List <string> ddd=new List<string>();
             * ddd.Add("y:\\TASSER_decoys\\1af7.pdb");
             * ddd.Add("y:\\TASSER_decoys\\1af7\\d1216.pdb");
             * DistanceMeasure maxsub = new MaxSub(ddd, "", false);
             *
             * double cc = maxsub.GetDistance("1af7.pdb","d1216.pdb");*/

            try
            {
                manager.opt.ReadDefaultFile();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }

            Settings setCheck = new Settings();

            try
            {
                setCheck.Load();
                if (!Directory.Exists(setCheck.profilesDir))
                {
                    MessageBox.Show("Directory for generated profiles:" + setCheck.profilesDir + " cannot be found\n You must provide correct directory!");
                    SetSettings(false);
                }
            }
            catch
            {
                MessageBox.Show("First you have to set options!");
                SetSettings(false);
            }
            foreach (var item in Enum.GetValues(typeof(INPUTMODE)))
            {
                comboBox1.Items.Add(item);
            }
            comboBox1.SelectedItem = setCheck.mode;

            foreach (var item in manager.opt.dataDir)
            {
                listBox1.Items.Add((string)item);
            }

            foreach (var item in manager.opt.dcdFiles)
            {
                listBox1.Items.Add(item);
            }

            foreach (var item in manager.opt.profileFiles)
            {
                listBox1.Items.Add(item + " profiles");
            }

            if (manager.opt.profileFiles.Count > 0)
            {
                radioButton1.Enabled = false;
                radioButton2.Enabled = false;
                radioButton3.Enabled = false;
                radioButton4.Checked = true;
            }

            SetDataDirOptions();
        }
Beispiel #8
0
 public StartForm()
 {
     InitializeComponent();
     InternalProfilesManager.RemoveProfilesFile();
     List <InternalProfileBase> profiles = InternalProfilesManager.InitProfiles();
 }