def get_journal_from_file_path(file_path, pmid): """returns a neuroelectro Journal object given a standardized file path and pmid as input adds journal to database """ journal_short_name = file_path.split('/')[-2] try: journal_ob = m.Journal.objects.get(short_title = journal_short_name) except ObjectDoesNotExist: # journal short_title not found from path, try getting from pubmed directly journal_title = get_journal(pmid) try: journal_ob = m.Journal.objects.get(short_title = journal_short_name) except ObjectDoesNotExist: article = add_single_article_full(pmid, overwrite_existing = False) # check if returned article is None if article is None: return None journal_ob = article.journal return journal_ob
from db_functions.pubmed_functions import add_single_article_full, get_journal from article_text_mining.mine_ephys_prop_in_table import assocDataTableEphysVal from article_text_processing import remove_spurious_table_headers from article_text_mining.auto_assign_neurons_table import assocNeuronstoArticleMult2 from article_text_mining.deprecated.db_add_full_text_wiley import make_html_filename import assign_metadata def add_article_full_text_from_file(file_name, path): os.chdir(path) try: pmid_str = re.match('\d+', file_name).group() except Exception, e: print "No pubmed id found in file name %s, skipping..." % file_name return None journal_name = get_journal(pmid_str) # is journal one among list of full text journals? if not isFullTextJournal(journal_name): # with open("analyzed_files.txt", "a") as af: # write_str = '%s\n' % file_name # af.write(write_str) print "Journal %s is not a full text journal, skipping..." % journal_name return None # does journal already have full text assoc with it? if m.ArticleFullText.objects.filter(article__pmid = pmid_str).count() > 0: print "Article %s already in db, skipping..." % pmid_str return None print 'adding article with pmid: %s' % pmid_str a = add_single_article_full(int(pmid_str)) if a is None: