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

added comments in Processing

parent 3802ad87
No related branches found
No related tags found
1 merge request!11merge verarbeitung to main repo
...@@ -43,7 +43,7 @@ def initialize_nodes_list(doi_input_list, search_depth_max, search_height_max, t ...@@ -43,7 +43,7 @@ def initialize_nodes_list(doi_input_list, search_depth_max, search_height_max, t
except ValueError: except ValueError:
continue continue
except IndexError: except IndexError:
print(pub_doi) continue
# checks if publication already exists in nodes # checks if publication already exists in nodes
...@@ -113,7 +113,6 @@ def create_graph_structure_references(pub, search_depth, search_depth_max, test_ ...@@ -113,7 +113,6 @@ def create_graph_structure_references(pub, search_depth, search_depth_max, test_
continue continue
# nur aus Testzwecken, da noch was bei Input falsch ist # nur aus Testzwecken, da noch was bei Input falsch ist
except IndexError: except IndexError:
print(reference.doi_url)
continue continue
reference_pub_obj.group = "depth" reference_pub_obj.group = "depth"
...@@ -168,7 +167,6 @@ def create_graph_structure_citations(pub, search_height, search_height_max, test ...@@ -168,7 +167,6 @@ def create_graph_structure_citations(pub, search_height, search_height_max, test
except ValueError: except ValueError:
continue continue
except IndexError: except IndexError:
print(citation.doi_url)
continue continue
citation_pub_obj.group = "height" citation_pub_obj.group = "height"
...@@ -236,7 +234,6 @@ def process_main(doi_input_list, search_height, search_depth, test_var = False): ...@@ -236,7 +234,6 @@ def process_main(doi_input_list, search_height, search_depth, test_var = False):
# calls a skript to save nodes and edges of graph in .json file # calls a skript to save nodes and edges of graph in .json file
output_to_json(nodes,edges) output_to_json(nodes,edges)
return(nodes,edges)
# only for unit tests # only for unit tests
if (test_var == True): if (test_var == True):
...@@ -244,4 +241,5 @@ def process_main(doi_input_list, search_height, search_depth, test_var = False): ...@@ -244,4 +241,5 @@ def process_main(doi_input_list, search_height, search_depth, test_var = False):
for node in nodes: for node in nodes:
doi_nodes_list.append(node.doi_url) doi_nodes_list.append(node.doi_url)
return(doi_nodes_list, edges) return(doi_nodes_list, edges)
\ No newline at end of file return(nodes,edges)
\ No newline at end of file
No preview for this file type
No preview for this file type
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Functions to read old json files to recreate old grpah structure Functions to read old json files to recreate old graph structure
""" """
...@@ -71,14 +71,20 @@ def add_ref_and_cit_to_pubs(input_dict): ...@@ -71,14 +71,20 @@ def add_ref_and_cit_to_pubs(input_dict):
''' '''
# iterates over the list of edges # iterates over the list of edges
for edge in input_dict["links"]: #iterates over the list of edges for edge in input_dict["links"]:
for node in list_of_nodes_py: for node in list_of_nodes_py:
# adds reference to current node
if (node.doi_url == edge["source"]): if (node.doi_url == edge["source"]):
new_reference = Reference(node.doi_url, node.title, node.contributors, node.journal, node.publication_date) new_reference = Reference(node.doi_url, node.title, node.contributors, node.journal, node.publication_date)
node.references.append(new_reference) node.references.append(new_reference)
# adds citation to current node
if (node.doi_url == edge["target"]): if (node.doi_url == edge["target"]):
new_citation = Citation(node.doi_url, node.title, node.contributors, node.journal, node.publication_date) new_citation = Citation(node.doi_url, node.title, node.contributors, node.journal, node.publication_date)
node.citations.append(new_citation) node.citations.append(new_citation)
# adds edge to list
list_of_edges_py.append([edge["source"],edge["target"]]) list_of_edges_py.append([edge["source"],edge["target"]])
...@@ -88,21 +94,20 @@ def input_from_json(json_file): ...@@ -88,21 +94,20 @@ def input_from_json(json_file):
:type json_file: Json File :type json_file: Json File
''' '''
# creates global sets for nodes and edges
global list_of_nodes_py, list_of_edges_py global list_of_nodes_py, list_of_edges_py
list_of_nodes_py = [] list_of_nodes_py = []
list_of_edges_py = [] list_of_edges_py = []
with open(json_file,'r') as file: #opens the json file with reading permission
input_dict = json.load(file) #saves the information in a dictionary
create_pubs_from_json(input_dict) #opens the json file and saves content in dictionary
with open(json_file,'r') as file:
input_dict = json.load(file)
# creates nodes of Class Publication from input Json file
create_pubs_from_json(input_dict)
# adds references and citations to publications and creates edges
add_ref_and_cit_to_pubs(input_dict) add_ref_and_cit_to_pubs(input_dict)
# Iteriert über die Liste der Kanten_dictionaries speichert sie als Liste
return(list_of_nodes_py, list_of_edges_py) return(list_of_nodes_py, list_of_edges_py)
...@@ -18,7 +18,7 @@ def format_nodes(V): ...@@ -18,7 +18,7 @@ def format_nodes(V):
new_dict["journal"] = node.journal new_dict["journal"] = node.journal
new_dict["doi"] = node.doi_url new_dict["doi"] = node.doi_url
new_dict["group"] = node.group new_dict["group"] = node.group
new_dict["citation count"] = len(node.citations) new_dict["citations"] = len(node.citations)
list_of_node_dicts.append(new_dict) list_of_node_dicts.append(new_dict)
return list_of_node_dicts return list_of_node_dicts
......
{"nodes": [{"name": "Comparing Molecular Patterns Using the Example of SMARTS: Applications and Filter Collection Analysis", "author": ["Emanuel S. R. Ehmki", "Robert Schmidt", "Farina Ohm", "Matthias Rarey"], "year": "May 24, 2019", "journal": "Journal of Chemical Information and Modeling", "doi": "https://doi.org/10.1021/acs.jcim.9b00249", "group": "input", "citation count": 5}, {"name": "Combining Machine Learning and Computational Chemistry for Predictive Insights Into Chemical Systems", "author": ["John A. Keith", "Valentin Vassilev-Galindo", "Bingqing Cheng", "Stefan Chmiela", "Michael Gastegger", "Klaus-Robert M\u00fcller", "Alexandre Tkatchenko"], "year": "July 7, 2021", "journal": "Chem. Rev.", "doi": "https://doi.org/10.1021/acs.chemrev.1c00107", "group": "height", "citation count": 1}, {"name": "Disconnected Maximum Common Substructures under Constraints", "author": ["Robert Schmidt", "Florian Krull", "Anna Lina Heinzke", "Matthias Rarey"], "year": "December 16, 2020", "journal": "Journal of Chemical Information and Modeling", "doi": "https://doi.org/10.1021/acs.jcim.0c00741", "group": "height", "citation count": 0}, {"name": "Evolution of Novartis\u2019 Small Molecule Screening Deck Design", "author": ["Ansgar Schuffenhauer", "Nadine Schneider", "Samuel Hintermann", "Douglas Auld", "Jutta Blank", "Simona Cotesta", "Caroline Engeloch", "Nikolas Fechner", "Christoph Gaul", "Jerome Giovannoni", "Johanna Jansen", "John Joslin", "Philipp Krastel", "Eugen Lounkine", "John Manchester", "Lauren G. Monovich", "Anna Paola Pelliccioli", "Manuel Schwarze", "Michael D. Shultz", "Nikolaus Stiefl", "Daniel K. Baeschlin"], "year": "November 3, 2020", "journal": "Journal of Medicinal Chemistry", "doi": "https://doi.org/10.1021/acs.jmedchem.0c01332", "group": "height", "citation count": 8}, {"name": "Comparing Molecular Patterns Using the Example of SMARTS: Theory and Algorithms", "author": ["Robert Schmidt", "Emanuel S. R. Ehmki", "Farina Ohm", "Hans-Christian Ehrlich", "Andriy Mashychev", "Matthias Rarey"], "year": "May 23, 2019", "journal": "Journal of Chemical Information and Modeling", "doi": "https://doi.org/10.1021/acs.jcim.9b00250", "group": "height", "citation count": 12}, {"name": "The Growing Importance of Chirality in 3D Chemical Space Exploration and Modern Drug Discovery Approaches for Hit-ID", "author": ["Ilaria Proietti Silvestri", "Paul J. J. Colbon"], "year": "July 16, 2021", "journal": "ACS Med. Chem. Lett.", "doi": "https://doi.org/10.1021/acsmedchemlett.1c00251", "group": "height", "citation count": 0}, {"name": "Target-Based Evaluation of \u201cDrug-Like\u201d Properties and Ligand Efficiencies", "author": ["Paul D. Leeson", "A. Patricia Bento", "Anna Gaulton", "Anne Hersey", "Emma J. Manners", "Chris J. Radoux", "Andrew R. Leach"], "year": "May 13, 2021", "journal": "Journal of Medicinal Chemistry", "doi": "https://doi.org/10.1021/acs.jmedchem.1c00416", "group": "height", "citation count": 0}], "links": [{"source": "https://doi.org/10.1021/acs.chemrev.1c00107", "target": "https://doi.org/10.1021/acs.jcim.9b00249"}, {"source": "https://doi.org/10.1021/acs.jcim.0c00741", "target": "https://doi.org/10.1021/acs.jcim.9b00249"}, {"source": "https://doi.org/10.1021/acs.jmedchem.0c01332", "target": "https://doi.org/10.1021/acs.jcim.9b00249"}, {"source": "https://doi.org/10.1021/acs.jcim.9b00250", "target": "https://doi.org/10.1021/acs.jcim.9b00249"}, {"source": "https://doi.org/10.1021/acsmedchemlett.1c00251", "target": "https://doi.org/10.1021/acs.jmedchem.0c01332"}, {"source": "https://doi.org/10.1021/acs.jmedchem.1c00416", "target": "https://doi.org/10.1021/acs.jmedchem.0c01332"}, {"source": "https://doi.org/10.1021/acs.chemrev.1c00107", "target": "https://doi.org/10.1021/acs.jcim.9b00250"}, {"source": "https://doi.org/10.1021/acs.jcim.0c00741", "target": "https://doi.org/10.1021/acs.jcim.9b00250"}, {"source": "https://doi.org/10.1021/acs.jmedchem.0c01332", "target": "https://doi.org/10.1021/acs.jcim.9b00250"}, {"source": "https://doi.org/10.1021/acs.jcim.9b00249", "target": "https://doi.org/10.1021/acs.jcim.9b00250"}]}
\ No newline at end of file
This diff is collapsed.
...@@ -15,11 +15,13 @@ __status__ = "Production" ...@@ -15,11 +15,13 @@ __status__ = "Production"
import sys import sys
#sys.path.insert(1, 'C:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input') #sys.path.insert(1, 'C:\Users\Malte\Git\CiS-Projekt\ci-s-projekt-verarbeitung\input')
sys.path.append(".") sys.path.append(".")
from input.interface import InputInterface as Input from input.interface import InputInterface as Input
#import input #import input
from Processing import process_main from Processing import process_main
from import_from_json import input_from_json
# a function to print nodes and edges from a graph # a function to print nodes and edges from a graph
def print_graph(nodes, edges): def print_graph(nodes, edges):
...@@ -33,12 +35,12 @@ def print_graph(nodes, edges): ...@@ -33,12 +35,12 @@ def print_graph(nodes, edges):
print(len(edges)) print(len(edges))
# program test, because there is no connection to UI yet. # program test with some random dois
def try_known_publications(): def try_known_publications():
doi_list = [] doi_list = []
doi_list.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249') 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://doi.org/10.1021/acs.jcim.9b00249')
#doi_list.append('https://pubs.acs.org/doi/10.1021/acs.jcim.1c00203') doi_list.append('https://pubs.acs.org/doi/10.1021/acs.jcim.1c00203')
#arr.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249') #arr.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249')
doi_list.append('https://doi.org/10.1021/acs.jmedchem.0c01332') doi_list.append('https://doi.org/10.1021/acs.jmedchem.0c01332')
#arr.append('https://doi.org/10.1021/acs.jcim.0c00741') #arr.append('https://doi.org/10.1021/acs.jcim.0c00741')
...@@ -51,8 +53,12 @@ def try_known_publications(): ...@@ -51,8 +53,12 @@ def try_known_publications():
#arr.append[url] #arr.append[url]
nodes, edges = process_main(doi_list,1,1) nodes, edges = process_main(doi_list,2,2)
print_graph(nodes, edges) print_graph(nodes, edges)
try_known_publications() return(nodes, edges)
\ No newline at end of file
nodes, edges = try_known_publications()
#nodes_new, edges_new = input_from_json("json_text.json")
#print_graph(nodes_new, edges_new)
\ No newline at end of file
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