Skip to content

Instantly share code, notes, and snippets.

View langner's full-sized avatar

Karol M. Langner langner

  • Google
  • Mountain View
View GitHub Profile
@langner
langner / similar_doi.py
Last active August 29, 2015 14:05
Python function for testing similarity of two DOIs
def similar_dois(d1, d2, accuracy=1.00):
"""Determine whether DOIs are similar.
DOIs basically need to be identical, but are case insensitive.
"""
if not (d1 and d2):
return False
d1 = d1.lower().strip()
d2 = d2.lower().strip()
return difflib.SequenceMatcher(None, d1, d2).ratio() == accuracy
@langner
langner / pubmed_search.py
Last active January 29, 2022 14:52
A class that searches Pubmed for a list of PMIDs via the BioPython Entrez module and returns the results in a simpler dictionary format.
"""Tools for searching Pubmed for a list of PMIDs.
The goal here is to search for many PMIDs at once, since searching
sequentially can take a long time. Using the the BioPython Entrez module
is super convenient to this end.
The results results are returned in a simple dictionary format.
"""