Skip to content

Instantly share code, notes, and snippets.

@cthoyt
Created August 25, 2022 11:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cthoyt/ac2a95058f43a4845df075514cfca061 to your computer and use it in GitHub Desktop.
Save cthoyt/ac2a95058f43a4845df075514cfca061 to your computer and use it in GitHub Desktop.
Extract Journal of Cheminformatics DOIs from https://github.com/egonw/jcheminform-kb
"""Get Journal of Cheminformatics DOIs."""
import requests
import pystow
MODULE = pystow.module("jcheminf", "volumes")
USER = "egonw" # alternative use first-party jcheminform if it ever gets updated
REPO = "jcheminform-kb"
BRANCH = "main"
PREFIX = "https://doi.org/10.1186/"
def main():
response = requests.get(f"https://api.github.com/repos/{USER}/{REPO}/git/trees/{BRANCH}?recursive=1")
response.raise_for_status()
results = set()
for element in response.json()["tree"]:
if not element["path"].endswith(".ttl"):
continue
graph = MODULE.ensure_rdf(
url=f'https://raw.githubusercontent.com/{USER}/{REPO}/{BRANCH}/{element["path"]}',
parse_kwargs={"format": "turtle"},
)
for entity in graph.subjects():
if entity.startswith(PREFIX):
results.add(entity.removeprefix(PREFIX))
results = sorted(results)
MODULE.join(name="dois.txt").write_text("\n".join(results))
if __name__ == '__main__':
main()
1758-2946-1-1
1758-2946-1-10
1758-2946-1-11
1758-2946-1-12
1758-2946-1-13
1758-2946-1-14
1758-2946-1-15
1758-2946-1-16
1758-2946-1-17
1758-2946-1-18
1758-2946-1-19
1758-2946-1-2
1758-2946-1-20
1758-2946-1-21
1758-2946-1-22
1758-2946-1-3
1758-2946-1-4
1758-2946-1-5
1758-2946-1-6
1758-2946-1-7
1758-2946-1-8
1758-2946-1-9
1758-2946-2-1
1758-2946-2-10
1758-2946-2-11
1758-2946-2-2
1758-2946-2-3
1758-2946-2-4
1758-2946-2-5
1758-2946-2-6
1758-2946-2-7
1758-2946-2-8
1758-2946-2-9
1758-2946-3-1
1758-2946-3-10
1758-2946-3-11
1758-2946-3-12
1758-2946-3-13
1758-2946-3-14
1758-2946-3-15
1758-2946-3-16
1758-2946-3-17
1758-2946-3-18
1758-2946-3-19
1758-2946-3-2
1758-2946-3-20
1758-2946-3-21
1758-2946-3-22
1758-2946-3-23
1758-2946-3-24
1758-2946-3-25
1758-2946-3-26
1758-2946-3-27
1758-2946-3-28
1758-2946-3-29
1758-2946-3-3
1758-2946-3-30
1758-2946-3-31
1758-2946-3-32
1758-2946-3-33
1758-2946-3-34
1758-2946-3-35
1758-2946-3-36
1758-2946-3-37
1758-2946-3-38
1758-2946-3-39
1758-2946-3-4
1758-2946-3-40
1758-2946-3-41
1758-2946-3-42
1758-2946-3-43
1758-2946-3-44
1758-2946-3-45
1758-2946-3-46
1758-2946-3-47
1758-2946-3-48
1758-2946-3-49
1758-2946-3-5
1758-2946-3-50
1758-2946-3-51
1758-2946-3-52
1758-2946-3-53
1758-2946-3-54
1758-2946-3-6
1758-2946-3-7
1758-2946-3-8
1758-2946-3-9
s13321-018-0323-6
s13321-018-0324-5
s13321-018-0325-4
s13321-018-0326-3
s13321-018-0327-2
s13321-019-0328-9
s13321-019-0329-8
s13321-019-0330-2
s13321-019-0331-1
s13321-019-0332-0
s13321-019-0333-z
s13321-019-0334-y
s13321-019-0335-x
s13321-019-0336-9
s13321-019-0337-8
s13321-019-0338-7
s13321-019-0339-6
s13321-019-0340-0
s13321-019-0341-z
s13321-019-0342-y
s13321-019-0343-x
s13321-019-0344-9
s13321-019-0345-8
s13321-019-0346-7
s13321-019-0347-6
s13321-019-0348-5
s13321-019-0349-4
s13321-019-0350-y
s13321-019-0351-x
s13321-019-0352-9
s13321-019-0353-8
s13321-019-0354-7
s13321-019-0355-6
s13321-019-0356-5
s13321-019-0357-4
s13321-019-0358-3
s13321-019-0359-2
s13321-019-0360-9
s13321-019-0361-8
s13321-019-0362-7
s13321-019-0363-6
s13321-019-0364-5
s13321-019-0365-4
s13321-019-0366-3
s13321-019-0367-2
s13321-019-0368-1
s13321-019-0369-0
s13321-019-0370-7
s13321-019-0371-6
s13321-019-0372-5
s13321-019-0373-4
s13321-019-0374-3
s13321-019-0375-2
s13321-019-0376-1
s13321-019-0377-0
s13321-019-0378-z
s13321-019-0380-5
s13321-019-0381-4
s13321-019-0382-3
s13321-019-0383-2
s13321-019-0384-1
s13321-019-0385-0
s13321-019-0386-z
s13321-019-0387-y
s13321-019-0388-x
s13321-019-0389-9
s13321-019-0390-3
s13321-019-0391-2
s13321-019-0392-1
s13321-019-0393-0
s13321-019-0394-z
s13321-019-0395-y
s13321-019-0396-x
s13321-019-0397-9
s13321-019-0398-8
s13321-019-0399-7
s13321-019-0400-5
s13321-019-0401-4
s13321-019-0402-3
s13321-019-0403-2
s13321-020-00448-1
s13321-020-00464-1
s13321-020-00467-y
s13321-020-00474-z
s13321-020-00478-9
s13321-021-00489-0
s13321-021-00491-6
s13321-021-00515-1
s13321-021-00520-4
s13321-021-00521-3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment