コード例 #1
0
ファイル: models.py プロジェクト: katur/eegi
    def get_l4440_control_filters(self):
        """
        Get the filters for the L4440 controls for this experiment.

        To get the actual control experiments from the returned filters,
        simply do Experiment.objects.filter(**filters). Returning
        the filters is more flexible for customization, or for inserting
        into a URL without performing the query.

        L4440 controls for this experiment are restricted to those from
        the same date, same temperature, same worm.

        If this experiment is itself an L4440 clone, the function works
        the same way, returning all L4440 experiments from the same
        date, same worm, same temperature.
        """
        filters = {
            'is_junk': False,
            'plate__date': self.date(),
            'plate__temperature': self.temperature(),
            'worm_strain': self.worm_strain.pk,
            'library_stock__intended_clone': Clone.get_l4440(),
        }

        return filters
コード例 #2
0
ファイル: forms.py プロジェクト: katur/eegi
 def to_python(self, value):
     if value == 'L4440':
         raise forms.ValidationError('RNAi query cannot be L4440')
     elif not value:
         return None
     else:
         return Clone.get_clones_from_search_term(value)
コード例 #3
0
 def to_python(self, value):
     if value == 'L4440':
         raise forms.ValidationError('RNAi query cannot be L4440')
     elif not value:
         return None
     else:
         return Clone.get_clones_from_search_term(value)
コード例 #4
0
    def get_n2_l4440_control_filters(self):
        """
        Get the filters for the L4440 controls for this experiment.

        To get the actual control experiments from the returned filters,
        simply do Experiment.objects.filter(**filters). Returning
        the filters is more flexible for customization, or for inserting
        into a URL without performing the query.

        L4440 controls for this experiment are restricted to those from
        the same date, same temperature, same worm.

        If this experiment is itself an L4440 clone, the function works
        the same way, returning all L4440 experiments from the same
        date, same worm, same temperature.
        """
        filters = {
            'is_junk': False,
            'plate__date': self.date(),
            'plate__temperature': self.temperature(),
            'worm_strain': WormStrain.get_n2().pk,
            'library_stock__intended_clone': Clone.get_l4440(),
        }

        return filters
コード例 #5
0
def mutant_knockdown(request, mutant, temperature):
    """
    Render the page showing knockdown by mutation only.

    context['data'] is returned in format:

        {date: {
            'experiments': [experiments], 'link_to_all': url,
        }}
    """
    data = OrderedDict()

    l4440 = Clone.get_l4440()
    mutant = get_object_or_404(WormStrain, pk=mutant)

    filters = {
        'is_junk': False,
        'worm_strain': mutant.pk,
        'library_stock__intended_clone': l4440,
        'plate__temperature': temperature,
    }

    # Do not join manual scores, since L4440 not manually scored
    experiments = (Experiment.objects.filter(**filters).select_related(
        'library_stock',
        'plate').prefetch_related('devstarscore_set').order_by(
            '-plate__date', 'id'))

    for experiment in experiments:
        date = experiment.plate.date
        if date not in data:
            data[date] = {'experiments': []}
        data[date]['experiments'].append(experiment)

        inner_filters = copy(filters)
        inner_filters['plate__date'] = date

        data[date]['link_to_all'] = build_url('find_experiment_wells_url',
                                              get=inner_filters)

    context = {
        'mutant': mutant,
        'l4440': l4440,
        'temperature': temperature,
        'data': data,
    }

    return render(request, 'mutant_knockdown.html', context)
コード例 #6
0
ファイル: views_knockdown.py プロジェクト: katur/eegi
def mutant_knockdown(request, mutant, temperature):
    """
    Render the page showing knockdown by mutation only.

    context['data'] is returned in format:

        {date: {
            'experiments': [experiments], 'link_to_all': url,
        }}
    """
    data = OrderedDict()

    l4440 = Clone.get_l4440()
    mutant = get_object_or_404(WormStrain, pk=mutant)

    filters = {
        'is_junk': False,
        'worm_strain': mutant.pk,
        'library_stock__intended_clone': l4440,
        'plate__temperature': temperature,
    }

    # Do not join manual scores, since L4440 not manually scored
    experiments = (Experiment.objects.filter(**filters)
                   .select_related('library_stock', 'plate')
                   .prefetch_related('devstarscore_set')
                   .order_by('-plate__date', 'id'))

    for experiment in experiments:
        date = experiment.plate.date
        if date not in data:
            data[date] = {'experiments': []}
        data[date]['experiments'].append(experiment)

        inner_filters = copy(filters)
        inner_filters['plate__date'] = date

        data[date]['link_to_all'] = build_url(
            'find_experiment_wells_url', get=inner_filters)

    context = {
        'mutant': mutant,
        'l4440': l4440,
        'temperature': temperature,
        'data': data,
    }

    return render(request, 'mutant_knockdown.html', context)
コード例 #7
0
def double_knockdown(request, mutant, clones, temperature):
    """
    Render the page showing knockdown by both mutation and RNAi.

    context['data'] is returned in format:

        {clone: {
            library_stock: {
                date: {
                    'mutant_rnai': {
                        'experiments': [experiments], 'link_to_all': url
                    },
                    'n2_rnai': {
                        'experiments': [experiments], 'link_to_all': url
                    },
                    'mutant_l4440': {
                        'experiments': [experiments], 'link_to_all': url
                    },
                    'n2_l4440': {
                        'experiments': [experiments], 'link_to_all': url
                    },
                }
            }
        }}

    """

    data = OrderedDict()

    n2 = WormStrain.get_n2()
    l4440 = Clone.get_l4440()
    mutant = get_object_or_404(WormStrain, pk=mutant)
    clones = Clone.objects.filter(pk__in=clones.split(','))

    for clone in clones:
        data_per_clone = OrderedDict()

        library_stocks = (LibraryStock.objects.filter(
            intended_clone=clone).order_by('-plate__screen_stage', 'id'))

        for library_stock in library_stocks:
            data_per_well = OrderedDict()

            dates = Experiment.get_distinct_dates({
                'is_junk':
                False,
                'worm_strain':
                mutant,
                'library_stock':
                library_stock,
                'plate__temperature':
                temperature,
            })

            for date in dates:
                # Add double knockdowns
                filters = {
                    'is_junk': False,
                    'plate__date': date,
                    'worm_strain': mutant.pk,
                    'library_stock': library_stock,
                    'plate__temperature': temperature,
                }
                mutant_rnai = _create_inner_dictionary(filters,
                                                       join_manual=True)

                # Add mutant + L4440 controls
                filters = {
                    'is_junk': False,
                    'plate__date': date,
                    'worm_strain': mutant.pk,
                    'library_stock__intended_clone': l4440,
                    'plate__temperature': temperature,
                }
                mutant_l4440 = _create_inner_dictionary(filters)

                # Add N2 + RNAi controls
                filters = {
                    'is_junk': False,
                    'plate__date': date,
                    'worm_strain': n2.pk,
                    'library_stock': library_stock,
                }

                t = Experiment.get_closest_temperature(temperature, filters)
                filters['plate__temperature'] = t

                n2_rnai = _create_inner_dictionary(filters)

                # Add N2 + L4440 controls
                filters = {
                    'is_junk': False,
                    'plate__date': date,
                    'worm_strain': n2.pk,
                    'library_stock__intended_clone': l4440,
                }

                t = Experiment.get_closest_temperature(temperature, filters)
                filters['plate__temperature'] = t

                n2_l4440 = _create_inner_dictionary(filters)

                data_per_well[date] = {
                    'mutant_rnai': mutant_rnai,
                    'mutant_l4440': mutant_l4440,
                    'n2_rnai': n2_rnai,
                    'n2_l4440': n2_l4440,
                }

            if data_per_well:
                data_per_clone[library_stock] = data_per_well

        data[clone] = data_per_clone

    context = {
        'mutant': mutant,
        'clones': clones,
        'temperature': temperature,
        'data': data,
    }

    return render(request, 'double_knockdown.html', context)
コード例 #8
0
ファイル: views_knockdown.py プロジェクト: katur/eegi
def double_knockdown(request, mutant, clones, temperature):
    """
    Render the page showing knockdown by both mutation and RNAi.

    context['data'] is returned in format:

        {clone: {
            library_stock: {
                date: {
                    'mutant_rnai': {
                        'experiments': [experiments], 'link_to_all': url
                    },
                    'n2_rnai': {
                        'experiments': [experiments], 'link_to_all': url
                    },
                    'mutant_l4440': {
                        'experiments': [experiments], 'link_to_all': url
                    },
                    'n2_l4440': {
                        'experiments': [experiments], 'link_to_all': url
                    },
                }
            }
        }}

    """

    data = OrderedDict()

    n2 = WormStrain.get_n2()
    l4440 = Clone.get_l4440()
    mutant = get_object_or_404(WormStrain, pk=mutant)
    clones = Clone.objects.filter(pk__in=clones.split(','))

    for clone in clones:
        data_per_clone = OrderedDict()

        library_stocks = (LibraryStock.objects.filter(intended_clone=clone)
                          .order_by('-plate__screen_stage', 'id'))

        for library_stock in library_stocks:
            data_per_well = OrderedDict()

            dates = Experiment.get_distinct_dates({
                'is_junk': False,
                'worm_strain': mutant,
                'library_stock': library_stock,
                'plate__temperature': temperature,
            })

            for date in dates:
                # Add double knockdowns
                filters = {
                    'is_junk': False,
                    'plate__date': date,
                    'worm_strain': mutant.pk,
                    'library_stock': library_stock,
                    'plate__temperature': temperature,
                }
                mutant_rnai = _create_inner_dictionary(
                    filters, join_manual=True)

                # Add mutant + L4440 controls
                filters = {
                    'is_junk': False,
                    'plate__date': date,
                    'worm_strain': mutant.pk,
                    'library_stock__intended_clone': l4440,
                    'plate__temperature': temperature,
                }
                mutant_l4440 = _create_inner_dictionary(filters)

                # Add N2 + RNAi controls
                filters = {
                    'is_junk': False,
                    'plate__date': date,
                    'worm_strain': n2.pk,
                    'library_stock': library_stock,
                }

                t = Experiment.get_closest_temperature(temperature, filters)
                filters['plate__temperature'] = t

                n2_rnai = _create_inner_dictionary(filters)

                # Add N2 + L4440 controls
                filters = {
                    'is_junk': False,
                    'plate__date': date,
                    'worm_strain': n2.pk,
                    'library_stock__intended_clone': l4440,
                }

                t = Experiment.get_closest_temperature(temperature, filters)
                filters['plate__temperature'] = t

                n2_l4440 = _create_inner_dictionary(filters)

                data_per_well[date] = {
                    'mutant_rnai': mutant_rnai,
                    'mutant_l4440': mutant_l4440,
                    'n2_rnai': n2_rnai,
                    'n2_l4440': n2_l4440,
                }

            if data_per_well:
                data_per_clone[library_stock] = data_per_well

        data[clone] = data_per_clone

    context = {
        'mutant': mutant,
        'clones': clones,
        'temperature': temperature,
        'data': data,
    }

    return render(request, 'double_knockdown.html', context)
コード例 #9
0
 def get_l4440_stocks(self):
     return self.librarystock_set.filter(intended_clone=Clone.get_l4440())
コード例 #10
0
ファイル: forms.py プロジェクト: katur/eegi
 def to_python(self, value):
     if not value:
         return Clone.objects.all()
     else:
         return Clone.get_clones_from_search_term(value)
コード例 #11
0
 def sync_clone_row_vidal(legacy_row):
     vidal_clone_name = generate_vidal_clone_name(legacy_row[0],
                                                  legacy_row[1])
     new_clone = Clone(id=vidal_clone_name)
     return update_or_save_object(command, new_clone, recorded_clones,
                                  fields_to_compare)
コード例 #12
0
 def sync_clone_row(legacy_row):
     new_clone = Clone(id=legacy_row[0])
     return update_or_save_object(command, new_clone, recorded_clones,
                                  fields_to_compare)
コード例 #13
0
 def to_python(self, value):
     if not value:
         return Clone.objects.all()
     else:
         return Clone.get_clones_from_search_term(value)
コード例 #14
0
ファイル: models.py プロジェクト: katur/eegi
 def get_l4440_stocks(self):
     return self.librarystock_set.filter(intended_clone=Clone.get_l4440())