forked from OBOFoundry/OBOFoundry.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract-publications.py
executable file
·66 lines (51 loc) · 2.32 KB
/
extract-publications.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# Read the ontologies.yml file
# collect the first 'publications' entry from each project,
# and write as Markdown.
__author__ = 'James A. Overton'
import argparse, yaml
header = '''---
layout: doc
title: Publications Related to the OBO Foundry
---
[The OBO Foundry: coordinated evolution of ontologies to support biomedical data integration](http://www.nature.com/nbt/journal/v25/n11/abs/nbt1346.html)
Barry Smith, Michael Ashburner, Cornelius Rosse, Jonathan Bard, William Bug, Werner Ceusters, Louis J Goldberg, Karen Eilbeck, Amelia Ireland, Christopher J Mungall, The OBI Consortium, Neocles Leontis, Philippe Rocca-Serra, Alan Ruttenberg, Susanna-Assunta Sansone, Richard H Scheuermann, Nigam Shah, Patricia L Whetzel, and Suzanna Lewis
*Nature Biotechnology* **25**, 1251 - 1255 (2007)
[Google Scholar list of papers citing The OBO Foundry.](https://scholar.google.ca/scholar?cites=13806088078865650870&as_sdt=2005&sciodt=0,5&hl=en)
### Ontology Project Publications
'''
template = '- {ontology} ({id}): [{title}]({link})\n'
def main():
parser = argparse.ArgumentParser(
description='Extract publication data')
parser.add_argument('ontologies',
type=argparse.FileType('r'),
help='the ontologies YAML file to read')
parser.add_argument('publications_path',
type=str,
help='the path to the output file')
args = parser.parse_args()
data = yaml.load(args.ontologies)
publications = []
for ontology in data['ontologies']:
result = {}
if 'title' in ontology:
result['ontology'] = ontology['title']
if 'id' in ontology:
result['id'] = ontology['id']
if 'publications' in ontology:
for publication in ontology['publications']:
if 'id' in publication and 'title' in publication:
result['link'] = publication['id']
result['title'] = publication['title']
break
if 'ontology' in result and 'id' in result \
and 'link' in result and 'title' in result:
publications.append(result)
publications = sorted(publications, key=lambda k: k['ontology'])
with open(args.publications_path, 'w') as output:
output.write(header)
for publication in publications:
output.write(template.format(**publication))
if __name__ == "__main__":
main()