private void search_additional_hmdb_in_hmdb_and_additional_hmdb_id() { List <metabolite> tmpListOfMetab = new List <metabolite>(); List <string> foundids = new List <string>(); if (metabolites.List_metabolites.Select(x => x.Hmdb_accession).Intersect(In_add_Hmdb_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any()) { Parallel.ForEach(In_add_Hmdb_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)), addHmdb => { if (metabolites.List_metabolites.Any(x => x.Hmdb_accession == addHmdb)) { tmpListOfMetab.Add(metabolites.List_metabolites.Where(x => x.Hmdb_accession == addHmdb).OrderByDescending(x => x.List_of_pathways.Count).First()); foundids.Add(addHmdb); } }); } else { Parallel.ForEach(In_add_Hmdb_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x)), addHmdb => { Parallel.ForEach(metabolites.List_metabolites, m => { if (m.Hmdb_secondary_accessions.Any(x => x == addHmdb)) { tmpListOfMetab.Add(m); foundids.Add(addHmdb); } }); }); } if (tmpListOfMetab.Count > 1) { outputToLog.WriteLine("more than one compounds in DB file for additional HMDB_ID=" + string.Join("|", foundids)); } ToHMDB_metabolite(tmpListOfMetab.OrderByDescending(x => x.List_of_pathways.Count).First()); }
public void getFromMetaboliteDB() { //here the idea is as follows //first search with primary hmdb, cas, kegg, chebi, pubchem, chemspider, lipidmaps and metlin in the all metabolites list on primary hmdb, cas, kegg, chebi, pubchem, chemspider, lipidmaps and metlin ids respectively //if nothing found search with primary hmdb, cas, kegg and chebi in the all metabolites list on additional (secodnary) hmdb, cas, kegg and chebi ids respectively //if nothing found search with additional (secondary) hmdb, cas, kegg, chebi, pubchem, chemspider, lipidmaps and metlin in the all metabolites list on primary and additional (secodnary) hmdb, cas, kegg, chebi, pubchem, chemspider, lipidmaps and metlin ids respectively if (!string.IsNullOrEmpty(In_Hmdb_id) && !string.IsNullOrWhiteSpace(In_Hmdb_id) && metabolites.List_metabolites.Any(x => x.Hmdb_accession == In_Hmdb_id)) { search_hmdb_in_hmdb_id(); } else if (!string.IsNullOrEmpty(In_Cas_id) && !string.IsNullOrWhiteSpace(In_Cas_id) && metabolites.List_metabolites.Any(x => x.Cas_registry_number == In_Cas_id)) { search_cas_in_cas_id(); } else if (!string.IsNullOrEmpty(In_Kegg_id) && !string.IsNullOrWhiteSpace(In_Kegg_id) && metabolites.List_metabolites.Any(x => x.Kegg_id == In_Kegg_id)) { search_kegg_in_kegg_id(); } else if (!string.IsNullOrEmpty(In_Chebi_id) && !string.IsNullOrWhiteSpace(In_Chebi_id) && metabolites.List_metabolites.Any(x => x.Chebi_id == In_Chebi_id)) { search_chebi_in_chebi_id(); } else if (!string.IsNullOrEmpty(In_Pubchem_id) && !string.IsNullOrWhiteSpace(In_Pubchem_id) && metabolites.List_metabolites.Any(x => x.Pubchem_compound_id == In_Pubchem_id)) { search_pubchem_in_pubchem_id(); } else if (!string.IsNullOrEmpty(In_Chemspider_id) && !string.IsNullOrWhiteSpace(In_Chemspider_id) && metabolites.List_metabolites.Any(x => x.Chemspider_id == In_Chemspider_id)) { search_chemspider_in_chemspider_id(); } else if (!string.IsNullOrEmpty(In_Lipidmaps_id) && !string.IsNullOrWhiteSpace(In_Lipidmaps_id) && metabolites.List_metabolites.Any(x => x.Lipidmaps_id == In_Lipidmaps_id)) { search_lipidmaps_in_lipidmaps_id(); } else if (!string.IsNullOrEmpty(In_Metlin_id) && !string.IsNullOrWhiteSpace(In_Metlin_id) && metabolites.List_metabolites.Any(x => x.Metlin_id == In_Metlin_id)) { search_metlin_in_metlin_id(); } else if (!string.IsNullOrEmpty(In_Hmdb_id) && !string.IsNullOrWhiteSpace(In_Hmdb_id) && metabolites.List_metabolites.SelectMany(x => x.Hmdb_secondary_accessions).Any(x => x == In_Hmdb_id)) { search_hmdb_in_additional_hmdb_id(); } else if (!string.IsNullOrEmpty(In_Cas_id) && !string.IsNullOrWhiteSpace(In_Cas_id) && metabolites.List_metabolites.SelectMany(x => x.Cts_cas).Any(x => x == In_Cas_id)) { search_cas_in_additional_cas_id(); } else if (!string.IsNullOrEmpty(In_Kegg_id) && !string.IsNullOrWhiteSpace(In_Kegg_id) && metabolites.List_metabolites.SelectMany(x => x.Cts_kegg).Any(x => x == In_Kegg_id)) { search_kegg_in_additional_kegg_id(); } else if (!string.IsNullOrEmpty(In_Chebi_id) && !string.IsNullOrWhiteSpace(In_Chebi_id) && metabolites.List_metabolites.SelectMany(x => x.Cts_chebi).Any(x => x == In_Chebi_id)) { search_chebi_in_additional_chebi_id(); } else if (In_add_Hmdb_id.Count > 0 && (metabolites.List_metabolites.Select(x => x.Hmdb_accession).Intersect(In_add_Hmdb_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any() || metabolites.List_metabolites.SelectMany(x => x.Hmdb_secondary_accessions).Intersect(In_add_Hmdb_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any())) { search_additional_hmdb_in_hmdb_and_additional_hmdb_id(); } else if (In_add_Cas_id.Count > 0 && (metabolites.List_metabolites.Select(x => x.Cas_registry_number).Intersect(In_add_Cas_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any() || metabolites.List_metabolites.SelectMany(x => x.Cts_cas).Intersect(In_add_Cas_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any())) { search_additional_cas_in_cas_and_additional_cas_id(); } else if (In_add_Kegg_id.Count > 0 && (metabolites.List_metabolites.Select(x => x.Kegg_id).Intersect(In_add_Kegg_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any() || metabolites.List_metabolites.SelectMany(x => x.Cts_kegg).Intersect(In_add_Kegg_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any())) { search_additional_kegg_in_kegg_and_additional_kegg_id(); } else if (In_add_Chebi_id.Count > 0 && (metabolites.List_metabolites.Select(x => x.Chebi_id).Intersect(In_add_Chebi_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any() || metabolites.List_metabolites.SelectMany(x => x.Cts_chebi).Intersect(In_add_Chebi_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any())) { search_additional_chebi_in_chebi_and_additional_chebi_id(); } else if (In_add_Pubchem_id.Count > 0 && metabolites.List_metabolites.Select(x => x.Pubchem_compound_id).Intersect(In_add_Pubchem_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any()) { search_additional_pubchem_in_pubchem(); } else if (In_add_Chemspider_id.Count > 0 && metabolites.List_metabolites.Select(x => x.Chemspider_id).Intersect(In_add_Chemspider_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any()) { search_additional_chemspider_in_chemspider(); } else if (In_add_Lipidmaps_id.Count > 0 && metabolites.List_metabolites.Select(x => x.Lipidmaps_id).Intersect(In_add_Lipidmaps_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any()) { search_additional_lipidmaps_in_lipidmaps(); } else if (In_add_Metlin_id.Count > 0 && metabolites.List_metabolites.Select(x => x.Metlin_id).Intersect(In_add_Metlin_id.Where(x => !string.IsNullOrEmpty(x) && !string.IsNullOrWhiteSpace(x))).Any()) { search_additional_metlin_in_metlin(); } else { add_not_found_metabolite(); return; } }