예제 #1
0
파일: views_basic.py 프로젝트: katur/eegi
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)
예제 #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)
예제 #3
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)