示例#1
0
def get_primer_plate(is_96):
    plates = [
        Plate(item['plate_id']) for item in Plate.list_plates(['primer'])
    ]

    if is_96:
        # use different plates for 16S
        shuffle(plates)
        hit = None
        for plate in plates:
            pc = plate.plate_configuration
            if pc.description == '96-well microtiter plate':
                hit = plate
                break
        if hit is None:
            raise ValueError("Unable to identify a primer plate")
        return (hit, None)
    else:
        # not shuffling as the order of the plates implicitly matters
        hits = []
        for plate in plates:
            pc = plate.plate_configuration
            if pc.description == '384-well microtiter plate':
                if 'primer' in plate.external_id.lower():
                    hits.append(plate)
        hits = hits[:2]
        if len(hits) != 2:
            raise ValueError("Unable to identify two primer plates")
        return hits
示例#2
0
    def test_plate_list_include_timestamp(self):
        # ...limit pathological failures by testing within an hour of creation
        exp = datetime.datetime.now()
        exp = str(datetime.datetime(exp.year, exp.month,
                                    exp.day)).split(None, 1)[0]

        for i in Plate.list_plates():
            obs = i['creation_timestamp'].split(None, 1)[0]
            self.assertEqual(obs, exp)
示例#3
0
    def get(self):
        plate_ids = self.get_arguments('plate_id')
        process_id = self.get_argument('process_id', None)
        gdna_plate = None
        epmotion = None
        epmotion_tm300 = None
        epmotion_tm50 = None
        primer_plate = None
        master_mix = None
        water_lot = None
        volume = None
        prep_date = None
        if process_id is not None:
            try:
                process = LibraryPrep16SProcess(process_id)
            except LabControlUnknownIdError:
                raise HTTPError(404,
                                reason="Amplicon process %s doesn't exist" %
                                process_id)
            gdna_plate = process.gdna_plate.id
            epmotion = process.epmotion.id
            epmotion_tm300 = process.epmotion_tm300_tool.id
            epmotion_tm50 = process.epmotion_tm50_tool.id
            master_mix = process.mastermix.external_lot_id
            water_lot = process.water_lot.external_lot_id
            primer_plate = process.primer_plate.id
            volume = process.volume
            prep_date = process.date.strftime(process.get_date_format())

        robots = Equipment.list_equipment('EpMotion')
        tools_tm300_8 = Equipment.list_equipment(
            'tm 300 8 channel pipette head')
        tools_tm50_8 = Equipment.list_equipment('tm 50 8 channel pipette head')

        primer_plates = []
        for pp in Plate.list_plates(['primer']):
            plate = Plate(pp['plate_id'])
            if plate.process.primer_set.target_name == 'Amplicon':
                primer_plates.append(pp)

        self.render('library_prep_16S.html',
                    plate_ids=plate_ids,
                    robots=robots,
                    tools_tm300_8=tools_tm300_8,
                    tools_tm50_8=tools_tm50_8,
                    primer_plates=primer_plates,
                    process_id=process_id,
                    gdna_plate=gdna_plate,
                    epmotion=epmotion,
                    epmotion_tm300=epmotion_tm300,
                    epmotion_tm50=epmotion_tm50,
                    master_mix=master_mix,
                    water_lot=water_lot,
                    primer_plate=primer_plate,
                    preparationDate=prep_date,
                    volume=volume)
示例#4
0
    def get(self):
        plate_type = self.get_argument('plate_type', None)
        only_quantified = self.get_argument('only_quantified', False)
        plate_type = (json_decode(plate_type)
                      if plate_type is not None else None)
        only_quantified = True if only_quantified == 'true' else False

        rows_list = [[
            p['plate_id'], p['external_id'], p['creation_timestamp'],
            p['studies'] if p['studies'] is not None else []
        ] for p in Plate.list_plates(plate_type,
                                     only_quantified=only_quantified,
                                     include_study_titles=True)]
        res = {"data": rows_list}

        self.write(res)
示例#5
0
    def get(self):
        plate_ids = self.get_arguments('plate_id')
        process_id = self.get_argument('process_id', None)
        kapa = None
        stub = None
        volume = None
        norm_plate = None
        i5plate = None
        i7plate = None
        if process_id is not None:
            try:
                process = LibraryPrepShotgunProcess(process_id)
            except LabControlUnknownIdError:
                raise HTTPError(404,
                                reason="Shotgun library prep process %s "
                                "doesn't exist" % process_id)
            kapa = process.kapa_hyperplus_kit.external_lot_id
            stub = process.stub_lot.external_lot_id
            norm_plate = process.normalized_plate.id
            i5plate = process.i5_primer_plate.id
            i7plate = process.i7_primer_plate.id
            volume = process.volume

        primer_plates = []
        for pp in Plate.list_plates(['primer']):
            plate = Plate(pp['plate_id'])
            if plate.process.primer_set.target_name == 'Shotgun':
                primer_plates.append(pp)

        self.render('library_prep_shotgun.html',
                    plate_ids=plate_ids,
                    primer_plates=primer_plates,
                    process_id=process_id,
                    kapa=kapa,
                    stub=stub,
                    volume=volume,
                    norm_plate=norm_plate,
                    i5plate=i5plate,
                    i7plate=i7plate)
示例#6
0
    def test_plate_list_discarded_functionality(self):
        # test case based on the test_list_plates
        obs = self.strip_out_creation_timestamp(Plate.list_plates())
        Plate(21).discard = True
        self.assertGreaterEqual(len(obs), 25)
        self.assertEqual(obs[0], {
            'plate_id': 1,
            'external_id': 'EMP 16S V4 primer plate 1'
        })
        self.assertEqual(obs[16], {
            'plate_id': 17,
            'external_id': 'EMP 16S V4 primer plate 7 10/23/2017'
        })
        self.assertEqual(obs[20], {
            'plate_id': 21,
            'external_id': 'Test plate 1'
        })
        Plate(21).discard = False

        # Test without returning discarded primer plates
        Plate(11).discarded = True
        Plate(12).discarded = True
        Plate(13).discarded = True
        obs = self.strip_out_creation_timestamp(
            Plate.list_plates(['primer'], include_discarded=False))

        exp = [{
            'plate_id': 14,
            'external_id': 'EMP 16S V4 primer plate 4 10/23/2017'
        }, {
            'plate_id': 15,
            'external_id': 'EMP 16S V4 primer plate 5 10/23/2017'
        }, {
            'plate_id': 16,
            'external_id': 'EMP 16S V4 primer plate 6 10/23/2017'
        }, {
            'plate_id': 17,
            'external_id': 'EMP 16S V4 primer plate 7 10/23/2017'
        }, {
            'plate_id': 18,
            'external_id': 'EMP 16S V4 primer plate 8 10/23/2017'
        }, {
            'plate_id': 19,
            'external_id': 'iTru 5 Primer Plate 10/23/2017'
        }, {
            'plate_id': 20,
            'external_id': 'iTru 7 Primer Plate 10/23/2017'
        }]
        self.assertEqual(obs, exp)

        # Test returning discarded primer plates
        obs = self.strip_out_creation_timestamp(
            Plate.list_plates(['primer'], include_discarded=True))
        exp = [{
            'plate_id': 11,
            'external_id': 'EMP 16S V4 primer plate 1 10/23/2017'
        }, {
            'plate_id': 12,
            'external_id': 'EMP 16S V4 primer plate 2 10/23/2017'
        }, {
            'plate_id': 13,
            'external_id': 'EMP 16S V4 primer plate 3 10/23/2017'
        }, {
            'plate_id': 14,
            'external_id': 'EMP 16S V4 primer plate 4 10/23/2017'
        }, {
            'plate_id': 15,
            'external_id': 'EMP 16S V4 primer plate 5 10/23/2017'
        }, {
            'plate_id': 16,
            'external_id': 'EMP 16S V4 primer plate 6 10/23/2017'
        }, {
            'plate_id': 17,
            'external_id': 'EMP 16S V4 primer plate 7 10/23/2017'
        }, {
            'plate_id': 18,
            'external_id': 'EMP 16S V4 primer plate 8 10/23/2017'
        }, {
            'plate_id': 19,
            'external_id': 'iTru 5 Primer Plate 10/23/2017'
        }, {
            'plate_id': 20,
            'external_id': 'iTru 7 Primer Plate 10/23/2017'
        }]
        self.assertEqual(obs, exp)

        # undo the discarding
        Plate(11).discarded = False
        Plate(12).discarded = False
        Plate(13).discarded = False
示例#7
0
    def test_list_plates(self):
        # Test returning all plates
        obs = self.strip_out_creation_timestamp(Plate.list_plates())

        # We are creating plates below, but at least we know there are 35
        # plates in the test database
        self.assertGreaterEqual(len(obs), 35)
        self.assertEqual(obs[0], {
            'plate_id': 1,
            'external_id': 'EMP 16S V4 primer plate 1'
        })
        self.assertEqual(obs[16], {
            'plate_id': 17,
            'external_id': 'EMP 16S V4 primer plate 7 10/23/2017'
        })
        self.assertEqual(obs[20], {
            'plate_id': 21,
            'external_id': 'Test plate 1'
        })

        # Test returning sample plates
        obs = self.strip_out_creation_timestamp(Plate.list_plates(['sample']))
        self.assertGreaterEqual(len(obs), 4)
        self.assertEqual(obs[0], {
            'plate_id': 21,
            'external_id': 'Test plate 1'
        })
        obs = self.strip_out_creation_timestamp(
            Plate.list_plates(['sample'], include_study_titles=True))
        self.assertGreaterEqual(len(obs), 4)
        self.assertEqual(
            obs[0], {
                'plate_id':
                21,
                'external_id':
                'Test plate 1',
                'studies':
                ['Identification of the Microbiomes '
                 'for Cannabis Soils']
            })

        # Test returning gDNA plates
        obs = self.strip_out_creation_timestamp(Plate.list_plates(['gDNA']))
        self.assertEqual(obs, [{
            'plate_id': 22,
            'external_id': 'Test gDNA plate 1'
        }, {
            'external_id': 'Test gDNA plate 2',
            'plate_id': 28
        }, {
            'external_id': 'Test gDNA plate 3',
            'plate_id': 31
        }, {
            'external_id': 'Test gDNA plate 4',
            'plate_id': 34
        }])

        obs = self.strip_out_creation_timestamp(
            Plate.list_plates(['compressed gDNA']))
        self.assertEqual(obs, [{
            'plate_id': 24,
            'external_id': 'Test compressed gDNA plates 1-4'
        }])

        # Test returning primer plates
        obs = self.strip_out_creation_timestamp(Plate.list_plates(['primer']))
        exp = [{
            'plate_id': 11,
            'external_id': 'EMP 16S V4 primer plate 1 10/23/2017'
        }, {
            'plate_id': 12,
            'external_id': 'EMP 16S V4 primer plate 2 10/23/2017'
        }, {
            'plate_id': 13,
            'external_id': 'EMP 16S V4 primer plate 3 10/23/2017'
        }, {
            'plate_id': 14,
            'external_id': 'EMP 16S V4 primer plate 4 10/23/2017'
        }, {
            'plate_id': 15,
            'external_id': 'EMP 16S V4 primer plate 5 10/23/2017'
        }, {
            'plate_id': 16,
            'external_id': 'EMP 16S V4 primer plate 6 10/23/2017'
        }, {
            'plate_id': 17,
            'external_id': 'EMP 16S V4 primer plate 7 10/23/2017'
        }, {
            'plate_id': 18,
            'external_id': 'EMP 16S V4 primer plate 8 10/23/2017'
        }, {
            'plate_id': 19,
            'external_id': 'iTru 5 Primer Plate 10/23/2017'
        }, {
            'plate_id': 20,
            'external_id': 'iTru 7 Primer Plate 10/23/2017'
        }]
        self.assertEqual(obs, exp)

        # Test returning gDNA and compressed gDNA plates
        obs = self.strip_out_creation_timestamp(
            Plate.list_plates(['gDNA', 'compressed gDNA']))
        self.assertEqual(obs, [{
            'plate_id': 22,
            'external_id': 'Test gDNA plate 1'
        }, {
            'plate_id': 24,
            'external_id': 'Test compressed gDNA plates 1-4'
        }, {
            'external_id': 'Test gDNA plate 2',
            'plate_id': 28
        }, {
            'external_id': 'Test gDNA plate 3',
            'plate_id': 31
        }, {
            'external_id': 'Test gDNA plate 4',
            'plate_id': 34
        }])

        obs = self.strip_out_creation_timestamp(
            Plate.list_plates(['compressed gDNA', 'normalized gDNA']))
        self.assertEqual(obs, [{
            'plate_id': 24,
            'external_id': 'Test compressed gDNA plates 1-4'
        }, {
            'plate_id': 25,
            'external_id': 'Test normalized gDNA plates 1-4'
        }])

        obs = self.strip_out_creation_timestamp(
            Plate.list_plates(['compressed gDNA', 'normalized gDNA'],
                              only_quantified=True,
                              include_study_titles=True))
        self.assertEqual(obs, [{
            'plate_id':
            24,
            'external_id':
            'Test compressed gDNA plates 1-4',
            'studies':
            ['Identification of the Microbiomes '
             'for Cannabis Soils']
        }])