diff --git a/verarbeitung/construct_new_graph/initialize_graph.py b/verarbeitung/construct_new_graph/initialize_graph.py index ef17df69a10048cc4c6d2d726c90737d79c174c6..bfc7df201873742484c6973a268ecb8e75dcbae5 100644 --- a/verarbeitung/construct_new_graph/initialize_graph.py +++ b/verarbeitung/construct_new_graph/initialize_graph.py @@ -75,7 +75,7 @@ def initialize_nodes_list(doi_input_list, search_depth_max, search_height_max, t for pub_doi in doi_input_list: #iterates over every incoming doi pub = get_pub(pub_doi, test_var) if (type(pub) != Publication): - print(pub) + #print(pub) continue # checks if publication already exists in nodes diff --git a/verarbeitung/start_script.py b/verarbeitung/start_script.py deleted file mode 100644 index 6e5854f4ffff81c2056595cdd0365c7909acf3cd..0000000000000000000000000000000000000000 --- a/verarbeitung/start_script.py +++ /dev/null @@ -1,12 +0,0 @@ -import sys -from pathlib import Path -from verarbeitung.process_main import Processing -from verarbeitung.dev_files.print_graph_test import try_known_publications, try_delete_nodes - - -doi_list = [] -doi_list.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249') -#doi_list.append('https://doi.org/10.1021/acs.jcim.9b00249') -doi_list.append('https://pubs.acs.org/doi/10.1021/acs.jcim.1c00203') -doi_list.append('https://doi.org/10.1021/acs.jmedchem.0c01332') -Processing(doi_list, 2, 2, 'test.json') diff --git a/verarbeitung/update_graph/update_depth.py b/verarbeitung/update_graph/update_depth.py index 40fc687c5855dfd5f76d1a12582e3539f109fdbc..2f0a1d8208ef02a759ac75371c624a0db6b80feb 100644 --- a/verarbeitung/update_graph/update_depth.py +++ b/verarbeitung/update_graph/update_depth.py @@ -18,7 +18,9 @@ sys.path.append("../../") from verarbeitung.construct_new_graph.add_citations_rec import add_citations from verarbeitung.construct_new_graph.initialize_graph import complete_inner_edges +from verarbeitung.get_pub_from_input import get_pub from .update_edges import back_to_valid_edges +from input.publication import Publication def reduce_max_height(max_height): @@ -62,7 +64,7 @@ def get_old_height_depth(): max_height = max(max_height, pub.group) return(max_height, max_depth) -def get_old_max_references(old_depth): +def get_old_max_references(old_depth, test_var): ''' :param old_depth: old maximum depth to search for citations :type old_depth: int @@ -72,13 +74,14 @@ def get_old_max_references(old_depth): old_max_references = [] for pub in processed_input_list: if (abs(pub.group) == old_depth): - for reference in pub.references: - for ref_pub in processed_input_list: - if reference.doi_url == ref_pub.doi_url: - old_max_references.append(ref_pub) + pub = get_pub(pub.doi_url, test_var) + if (type(pub) != Publication): + #print(pub) + continue + old_max_references.append(pub) return(old_max_references) -def get_old_max_citations(old_height): +def get_old_max_citations(old_height, test_var): ''' :param old_height: old maximum height to search for citations :type old_height: int @@ -88,10 +91,11 @@ def get_old_max_citations(old_height): old_max_citations = [] for pub in processed_input_list: if (abs(pub.group) == old_height): - for citation in pub.citations: - for cit_pub in processed_input_list: - if citation.doi_url == cit_pub.doi_url: - old_max_citations.append(cit_pub) + pub = get_pub(pub.doi_url, test_var) + if (type(pub) != Publication): + #print(pub) + continue + old_max_citations.append(pub) return(old_max_citations) def update_depth(obj_input_list, input_edges, new_depth, new_height, test_var): @@ -120,20 +124,22 @@ def update_depth(obj_input_list, input_edges, new_depth, new_height, test_var): old_height, old_depth = get_old_height_depth() - # removes publications and links from recursion levels which aren't needed anymore + # removes publications and links from recursion levels which aren't needed anymore or adds new ones if (old_depth > new_depth): reduce_max_depth(new_depth) - elif (old_height > new_height): + elif (old_depth < new_depth): + old_max_references = get_old_max_references(old_depth, test_var) + add_citations(processed_input_list, valid_edges, old_max_references, old_depth, new_depth, "Reference", test_var) + + if (old_height > new_height): reduce_max_height(new_height) + elif (old_height < new_height): + old_max_citations = get_old_max_citations(old_height, test_var) + add_citations(processed_input_list, valid_edges, old_max_citations, old_height, new_height, "Citation", test_var) + + - # adds publications and links for new recursion levels - elif (old_depth < new_depth): - old_max_references = get_old_max_references(old_depth) - add_citations(processed_input_list, valid_edges, old_max_references, old_depth+1, new_depth, "Reference", test_var) - elif (old_height < new_height): - old_max_citations = get_old_max_citations(old_height) - add_citations(processed_input_list, valid_edges, old_max_citations, old_height+1, new_height, "Citation", test_var) back_to_valid_edges(valid_edges, processed_input_list) # adds edges between reference group and citation group of known publications diff --git a/verarbeitung/update_graph/update_graph.py b/verarbeitung/update_graph/update_graph.py index 7bbb9072377afc5a52ca83341c7ad322566544c5..7e3ad76924a2e7fab9d2a5a5e2e81272abeb60a1 100644 --- a/verarbeitung/update_graph/update_graph.py +++ b/verarbeitung/update_graph/update_graph.py @@ -59,7 +59,7 @@ def get_new_input_dois(new_input, test_var): # retrieves information and adds to new list if successful pub = get_pub(new_node, test_var) if (type(pub) != Publication): - print(pub) + #print(pub) continue new_input_dois.append(pub.doi_url)