示例#1
0
        private void AlignProfile(string protName, string profileName, List <byte> prof)
        {
            List <byte> ll = new List <byte>(prof.Count);
            int         m  = 0;

            if (align == null || align[profileName] == null || !align[profileName].ContainsKey(protName))
            {
                foreach (var item in prof)
                {
                    ll.Add(item);
                }
            }
            else
            {
                string alignProfile = align[profileName][protName];

                for (int i = 0; i < alignProfile.Length; i++)
                {
                    if (alignProfile[i] == '-')
                    {
                        ll.Add(0);
                        continue;
                    }
                    if (m < prof.Count)
                    {
                        ll.Add(prof[m++]);
                    }
                    else
                    {
                        ErrorBase.AddErrors("Profile " + profileName + " for " + protName + " seems to be incorect");
                    }
                }
            }
            protInfo tmp = new protInfo();

            if (r.profiles[profileName].ContainsKey(protName))
            {
                tmp           = r.profiles[profileName][protName];
                tmp.alignment = ll;
                r.profiles[profileName][protName] = tmp;
            }
        }
示例#2
0
        public Dictionary <string, List <byte> > CombineProfiles(string protName, Dictionary <string, Dictionary <string, protInfo> > pr)
        {
            if (protCombineStates == null)
            {
                protCombineStates = new Dictionary <string, List <byte> >();
            }

            if (combine == profileCombination.JOIN_STATES)
            {
                List <string> profName = new List <string>(pr.Keys);
                List <string> states   = new List <string>(pr[profName[0]][protName].alignment.Count);
                protInfo      info     = pr[profName[0]][protName];

                for (int i = 0; i < info.alignment.Count; i++)
                {
                    string currentState = "";
                    foreach (var profileName in pr.Keys)
                    {
                        byte cc = pr[profileName][protName].alignment[i];
                        if (cc == 0)
                        {
                            currentState = "0";
                            break;
                        }
                        currentState += cc.ToString();
                    }
                    states.Add(currentState);
                }
                if (states.Count > 0)
                {
                    //return states;
                    if (protCombineStates.Count > 0)
                    {
                        List <string> keys = new List <string>(protCombineStates.Keys);
                        if (states.Count == protCombineStates[keys[0]].Count)
                        {
                            AddItemsCombineStates(protName, states);
                        }
                        else
                        {
                            ErrorBase.AddErrors("Wrong alignment: " + protName);
                        }
                    }
                    else
                    {
                        AddItemsCombineStates(protName, states);
                    }
                }
            }
            else
            {
                List <string> profNames = new List <string>(pr.Keys);

                for (int i = 0; i < profNames.Count; i++)
                {
                    List <string> codes = new List <string>();
                    foreach (var code in pr[profNames[i]][protName].alignment)
                    {
                        if (code != 0)
                        {
                            codes.Add(code.ToString() + "_" + i);
                        }
                        else
                        {
                            codes.Add("0");
                        }
                        AddItemsCombineStates(protName, codes);
                        codes.Clear();
                    }
                }
            }
            return(protCombineStates);
        }