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

updated processing_test_doi_ueberarbeitet

parent fba86506
No related branches found
No related tags found
2 merge requests!7Main,!5Main
This commit is part of merge request !7. Comments created here will be created in the context of that merge request.
......@@ -10,12 +10,13 @@ import requests as req
import sys
from pathlib import Path
from input_fj import input
from json_demo import output_to_json
def process_main(array, depth):
def process_main(doi_input_array, depth):
# ERROR-Handling doi_array = NULL
if (len(array) == 0):
if (len(doi_input_array) == 0):
print("Error, no input data")
# ERROR- wenn für die Tiefe eine negative Zahl eingegeben wird
......@@ -30,14 +31,21 @@ def process_main(array, depth):
edges = []
# Jede Publikation aus dem Input-Array wird in den Knoten-Array(nodes) eingefügt.
for pub in array:
if (pub not in nodes):
for pub_doi in doi_input_array:
pub = input(pub_doi)
not_in_nodes = True
for node in nodes:
if (pub.doi_url == node.doi_url):
not_in_nodes = False
break
if (not_in_nodes):
nodes.append(pub)
else:
array.remove(pub)
doi_input_array.remove(pub_doi)
process_rec_depth(array, 0, depth)
process_rec_depth(doi_input_array, 0, depth)
output_to_json(nodes,edges)
return(nodes,edges)
......@@ -56,9 +64,14 @@ def process_rec_depth(array, depth, depth_max):
# Wenn die citation noch nicht im Knoten-Array(nodes) existiert UND die maximale Tiefe
# noch nicht erreicht wurde, wird diese als Knoten im Knoten-Array gespeichert. Zusätzlich
# wird die Verbindung zur Publikation als Tupel im Kanten-Array(edges) gespeichert.
if (citation.doi_url not in nodes):
not_in_nodes = True
for node in nodes:
if (citation.doi_url == node.doi_url):
not_in_nodes = False
break
if (not_in_nodes):
if (depth <= depth_max):
nodes.append(citation.doi_url)
nodes.append(citation)
edges.append([pub.doi_url,citation.doi_url])
# Wenn die citaion bereits im Knoten-Array existiert, wird nur die Verbindung zur Publikation
......@@ -85,8 +98,8 @@ def process_rec_depth(array, depth, depth_max):
# Programmtest, weil noch keine Verbindung zum Input besteht.
arr = []
arr.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249')
#arr.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249')
#arr.append('https://doi.org/10.1021/acs.jmedchem.0c01332')
arr.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249')
arr.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/ci700007b')
......@@ -97,8 +110,8 @@ arr.append('https://pubs.acs.org/doi/10.1021/acs.jcim.9b00249')
nodes,edges = process_main(arr,1)
print("Knoten:\n")
for vortex in nodes:
print(vortex, "\n")
for node in nodes:
print(node.title, "\n")
print("\nKanten:\n")
for edge in edges:
print(edge,"\n")
\ No newline at end of file
File added
File added
File moved
#!/usr/bin/env python3
import json
from input_fj import input
def output_to_json(V,E):
list_of_node_dicts = list()
list_of_edge_dicts = list()
dict_of_all = dict()
for node in V:
new_dict = dict()
new_dict["doi"] = node
list_of_node_dicts.append(new_dict)
for edge in E:
new_dict_2 = dict()
new_dict_2["source"] = edge[0]
new_dict_2["target"] = edge[1]
list_of_edge_dicts.append(new_dict_2)
dict_of_all["nodes"] = list_of_node_dicts
dict_of_all["links"] = list_of_edge_dicts
return(dict_of_all)
with open('json_text_json','w') as outfile:
json_dump(dict_of_all, outfile)
list_of_node_dicts = list()
list_of_edge_dicts = list()
dict_of_all = dict()
for node in V:
new_dict = dict()
new_dict["name"] = node.title
new_dict["author"] = node.contributors
new_dict["year"] = node.publication_date
new_dict["doi"] = node.doi_url
list_of_node_dicts.append(new_dict)
for edge in E:
new_dict_2 = dict()
new_dict_2["source"] = edge[0]
new_dict_2["target"] = edge[1]
list_of_edge_dicts.append(new_dict_2)
dict_of_all["nodes"] = list_of_node_dicts
dict_of_all["links"] = list_of_edge_dicts
#return(dict_of_all)
with open('json_text.txt','w') as outfile:
json.dump(dict_of_all, outfile)
knoten = ["doi1", "doi2", "doi3"]
kanten = [[1,2],[3,4],[5,6]]
output_to_json(knoten,kanten)
#knoten = ["doi1", "doi2", "doi3"]
#kanten = [[1,2],[3,4],[5,6]]
#output_to_json(knoten,kanten)
{"nodes": [{"name": "Comparing Molecular Patterns Using the Example of SMARTS: Applications and Filter Collection Analysis", "doi": "https://doi.org/10.1021/acs.jcim.9b00249"}, {"name": "Combining Machine Learning and Computational Chemistry for Predictive Insights Into Chemical Systems ", "doi": "https://doi.org/10.1021/acs.chemrev.1c00107"}, {"name": "Disconnected Maximum Common Substructures under Constraints ", "doi": "https://doi.org/10.1021/acs.jcim.0c00741"}, {"name": "Evolution of Novartis\u2019 Small Molecule Screening Deck Design ", "doi": "https://doi.org/10.1021/acs.jmedchem.0c01332"}, {"name": "Comparing Molecular Patterns Using the Example of SMARTS: Theory and Algorithms ", "doi": "https://doi.org/10.1021/acs.jcim.9b00250"}, {"name": "Machine learning accelerates quantum mechanics predictions of molecular crystals ", "doi": "https://doi.org/10.1016/j.physrep.2021.08.002"}, {"name": "The Growing Importance of Chirality in 3D Chemical Space Exploration and Modern Drug Discovery Approaches for Hit-ID ", "doi": "https://doi.org/10.1021/acsmedchemlett.1c00251"}, {"name": "Target-Based Evaluation of \u201cDrug-Like\u201d Properties and Ligand Efficiencies ", "doi": "https://doi.org/10.1021/acs.jmedchem.1c00416"}, {"name": "BonMOLi\u00e8re: Small-Sized Libraries of Readily Purchasable Compounds, Optimized to Produce Genuine Hits in Biological Screens across the Protein Space ", "doi": "https://doi.org/10.3390/ijms22157773"}, {"name": "Accelerating high-throughput virtual screening through molecular pool-based active learning ", "doi": "https://doi.org/10.1039/D0SC06805E"}, {"name": "Compound Screening ", "doi": "https://doi.org/10.1016/B978-0-12-820472-6.00078-5"}], "links": [{"source": "https://doi.org/10.1021/acs.jcim.9b00249", "target": "https://doi.org/10.1021/acs.chemrev.1c00107"}, {"source": "https://doi.org/10.1021/acs.jcim.9b00249", "target": "https://doi.org/10.1021/acs.jcim.0c00741"}, {"source": "https://doi.org/10.1021/acs.jcim.9b00249", "target": "https://doi.org/10.1021/acs.jmedchem.0c01332"}, {"source": "https://doi.org/10.1021/acs.jcim.9b00249", "target": "https://doi.org/10.1021/acs.jcim.9b00250"}, {"source": "https://doi.org/10.1021/acs.jcim.9b00249", "target": "https://doi.org/10.1016/j.physrep.2021.08.002"}, {"source": "https://doi.org/10.1021/acs.jmedchem.0c01332", "target": "https://doi.org/10.1021/acsmedchemlett.1c00251"}, {"source": "https://doi.org/10.1021/acs.jmedchem.0c01332", "target": "https://doi.org/10.1021/acs.jmedchem.1c00416"}, {"source": "https://doi.org/10.1021/acs.jmedchem.0c01332", "target": "https://doi.org/10.3390/ijms22157773"}, {"source": "https://doi.org/10.1021/acs.jmedchem.0c01332", "target": "https://doi.org/10.1039/D0SC06805E"}, {"source": "https://doi.org/10.1021/acs.jmedchem.0c01332", "target": "https://doi.org/10.1016/B978-0-12-820472-6.00078-5"}]}
\ 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