Esempio n. 1
0
        public override bool Equals(object obj)
        {
            AASeq other = obj as AASeq;

            if (other == null)
            {
                return(false);
            }
            else
            {
                return(ToString() == other.ToString());
            }
        }
Esempio n. 2
0
        public static NamedSequence GetConsensus(List <NamedSequence> seqs)
        {
            int len = -1;
            //StringBuilder consensusSeq = new StringBuilder();
            List <AASeq> aaSeqs = new List <AASeq>();
            bool         isDna  = seqs[0].IsDna();

            foreach (NamedSequence seq in seqs)
            {
                AASeq aaSeq = isDna ? DnaSeq.GetInstance(seq.Sequence, MixtureSemantics.Uncertainty) : AASeq.GetInstance(seq.Sequence, MixtureSemantics.Uncertainty);

                len = Math.Max(len, aaSeq.Count);
                //if (len < 0)
                //{
                //    len = aaSeq.Count;
                //}
                //else
                //{
                //    Helper.CheckCondition(len == aaSeq.Count, String.Format("Sequence {0} is a different length from previous sequences", seq.Name));
                //}
                aaSeqs.Add(aaSeq);
            }

            //for (int i = 0; i < len; i++)
            //{
            //    Dictionary<string, int> charToCount = new Dictionary<string, int>();
            //    KeyValuePair<string, int> currentConsensus = new KeyValuePair<string, int>("z", -1);
            //    foreach (AASeq aaSeq in aaSeqs)
            //    {
            //        if (i < aaSeq.Count)
            //        {
            //            string residue = aaSeq.SubSeqAA0Pos(i, 1).ToString();
            //            charToCount[residue] = SpecialFunctions.GetValueOrDefault(charToCount, residue) + 1;
            //            if (charToCount[residue] > currentConsensus.Value)
            //            {
            //                currentConsensus = new KeyValuePair<string, int>(residue, charToCount[residue]);
            //            }
            //        }
            //    }
            //    consensusSeq.Append(currentConsensus.Key);
            //}
            AASeq         consensusAaSeq = GetAaSeqConsensus(aaSeqs);
            NamedSequence consensus      = new NamedSequence("consensus", consensusAaSeq.ToString());

            return(consensus);
        }