<commit_before>"""

This file contains a bunch of methods for transforming server objects to JSON that can be rendered to client
For example, turn a list of base.Family instances into JSON with relevant fields
These JSON objects are used by client javascript and by django templates

"""
from django.core.urlresolvers import reverse
from django.conf import settings


def individual_list(_individual_list):
    individual_d_list = []
    for indiv in _individual_list:
        project_id = indiv.project.project_id
        family_id = indiv.get_family_id()
        individual_d_list.append({
            'indiv_id': indiv.indiv_id,
            'nickname': indiv.nickname,
            'family_id': family_id,
            'family_url': (reverse('family_home', args=(project_id, family_id) ) if family_id else None),
            'project_id': project_id,
            'maternal_id': indiv.maternal_id,
            'paternal_id': indiv.paternal_id,
            'gender': indiv.gender,
            'affected_status': indiv.affected,
            'phenotypes': [{'slug': ipheno.slug(), 'value': ipheno.val()} for ipheno in indiv.get_phenotypes() if ipheno.val() is not None],
            'data': indiv.data(),
        })
    return individual_d_list


def family_list(_family_list):
    family_d_list = []
    family_tuples = []
    for family in _family_list:
        family_tuples.append((family.project.project_id, family.family_id))
        family_d_list.append({
            'url': reverse('family_home', args=(family.project.project_id, family.family_id)),
            'family_id': family.family_id,
            'family_name': family.family_name,
            'project_id': family.project.project_id,
            'num_individuals': family.num_individuals(),
            'analysis_status': family.analysis_status,
            'short_description': family.short_description,
            'phenotypes': [p.slug for p in family.get_phenotypes()],
        })
    return family_d_list<commit_msg>Add pedigree image, num_causal_variants to families table<commit_after>"""

This file contains a bunch of methods for transforming server objects to JSON that can be rendered to client
For example, turn a list of base.Family instances into JSON with relevant fields
These JSON objects are used by client javascript and by django templates

"""
from django.core.urlresolvers import reverse
from django.conf import settings


def individual_list(_individual_list):
    individual_d_list = []
    for indiv in _individual_list:
        project_id = indiv.project.project_id
        family_id = indiv.get_family_id()
        individual_d_list.append({
            'indiv_id': indiv.indiv_id,
            'nickname': indiv.nickname,
            'family_id': family_id,
            'family_url': (reverse('family_home', args=(project_id, family_id) ) if family_id else None),
            'project_id': project_id,
            'maternal_id': indiv.maternal_id,
            'paternal_id': indiv.paternal_id,
            'gender': indiv.gender,
            'affected_status': indiv.affected,
            'phenotypes': [{'slug': ipheno.slug(), 'value': ipheno.val()} for ipheno in indiv.get_phenotypes() if ipheno.val() is not None],
            'data': indiv.data(),
        })
    return individual_d_list


def family_list(_family_list):
    family_d_list = []
    family_tuples = []
    for family in _family_list:
        family_tuples.append((family.project.project_id, family.family_id))
        family_d_list.append({
            'url': reverse('family_home', args=(family.project.project_id, family.family_id)),
            'family_id': family.family_id,
            'family_name': family.family_name,
            'project_id': family.project.project_id,
            'num_individuals': family.num_individuals(),
            'num_causal_variants': family.num_causal_variants(),
            'analysis_status': family.analysis_status,
            'short_description': family.short_description,
            'pedigree_image_url': family.pedigree_image.url if family.pedigree_image else None,            
            'phenotypes': [p.slug for p in family.get_phenotypes()],
        })
    return family_d_list
{'fraction_non_alphanumeric': 0.10054931932171006, 'fraction_numerical': 0.0, 'mean_word_length': 2.9176800748362957, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2340514', 'n_tokens_mistral': 1266, 'n_tokens_neox': 1215, 'n_words': 297}