Ejemplo n.º 1
0
        private void AnnotateQuantEntries(string annotationString, List <AnnotationType> annotationsToAdd, Dictionary <string, AnnotationEntry> annotationEntryDict, Dictionary <string, Dictionary <AnnotationType, List <string> > > uniprotToAnnotationList)
        {
            foreach (QuantEntry quantEntry in CombinedQuantEntryDict.Values)
            {
                quantEntry.PopulateUniprotList(UniprotHeader);

                foreach (string uniprotID in quantEntry.UniprotIDList)
                {
                    Dictionary <AnnotationType, List <string> > annotationTypeToAnnotationEntry = null;

                    if (uniprotToAnnotationList.TryGetValue(uniprotID, out annotationTypeToAnnotationEntry))
                    {
                        foreach (AnnotationType annotationType in annotationsToAdd)
                        {
                            List <string> goTermsToadd = null;
                            if (annotationTypeToAnnotationEntry.TryGetValue(annotationType, out goTermsToadd))
                            {
                                foreach (string goID in goTermsToadd)
                                {
                                    if (annotationType.Equals(AnnotationType.ProteinInteraction))
                                    {
                                        AnnotationEntry addEntry = new AnnotationEntry(goID, goID, AnnotationType.ProteinInteraction);
                                        quantEntry.AddAnnotation(annotationType, addEntry);
                                    }
                                    else
                                    {
                                        quantEntry.AddAnnotation(annotationType, annotationEntryDict[goID]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void AddAnnotation(AnnotationType annotationType, AnnotationEntry annotationEntry)
        {
            List <AnnotationEntry> outEntries = null;

            if (AnnotationEntries.TryGetValue(annotationType, out outEntries))
            {
                if (!outEntries.Contains(annotationEntry))
                {
                    outEntries.Add(annotationEntry);
                }
            }
            else
            {
                List <AnnotationEntry> addList = new List <AnnotationEntry>();
                addList.Add(annotationEntry);
                AnnotationEntries.Add(annotationType, addList);
            }
        }
Ejemplo n.º 3
0
 public void AddAnnotation(AnnotationType annotationType, AnnotationEntry annotationEntry)
 {
     List<AnnotationEntry> outEntries = null;
     if (AnnotationEntries.TryGetValue(annotationType, out outEntries))
     {
         if(!outEntries.Contains(annotationEntry))
         {
             outEntries.Add(annotationEntry);
         }
     }
     else
     {
         List<AnnotationEntry> addList = new List<AnnotationEntry>();
         addList.Add(annotationEntry);
         AnnotationEntries.Add(annotationType, addList);
     }
 }
Ejemplo n.º 4
0
        private void AnnotateQuantEntries(string annotationString, List<AnnotationType> annotationsToAdd, Dictionary<string, AnnotationEntry> annotationEntryDict, Dictionary<string, Dictionary<AnnotationType, List<string>>> uniprotToAnnotationList)
        {
            foreach (QuantEntry quantEntry in CombinedQuantEntryDict.Values)
            {
                quantEntry.PopulateUniprotList(UniprotHeader);

                foreach(string uniprotID in quantEntry.UniprotIDList)
                {
                    Dictionary<AnnotationType, List<string>> annotationTypeToAnnotationEntry = null;

                    if (uniprotToAnnotationList.TryGetValue(uniprotID, out annotationTypeToAnnotationEntry))
                    {
                        foreach (AnnotationType annotationType in annotationsToAdd)
                        {
                            List<string> goTermsToadd = null;
                            if (annotationTypeToAnnotationEntry.TryGetValue(annotationType, out goTermsToadd))
                            {
                                foreach (string goID in goTermsToadd)
                                {
                                    if (annotationType.Equals(AnnotationType.ProteinInteraction))
                                    {
                                        AnnotationEntry addEntry = new AnnotationEntry(goID, goID, AnnotationType.ProteinInteraction);
                                        quantEntry.AddAnnotation(annotationType, addEntry);
                                    }
                                    else
                                    {
                                        quantEntry.AddAnnotation(annotationType, annotationEntryDict[goID]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void BuildAnnotationDictionary(string databaseString, List<AnnotationType> annotationsToAdd)
        {
            //Fill the AnnotationEntryDict and UniprotIDtoAnnotationList
            CurrentOrganism = databaseString;

            string databaseFile = GetDatabasePath(databaseString);

            UniProtXml uniprotXml = new UniProtXml(databaseFile);

            Dictionary<string, List<string>> ensemblToUniprotDict = new Dictionary<string, List<string>>();
            foreach (entry uniprotEntry in uniprotXml.Entries)
            {
                List<string> uniprotIDs = new List<string>();
                List<AnnotationEntry> annotationEntries = new List<AnnotationEntry>();
                foreach (string acession in uniprotEntry.accession)
                {
                    uniprotIDs.Add(acession);
                }

                if (uniprotEntry.keyword != null)
                {
                    if (annotationsToAdd.Contains(AnnotationType.Keywords))
                    {
                        foreach (keywordType keyword in uniprotEntry.keyword)
                        {
                            string keywordID = keyword.id;
                            AnnotationEntry outEntry = null;

                            if (AnnotationEntryDict.TryGetValue(keywordID, out outEntry))
                            {
                                annotationEntries.Add(outEntry);
                            }
                            else
                            {
                                AnnotationEntry addEntry = new AnnotationEntry(keywordID, keyword.Value, AnnotationType.Keywords);
                                annotationEntries.Add(addEntry);
                                AnnotationEntryDict.Add(addEntry.UniqueID, addEntry);
                            }
                        }
                    }
                }

                if (uniprotEntry.dbReference != null)
                {
                    foreach (dbReferenceType goTerm in uniprotEntry.dbReference)
                    {
                        if (goTerm.type.Equals("GO"))
                        {
                            string goID = goTerm.id;
                            AnnotationEntry outEntry = null;

                            if (AnnotationEntryDict.TryGetValue(goID, out outEntry))
                            {
                                annotationEntries.Add(outEntry);
                            }
                            else
                            {
                                string goName = null;
                                AnnotationType goType = AnnotationType.GOCellularComponent;
                                foreach (propertyType property in goTerm.property)
                                {
                                    if (property.type.Equals("term"))
                                    {
                                        string goString = property.value;
                                        string[] goArray = goString.Split(':');

                                        if (goArray[0].Equals("C"))
                                        {
                                            goType = AnnotationType.GOCellularComponent;
                                        }
                                        else if (goArray[0].Equals("F"))
                                        {
                                            goType = AnnotationType.GOMolecularFunction;
                                        }
                                        else if (goArray[0].Equals("P"))
                                        {
                                            goType = AnnotationType.GOBiologicalProcesses;
                                        }

                                        goName = goArray[1];
                                    }
                                }

                                if (annotationsToAdd.Contains(goType))
                                {
                                    AnnotationEntry addEntry = new AnnotationEntry(goID, goName, goType);
                                    annotationEntries.Add(addEntry);
                                    AnnotationEntryDict.Add(addEntry.UniqueID, addEntry);
                                }
                            }
                        }

                        if (goTerm.type.Equals("Ensembl"))
                        {
                            foreach (propertyType property in goTerm.property)
                            {
                                if (property.type.Equals("protein sequence ID"))
                                {
                                    string ensemblID = property.value;

                                    AnnotationEntry addEntry = new AnnotationEntry(ensemblID, "Ensembl ID", AnnotationType.EnsemblID);

                                    List<string> outList1 = null;
                                    if (ensemblToUniprotDict.TryGetValue(ensemblID, out outList1))
                                    {
                                        foreach (string id in uniprotIDs)
                                        {
                                            if(!outList1.Contains(id))
                                            {
                                                outList1.Add(id);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        List<string> addList = new List<string>();
                                        foreach (string id in uniprotIDs)
                                        {
                                            addList.Add(id);
                                        }
                                        ensemblToUniprotDict.Add(ensemblID, addList);
                                    }
                                }
                            }
                        }
                    }
                }

                //Build the connections to the UniprotIDs
                foreach (AnnotationEntry annotationEntry in annotationEntries)
                {
                    foreach (string uniprotID in uniprotIDs)
                    {
                        Dictionary<AnnotationType, List<string>> outDict = null;
                        if (UniprotIDtoAnnotationList.TryGetValue(uniprotID, out outDict))
                        {
                            List<string> outList = null;
                            if (outDict.TryGetValue(annotationEntry.Type, out outList))
                            {
                                if(!outList.Contains(annotationEntry.UniqueID))
                                {
                                    outList.Add(annotationEntry.UniqueID);
                                }
                            }
                            else
                            {
                                List<string> addList = new List<string>();
                                addList.Add(annotationEntry.UniqueID);
                                outDict.Add(annotationEntry.Type, addList);
                            }
                        }
                        else
                        {
                            Dictionary<AnnotationType, List<string>> addDict = new Dictionary<AnnotationType, List<string>>();
                            List<string> addList = new List<string>();
                            addList.Add(annotationEntry.UniqueID);
                            addDict.Add(annotationEntry.Type, addList);

                            UniprotIDtoAnnotationList.Add(uniprotID, addDict);
                        }
                    }
                }
            }

            //Import the Protein Interactions
            string interactionFile = "C:\\Users\\Chris\\Desktop\\Programs\\Mouse_Protein_Interactions.csv";
            Dictionary<string, Dictionary<string, int>> ProteinInteractionDict = ImportProteinInteractionDictionary(interactionFile);
            foreach (KeyValuePair<string, Dictionary<string, int>> kvp in ProteinInteractionDict)
            {
                List<string> outList = null;
                if (ensemblToUniprotDict.TryGetValue(kvp.Key, out outList))
                {
                    foreach (string primaryUniprotID in outList)
                    {
                        //Grab the annotation list for the uniprot ID
                        Dictionary<AnnotationType, List<string>> outDict = null;
                        if (UniprotIDtoAnnotationList.TryGetValue(primaryUniprotID, out outDict))
                        {
                            List<string> outList2 = null;
                            if (outDict.TryGetValue(AnnotationType.ProteinInteraction, out outList2))
                            {
                                foreach (string secondaryProtein in kvp.Value.Keys)
                                {
                                    List<string> outList3 = null;
                                    if (ensemblToUniprotDict.TryGetValue(secondaryProtein, out outList3))
                                    {
                                        foreach (string secondaryUniprotID in outList3)
                                        {
                                            outList2.Add(secondaryUniprotID);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                List<string> addList = new List<string>();
                                foreach (string secondaryProtein in kvp.Value.Keys)
                                {
                                    List<string> outList3 = null;
                                    if (ensemblToUniprotDict.TryGetValue(secondaryProtein, out outList3))
                                    {
                                        foreach (string secondaryUniprotID in outList3)
                                        {
                                            addList.Add(secondaryUniprotID);
                                        }
                                    }
                                }

                                outDict.Add(AnnotationType.ProteinInteraction, addList);
                            }
                        }
                    }
                }
            }

            uniprotXml.Dispose();
        }
Ejemplo n.º 6
0
        private void LoadEmbededDatabase(string databaseString)
        {
            string databaseLocation = null;
            if (databaseString.Equals("Mouse"))
            {
                databaseLocation = "Coon.Compass.Procyon.Procyon_Mouse_GODatabase.csv";
            }
            else if (databaseString.Equals("Human"))
            {
                databaseLocation = "Coon.Compass.Procyon.Procyon_Human_GODatabase.csv";
            }
            else if (databaseString.Equals("Yeast"))
            {
                databaseLocation = "Coon.Compass.Procyon.Procyon_Yeast_GODatabase.csv";
            }

            if (databaseLocation != null)
            {
                using (var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(databaseLocation))
                using (CsvReader reader = new CsvReader(new StreamReader(stream), true))
                {
                    while (reader.ReadNextRecord())
                    {
                        if (reader["Linkage"].Equals("Connection") || reader["Linkage"].Equals("Interaction"))
                        {
                            string uniprotID = reader["ID"];
                            string goIDList = reader["Contents"];
                            string type = reader["Type"];

                            AnnotationType addType = GetAnnotationType(type);

                            Dictionary<AnnotationType, List<string>> outDict = new Dictionary<AnnotationType, List<string>>();
                            if (UniprotIDtoAnnotationList.TryGetValue(uniprotID, out outDict))
                            {
                                List<string> outStringList = null;
                                if (outDict.TryGetValue(addType, out outStringList))
                                {
                                    foreach (string goID in goIDList.Split('|').ToList())
                                    {
                                        outStringList.Add(goID);
                                    }
                                }
                                else
                                {
                                    List<String> addList = new List<string>();
                                    foreach (string goID in goIDList.Split('|').ToList())
                                    {
                                        addList.Add(goID);
                                    }
                                    outDict.Add(addType, addList);
                                }
                            }
                            else
                            {
                                List<string> addList = new List<string>();
                                foreach (string goID in goIDList.Split('|').ToList())
                                {
                                    addList.Add(goID);
                                }
                                Dictionary<AnnotationType, List<string>> addDict = new Dictionary<AnnotationType, List<string>>();
                                addDict.Add(addType, addList);

                                UniprotIDtoAnnotationList.Add(uniprotID, addDict);
                            }

                        }
                        else if (reader["Linkage"].Equals("Annotation"))
                        {
                            string annotationID = reader["ID"];
                            string annotationName = reader["Contents"];
                            string type = reader["Type"];

                            AnnotationType addType = GetAnnotationType(type);

                            AnnotationEntry addEntry = new AnnotationEntry(annotationID, annotationName, addType);

                            AnnotationEntryDict.Add(addEntry.UniqueID, addEntry);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        private void ImportSavedProcyonDatabase(string databaseFile)
        {
            using (CsvReader reader = new CsvReader(new StreamReader(databaseFile), true))
            {
                while (reader.ReadNextRecord())
                {
                    if (reader["Linkage"].Equals("Connection") || reader["Linkage"].Equals("Interaction"))
                    {
                        string uniprotID = reader["ID"];
                        string goIDList = reader["Contents"];
                        string type = reader["Type"];

                        AnnotationType addType = GetAnnotationType(type);

                        Dictionary<AnnotationType, List<string>> outDict = new Dictionary<AnnotationType, List<string>>();
                        if (UniprotIDtoAnnotationList.TryGetValue(uniprotID, out outDict))
                        {
                            List<string> outStringList = null;
                            if (outDict.TryGetValue(addType, out outStringList))
                            {
                                foreach (string goID in goIDList.Split('|').ToList())
                                {
                                    outStringList.Add(goID);
                                }
                            }
                            else
                            {
                                List<String> addList = new List<string>();
                                foreach (string goID in goIDList.Split('|').ToList())
                                {
                                    addList.Add(goID);
                                }
                                outDict.Add(addType, addList);
                            }
                        }
                        else
                        {
                            List<string> addList = new List<string>();
                            foreach (string goID in goIDList.Split('|').ToList())
                            {
                                addList.Add(goID);
                            }
                            Dictionary<AnnotationType, List<string>> addDict = new Dictionary<AnnotationType, List<string>>();
                            addDict.Add(addType, addList);

                            UniprotIDtoAnnotationList.Add(uniprotID, addDict);
                        }

                    }
                    else if (reader["Linkage"].Equals("Annotation"))
                    {
                        string annotationID = reader["ID"];
                        string annotationName = reader["Contents"];
                        string type = reader["Type"];

                        AnnotationType addType = GetAnnotationType(type);

                        AnnotationEntry addEntry = new AnnotationEntry(annotationID, annotationName, addType);

                        AnnotationEntryDict.Add(addEntry.UniqueID, addEntry);
                    }
                }
            }
        }