コード例 #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
        // translate(mRNA) <== pairwise-align ==> 3D Seq
        // Consensus object will be loaded with the aa seq to aa seq (from 3d protein) alignments
        // The first aa seq will actually have to map back to mRNA nucleotides. But that's job of Consensus.
        // Not sure if it's the best way to do this however. Open to better ideas.
        public Consensus alignTo3DProtein(string name, Seq type, List <Residue> _3DSeq)
        {
            if (pam100 == null)
            {
                populatePAM();
            }
            FASTAModel model = getFASTAModel(type);
            string     key   = model.niceName[name];
            string     seq   = model.data[key][1];

            id = name + "," + name + ":" + type.ToString() + "," + Seq.AA.ToString();

            Consensus c;

            if (!seqModel.alignments.TryGetValue(id, out c))
            {
                c = new Consensus();
                //map DNA, AA. onto nucXaa.
                List <List <string> > mapping = new List <List <string> >();
                List <string>         nuc     = new List <string>();
                List <string>         aa      = new List <string>();

                for (int i = 0; i < seq.Length / 3; i++)
                {
                    string codon = "" + seq[i * 3] + seq[i * 3 + 1] + seq[i * 3 + 2];
                    string AA3   = GeneticCode.DNAtoAA[codon];
                    // Debug.Log("AA3: " + AA3);
                    string oneLetter = AminoAcid.OneLetterCode[AA3];
                    nuc.Add(codon);
                    aa.Add(oneLetter);
                }

                mapping.Add(nuc);
                mapping.Add(aa);

                c.nucMapAA = mapping;

                startPairwise(name, type, name, Seq.AA);

                if (c == null)
                {
                    Debug.Log("pairwise algorithm did not work!!!");                     //not sure how it follows that if c is null, alg didnt work.
                }

                c.aas = result;
                seqModel.alignments[id] = c;
            }

            return(c);
        }
コード例 #3
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);
        }