Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
BREAKING_CHANGE
  • Loading branch information
gurdeep330 committed Feb 21, 2024
1 parent e1067fa commit 360ec09
Show file tree
Hide file tree
Showing 14 changed files with 242 additions and 160 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ jobs:
- name: Run pylint
shell: bash -l {0}
run: |
pylint tests
pylint app
pylint --disable=E0401,R0801,C010 tests
pylint --disable=E0401,R0801,C010 app
# code coverage job for ubuntu and macos
code-cov-ubuntu-macos:
Expand Down
16 changes: 5 additions & 11 deletions README.md
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.
137 changes: 137 additions & 0 deletions app/literatureFetch.py
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)
72 changes: 0 additions & 72 deletions app/uniprot.py

This file was deleted.

22 changes: 21 additions & 1 deletion docs/index.md
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'} |



3 changes: 3 additions & 0 deletions docs/literatureFetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## class Arxiv

:::app.literatureFetch
3 changes: 3 additions & 0 deletions docs/test_literatureFetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## class Arxiv

:::app.test_literatureFetch
3 changes: 0 additions & 3 deletions docs/test_uniprot.md

This file was deleted.

3 changes: 0 additions & 3 deletions docs/uniprot.md

This file was deleted.

8 changes: 5 additions & 3 deletions mkdocs.yml
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

35 changes: 12 additions & 23 deletions release.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,22 @@ const config = {
'@semantic-release/commit-analyzer',
'@semantic-release/release-notes-generator',
["@semantic-release/exec", {
// "publishCmd": "echo 'RELEASE_VERSION=${nextRelease.version}' >> $GITHUB_ENV && echo ${nextRelease.version} > release_version.txt",
// "prepareCmd": "echo ${nextRelease.version} > release_version.txt ; python3 setup.py bdist_wheel --dist-dir dist/ ; mv dist/*-${nextRelease.version}-*whl dist/gurdeep-demo.whl",
// "publishCmd": "echo 'RELEASE_VERSION=${nextRelease.version}' > release_version.txt",
// "prepareCmd": "python3 setup.py bdist_wheel --dist-dir dist/",
"prepareCmd": "echo ${nextRelease.version} > release_version.txt ; python3 setup.py bdist_wheel --dist-dir dist/ ; mv dist/*-${nextRelease.version}-*whl dist/"+package_name+"-latest-py3-none-any.whl",
// "prepareCmd": "echo ${nextRelease.version} > release_version.txt ; python3 setup.py bdist_wheel --dist-dir dist/ ; mv dist/*-${nextRelease.version}-*whl dist/"+package_name+"-latest-py3-none-any.whl",
}],
["@semantic-release/git", {
// "assets": ["dist/*.js", "dist/*.js.map"],
// "assets": ["dist/gurdeep-demo.whl"],
// "assets": ["dist/gurdeepdemo-${nextRelease.version}-py3-none-any.whl"],
"assets": ["dist/"+package_name+"-latest-py3-none-any.whl"],
// "assets": ["dist/"+package_name+"-latest-py3-none-any.whl"],
}],

// '@semantic-release/github'
[
"@semantic-release/github",
{
"assets": [
{
// "path": "dist/gurdeep-demo.whl",
// "path": "dist/gurdeep-demo-${nextRelease.version}-*whl",
"path": "dist/"+package_name+"-latest-py3-none-any.whl",
"label": package_name+"-${nextRelease.version}",
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
}
// "@semantic-release/github",
// {
// "assets": [
// {
// "path": "dist/"+package_name+"-latest-py3-none-any.whl",
// "label": package_name+"-${nextRelease.version}",
// "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
// }
// ]
// }
],
]
};
Expand Down
28 changes: 28 additions & 0 deletions templates/message.txt
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>
Loading

0 comments on commit 360ec09

Please sign in to comment.