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
This commit is part of merge request !14. Comments created here will be created in the context of that merge request.
......@@ -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
......
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("../../")
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
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment