def publications_page(): global publications if request.method == 'POST': publication_ids = parse_pubmed_ids(request.form['pubmed_ids']) logging.debug("Request to add publications: %s" % "; ".join(map(str, publication_ids))) new_publications = Publications.from_pubmed_ids(publication_ids) for publication in new_publications.values(): publication.update_authors(users) logging.debug("Found %s potential authors for %s" % (len(publication.most_likely_affiliated_authors()), publication.pubmed_id)) flash(message_about_new_publications(new_publications)) publications = Publications.merge(publications, new_publications) return redirect(url_for('publications_page')) return render_template('affiliated.html', publications=publications.not_denied(), users=users, user_title="All affiliated publications", download_link=url_for('download'))
pubmed_ids = set() logging.info("Searching pubmed for publications") for user in users.values(): new_pubmed_ids = Searcher.get_pubmed_ids_for_user(user, options.start, options.end) pubmed_ids.update(new_pubmed_ids) pubmed_id_count = len(pubmed_ids) logging.info("Found %s citations by searching pubmed" % pubmed_id_count) logging.info("Getting pubmed_ids from the Library") new_pubmed_ids = LibrarySearcher.get_pubmed_ids(options.start, options.end) pubmed_ids.update(new_pubmed_ids) logging.info("Found additional %s publications in Library" % (len(pubmed_ids) - pubmed_id_count)) new_publications = Publications.from_pubmed_ids(list(pubmed_ids)) publications = Publications.merge(publications, new_publications) for publication in publications.values(): publication.update_authors(users) if options.outputfile != "": with open(options.outputfile, "wb") as output: affiliated_publications = publications.not_denied() affiliated_publications.to_csv(output) logging.info("%s citations with at least one user matching the input queries have been printed to %s" % ( len(affiliated_publications), options.outputfile)) try: with open(options.publicationsfile, 'w') as publications_output: publications_output.write(publications.to_yaml()) except IOError: # The file is missing
logging.info("Searching pubmed for publications") for user in users.values(): new_pubmed_ids = Searcher.get_pubmed_ids_for_user( user, options.start, options.end) pubmed_ids.update(new_pubmed_ids) pubmed_id_count = len(pubmed_ids) logging.info("Found %s citations by searching pubmed" % pubmed_id_count) logging.info("Getting pubmed_ids from the Library") new_pubmed_ids = LibrarySearcher.get_pubmed_ids(options.start, options.end) pubmed_ids.update(new_pubmed_ids) logging.info("Found additional %s publications in Library" % (len(pubmed_ids) - pubmed_id_count)) new_publications = Publications.from_pubmed_ids(list(pubmed_ids)) publications = Publications.merge(publications, new_publications) for publication in publications.values(): publication.update_authors(users) if options.outputfile != "": with open(options.outputfile, "wb") as output: affiliated_publications = publications.not_denied() affiliated_publications.to_csv(output) logging.info( "%s citations with at least one user matching the input queries have been printed to %s" % (len(affiliated_publications), options.outputfile)) try: with open(options.publicationsfile, 'w') as publications_output: publications_output.write(publications.to_yaml()) except IOError: