def aliases(self, aliases, provider_url_template=None, cache_enabled=True): # have reported all of these to mendeley, ie http://support.mendeley.com/customer/en/portal/questions/11307109-wrong-pmid?new=11307109 bad_mendeley_aliases = [ ("pmid", "19016882"), # http://www.mendeley.com/catalog/scientific-workflow-management-kepler-system-1/ ("pmid", "22170219"), #http://www.mendeley.com/catalog/social-network-analysis-animal-behaviour-promising-tool-study-sociality-1/ ("pmid", "20433197") #http://support.mendeley.com/customer/en/portal/questions/11494864-wrong-pmid?new=11494864 ] doc = self._get_doc(aliases) new_aliases = [] if doc: if doc.identifiers: from totalimpactwebapp.aliases import alias_dict_from_tuples aliases_dict = alias_dict_from_tuples(aliases) for namespace in doc.identifiers: if namespace in ["doi", "arxiv", "pmid", "scopus"] and (namespace not in aliases_dict): new_alias = normalize_alias_tuple(namespace, doc.identifiers[namespace]) if new_alias and new_alias not in bad_mendeley_aliases: new_aliases += [new_alias] new_aliases += [("url", doc.link)] new_aliases += [("mendeley_uuid", doc.id)] new_aliases = [alias for alias in new_aliases if alias not in aliases] return new_aliases
def metrics(self, aliases, provider_url_template=None, # ignore this because multiple url steps cache_enabled=True): # if haven't loaded batch_data, return no metrics global batch_data if not batch_data: batch_data = self.build_batch_data_dict() pass metrics_and_drilldown = {} # Only lookup metrics for items with appropriate ids from totalimpactwebapp.aliases import alias_dict_from_tuples aliases_dict = alias_dict_from_tuples(aliases) try: pmid = aliases_dict["pmid"][0] except KeyError: return {} pmid_alias = ("pmid", pmid) page = "" if pmid_alias in batch_data: pages = [page["raw"] for page in batch_data[pmid_alias]] if page: metrics_and_drilldown = self._get_metrics_and_drilldown(pages, pmid) return metrics_and_drilldown
def get_best_url(self, aliases): filtered = self.relevant_aliases(aliases) if filtered: from totalimpactwebapp.aliases import alias_dict_from_tuples aliases_dict = alias_dict_from_tuples(aliases) if "doi" in aliases_dict: return u"http://doi.org/" + aliases_dict["doi"][0] if "pmid" in aliases_dict: return u"http://www.ncbi.nlm.nih.gov/pubmed/" + aliases_dict["pmid"][0] if "pmc" in aliases_dict: return u"http://www.ncbi.nlm.nih.gov/pmc/articles/" + aliases_dict["pmc"][0] if "url" in aliases_dict: return aliases_dict["url"][0] return None
def _get_doc(self, aliases): from totalimpactwebapp.aliases import alias_dict_from_tuples aliases_dict = alias_dict_from_tuples(aliases) if not self.session: self.session = self._connect() doc = None lookup_by = [namespace for namespace in aliases_dict.keys() if namespace in ["doi", "pmid", "arxiv"]] if lookup_by: doc = self._get_doc_by_id(lookup_by[0], aliases_dict) if not doc and ("biblio" in aliases_dict): doc = self._get_doc_by_title(aliases_dict) return doc