Exemplo n.º 1
0
def add_experiment_plate(request):
    """
    Render the page to add a new experiment plate.

    Adding an experiment plate also adds the corresponding experiment wells.
    """
    if request.POST:
        form = AddExperimentPlateForm(request.POST)

        if form.is_valid():
            data = form.cleaned_data
            experiment_plate_id = data['experiment_plate_id']

            ExperimentPlate.create_plate_and_wells(
                experiment_plate_id, data['screen_stage'], data['date'],
                data['temperature'], data['worm_strain'],
                data['library_plate'], is_junk=data['is_junk'],
                plate_comment=data['plate_comment'])

            return redirect('experiment_plate_url', experiment_plate_id)

    else:
        form = AddExperimentPlateForm()

    context = {
        'form': form,
    }

    return render(request, 'add_experiment_plate.html', context)
Exemplo n.º 2
0
def add_experiment_plate(request):
    """
    Render the page to add a new experiment plate.

    Adding an experiment plate also adds the corresponding experiment wells.
    """
    if request.POST:
        form = AddExperimentPlateForm(request.POST)

        if form.is_valid():
            data = form.cleaned_data
            experiment_plate_id = data['experiment_plate_id']

            ExperimentPlate.create_plate_and_wells(
                experiment_plate_id,
                data['screen_stage'],
                data['date'],
                data['temperature'],
                data['worm_strain'],
                data['library_plate'],
                is_junk=data['is_junk'],
                plate_comment=data['plate_comment'])

            return redirect('experiment_plate_url', experiment_plate_id)

    else:
        form = AddExperimentPlateForm()

    context = {
        'form': form,
    }

    return render(request, 'add_experiment_plate.html', context)
Exemplo n.º 3
0
    def sync_experiment_row(legacy_row):
        experiment_plate_id = legacy_row[0]
        worm_strain = get_worm_strain(legacy_row[1], legacy_row[2])
        legacy_library_plate_name = legacy_row[3]
        temperature = legacy_row[4]
        date = legacy_row[5]
        is_junk = legacy_row[6]
        comment = legacy_row[7]

        all_match = True

        if experiment_plate_id < 40000:
            screen_stage = 1
        else:
            screen_stage = 2

        new_plate = ExperimentPlate(id=experiment_plate_id,
                                    screen_stage=screen_stage,
                                    temperature=temperature,
                                    date=date,
                                    comment=comment)

        all_match &= update_or_save_object(command, new_plate, recorded_plates,
                                           plate_fields_to_compare)

        experiment_plate = get_experiment_plate(experiment_plate_id)

        for well in get_well_list():
            new_well = Experiment(
                id=generate_experiment_id(experiment_plate_id, well),
                plate=experiment_plate,
                well=well,
                worm_strain=worm_strain,
                library_stock=get_library_stock(legacy_library_plate_name,
                                                well),
                is_junk=is_junk)

            all_match &= update_or_save_object(command, new_well,
                                               recorded_wells,
                                               well_fields_to_compare)

        return all_match
Exemplo n.º 4
0
def _parse_gdoc_experiment_rows(rows, screen_stage, date, worms,
                                temperatures):
    """Parse the rows with new experiments."""
    all_new_plates = []
    all_new_wells = []

    for i, row in enumerate(rows):
        current_row_number = FIRST_EXP_ROW + i + 1  # gdoc 1-indexed
        library_plate_name = generate_library_plate_name(row[0])
        if not library_plate_name:
            raise ValueError('Library plate cannot be blank; see row {}'
                             .format(current_row_number))

        try:
            library_plate = LibraryPlate.objects.get(id=library_plate_name)
        except ObjectDoesNotExist:
            raise ValueError('Library Plate {} does not exist; see row {}'
                             .format(library_plate_name,
                                     current_row_number))

        for j, experiment_plate_id in enumerate(row[1:]):
            if not experiment_plate_id:
                continue

            # Do dry_run=True to save inserts for bulk queries at end
            plate, wells = ExperimentPlate.create_plate_and_wells(
                experiment_plate_id, screen_stage, date,
                temperatures[j], worms[j], library_plate, dry_run=True)

            all_new_plates.append(plate)
            all_new_wells.extend(wells)

    ExperimentPlate.objects.bulk_create(all_new_plates)
    Experiment.objects.bulk_create(all_new_wells)

    return len(all_new_plates)
Exemplo n.º 5
0
Arquivo: forms.py Projeto: katur/eegi
 def __init__(self, **kwargs):
     temperatures = ExperimentPlate.get_tested_temperatures()
     kwargs["choices"] = [EMPTY_CHOICE] + [(x, x) for x in temperatures]
     super(TemperatureChoiceField, self).__init__(**kwargs)