public void ToHMDB_metabolite(metabolite db_metabolite) { Hmdb_accession = db_metabolite.Hmdb_accession; Hmdb_secondary_accessions = db_metabolite.Hmdb_secondary_accessions; Name = db_metabolite.Name; IsProblematic = db_metabolite.IsProblematic; Synonym_names = db_metabolite.Synonym_names; Description = db_metabolite.Description; Description_chebi = db_metabolite.Description_chebi; Quality = db_metabolite.Quality; Comment = db_metabolite.Comment; Charge = db_metabolite.Charge; Formula = db_metabolite.Formula; Formula_chebi = db_metabolite.Formula_chebi; Average_molecular_weight = db_metabolite.Average_molecular_weight; Monisotopic_molecular_weight = db_metabolite.Monisotopic_molecular_weight; Mass = db_metabolite.Mass; Monoisotopic_mass = db_metabolite.Monoisotopic_mass; Iupac_name = db_metabolite.Iupac_name; Traditional_iupac = db_metabolite.Traditional_iupac; Cas_registry_number = db_metabolite.Cas_registry_number; Cts_cas = db_metabolite.Cts_cas; Smiles = db_metabolite.Smiles; Inchi = db_metabolite.Inchi; Inchi_chebi = db_metabolite.Inchi_chebi; Inchikey = db_metabolite.Inchikey; My_taxonomy = new taxonomy() { Direct_parent = db_metabolite.My_taxonomy.Direct_parent, Kingdom = db_metabolite.My_taxonomy.Kingdom, Super_class = db_metabolite.My_taxonomy.Super_class, Tclass = db_metabolite.My_taxonomy.Tclass, Substituents = db_metabolite.My_taxonomy.Substituents, Other_descriptors = db_metabolite.My_taxonomy.Other_descriptors }; My_onotology = new ontology() { Status = db_metabolite.My_onotology.Status, Origins = db_metabolite.My_onotology.Origins, Biofunctions = db_metabolite.My_onotology.Biofunctions, Applications = db_metabolite.My_onotology.Applications, Cellular_locations = db_metabolite.My_onotology.Cellular_locations }; State = db_metabolite.State; Biofluid_locations = db_metabolite.Biofluid_locations; Tissue_locations = db_metabolite.Tissue_locations; List_of_pathways = db_metabolite.List_of_pathways; Drugbank_id = db_metabolite.Drugbank_id; Drugbank_metabolite_id = db_metabolite.Drugbank_metabolite_id; Chemspider_id = db_metabolite.Chemspider_id; Kegg_id = db_metabolite.Kegg_id; Cts_kegg = db_metabolite.Cts_kegg; Metlin_id = db_metabolite.Metlin_id; Pubchem_compound_id = db_metabolite.Pubchem_compound_id; Chebi_id = db_metabolite.Chebi_id; Cts_chebi = db_metabolite.Cts_chebi; Synthesis_reference = db_metabolite.Synthesis_reference; List_of_proteins = db_metabolite.List_of_proteins; }
public void metabolite_from_db(string db_line) { List <string> breakAtSep = db_line.Split('\t').ToList(); Hmdb_accession = breakAtSep.First(); //0 Hmdb_secondary_accessions = breakAtSep.ElementAt(1).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(); //1 Name = breakAtSep.ElementAt(2); //2 IsProblematic = Convert.ToBoolean(breakAtSep.ElementAt(3)); //3 Synonym_names = breakAtSep.ElementAt(4).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(); //4 Description = breakAtSep.ElementAt(5); //5 Description_chebi = breakAtSep.ElementAt(6); //6 Quality = breakAtSep.ElementAt(7); //7 Comment = breakAtSep.ElementAt(8); //8 Charge = breakAtSep.ElementAt(9); //9 Formula = breakAtSep.ElementAt(10); //10 Formula_chebi = breakAtSep.ElementAt(11); //11 Average_molecular_weight = Convert.ToDouble(breakAtSep.ElementAt(12)); //12 Monisotopic_molecular_weight = Convert.ToDouble(breakAtSep.ElementAt(13)); //13 Mass = Convert.ToDouble(breakAtSep.ElementAt(14)); //14 Monoisotopic_mass = Convert.ToDouble(breakAtSep.ElementAt(15)); //15 Iupac_name = breakAtSep.ElementAt(16); //16 Traditional_iupac = breakAtSep.ElementAt(17); //17 Cas_registry_number = breakAtSep.ElementAt(18); //18 Cts_cas = breakAtSep.ElementAt(19).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(); //19 Smiles = breakAtSep.ElementAt(20); //20 Inchi = breakAtSep.ElementAt(21); //21 Inchi_chebi = breakAtSep.ElementAt(22); //22 Inchikey = breakAtSep.ElementAt(23); //23 My_taxonomy = new taxonomy() { Description = breakAtSep.ElementAt(24), //24 Direct_parent = breakAtSep.ElementAt(25), //25 Kingdom = breakAtSep.ElementAt(26), //26 Super_class = breakAtSep.ElementAt(27), //27 Tclass = breakAtSep.ElementAt(28), //28 Molecular_framework = breakAtSep.ElementAt(29), //29 Alternative_parents = breakAtSep.ElementAt(30).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(), //30 Substituents = breakAtSep.ElementAt(31).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(), //31 Other_descriptors = breakAtSep.ElementAt(32).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList() //32 }; My_onotology = new ontology() { Status = breakAtSep.ElementAt(33), //33 Origins = breakAtSep.ElementAt(34).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(), //34 Biofunctions = breakAtSep.ElementAt(35).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(), //35 Applications = breakAtSep.ElementAt(36).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(), //36 Cellular_locations = breakAtSep.ElementAt(37).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList() //37 }; State = breakAtSep.ElementAt(38); //38 Biofluid_locations = breakAtSep.ElementAt(39).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(); //39 Tissue_locations = breakAtSep.ElementAt(40).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(); //40 List_of_pathways = returnListOfPathways(breakAtSep.GetRange(41, 16)); //41-56 Drugbank_id = breakAtSep.ElementAt(57); //57 Drugbank_metabolite_id = breakAtSep.ElementAt(58); //58 Chemspider_id = breakAtSep.ElementAt(59); //59 Kegg_id = breakAtSep.ElementAt(60); //60 Cts_kegg = breakAtSep.ElementAt(61).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(); //61 Metlin_id = breakAtSep.ElementAt(62); //62 Pubchem_compound_id = breakAtSep.ElementAt(63); //63 Cts_Pubchem = breakAtSep.ElementAt(64).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(); //64 Lipidmaps_id = breakAtSep.ElementAt(65); //65 Cts_Lipidmaps = breakAtSep.ElementAt(66).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(); //66 Chebi_id = breakAtSep.ElementAt(67); //67 Cts_chebi = breakAtSep.ElementAt(68).Split('|').Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)).ToList(); //68 Synthesis_reference = breakAtSep.ElementAt(69); //69 List_of_proteins = returnListOfProteins(breakAtSep.GetRange(70, 5)); //70-74 List_of_diseases = returnListOfDiseases(breakAtSep.GetRange(75, 3)); //75-77 }
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; } } }