示例#1
0
        private UniprotEntry CopyEntry()
        {
            UniprotEntry newEntry = new UniprotEntry();

            DbReferenceType[] dbRefTypes = new DbReferenceType[dbEntries.Keys.Count];
            dbEntries.Keys.CopyTo(dbRefTypes, 0);
            foreach (DbReferenceType refType in dbRefTypes)
            {
                string[] dbRefIDs = Get(refType);
                foreach (string id in dbRefIDs)
                {
                    newEntry.AddDbEntry(refType.UniprotName, id);
                    foreach (KeyValuePair <string, List <string> > property in dbEntries[refType][id].properties)
                    {
                        foreach (string propertyValue in property.Value)
                        {
                            newEntry.AddDbEntryProperty(refType.UniprotName, id, property.Key, propertyValue);
                        }
                    }
                }
            }
            if (features != null)
            {
                foreach (FeatureType type in GetAllFeatureTypes())
                {
                    newEntry.AddFeatures(type, GetFeatures(type));
                }
            }
            foreach (string kword in Keywords)
            {
                newEntry.AddKeyword(kword);
            }
            newEntry.ProteinFullNames  = ProteinFullNames;
            newEntry.ProteinShortNames = ProteinShortNames;
            newEntry.ProteinEcNumbers  = ProteinEcNumbers;
            newEntry.Accessions        = Accessions;
            newEntry.GeneNamesAndTypes = GeneNamesAndTypes;
            newEntry.OrganismNames     = OrganismNames;
            newEntry.UniprotNames      = UniprotNames;
            newEntry.Sequence          = Sequence;
            foreach (string taxId in taxonomyIds)
            {
                newEntry.AddTaxonomyId(taxId);
            }
            foreach (string hostTaxId in hostTaxonomyIds)
            {
                newEntry.AddHostTaxonomyId(hostTaxId);
            }
            return(newEntry);
        }
示例#2
0
        public List <UniprotEntry> ResolveIsoforms(Dictionary <string, List <string> > isoformToEnsembl)
        {
            DbReferenceType     dbRefType = DbReferenceType.ensembl;
            List <UniprotEntry> isoforms  = new List <UniprotEntry>();

            foreach (KeyValuePair <string, List <string> > isofToEnsembl in isoformToEnsembl)
            {
                UniprotEntry modEntry = CopyEntry();
                modEntry.dbEntries.Remove(dbRefType);
                Dictionary <string, UniprotDbReference> enstToData = new Dictionary <string, UniprotDbReference>();
                foreach (string enst in isofToEnsembl.Value)
                {
                    enstToData.Add(enst, dbEntries[dbRefType][enst]);
                }
                modEntry.dbEntries.Add(dbRefType, enstToData);
                isoforms.Add(modEntry);
            }
            return(isoforms);
        }
示例#3
0
 private void StartElement(IEquatable<string> qName, IDictionary<string, string> attrs)
 {
     if (inFeature){
         if (qName.Equals("location")){
             //inFeatureLocation = true;
         } else if (qName.Equals("position")){
             string position = attrs["position"];
             featureBegin = position;
             featureEnd = position;
         } else if (qName.Equals("begin")){
             string position = attrs.ContainsKey("position") ? attrs["position"] : attrs["status"];
             featureBegin = position;
         } else if (qName.Equals("end")){
             string position = attrs.ContainsKey("position") ? attrs["position"] : attrs["status"];
             featureEnd = position;
         } else if (qName.Equals("original")){
             original = new StringBuilder();
         } else if (qName.Equals("variation")){
             variation = new StringBuilder();
         }else{
             throw new Exception("Unknown qname: " + qName);
         }
     }
     if (inOrganism) {
         if (qName.Equals("name")) {
             string type = attrs["type"];
             if (type.Equals("scientific")) {
                 oname = new StringBuilder();
             }
         } else if (qName.Equals("dbReference")) {
             string type = attrs["type"];
             if (type.Equals("NCBI Taxonomy")) {
                 string id = attrs["id"];
                 entry.AddTaxonomyId(id);
             }
         }
     }
     if (inOrganismHost) {
         if (qName.Equals("dbReference")) {
             string type = attrs["type"];
             if (type.Equals("NCBI Taxonomy")) {
                 string id = attrs["id"];
                 entry.AddHostTaxonomyId(id);
             }
         }
     }
     if (qName.Equals("entry")) {
         entry = new UniprotEntry();
         accessions = new List<string>();
         proteinFullNames = new List<string>();
         proteinShortNames = new List<string>();
         proteinEcNumbers = new List<string>();
         gnames = new List<Tuple<string, string>>();
         onames = new List<string>();
         unames = new List<string>();
         level = 0;
         numIsoforms = 0;
         isoformToEnst = new Dictionary<string, List<string>>();
     } else if (qName.Equals("dbReference")){
         inDbRef = true;
         dbReferenceType = attrs["type"];
         dbReferenceId = attrs["id"];
         entry.AddDbEntry(dbReferenceType, dbReferenceId);
     } else if (qName.Equals("molecule") && dbReferenceType.Equals("Ensembl")){
         molecule = new StringBuilder();
     } else if (qName.Equals("property")){
         if (inDbRef){
             entry.AddDbEntryProperty(dbReferenceType, dbReferenceId, attrs["type"], attrs["value"]);
         }
     } else if (qName.Equals("feature")){
         inFeature = true;
         featureType = attrs.ContainsKey("type") ? attrs["type"] : "";
         featureDescription = attrs.ContainsKey("description") ? attrs["description"] : "";
         featureStatus = attrs.ContainsKey("status") ? attrs["status"] : "";
         featureId = attrs.ContainsKey("id") ? attrs["id"] : "";
         entry.AddFeature(featureType, featureDescription, featureStatus, featureId);
     } else if (qName.Equals("sequence")) {
         sequence = new StringBuilder();
     } else if (qName.Equals("keyword")) {
         keyword = new StringBuilder();
     } else if (qName.Equals("accession")) {
         accession = new StringBuilder();
     } else if (qName.Equals("protein")){
         inProtein = true;
     } else if (qName.Equals("recommendedName") && inProtein){
         inProteinRecommendedName = true;
     } else if (qName.Equals("organism")) {
         inOrganism = true;
     } else if (qName.Equals("organismHost")) {
         inOrganismHost = true;
     } else if (qName.Equals("gene")) {
         inGene = true;
     } else if (qName.Equals("fullName") && inProteinRecommendedName){
         proteinFullName = new StringBuilder();
     } else if (qName.Equals("shortName") && inProteinRecommendedName){
         proteinShortName = new StringBuilder();
     } else if (qName.Equals("ecNumber") && inProteinRecommendedName){
         proteinEcNumber = new StringBuilder();
     } else if (qName.Equals("name") && inGene){
         gname = new StringBuilder();
         gnameType = attrs["type"];
     } else if (qName.Equals("name") && level == 1){
         uname = new StringBuilder();
     } else if (qName.Equals("isoform")){
         if (inDbRef)
             ++numIsoforms;
     }
 }
示例#4
0
 private UniprotEntry CopyEntry()
 {
     UniprotEntry newEntry = new UniprotEntry();
     DbReferenceType[] dbRefTypes = new DbReferenceType[dbEntries.Keys.Count];
     dbEntries.Keys.CopyTo(dbRefTypes, 0);
     foreach (DbReferenceType refType in dbRefTypes){
         string[] dbRefIDs = Get(refType);
         foreach (string id in dbRefIDs){
             newEntry.AddDbEntry(refType.UniprotName, id);
             foreach (KeyValuePair<string, List<string>> property in dbEntries[refType][id].properties){
                 foreach (var propertyValue in property.Value){
                     newEntry.AddDbEntryProperty(refType.UniprotName, id, property.Key, propertyValue);
                 }
             }
         }
     }
     if (features != null){
         foreach (FeatureType type in GetAllFeatureTypes()){
             newEntry.AddFeatures(type, GetFeatures(type));
         }
     }
     foreach (string kword in Keywords){
         newEntry.AddKeyword(kword);
     }
     newEntry.ProteinFullNames = ProteinFullNames;
     newEntry.ProteinShortNames = ProteinShortNames;
     newEntry.ProteinEcNumbers = ProteinEcNumbers;
     newEntry.Accessions = Accessions;
     newEntry.GeneNamesAndTypes = GeneNamesAndTypes;
     newEntry.OrganismNames = OrganismNames;
     newEntry.UniprotNames = UniprotNames;
     newEntry.Sequence = Sequence;
     foreach (string taxId in taxonomyIds){
         newEntry.AddTaxonomyId(taxId);
     }
     foreach (string hostTaxId in hostTaxonomyIds){
         newEntry.AddHostTaxonomyId(hostTaxId);
     }
     return newEntry;
 }
示例#5
0
 private void StartElement(IEquatable <string> qName, IDictionary <string, string> attrs)
 {
     if (inFeature)
     {
         if (qName.Equals("location"))
         {
             //inFeatureLocation = true;
         }
         else if (qName.Equals("position"))
         {
             string position = attrs["position"];
             featureBegin = position;
             featureEnd   = position;
         }
         else if (qName.Equals("begin"))
         {
             string position = attrs.ContainsKey("position") ? attrs["position"] : attrs["status"];
             featureBegin = position;
         }
         else if (qName.Equals("end"))
         {
             string position = attrs.ContainsKey("position") ? attrs["position"] : attrs["status"];
             featureEnd = position;
         }
         else if (qName.Equals("original"))
         {
             original = new StringBuilder();
         }
         else if (qName.Equals("variation"))
         {
             variation = new StringBuilder();
         }
         else
         {
             throw new Exception("Unknown qname: " + qName);
         }
     }
     if (inOrganism)
     {
         if (qName.Equals("name"))
         {
             string type = attrs["type"];
             if (type.Equals("scientific"))
             {
                 oname = new StringBuilder();
             }
         }
         else if (qName.Equals("dbReference"))
         {
             string type = attrs["type"];
             if (type.Equals("NCBI Taxonomy"))
             {
                 string id = attrs["id"];
                 entry.AddTaxonomyId(id);
             }
         }
     }
     if (inOrganismHost)
     {
         if (qName.Equals("dbReference"))
         {
             string type = attrs["type"];
             if (type.Equals("NCBI Taxonomy"))
             {
                 string id = attrs["id"];
                 entry.AddHostTaxonomyId(id);
             }
         }
     }
     if (qName.Equals("entry"))
     {
         entry             = new UniprotEntry();
         accessions        = new List <string>();
         proteinFullNames  = new List <string>();
         proteinShortNames = new List <string>();
         proteinEcNumbers  = new List <string>();
         gnames            = new List <Tuple <string, string> >();
         onames            = new List <string>();
         unames            = new List <string>();
         level             = 0;
         numIsoforms       = 0;
         isoformToEnst     = new Dictionary <string, List <string> >();
     }
     else if (qName.Equals("dbReference"))
     {
         inDbRef         = true;
         dbReferenceType = attrs["type"];
         dbReferenceId   = attrs["id"];
         entry.AddDbEntry(dbReferenceType, dbReferenceId);
     }
     else if (qName.Equals("molecule") && dbReferenceType.Equals("Ensembl"))
     {
         molecule = new StringBuilder();
     }
     else if (qName.Equals("property"))
     {
         if (inDbRef)
         {
             entry.AddDbEntryProperty(dbReferenceType, dbReferenceId, attrs["type"], attrs["value"]);
         }
     }
     else if (qName.Equals("feature"))
     {
         inFeature          = true;
         featureType        = attrs.ContainsKey("type") ? attrs["type"] : "";
         featureDescription = attrs.ContainsKey("description") ? attrs["description"] : "";
         featureStatus      = attrs.ContainsKey("status") ? attrs["status"] : "";
         featureId          = attrs.ContainsKey("id") ? attrs["id"] : "";
         entry.AddFeature(featureType, featureDescription, featureStatus, featureId);
     }
     else if (qName.Equals("sequence"))
     {
         sequence = new StringBuilder();
     }
     else if (qName.Equals("keyword"))
     {
         keyword = new StringBuilder();
     }
     else if (qName.Equals("accession"))
     {
         accession = new StringBuilder();
     }
     else if (qName.Equals("protein"))
     {
         inProtein = true;
     }
     else if (qName.Equals("recommendedName") && inProtein)
     {
         inProteinRecommendedName = true;
     }
     else if (qName.Equals("organism"))
     {
         inOrganism = true;
     }
     else if (qName.Equals("organismHost"))
     {
         inOrganismHost = true;
     }
     else if (qName.Equals("gene"))
     {
         inGene = true;
     }
     else if (qName.Equals("fullName") && inProteinRecommendedName)
     {
         proteinFullName = new StringBuilder();
     }
     else if (qName.Equals("shortName") && inProteinRecommendedName)
     {
         proteinShortName = new StringBuilder();
     }
     else if (qName.Equals("ecNumber") && inProteinRecommendedName)
     {
         proteinEcNumber = new StringBuilder();
     }
     else if (qName.Equals("name") && inGene)
     {
         gname     = new StringBuilder();
         gnameType = attrs["type"];
     }
     else if (qName.Equals("name") && level == 1)
     {
         uname = new StringBuilder();
     }
     else if (qName.Equals("isoform"))
     {
         if (inDbRef)
         {
             ++numIsoforms;
         }
     }
 }