示例#1
0
        //NOTICE: VERY SIMILAR TO GETPEPTIDE. @todo: create a common helper function for these two functions.
        public int getPeptidePos(string name, int pos, Nuc n, Seq type)
        {
            Debug.Log("getPeptidePos");
            int        index;
            int        offset = 0;
            FASTAModel m      = registerModel(type);        //lol

            if (m.GetType() == typeof(RNAModel))
            {
                offset = (m as RNAModel).exonStartIndices[0];
            }
            else                         //dna model, uses start index.
            {
                offset = (m as DNAModel).indexStart;
            }
            string key = name + "," + name + ":" + type.ToString() + "," + Seq.AA.ToString();

            if (currentAlignment == null || !currentAlignment.id.Equals(key))
            {
                Consensus alignment;

                Debug.Log("getPeptidePos, key: " + key);

                if (alignments.TryGetValue(key, out alignment))
                {
                    currentAlignment = alignment;
                }
                else                     //make the alignment object.
                {
                    if (proteinSeq == null)
                    {
                        registerProteinModel();
                    }
                    alignment       = seqAligner.alignTo3DProtein(name, type, proteinSeq._3DSeq);
                    alignment.id    = key;
                    alignments[key] = alignment;                             //warning, overwrite the old val at the given key!
                }
                currentAlignment = alignment;

                index = alignment.getResNum(pos - offset, n);
            }
            else
            {
                index = currentAlignment.getResNum(pos - offset, n);
                if (index == -1)
                {
                    Debug.Log("incorrect!!");
                }
            }

            return(index);
        }
示例#2
0
        //niceName: rattus, mus musculus, etc.
        //int pos: the position we are interested in
        //Nuc n : whether it's A|T|C|G
        //Seq type: DNA or RNA. shouldn't be AA.
        public string getPeptide(string name, int pos, Nuc n, Seq type)
        {
            string     result;
            string     key = name + "," + name + ":" + type.ToString() + "," + Seq.AA.ToString();
            int        index;
            int        offset = 0;
            FASTAModel m      = registerModel(type);        //could be either DNA or RNA.

            if (m.GetType() == typeof(RNAModel))
            {
                offset = (m as RNAModel).exonStartIndices[0];
            }
            else                 //dna model, uses start index.
            {
                offset = (m as DNAModel).indexStart;
            }

            Consensus alignment;

            if (!alignments.TryGetValue(key, out alignment))               //alignment is null, create one.
            {
                if (proteinSeq == null)
                {
                    registerProteinModel();
                }
                Debug.Log("inside getPeptide");
                alignment       = seqAligner.alignTo3DProtein(name, type, proteinSeq._3DSeq);
                alignment.id    = key;
                alignments[key] = alignment;
            }
            else
            {
                // (alignment != null)
            }

            index = alignment.getResNum(pos - offset, n);
            if (index == -1)
            {
                return("-");
            }
            result = proteinSeq._3DSeq[index].name;

            return(result);
        }