Skip to content
Snippets Groups Projects
Commit e0522cbe authored by Malte Schokolowski's avatar Malte Schokolowski
Browse files

bug fixed for max cit/ref not found while updating

parent d2fd9bc9
No related branches found
No related tags found
1 merge request!14stable version and bug fixes for graph update
...@@ -75,7 +75,7 @@ def initialize_nodes_list(doi_input_list, search_depth_max, search_height_max, t ...@@ -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 for pub_doi in doi_input_list: #iterates over every incoming doi
pub = get_pub(pub_doi, test_var) pub = get_pub(pub_doi, test_var)
if (type(pub) != Publication): if (type(pub) != Publication):
print(pub) #print(pub)
continue continue
# checks if publication already exists in nodes # checks if publication already exists in nodes
......
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')
...@@ -18,7 +18,9 @@ sys.path.append("../../") ...@@ -18,7 +18,9 @@ sys.path.append("../../")
from verarbeitung.construct_new_graph.add_citations_rec import add_citations from verarbeitung.construct_new_graph.add_citations_rec import add_citations
from verarbeitung.construct_new_graph.initialize_graph import complete_inner_edges 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 .update_edges import back_to_valid_edges
from input.publication import Publication
def reduce_max_height(max_height): def reduce_max_height(max_height):
...@@ -62,7 +64,7 @@ def get_old_height_depth(): ...@@ -62,7 +64,7 @@ def get_old_height_depth():
max_height = max(max_height, pub.group) max_height = max(max_height, pub.group)
return(max_height, max_depth) 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 :param old_depth: old maximum depth to search for citations
:type old_depth: int :type old_depth: int
...@@ -72,13 +74,14 @@ def get_old_max_references(old_depth): ...@@ -72,13 +74,14 @@ def get_old_max_references(old_depth):
old_max_references = [] old_max_references = []
for pub in processed_input_list: for pub in processed_input_list:
if (abs(pub.group) == old_depth): if (abs(pub.group) == old_depth):
for reference in pub.references: pub = get_pub(pub.doi_url, test_var)
for ref_pub in processed_input_list: if (type(pub) != Publication):
if reference.doi_url == ref_pub.doi_url: #print(pub)
old_max_references.append(ref_pub) continue
old_max_references.append(pub)
return(old_max_references) 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 :param old_height: old maximum height to search for citations
:type old_height: int :type old_height: int
...@@ -88,10 +91,11 @@ def get_old_max_citations(old_height): ...@@ -88,10 +91,11 @@ def get_old_max_citations(old_height):
old_max_citations = [] old_max_citations = []
for pub in processed_input_list: for pub in processed_input_list:
if (abs(pub.group) == old_height): if (abs(pub.group) == old_height):
for citation in pub.citations: pub = get_pub(pub.doi_url, test_var)
for cit_pub in processed_input_list: if (type(pub) != Publication):
if citation.doi_url == cit_pub.doi_url: #print(pub)
old_max_citations.append(cit_pub) continue
old_max_citations.append(pub)
return(old_max_citations) return(old_max_citations)
def update_depth(obj_input_list, input_edges, new_depth, new_height, test_var): 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): ...@@ -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() 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): if (old_depth > new_depth):
reduce_max_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) 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) back_to_valid_edges(valid_edges, processed_input_list)
# adds edges between reference group and citation group of known publications # adds edges between reference group and citation group of known publications
......
...@@ -59,7 +59,7 @@ def get_new_input_dois(new_input, test_var): ...@@ -59,7 +59,7 @@ def get_new_input_dois(new_input, test_var):
# retrieves information and adds to new list if successful # retrieves information and adds to new list if successful
pub = get_pub(new_node, test_var) pub = get_pub(new_node, test_var)
if (type(pub) != Publication): if (type(pub) != Publication):
print(pub) #print(pub)
continue continue
new_input_dois.append(pub.doi_url) new_input_dois.append(pub.doi_url)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment