-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
14 changed files
with
242 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,9 @@ | ||
[![TESTS](https://github.com/VirtualPatientEngine/demo/actions/workflows/tests.yml/badge.svg)](https://github.com/VirtualPatientEngine/demo/actions/workflows/tests.yml) | ||
[![RELEASE](https://github.com/VirtualPatientEngine/demo/actions/workflows/release.yml/badge.svg)](https://github.com/VirtualPatientEngine/demo/actions/workflows/release.yml) | ||
[![TESTS](https://github.com/VirtualPatientEngine/literatureSurvey/actions/workflows/tests.yml/badge.svg)](https://github.com/VirtualPatientEngine/literatureSurvey/actions/workflows/tests.yml) | ||
[![RELEASE](https://github.com/VirtualPatientEngine/literatureSurvey/actions/workflows/release.yml/badge.svg)](https://github.com/VirtualPatientEngine/literatureSurvey/actions/workflows/release.yml) | ||
|
||
<h1 align="center" style="border-bottom: none;">🚀 Demo</h1> | ||
<h1 align="center" style="border-bottom: none;">🚀 Literature Survey</h1> | ||
|
||
This repository serves as a template to develop a code repository (shareable packages). The followoing features are pre-embedded into this repository to help you kick start with your work: | ||
1. **Automated Workflows for testing and Semantic Release using GitHub Actions** | ||
2. **Automated Documentation and Hosting using MkDocs** | ||
3. **Automated Distributable Release (.whl package) using setup.py** | ||
|
||
In the files ```setup.py``` and ```release.config.js```, change the package name from **gurdeepdemo** to whatever you desire. | ||
|
||
View the documentation of the example code used in the repo @ https://virtualpatientengine.github.io/demo | ||
This repository serves as a template to develop a literature survey repository. | ||
View the documentation of the example code used in the repo @ https://virtualpatientengine.github.io/literatureSurvey | ||
|
||
>NOTE: Read more about these and other features in the CodeOps and DevOps documents available on the teams channel. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
""" | ||
A class to extract the data from Uniprot | ||
for a given protein | ||
""" | ||
|
||
import requests | ||
from jinja2 import Environment, FileSystemLoader | ||
|
||
class Arxiv: | ||
""" | ||
A class to extract the data from Arxiv | ||
for a given arxiv id | ||
""" | ||
def __init__(self, paper_id) -> None: | ||
""" | ||
Initialize the class | ||
Args: | ||
arxiv_id (str): arxiv id | ||
title (str): title of the paper | ||
published (str): published date | ||
link (str): link to the paper | ||
Returns: | ||
None | ||
""" | ||
self.arxiv_id = paper_id | ||
self.semantic_scholar_data = {} | ||
def get_semantic_scholar_data(self) -> dict: | ||
""" | ||
Return the semantic scholar data for a given arxiv id | ||
Args: | ||
None | ||
Returns: | ||
dict: semantic scholar data | ||
""" | ||
return self.semantic_scholar_data | ||
def get_arxiv_id(self): | ||
""" | ||
Return the arxiv id | ||
Args: | ||
None | ||
Returns: | ||
str: arxiv id | ||
""" | ||
return self.arxiv_id | ||
|
||
def get_semantic_scholar(article_ids): | ||
""" | ||
Return the semantic scholar data for a given arxiv ids | ||
Args: | ||
arxiv_ids (list): list of arxiv ids | ||
Returns: | ||
dict: dictionary of arxiv ids and their semantic scholar data | ||
""" | ||
|
||
fields = 'referenceCount,citationCount,title,authors,' | ||
fields += 'journal,fieldsOfStudy,publicationTypes,publicationDate,url' | ||
r = requests.post( | ||
'https://api.semanticscholar.org/graph/v1/paper/batch', | ||
params={'fields': fields}, | ||
json={"ids": article_ids}, | ||
timeout=10 | ||
) | ||
# print(json.dumps(r.json(), indent=2)) | ||
return r.json() | ||
|
||
if __name__ == "__main__": | ||
# Run the script from command line | ||
import markdownify | ||
import feedparser | ||
# Define the query | ||
QUERY = 'stat.ML:causal+link+prediction' | ||
# Define the base url | ||
BASE_URL = 'http://export.arxiv.org/api/query?search_query=' | ||
# Define the search parameters | ||
START = 0 | ||
MAX_RESULTS = 500 | ||
SORT_BY = 'relevance' | ||
SEARCH_PARAMS = f'&start={START}&max_results={MAX_RESULTS}&sortBy={SORT_BY}' | ||
# Define the url link | ||
URL_LINK = BASE_URL + QUERY + SEARCH_PARAMS | ||
# Parse the url link | ||
feed = feedparser.parse(URL_LINK) | ||
num_entries = len(feed.entries) | ||
arxiv_ids = [] # List to store the arxiv ids | ||
dic_arxiv_ids = {} # Dictionary to store the arxiv ids | ||
for i in range(num_entries): | ||
# print (feed.entries[i]['title'], feed.entries[i]['published'], feed.entries[i]['link']) | ||
arxiv_id = feed.entries[i]['link'].split('/')[-1].split('v')[0] | ||
dic_arxiv_ids[arxiv_id] = Arxiv(arxiv_id) | ||
arxiv_ids = ["ARXIV:"+arxiv_id for arxiv_id in dic_arxiv_ids] | ||
# print (arxiv_ids) | ||
results = get_semantic_scholar(arxiv_ids) | ||
# print (results) | ||
print (len(results)) | ||
|
||
articles = [] | ||
for i in range(num_entries): | ||
arxiv_id = arxiv_ids[i].split(':')[1] | ||
print (results[i]) | ||
if results[i] is None: | ||
continue | ||
dic_arxiv_ids[arxiv_id].semantic_scholar_data = results[i] | ||
# Append the articles | ||
if dic_arxiv_ids[arxiv_id].semantic_scholar_data is not None: | ||
if int(dic_arxiv_ids[arxiv_id].semantic_scholar_data['citationCount']) > 1000: | ||
# Extract author names | ||
authors = [] | ||
for author in dic_arxiv_ids[arxiv_id].semantic_scholar_data['authors']: | ||
authors.append(author['name']) | ||
articles.append({"title": results[i]['title'], | ||
'url': results[i]['url'], | ||
"authors": ', '.join(authors), | ||
"citations": results[i]['citationCount'], | ||
'journal': results[i]['journal'], | ||
'fieldsOfStudy': results[i]['fieldsOfStudy'], | ||
'publicationTypes': results[i]['publicationTypes'], | ||
'publicationDate': results[i]['publicationDate'] | ||
}) | ||
# Set the template environment | ||
environment = Environment(loader=FileSystemLoader("../templates/")) | ||
# Get the template | ||
template = environment.get_template("message.txt") | ||
# Render the template | ||
content = template.render( | ||
articles=articles, | ||
query=QUERY, | ||
) | ||
# Convert the content to markdown | ||
markdown_text = markdownify.markdownify(content) | ||
# Write the markdown text to a file | ||
with open('../docs/index.md', 'w', encoding='utf-8') as file: | ||
file.write(markdown_text) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,21 @@ | ||
# Welcome to the documentation of the demo app developed by Team VPE | ||
|
||
|
||
|
||
|
||
|
||
|
||
### Query: stat.ML:causal+link+prediction | ||
|
||
|
||
|
||
|
||
| Title | Authors | PublicationDate | #Citations | Journal/Conference | | ||
| --- | --- | --- | --- | --- | | ||
| [Link Prediction in Complex Networks: A Survey](https://www.semanticscholar.org/paper/8cd9aa720a3a2f9dcb52ad9eb1bf258a80ce0648) | Linyuan Lu, Tao Zhou | 2010-10-05 | 2520 | {'name': 'ArXiv', 'volume': 'abs/1010.0725'} | | ||
| [Link Prediction Based on Graph Neural Networks](https://www.semanticscholar.org/paper/e4715a13f6364b1c81e64f247651c3d9e80b6808) | Muhan Zhang, Yixin Chen | 2018-02-27 | 1422 | {'pages': '5171-5181'} | | ||
| [Predicting missing links via local information](https://www.semanticscholar.org/paper/76c361552181f3798a3fae7485a22a333af85047) | Tao Zhou, Linyuan Lü, Yi‐Cheng Zhang | 2009-01-05 | 1495 | {'name': 'The European Physical Journal B', 'pages': '623-630', 'volume': '71'} | | ||
| [Variational Graph Auto-Encoders](https://www.semanticscholar.org/paper/54906484f42e871f7c47bbfe784a358b1448231f) | Thomas Kipf, M. Welling | 2016-11-21 | 2597 | {'name': 'ArXiv', 'volume': 'abs/1611.07308'} | | ||
| [Predicting positive and negative links in online social networks](https://www.semanticscholar.org/paper/1926bad0dc2c1d302ad9a673226f8ca56869683c) | J. Leskovec, D. Huttenlocher, J. Kleinberg | 2010-03-11 | 1601 | {'name': 'ArXiv', 'volume': 'abs/1003.2429'} | | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## class Arxiv | ||
|
||
:::app.literatureFetch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## class Arxiv | ||
|
||
:::app.test_literatureFetch |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
site_name: Demo | ||
site_name: Literature Survey | ||
plugins: | ||
- mkdocstrings: | ||
paths: ["app", "tests"] | ||
theme: | ||
name: material | ||
nav: | ||
- Home: index.md | ||
- class UniProt: uniprot.md | ||
- methods in tests/uniprot: test_uniprot.md | ||
- API Reference: | ||
- Arxiv: literatureFetch.md | ||
- Tests: test_literatureFetch.md | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
</head> | ||
|
||
<body> | ||
<h3>Query: {{ query }}</h3> | ||
<table> | ||
<tr> | ||
<th>Title</th> | ||
<th>Authors</th> | ||
<th>PublicationDate</th> | ||
<th>#Citations</th> | ||
<th>Journal/Conference</th> | ||
</tr> | ||
{% for article in articles %} | ||
<tr> | ||
<td>[{{ article.title}}]({{article.url}})</a></td> | ||
<td>{{ article.authors}}</td> | ||
<td>{{ article.publicationDate}}</td> | ||
<td>{{ article.citations }}</td> | ||
<td>{{ article.journal }}</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
</body> | ||
</html> |
Oops, something went wrong.