コード例 #1
0
        public override List <byte> CreateNewProfile(profileNode node, string[] profile)
        {
            List <byte> newProfile = new List <byte>(profile.Length);

            for (int i = 0; i < profile.Length; i++)
            {
                string state = profile[i];
                if (node.ContainsState(state))
                {
                    if (Convert.ToInt32(state, System.Globalization.CultureInfo.InvariantCulture) > 255)
                    {
                        state = "255";
                    }
                }
                if (node.ContainsState(state))
                {
                    newProfile.Add(node.GetCodedState(node.states[state], true));
                }
                else
                {
                    ErrorBase.AddErrors("Unknow state " + state + " in " + node.profName + " profile!");
                }
            }
            return(newProfile);
        }
コード例 #2
0
        public virtual List <byte> CreateNewProfile(profileNode node, string [] profile)
        {
            List <byte> newProfile = new List <byte>(profile.Length);

            for (int i = 0; i < profile.Length; i++)
            {
                string state = profile[i];
                if (node.ContainsState(state))
                {
                    newProfile.Add(node.GetCodedState(node.states[state]));
                }
                else
                {
                    ErrorBase.AddErrors("Unknow state " + state + " in " + node.profName + " profile!");
                }
            }
            return(newProfile);
        }
コード例 #3
0
        public override Dictionary<string, protInfo> GetProfile(profileNode node, string fileName, DCDFile dcd)
        {
            Dictionary<string, protInfo> dic = new Dictionary<string, protInfo>();
            StreamReader wr;
            DebugClass.WriteMessage("profile" + fileName);
            wr = new StreamReader(fileName);
            
            protInfo info;
            string line = wr.ReadLine();
            string name = "";
            string seq = "";
            List<string> profile = new List<string>();
            List<byte> newProfile = new List<byte>();
            while (line != null)
            {
                if (line.Contains(">"))
                {
                    if (name.Length > 0)
                    {
                        info = new protInfo();
                        info.sequence = null;
                        info.profile = newProfile;
                        dic.Add(name, info);
                    }

                    name = line.Replace(">", "");
                    line = wr.ReadLine();
                }
                if (line.Contains(node.profName+" "))
                {

                    string cLine=line.Remove(0, (node.profName+" profile ").Length);
                    cLine = Regex.Replace(cLine, @"\s+", " ");
                    cLine = cLine.Trim();
                    string[] aux;
                    if (cLine.Contains(' '))
                        aux = cLine.Split(' ');
                    else
                    {
                        char[] charArray = cLine.ToCharArray();
                        aux = cLine.Select(x => x.ToString()).ToArray();                        
                    }

                    profile.Clear();

                    foreach (var item in aux)
                        profile.Add(item);

                    
                    newProfile = new List<byte>();
                    for (int i = 0; i < profile.Count; i++)
                        if (node.ContainsState(profile[i].ToString()))
                            newProfile.Add(node.GetCodedState(node.states[profile[i].ToString()]));
                        else
                            if(profile[i].ToString()!="-" && profile[i].ToString()!="X")
                                throw new Exception("Unknow state " + profile[i].ToString() + " in "+ node.profName + " profile!");
                            else
                                newProfile.Add(0);


                }
                line = wr.ReadLine();
            }
            info = new protInfo();
            info.sequence = seq;
            info.profile = newProfile;
            dic.Add(name, info);
            DebugClass.WriteMessage("number of profiles " + dic.Keys.Count);

            wr.Close();            

            return dic;
        }
コード例 #4
0
        public override Dictionary <string, protInfo> GetProfile(profileNode node, string fileName, DCDFile dcd)
        {
            Dictionary <string, protInfo> dic = new Dictionary <string, protInfo>();
            StreamReader wr;

            DebugClass.WriteMessage("profile" + fileName);
            wr = new StreamReader(fileName);

            protInfo      info;
            string        line       = wr.ReadLine();
            string        name       = "";
            string        seq        = "";
            List <string> profile    = new List <string>();
            List <byte>   newProfile = new List <byte>();

            while (line != null)
            {
                if (line.Contains(">"))
                {
                    if (name.Length > 0)
                    {
                        info          = new protInfo();
                        info.sequence = null;
                        info.profile  = newProfile;
                        if (dic.ContainsKey(name))
                        {
                            wr.Close();
                            throw new Exception("The nameof profile must be unique, name: " + name + " already exists in " + fileName);
                        }
                        dic.Add(name, info);
                    }
                    newProfile = new List <byte>();
                    name       = line.Replace(">", "");
                    line       = wr.ReadLine();
                }
                if (line != null && line.Contains(" profile "))
                {
                    int index = line.IndexOf(" profile ");
                    if (index == -1)
                    {
                        wr.Close();
                        throw new Exception("Incorrect file format you have to have 'profile' word!");
                    }

                    string cLine = line.Remove(0, " profile ".Length + index);

                    cLine = Regex.Replace(cLine, @"\s+", " ");
                    if (line.Length == 0)
                    {
                        continue;
                    }
                    cLine = cLine.Trim();
                    string[] aux;
                    if (cLine.Contains(' '))
                    {
                        aux = cLine.Split(' ');
                    }
                    else
                    {
                        char[] charArray = cLine.ToCharArray();
                        aux = cLine.Select(x => x.ToString()).ToArray();
                    }

                    profile.Clear();

                    foreach (var item in aux)
                    {
                        profile.Add(item);
                    }


                    newProfile = new List <byte>();
                    for (int i = 0; i < profile.Count; i++)
                    {
                        if (node.ContainsState(profile[i].ToString()))
                        {
                            newProfile.Add(node.GetCodedState(node.states[profile[i].ToString()]));
                        }
                        else
                        if (profile[i].ToString() != "-" && profile[i].ToString() != "X")
                        {
                            throw new Exception("Unknow state " + profile[i].ToString() + " in " + node.profName + " profile!");
                        }
                        else
                        {
                            newProfile.Add(0);
                        }
                    }
                }
                line = wr.ReadLine();
            }
            if (newProfile.Count > 0)
            {
                info          = new protInfo();
                info.sequence = seq;
                info.profile  = newProfile;
                dic.Add(name, info);
            }
            DebugClass.WriteMessage("number of profiles " + dic.Keys.Count);

            wr.Close();

            return(dic);
        }
コード例 #5
0
        public override Dictionary <string, protInfo> GetProfile(profileNode node, string fileName, DCDFile dcd)
        {
            Dictionary <string, protInfo> dic = new Dictionary <string, protInfo>();
            StreamReader wr;

            DebugClass.WriteMessage("profile" + fileName);
            wr = new StreamReader(fileName);

            protInfo      info;
            string        line       = wr.ReadLine();
            string        name       = "";
            string        seq        = "";
            List <string> profile    = new List <string>();
            List <byte>   newProfile = new List <byte>();

            while (line != null)
            {
                if (line.Contains(">"))
                {
                    if (name.Length > 0)
                    {
                        info          = new protInfo();
                        info.sequence = null;
                        info.profile  = newProfile;
                        dic.Add(name, info);
                    }

                    name = line.Replace(">", "");
                    line = wr.ReadLine();
                }
                if (line.Contains(" profile "))
                //if (line.Contains(node.profName+" "))
                {
                    string[] aux;
                    aux           = line.Split(' ');
                    node.profName = aux[0];
                    string cLine = line.Remove(0, (node.profName + " profile ").Length);
                    cLine = Regex.Replace(cLine, @"\s+", " ");
                    cLine = cLine.Trim();
                    if (cLine.Contains(' '))
                    {
                        aux = cLine.Split(' ');
                    }
                    else
                    {
                        char[] charArray = cLine.ToCharArray();
                        aux = cLine.Select(x => x.ToString()).ToArray();
                    }

                    profile.Clear();

                    foreach (var item in aux)
                    {
                        profile.Add(item);
                    }


                    newProfile = new List <byte>();
                    for (int i = 0; i < profile.Count; i++)
                    {
                        if (node.ContainsState(profile[i].ToString()))
                        {
                            newProfile.Add(node.GetCodedState(node.states[profile[i].ToString()]));
                        }
                        else
                        if (profile[i].ToString() != "-" && profile[i].ToString() != "X")
                        {
                            throw new Exception("Unknow state " + profile[i].ToString() + " in " + node.profName + " profile!");
                        }
                        else
                        {
                            newProfile.Add(0);
                        }
                    }
                }
                line = wr.ReadLine();
            }
            info          = new protInfo();
            info.sequence = seq;
            info.profile  = newProfile;
            dic.Add(name, info);
            DebugClass.WriteMessage("number of profiles " + dic.Keys.Count);

            wr.Close();

            return(dic);
        }
コード例 #6
0
        public override Dictionary <string, protInfo> GetProfile(profileNode node, string fileName, DCDFile dcd = null)
        {
            Dictionary <string, protInfo> dic = new Dictionary <string, protInfo>();

            currentProgress = 0;

            if (!File.Exists(GetProfileFileName(fileName)))
            {
                throw new Exception("Profile rnaSS does not exists!");
            }

            string profileName;

            if (node.ContainsState("+"))
            {
                profileName = LWprofile;
            }
            else
            {
                profileName = SSprofile;
            }
            StreamReader wr = new StreamReader(GetProfileFileName(fileName));

            List <string> files = GetFileList(fileName);

            maxV = files.Count;
            Dictionary <string, int> dicFile = new Dictionary <string, int>();

            foreach (var item in files)
            {
                string[] aux = item.Split(Path.DirectorySeparatorChar);
                if (!dicFile.ContainsKey(aux[aux.Length - 1]))
                {
                    dicFile.Add(aux[aux.Length - 1], 0);
                }
            }

            protInfo      info;
            string        line       = wr.ReadLine();
            string        name       = "";
            string        seq        = "";
            List <string> profile    = new List <string>();
            List <byte>   newProfile = new List <byte>();

            while (line != null)
            {
                if (line.Contains('>'))
                {
                    if (name.Length > 0)
                    {
                        info          = new protInfo();
                        info.sequence = seq;
                        info.profile  = newProfile;
                        if (dicFile.ContainsKey(name))
                        {
                            if (!dic.ContainsKey(name))
                            {
                                dic.Add(name, info);
                            }
                            else
                            {
                                ErrorBase.AddErrors("There are two the same names " + name + " in the profile file " + GetProfileFileName(fileName));
                            }
                        }
                        currentProgress++;
                    }

                    name = line.Remove(0, 1);
                }
                if (line.Contains(SEQprofile))
                {
                    seq = line.Remove(0, SEQprofile.Length);
                }

                if (line.Contains(profileName))
                {
                    string   tmp = line.Remove(0, profileName.Length);
                    string[] aux;
                    profile.Clear();
                    if (tmp.Contains(" "))
                    {
                        tmp = tmp.TrimEnd();
                        aux = tmp.Split(' ');
                        foreach (var item in aux)
                        {
                            profile.Add(item);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < tmp.Length; i++)
                        {
                            profile.Add(tmp[i].ToString());
                        }
                    }

                    newProfile = new List <byte>();
                    for (int i = 0; i < profile.Count; i++)
                    {
                        if (node.ContainsState(profile[i].ToString()))
                        {
                            newProfile.Add(node.GetCodedState(node.states[profile[i].ToString()]));
                        }
                        else
                        if (profile[i].ToString() != "-" && profile[i].ToString() != "X")
                        {
                            throw new Exception("Unknow state: " + profile[i].ToString() + " in structure " + name + " in profile " + node.profName + " profile!");
                        }
                        else
                        {
                            newProfile.Add(0);
                        }
                    }
                }

                line = wr.ReadLine();
            }

            info          = new protInfo();
            info.sequence = seq;
            info.profile  = newProfile;
            if (!dic.ContainsKey(name))
            {
                dic.Add(name, info);
            }
            else
            {
                ErrorBase.AddErrors("There are two the same names " + name + " in the profile file " + GetProfileFileName(fileName));
            }

            wr.Close();
            currentProgress = maxV;
            return(dic);
        }
コード例 #7
0
        public virtual List<byte> CreateNewProfile(profileNode node,string [] profile)
        {
            List <byte>newProfile = new List<byte>(profile.Length);

            for (int i = 0; i < profile.Length; i++)
            {
                string state = profile[i];
                if (node.ContainsState(state))
                    newProfile.Add(node.GetCodedState(node.states[state]));
                else
                    ErrorBase.AddErrors("Unknow state " + state + " in " + node.profName + " profile!");
            }
            return newProfile;
        }