def assign_ephys_grandfather(article): """ Assign 1 of N ephys grandfathers to a NeuroElectro article object by searching NeuroTree """ result = None grandfather_list = define_ephys_grandfathers() last_author_ob = get_article_last_author(article) if last_author_ob is not None: a_node = get_neurotree_author(last_author_ob) if a_node is not None: closest_grandfather = get_closest_grandfather(a_node, grandfather_list) result = closest_grandfather return result
def assign_articles_grandfathers(): """ Assign ephys grandfathers to each article containing ephys data in NeuroElectro. """ q1 = Q(datatable__datasource__neuronconceptmap__times_validated__gte = 1) q2 = Q(usersubmission__datasource__neuronconceptmap__times_validated__gte = 1) articles = m.Article.objects.filter(q1 | q2).distinct() article_info_list = [] for article in articles: grandfather = assign_ephys_grandfather(article) author = get_article_last_author(article) if author is not None: neurotree_node = get_neurotree_author(author) else: neurotree_node = None article_info = [author, neurotree_node, grandfather] article_info_list.append(article_info) return article_info_list