public HMDB_metabolite_multiple_files(string inputFile) { Cts_cas = new List <string>(); Cts_kegg = new List <string>(); Cts_chebi = new List <string>(); string tmp_string = ""; XmlReader reader = XmlReader.Create(@"" + inputFile); XmlReader subTree; XElement subTreeContent; #region accession reader.ReadToFollowing("accession"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Hmdb_accession = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region secondary_accessions Hmdb_secondary_accessions = new List <string>(); reader.ReadToFollowing("secondary_accessions"); subTree = reader.ReadSubtree(); subTreeContent = XElement.Load(subTree); foreach (XElement synonym_content in subTreeContent.Descendants("accession")) { if (string.IsNullOrEmpty(synonym_content.Value) || string.IsNullOrWhiteSpace(synonym_content.Value) || synonym_content.Value == "\n") { continue; } else { Hmdb_secondary_accessions.Add(synonym_content.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()); } } #endregion #region name reader.ReadToFollowing("name"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Name = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region description reader.ReadToFollowing("description"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Description = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region synonyms Synonym_names = new List <string>(); reader.ReadToFollowing("synonyms"); subTree = reader.ReadSubtree(); subTreeContent = XElement.Load(subTree); foreach (XElement synonym_content in subTreeContent.Descendants("synonym")) { if (string.IsNullOrEmpty(synonym_content.Value) || string.IsNullOrWhiteSpace(synonym_content.Value) || synonym_content.Value == "\n") { continue; } else { Synonym_names.Add(synonym_content.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()); } } #endregion #region chemical_formula reader.ReadToFollowing("chemical_formula"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Formula = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region average_molecular_weight reader.ReadToFollowing("average_molecular_weight"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Average_molecular_weight = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? -1 : Convert.ToDouble(tmp_string); #endregion #region monisotopic_moleculate_weight reader.ReadToFollowing("monisotopic_moleculate_weight"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Monisotopic_molecular_weight = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? -1 : Convert.ToDouble(tmp_string); #endregion #region iupac_name reader.ReadToFollowing("iupac_name"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Iupac_name = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region traditional_iupac reader.ReadToFollowing("traditional_iupac"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Traditional_iupac = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region cas_registry_number reader.ReadToFollowing("cas_registry_number"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Cas_registry_number = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region smiles reader.ReadToFollowing("smiles"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Smiles = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region inchi reader.ReadToFollowing("inchi"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim().Split('=').Last(); Inchi = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region inchikey reader.ReadToFollowing("inchikey"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim().Split('=').Last(); Inchikey = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region taxonomy reader.ReadToFollowing("taxonomy"); subTree = reader.ReadSubtree(); subTreeContent = XElement.Load(subTree); My_taxonomy = new taxonomy() { Direct_parent = (string.IsNullOrEmpty(subTreeContent.Descendants("direct_parent").First().Value) || string.IsNullOrWhiteSpace(subTreeContent.Descendants("direct_parent").First().Value) || subTreeContent.Descendants("direct_parent").First().Value == "\n") ? "" : subTreeContent.Descendants("direct_parent").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Kingdom = (string.IsNullOrEmpty(subTreeContent.Descendants("kingdom").First().Value) || string.IsNullOrWhiteSpace(subTreeContent.Descendants("kingdom").First().Value) || subTreeContent.Descendants("kingdom").First().Value == "\n") ? "" : subTreeContent.Descendants("kingdom").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Super_class = (string.IsNullOrEmpty(subTreeContent.Descendants("super_class").First().Value) || string.IsNullOrWhiteSpace(subTreeContent.Descendants("super_class").First().Value) || subTreeContent.Descendants("super_class").First().Value == "\n") ? "" : subTreeContent.Descendants("super_class").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Tclass = (string.IsNullOrEmpty(subTreeContent.Descendants("class").First().Value) || string.IsNullOrWhiteSpace(subTreeContent.Descendants("class").First().Value) || subTreeContent.Descendants("class").First().Value == "\n") ? "" : subTreeContent.Descendants("class").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Substituents = subTreeContent.Descendants("substituents").First().Descendants("substituent").Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList(), Other_descriptors = subTreeContent.Descendants("other_descriptors").First().Descendants("descriptor").Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList() }; #endregion #region ontology reader.ReadToFollowing("ontology"); subTree = reader.ReadSubtree(); subTreeContent = XElement.Load(subTree); My_onotology = new ontology() { Status = (string.IsNullOrEmpty(subTreeContent.Descendants("status").First().Value) || string.IsNullOrWhiteSpace(subTreeContent.Descendants("status").First().Value) || subTreeContent.Descendants("status").First().Value == "\n") ? "" : subTreeContent.Descendants("status").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Origins = subTreeContent.Descendants("origins").First().Descendants("origin").Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList(), Biofunctions = subTreeContent.Descendants("biofunctions").First().Descendants("biofunction").Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList(), Applications = subTreeContent.Descendants("applications").First().Descendants("application").Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList(), Cellular_locations = subTreeContent.Descendants("cellular_locations").First().Descendants("cellular_location").Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList() }; #endregion #region state reader.ReadToFollowing("state"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); State = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region biofluid_locations Biofluid_locations = new List <string>(); reader.ReadToFollowing("biofluid_locations"); subTree = reader.ReadSubtree(); subTreeContent = XElement.Load(subTree); foreach (XElement synonym_content in subTreeContent.Descendants("biofluid")) { if (string.IsNullOrEmpty(synonym_content.Value) || string.IsNullOrWhiteSpace(synonym_content.Value) || synonym_content.Value == "\n") { continue; } else { Biofluid_locations.Add(synonym_content.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()); } } #endregion #region tissue_locations Tissue_locations = new List <string>(); reader.ReadToFollowing("tissue_locations"); subTree = reader.ReadSubtree(); subTreeContent = XElement.Load(subTree); foreach (XElement synonym_content in subTreeContent.Descendants("tissue")) { if (string.IsNullOrEmpty(synonym_content.Value) || string.IsNullOrWhiteSpace(synonym_content.Value) || synonym_content.Value == "\n") { continue; } else { Tissue_locations.Add(synonym_content.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()); } } #endregion #region pathways List_of_pathways = new List <pathway>(); reader.ReadToFollowing("pathways"); subTree = reader.ReadSubtree(); subTreeContent = XElement.Load(subTree); string kegg_map_id = "", smpdb_id = ""; pathway ptwy; foreach (XElement pathway_content in subTreeContent.Descendants("pathway")) { kegg_map_id = (string.IsNullOrEmpty(pathway_content.Descendants("kegg_map_id").First().Value) || string.IsNullOrWhiteSpace(pathway_content.Descendants("kegg_map_id").First().Value) || pathway_content.Descendants("kegg_map_id").First().Value == "\n") ? "" : pathway_content.Descendants("kegg_map_id").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); smpdb_id = (string.IsNullOrEmpty(pathway_content.Descendants("smpdb_id").First().Value) || string.IsNullOrWhiteSpace(pathway_content.Descendants("smpdb_id").First().Value) || pathway_content.Descendants("smpdb_id").First().Value == "\n") ? "" : pathway_content.Descendants("smpdb_id").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); ptwy = new pathway() { Kegg_map_id = kegg_map_id, Smpdb_map_id = smpdb_id }; ptwy.get_details(); List_of_pathways.Add(ptwy); } foreach (SMPDB_pathway smpdb_ptwy in SMPDB_pathways.list_of_smpdb_pathways.Where(x => x.Hmdb_id == Hmdb_accession)) { if (!List_of_pathways.Any(x => x.Smpdb_map_id == smpdb_ptwy.Id)) { ptwy = new pathway() { Kegg_map_id = "", Smpdb_map_id = smpdb_ptwy.Id }; ptwy.get_details(); List_of_pathways.Add(ptwy); } } #endregion #region drugbank_id reader.ReadToFollowing("drugbank_id"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Drugbank_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region drugbank_metabolite_id reader.ReadToFollowing("drugbank_metabolite_id"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Drugbank_metabolite_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region chemspider_id reader.ReadToFollowing("chemspider_id"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Chemspider_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region kegg_id Dict_kegg_details = new Dictionary <string, KEGG_entry_details>(); reader.ReadToFollowing("kegg_id"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Kegg_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; addKeggDetails((string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string); #endregion #region metlin_id reader.ReadToFollowing("metlin_id"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Metlin_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region pubchem_compound_id reader.ReadToFollowing("pubchem_compound_id"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Pubchem_compound_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region chebi_id reader.ReadToFollowing("chebi_id"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Chebi_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region synthesis_reference reader.ReadToFollowing("synthesis_reference"); tmp_string = reader.ReadElementContentAsString().Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Synthesis_reference = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; #endregion #region protein_associations List_of_proteins = new List <protein>(); reader.ReadToFollowing("protein_associations"); subTree = reader.ReadSubtree(); subTreeContent = XElement.Load(subTree); foreach (XElement pathway_content in subTreeContent.Descendants("protein")) { List_of_proteins.Add(new protein() { Protein_accession = (string.IsNullOrEmpty(pathway_content.Descendants("protein_accession").First().Value) || string.IsNullOrWhiteSpace(pathway_content.Descendants("protein_accession").First().Value) || pathway_content.Descendants("protein_accession").First().Value == "\n") ? "" : pathway_content.Descendants("protein_accession").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Name = (string.IsNullOrEmpty(pathway_content.Descendants("name").First().Value) || string.IsNullOrWhiteSpace(pathway_content.Descendants("name").First().Value) || pathway_content.Descendants("name").First().Value == "\n") ? "" : pathway_content.Descendants("name").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Uniprot_id = (string.IsNullOrEmpty(pathway_content.Descendants("uniprot_id").First().Value) || string.IsNullOrWhiteSpace(pathway_content.Descendants("uniprot_id").First().Value) || pathway_content.Descendants("uniprot_id").First().Value == "\n") ? "" : pathway_content.Descendants("uniprot_id").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Gene_name = (string.IsNullOrEmpty(pathway_content.Descendants("gene_name").First().Value) || string.IsNullOrWhiteSpace(pathway_content.Descendants("gene_name").First().Value) || pathway_content.Descendants("gene_name").First().Value == "\n") ? "" : pathway_content.Descendants("gene_name").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Protein_type = (string.IsNullOrEmpty(pathway_content.Descendants("protein_type").First().Value) || string.IsNullOrWhiteSpace(pathway_content.Descendants("protein_type").First().Value) || pathway_content.Descendants("protein_type").First().Value == "\n") ? "" : pathway_content.Descendants("protein_type").First().Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim() }); } #endregion }
public HMDB_metabolite_single_file(XElement metaboliteElement) { Cts_cas = new List <string>(); Cts_kegg = new List <string>(); Cts_chebi = new List <string>(); string tmp_string = ""; foreach (XElement item in metaboliteElement.Elements()) { switch (item.Name.LocalName) { case "accession": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Hmdb_accession = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "secondary_accessions": Hmdb_secondary_accessions = new List <string>(); foreach (XElement secondary_accession in item.Elements().Where(x => x.Name.LocalName == "accession")) { if (string.IsNullOrEmpty(secondary_accession.Value) || string.IsNullOrWhiteSpace(secondary_accession.Value) || secondary_accession.Value == "\n") { continue; } else { Hmdb_secondary_accessions.Add(secondary_accession.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()); } } break; case "name": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Name = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "description": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Description = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "synonyms": Synonym_names = new List <string>(); foreach (XElement synonym_content in item.Elements().Where(x => x.Name.LocalName == "synonym")) { if (string.IsNullOrEmpty(synonym_content.Value) || string.IsNullOrWhiteSpace(synonym_content.Value) || synonym_content.Value == "\n") { continue; } else { Synonym_names.Add(synonym_content.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()); } } break; case "chemical_formula": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Formula = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "average_molecular_weight": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Average_molecular_weight = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? -1 : Convert.ToDouble(tmp_string); break; case "monisotopic_moleculate_weight": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Monisotopic_molecular_weight = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? -1 : Convert.ToDouble(tmp_string); break; case "iupac_name": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Iupac_name = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "traditional_iupac": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Traditional_iupac = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "cas_registry_number": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Cas_registry_number = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "smiles": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Smiles = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "inchi": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Inchi = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "inchikey": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Inchikey = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "taxonomy": My_taxonomy = new taxonomy() { Description = (string.IsNullOrEmpty(item.Elements().First(x => x.Name.LocalName == "description").Value) || string.IsNullOrWhiteSpace(item.Elements().First(x => x.Name.LocalName == "description").Value) || item.Elements().First(x => x.Name.LocalName == "description").Value == "\n") ? "" : item.Elements().First(x => x.Name.LocalName == "description").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Direct_parent = (string.IsNullOrEmpty(item.Elements().First(x => x.Name.LocalName == "direct_parent").Value) || string.IsNullOrWhiteSpace(item.Elements().First(x => x.Name.LocalName == "direct_parent").Value) || item.Elements().First(x => x.Name.LocalName == "direct_parent").Value == "\n") ? "" : item.Elements().First(x => x.Name.LocalName == "direct_parent").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Kingdom = (string.IsNullOrEmpty(item.Elements().First(x => x.Name.LocalName == "kingdom").Value) || string.IsNullOrWhiteSpace(item.Elements().First(x => x.Name.LocalName == "kingdom").Value) || item.Elements().First(x => x.Name.LocalName == "kingdom").Value == "\n") ? "" : item.Elements().First(x => x.Name.LocalName == "kingdom").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Super_class = (string.IsNullOrEmpty(item.Elements().First(x => x.Name.LocalName == "super_class").Value) || string.IsNullOrWhiteSpace(item.Elements().First(x => x.Name.LocalName == "super_class").Value) || item.Elements().First(x => x.Name.LocalName == "super_class").Value == "\n") ? "" : item.Elements().First(x => x.Name.LocalName == "super_class").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Tclass = (string.IsNullOrEmpty(item.Elements().First(x => x.Name.LocalName == "class").Value) || string.IsNullOrWhiteSpace(item.Elements().First(x => x.Name.LocalName == "class").Value) || item.Elements().First(x => x.Name.LocalName == "class").Value == "\n") ? "" : item.Elements().First(x => x.Name.LocalName == "class").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Molecular_framework = (string.IsNullOrEmpty(item.Elements().First(x => x.Name.LocalName == "direct_parent").Value) || string.IsNullOrWhiteSpace(item.Elements().First(x => x.Name.LocalName == "direct_parent").Value) || item.Elements().First(x => x.Name.LocalName == "direct_parent").Value == "\n") ? "" : item.Elements().First(x => x.Name.LocalName == "direct_parent").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Alternative_parents = item.Elements().First(x => x.Name.LocalName == "alternative_parents").Elements().Where(x => x.Name.LocalName == "alternative_parent"). Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList(), Substituents = item.Elements().First(x => x.Name.LocalName == "substituents").Elements().Where(x => x.Name.LocalName == "substituent"). Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList() }; break; case "ontology": My_onotology = new ontology() { Status = (string.IsNullOrEmpty(item.Elements().First(x => x.Name.LocalName == "status").Value) || string.IsNullOrWhiteSpace(item.Elements().First(x => x.Name.LocalName == "status").Value) || item.Elements().First(x => x.Name.LocalName == "status").Value == "\n") ? "" : item.Elements().First(x => x.Name.LocalName == "status").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Origins = item.Elements().First(x => x.Name.LocalName == "origins").Elements().Where(x => x.Name.LocalName == "origin"). Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList(), Biofunctions = item.Elements().First(x => x.Name.LocalName == "biofunctions").Elements().Where(x => x.Name.LocalName == "biofunction"). Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList(), Applications = item.Elements().First(x => x.Name.LocalName == "applications").Elements().Where(x => x.Name.LocalName == "application"). Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList(), Cellular_locations = item.Elements().First(x => x.Name.LocalName == "cellular_locations").Elements().Where(x => x.Name.LocalName == "cellular_location"). Select(x => x.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()).ToList() }; break; case "state": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); State = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "biofluid_locations": Biofluid_locations = new List <string>(); foreach (XElement biofluid in item.Elements().Where(x => x.Name.LocalName == "biofluid")) { if (string.IsNullOrEmpty(biofluid.Value) || string.IsNullOrWhiteSpace(biofluid.Value) || biofluid.Value == "\n") { continue; } else { Biofluid_locations.Add(biofluid.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()); } } break; case "tissue_locations": Tissue_locations = new List <string>(); foreach (XElement tissue in item.Elements().Where(x => x.Name.LocalName == "tissue")) { if (string.IsNullOrEmpty(tissue.Value) || string.IsNullOrWhiteSpace(tissue.Value) || tissue.Value == "\n") { continue; } else { Tissue_locations.Add(tissue.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()); } } break; case "pathways": List_of_pathways = new List <pathway>(); string kegg_map_id = "", smpdb_id = ""; pathway ptwy; foreach (XElement cpathway in item.Elements().Where(x => x.Name.LocalName == "pathway")) { kegg_map_id = (string.IsNullOrEmpty(cpathway.Elements().First(x => x.Name.LocalName == "kegg_map_id").Value) || string.IsNullOrWhiteSpace(cpathway.Elements().First(x => x.Name.LocalName == "kegg_map_id").Value) || cpathway.Elements().First(x => x.Name.LocalName == "kegg_map_id").Value == "\n") ? "" : cpathway.Elements().First(x => x.Name.LocalName == "kegg_map_id").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); smpdb_id = (string.IsNullOrEmpty(cpathway.Elements().First(x => x.Name.LocalName == "smpdb_id").Value) || string.IsNullOrWhiteSpace(cpathway.Elements().First(x => x.Name.LocalName == "smpdb_id").Value) || cpathway.Elements().First(x => x.Name.LocalName == "smpdb_id").Value == "\n") ? "" : cpathway.Elements().First(x => x.Name.LocalName == "smpdb_id").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); ptwy = new pathway() { Kegg_map_id = kegg_map_id, Smpdb_map_id = smpdb_id }; ptwy.get_details(); List_of_pathways.Add(ptwy); } foreach (SMPDB_pathway smpdb_ptwy in SMPDB_pathways.list_of_smpdb_pathways.Where(x => x.Hmdb_id == Hmdb_accession)) { if (!List_of_pathways.Any(x => x.Smpdb_map_id == smpdb_ptwy.Id)) { ptwy = new pathway() { Kegg_map_id = "", Smpdb_map_id = smpdb_ptwy.Id }; ptwy.get_details(); List_of_pathways.Add(ptwy); } } break; case "drugbank_id": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Drugbank_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "drugbank_metabolite_id": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Drugbank_metabolite_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "chemspider_id": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Chemspider_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "kegg_id": Dict_kegg_details = new Dictionary <string, KEGG_entry_details>(); tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Kegg_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; addKeggDetails((string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string); break; case "metlin_id": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Metlin_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "pubchem_compound_id": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Pubchem_compound_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "chebi_id": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Chebi_id = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "synthesis_reference": tmp_string = item.Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(); Synthesis_reference = (string.IsNullOrEmpty(tmp_string) || string.IsNullOrWhiteSpace(tmp_string) || tmp_string == "\n") ? "" : tmp_string; break; case "protein_associations": List_of_proteins = new List <protein>(); foreach (XElement protein in item.Elements().Where(x => x.Name.LocalName == "protein")) { List_of_proteins.Add(new protein() { Protein_accession = (string.IsNullOrEmpty(protein.Elements().First(x => x.Name.LocalName == "protein_accession").Value) || string.IsNullOrWhiteSpace(protein.Elements().First(x => x.Name.LocalName == "protein_accession").Value) || protein.Elements().First(x => x.Name.LocalName == "protein_accession").Value == "\n") ? "" : protein.Elements().First(x => x.Name.LocalName == "protein_accession").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Name = (string.IsNullOrEmpty(protein.Elements().First(x => x.Name.LocalName == "name").Value) || string.IsNullOrWhiteSpace(protein.Elements().First(x => x.Name.LocalName == "name").Value) || protein.Elements().First(x => x.Name.LocalName == "name").Value == "\n") ? "" : protein.Elements().First(x => x.Name.LocalName == "name").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Uniprot_id = (string.IsNullOrEmpty(protein.Elements().First(x => x.Name.LocalName == "uniprot_id").Value) || string.IsNullOrWhiteSpace(protein.Elements().First(x => x.Name.LocalName == "uniprot_id").Value) || protein.Elements().First(x => x.Name.LocalName == "uniprot_id").Value == "\n") ? "" : protein.Elements().First(x => x.Name.LocalName == "uniprot_id").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Gene_name = (string.IsNullOrEmpty(protein.Elements().First(x => x.Name.LocalName == "gene_name").Value) || string.IsNullOrWhiteSpace(protein.Elements().First(x => x.Name.LocalName == "gene_name").Value) || protein.Elements().First(x => x.Name.LocalName == "gene_name").Value == "\n") ? "" : protein.Elements().First(x => x.Name.LocalName == "gene_name").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Protein_type = (string.IsNullOrEmpty(protein.Elements().First(x => x.Name.LocalName == "protein_type").Value) || string.IsNullOrWhiteSpace(protein.Elements().First(x => x.Name.LocalName == "protein_type").Value) || protein.Elements().First(x => x.Name.LocalName == "protein_type").Value == "\n") ? "" : protein.Elements().First(x => x.Name.LocalName == "protein_type").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim() }); } break; case "diseases": List_of_diseases = new List <disease>(); disease ds; foreach (XElement cdisease in item.Elements().Where(x => x.Name.LocalName == "disease")) { ds = new disease() { Name = (string.IsNullOrEmpty(cdisease.Elements().First(x => x.Name.LocalName == "name").Value) || string.IsNullOrWhiteSpace(cdisease.Elements().First(x => x.Name.LocalName == "name").Value) || cdisease.Elements().First(x => x.Name.LocalName == "name").Value == "\n") ? "" : cdisease.Elements().First(x => x.Name.LocalName == "name").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), Omim_id = (string.IsNullOrEmpty(cdisease.Elements().First(x => x.Name.LocalName == "omim_id").Value) || string.IsNullOrWhiteSpace(cdisease.Elements().First(x => x.Name.LocalName == "omim_id").Value) || cdisease.Elements().First(x => x.Name.LocalName == "omim_id").Value == "\n") ? "" : cdisease.Elements().First(x => x.Name.LocalName == "omim_id").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim(), List_of_pubmed_ids = new List <string>() }; foreach (XElement references in cdisease.Elements().Where(x => x.Name.LocalName == "references")) { foreach (XElement reference in references.Elements().Where(x => x.Name.LocalName == "reference")) { if (reference.Elements().Any(x => x.Name.LocalName == "pubmed_id") && !string.IsNullOrEmpty(reference.Elements().First(x => x.Name.LocalName == "pubmed_id").Value) && !string.IsNullOrWhiteSpace(reference.Elements().First(x => x.Name.LocalName == "pubmed_id").Value) && reference.Elements().First(x => x.Name.LocalName == "pubmed_id").Value != "\n") { ds.List_of_pubmed_ids.Add(reference.Elements().First(x => x.Name.LocalName == "pubmed_id").Value.Replace("\r", "").Replace("\n", "").Replace("\t", "").Trim()); } } } List_of_diseases.Add(ds); } break; default: break; } } }