Ejemplo n.º 1
0
    def get(self):
        plate_ids = self.get_arguments('plate_id')
        process_id = self.get_argument('process_id', None)
        kingfisher = None
        epmotion = None
        epmotion_tool = None
        extraction_kit = None
        sample_plate = None
        externally_extracted = False
        volume = None
        ext_date = None
        notes = None
        if process_id is not None:
            try:
                process = GDNAExtractionProcess(process_id)
            except LabmanUnknownIdError:
                raise HTTPError(404,
                                reason="Extraction process %s doesn't exist" %
                                process_id)
            kingfisher = process.kingfisher.id
            epmotion = process.epmotion.id
            epmotion_tool = process.epmotion_tool.id
            extraction_kit = process.extraction_kit.external_lot_id
            sample_plate = process.sample_plate.id
            externally_extracted = process.externally_extracted
            volume = process.volume
            ext_date = process.date.strftime(process.get_date_format())
            notes = process.notes

        ep_robots = Equipment.list_equipment('EpMotion')
        kf_robots = Equipment.list_equipment('King Fisher')
        tools = Equipment.list_equipment('tm 1000 8 channel pipette head')
        self.render('extraction.html',
                    plate_ids=plate_ids,
                    kf_robots=kf_robots,
                    ep_robots=ep_robots,
                    tools=tools,
                    process_id=process_id,
                    kingfisher=kingfisher,
                    epmotion=epmotion,
                    epmotion_tool=epmotion_tool,
                    extraction_kit=extraction_kit,
                    sample_plate=sample_plate,
                    externally_extracted=externally_extracted,
                    volume=volume,
                    extraction_date=ext_date,
                    notes=notes)
Ejemplo n.º 2
0
 def test_gDNA_composition_attributes(self):
     obs = GDNAComposition(1)
     self.assertEqual(obs.sample_composition, SampleComposition(1))
     self.assertEqual(obs.upstream_process, GDNAExtractionProcess(1))
     self.assertEqual(obs.container, Well(3074))
     self.assertEqual(obs.total_volume, 10)
     self.assertIsNone(obs.notes)
     self.assertEqual(obs.composition_id, 3082)
Ejemplo n.º 3
0
def create_gdna_extraction_process(user, plate):
    kingfisher = Equipment(11)
    epmotion = Equipment(6)
    epmotion_tool = Equipment(15)
    extraction_kit = ReagentComposition(1)
    ext_process = GDNAExtractionProcess.create(
        user, plate, kingfisher, epmotion, epmotion_tool, extraction_kit, 100,
        'GDNA test plate %s' % datetime.now())
    gdna_plate = ext_process.plates[0]
    return ext_process, gdna_plate
Ejemplo n.º 4
0
    def post(self):
        robot = self.get_argument('robot')
        tool = self.get_argument('tool')
        kit = self.get_argument('kit')
        plates = self.get_argument('plates')
        volume = self.get_argument('volume')

        plates = [Plate(pid) for pid in json_decode(plates)]

        process = GDNAExtractionProcess.create(
            self.current_user, Equipment(robot), Equipment(tool),
            ReagentComposition.from_external_id(kit), plates, volume)

        self.write({'process': process.id})
Ejemplo n.º 5
0
    def post(self):
        plates_info = self.get_argument('plates_info')
        extraction_date = self.get_argument('extraction_date')
        volume = self.get_argument('volume')

        month, day, year = map(int, extraction_date.split('/'))
        extraction_date = date(year, month, day)

        plates_info = [
            (Plate(pid), Equipment(kf), Equipment(ep), Equipment(ept),
             ReagentComposition.from_external_id(kit), p_name)
            for pid, kf, ep, ept, kit, p_name in json_decode(plates_info)
        ]

        process = GDNAExtractionProcess.create(self.current_user,
                                               plates_info,
                                               volume,
                                               extraction_date=extraction_date)

        self.write({'process': process.id})
Ejemplo n.º 6
0
    def post(self):
        plates_info = self.get_argument('plates_info')
        extraction_date = self.get_argument('extraction_date')
        volume = self.get_argument('volume')

        month, day, year = map(int, extraction_date.split('/'))
        extraction_date = date(year, month, day)

        # We create one process per plate
        processes = []
        for pid, ee, kf, ep, ept, kit, p_name, nt in json_decode(plates_info):
            # Check whether plate was externally extracted
            if ee is True:
                # find the id of null things
                eq_no = \
                  Equipment.list_equipment('Not applicable')[0]['equipment_id']
                ep = ept = kf = Equipment(eq_no)
                kit = ReagentComposition.from_external_id('Not applicable')
            else:
                kf = Equipment(kf)
                ep = Equipment(ep)
                ept = Equipment(ept)
                kit = ReagentComposition.from_external_id(kit)
            processes.append(
                GDNAExtractionProcess.create(self.current_user,
                                             Plate(pid),
                                             kf,
                                             ep,
                                             ept,
                                             kit,
                                             volume,
                                             p_name,
                                             externally_extracted=ee,
                                             extraction_date=extraction_date,
                                             notes=nt).id)

        self.write({'processes': processes})
Ejemplo n.º 7
0
    def test_properties(self):
        # Plate 21 - Defined in the test DB
        tester = Plate(21)
        self.assertEqual(tester.external_id, 'Test plate 1')
        self.assertEqual(tester.plate_configuration, PlateConfiguration(1))
        self.assertFalse(tester.discarded)
        self.assertIsNone(tester.notes)
        obs_layout = tester.layout
        self.assertEqual(len(obs_layout), 8)
        for row in obs_layout:
            self.assertEqual(len(row), 12)
        self.assertEqual(tester.studies, {Study(1)})
        self.assertIsNone(tester.quantification_process)
        self.assertEqual(tester.process, SamplePlatingProcess(10))

        # Test changing the name of the plate
        tester.external_id = 'Some new name'
        self.assertEqual(tester.external_id, 'Some new name')
        tester.external_id = 'Test plate 1'
        self.assertEqual(tester.external_id, 'Test plate 1')

        self.assertEqual(
            Plate(23).quantification_process, QuantificationProcess(1))
        self.assertEqual(Plate(22).process, GDNAExtractionProcess(1))

        exp = {
            '1.SKB1.640202': [
                Well(3073),
                Well(3253),
                Well(3433),
                Well(3613),
                Well(3793),
                Well(3973)
            ],
            '1.SKB2.640194': [
                Well(3088),
                Well(3268),
                Well(3448),
                Well(3628),
                Well(3808),
                Well(3988)
            ],
            '1.SKB3.640195': [
                Well(3103),
                Well(3283),
                Well(3463),
                Well(3643),
                Well(3823),
                Well(4003)
            ],
            '1.SKB4.640189': [
                Well(3118),
                Well(3298),
                Well(3478),
                Well(3658),
                Well(3838),
                Well(4018)
            ],
            '1.SKB5.640181': [
                Well(3133),
                Well(3313),
                Well(3493),
                Well(3673),
                Well(3853),
                Well(4033)
            ],
            '1.SKB6.640176': [
                Well(3148),
                Well(3328),
                Well(3508),
                Well(3688),
                Well(3868),
                Well(4048)
            ],
            '1.SKB7.640196': [
                Well(3163),
                Well(3343),
                Well(3523),
                Well(3703),
                Well(3883),
                Well(4063)
            ],
            '1.SKB8.640193': [
                Well(3178),
                Well(3358),
                Well(3538),
                Well(3718),
                Well(3898),
                Well(4078)
            ],
            '1.SKB9.640200': [
                Well(3193),
                Well(3373),
                Well(3553),
                Well(3733),
                Well(3913),
                Well(4093)
            ],
            '1.SKD1.640179': [
                Well(3208),
                Well(3388),
                Well(3568),
                Well(3748),
                Well(3928),
                Well(4108)
            ],
            '1.SKD2.640178': [
                Well(3223),
                Well(3403),
                Well(3583),
                Well(3763),
                Well(3943),
                Well(4123)
            ],
            '1.SKD3.640198': [
                Well(3238),
                Well(3418),
                Well(3598),
                Well(3778),
                Well(3958),
                Well(4138)
            ]
        }
        self.assertEqual(tester.duplicates, exp)
Ejemplo n.º 8
0
    def test_properties(self):
        # Plate 21 - Defined in the test DB
        tester = Plate(21)
        self.assertEqual(tester.external_id, 'Test plate 1')
        self.assertEqual(tester.plate_configuration, PlateConfiguration(1))
        self.assertFalse(tester.discarded)
        tester.discarded = True
        self.assertTrue(tester.discarded)
        self.assertIsNone(tester.notes)
        obs_layout = tester.layout
        self.assertEqual(len(obs_layout), 8)
        for row in obs_layout:
            self.assertEqual(len(row), 12)
        self.assertEqual(tester.studies, {Study(1)})
        self.assertIsNone(tester.quantification_process)
        self.assertEqual(tester.process, SamplePlatingProcess(10))

        # Test changing the name of the plate
        tester.external_id = 'Some new name'
        self.assertEqual(tester.external_id, 'Some new name')
        tester.external_id = 'Test plate 1'
        self.assertEqual(tester.external_id, 'Test plate 1')

        self.assertEqual(
            Plate(23).quantification_process, QuantificationProcess(1))
        self.assertEqual(Plate(22).process, GDNAExtractionProcess(1))

        exp = {
            '1.SKB1.640202': [[Well(3073), '1.SKB1.640202.21.A1'],
                              [Well(3253), '1.SKB1.640202.21.B1'],
                              [Well(3433), '1.SKB1.640202.21.C1'],
                              [Well(3613), '1.SKB1.640202.21.D1'],
                              [Well(3793), '1.SKB1.640202.21.E1'],
                              [Well(3973), '1.SKB1.640202.21.F1']],
            '1.SKB2.640194': [[Well(3088), '1.SKB2.640194.21.A2'],
                              [Well(3268), '1.SKB2.640194.21.B2'],
                              [Well(3448), '1.SKB2.640194.21.C2'],
                              [Well(3628), '1.SKB2.640194.21.D2'],
                              [Well(3808), '1.SKB2.640194.21.E2'],
                              [Well(3988), '1.SKB2.640194.21.F2']],
            '1.SKB3.640195': [[Well(3103), '1.SKB3.640195.21.A3'],
                              [Well(3283), '1.SKB3.640195.21.B3'],
                              [Well(3463), '1.SKB3.640195.21.C3'],
                              [Well(3643), '1.SKB3.640195.21.D3'],
                              [Well(3823), '1.SKB3.640195.21.E3'],
                              [Well(4003), '1.SKB3.640195.21.F3']],
            '1.SKB4.640189': [[Well(3118), '1.SKB4.640189.21.A4'],
                              [Well(3298), '1.SKB4.640189.21.B4'],
                              [Well(3478), '1.SKB4.640189.21.C4'],
                              [Well(3658), '1.SKB4.640189.21.D4'],
                              [Well(3838), '1.SKB4.640189.21.E4'],
                              [Well(4018), '1.SKB4.640189.21.F4']],
            '1.SKB5.640181': [[Well(3133), '1.SKB5.640181.21.A5'],
                              [Well(3313), '1.SKB5.640181.21.B5'],
                              [Well(3493), '1.SKB5.640181.21.C5'],
                              [Well(3673), '1.SKB5.640181.21.D5'],
                              [Well(3853), '1.SKB5.640181.21.E5'],
                              [Well(4033), '1.SKB5.640181.21.F5']],
            '1.SKB6.640176': [[Well(3148), '1.SKB6.640176.21.A6'],
                              [Well(3328), '1.SKB6.640176.21.B6'],
                              [Well(3508), '1.SKB6.640176.21.C6'],
                              [Well(3688), '1.SKB6.640176.21.D6'],
                              [Well(3868), '1.SKB6.640176.21.E6'],
                              [Well(4048), '1.SKB6.640176.21.F6']],
            '1.SKB7.640196': [[Well(3163), '1.SKB7.640196.21.A7'],
                              [Well(3343), '1.SKB7.640196.21.B7'],
                              [Well(3523), '1.SKB7.640196.21.C7'],
                              [Well(3703), '1.SKB7.640196.21.D7'],
                              [Well(3883), '1.SKB7.640196.21.E7'],
                              [Well(4063), '1.SKB7.640196.21.F7']],
            '1.SKB8.640193': [[Well(3178), '1.SKB8.640193.21.A8'],
                              [Well(3358), '1.SKB8.640193.21.B8'],
                              [Well(3538), '1.SKB8.640193.21.C8'],
                              [Well(3718), '1.SKB8.640193.21.D8'],
                              [Well(3898), '1.SKB8.640193.21.E8'],
                              [Well(4078), '1.SKB8.640193.21.F8']],
            '1.SKB9.640200': [[Well(3193), '1.SKB9.640200.21.A9'],
                              [Well(3373), '1.SKB9.640200.21.B9'],
                              [Well(3553), '1.SKB9.640200.21.C9'],
                              [Well(3733), '1.SKB9.640200.21.D9'],
                              [Well(3913), '1.SKB9.640200.21.E9'],
                              [Well(4093), '1.SKB9.640200.21.F9']],
            '1.SKD1.640179': [[Well(3208), '1.SKD1.640179.21.A10'],
                              [Well(3388), '1.SKD1.640179.21.B10'],
                              [Well(3568), '1.SKD1.640179.21.C10'],
                              [Well(3748), '1.SKD1.640179.21.D10'],
                              [Well(3928), '1.SKD1.640179.21.E10'],
                              [Well(4108), '1.SKD1.640179.21.F10']],
            '1.SKD2.640178': [[Well(3223), '1.SKD2.640178.21.A11'],
                              [Well(3403), '1.SKD2.640178.21.B11'],
                              [Well(3583), '1.SKD2.640178.21.C11'],
                              [Well(3763), '1.SKD2.640178.21.D11'],
                              [Well(3943), '1.SKD2.640178.21.E11'],
                              [Well(4123), '1.SKD2.640178.21.F11']],
            '1.SKD3.640198': [[Well(3238), '1.SKD3.640198.21.A12'],
                              [Well(3418), '1.SKD3.640198.21.B12'],
                              [Well(3598), '1.SKD3.640198.21.C12'],
                              [Well(3778), '1.SKD3.640198.21.D12'],
                              [Well(3958), '1.SKD3.640198.21.E12'],
                              [Well(4138), '1.SKD3.640198.21.F12']]
        }
        self.assertEqual(tester.duplicates, exp)
        self.assertEqual(tester.unknown_samples, [])
        exp = tester.get_well(1, 1)
        exp.composition.update('Unknown')
        self.assertEqual(tester.unknown_samples, [exp])
        exp.composition.update('1.SKB1.640202')
Ejemplo n.º 9
0
    def test_properties(self):
        # Plate 21 - Defined in the test DB
        tester = Plate(21)
        self.assertEqual(tester.external_id, 'Test plate 1')
        self.assertEqual(tester.plate_configuration, PlateConfiguration(1))
        self.assertFalse(tester.discarded)
        tester.discarded = True
        self.assertTrue(tester.discarded)
        self.assertIsNone(tester.notes)
        obs_layout = tester.layout
        self.assertEqual(len(obs_layout), 8)
        for row in obs_layout:
            self.assertEqual(len(row), 12)
        self.assertEqual(tester.studies, {Study(1)})
        self.assertListEqual(tester.quantification_processes, [])
        self.assertEqual(tester.process, SamplePlatingProcess(10))

        # Test changing the name of the plate
        tester.external_id = 'Some new name'
        self.assertEqual(tester.external_id, 'Some new name')
        tester.external_id = 'Test plate 1'
        self.assertEqual(tester.external_id, 'Test plate 1')

        self.assertEqual(len(Plate(23).quantification_processes), 1)
        self.assertEqual(
            Plate(23).quantification_processes[0], QuantificationProcess(1))
        self.assertEqual(Plate(22).process, GDNAExtractionProcess(1))

        exp = {
            '1.SKB1.640202': [[Well(3073), '1.SKB1.640202.21.A1'],
                              [Well(3121), '1.SKB1.640202.21.A2'],
                              [Well(3169), '1.SKB1.640202.21.A3'],
                              [Well(3217), '1.SKB1.640202.21.A4'],
                              [Well(3265), '1.SKB1.640202.21.A5'],
                              [Well(3313), '1.SKB1.640202.21.A6'],
                              [Well(3361), '1.SKB1.640202.21.A7'],
                              [Well(3409), '1.SKB1.640202.21.A8'],
                              [Well(3457), '1.SKB1.640202.21.A9'],
                              [Well(3505), '1.SKB1.640202.21.A10'],
                              [Well(3553), '1.SKB1.640202.21.A11'],
                              [Well(3601), '1.SKB1.640202.21.A12']],
            '1.SKB2.640194': [[Well(3079), '1.SKB2.640194.21.B1'],
                              [Well(3127), '1.SKB2.640194.21.B2'],
                              [Well(3175), '1.SKB2.640194.21.B3'],
                              [Well(3223), '1.SKB2.640194.21.B4'],
                              [Well(3271), '1.SKB2.640194.21.B5'],
                              [Well(3319), '1.SKB2.640194.21.B6'],
                              [Well(3367), '1.SKB2.640194.21.B7'],
                              [Well(3415), '1.SKB2.640194.21.B8'],
                              [Well(3463), '1.SKB2.640194.21.B9'],
                              [Well(3511), '1.SKB2.640194.21.B10'],
                              [Well(3559), '1.SKB2.640194.21.B11'],
                              [Well(3607), '1.SKB2.640194.21.B12']],
            '1.SKB3.640195': [[Well(3085), '1.SKB3.640195.21.C1'],
                              [Well(3133), '1.SKB3.640195.21.C2'],
                              [Well(3181), '1.SKB3.640195.21.C3'],
                              [Well(3229), '1.SKB3.640195.21.C4'],
                              [Well(3277), '1.SKB3.640195.21.C5'],
                              [Well(3325), '1.SKB3.640195.21.C6'],
                              [Well(3373), '1.SKB3.640195.21.C7'],
                              [Well(3421), '1.SKB3.640195.21.C8'],
                              [Well(3469), '1.SKB3.640195.21.C9'],
                              [Well(3517), '1.SKB3.640195.21.C10'],
                              [Well(3565), '1.SKB3.640195.21.C11'],
                              [Well(3613), '1.SKB3.640195.21.C12']],
            '1.SKB4.640189': [[Well(3091), '1.SKB4.640189.21.D1'],
                              [Well(3139), '1.SKB4.640189.21.D2'],
                              [Well(3187), '1.SKB4.640189.21.D3'],
                              [Well(3235), '1.SKB4.640189.21.D4'],
                              [Well(3283), '1.SKB4.640189.21.D5'],
                              [Well(3331), '1.SKB4.640189.21.D6'],
                              [Well(3379), '1.SKB4.640189.21.D7'],
                              [Well(3427), '1.SKB4.640189.21.D8'],
                              [Well(3475), '1.SKB4.640189.21.D9'],
                              [Well(3523), '1.SKB4.640189.21.D10'],
                              [Well(3571), '1.SKB4.640189.21.D11'],
                              [Well(3619), '1.SKB4.640189.21.D12']],
            '1.SKB5.640181': [[Well(3097), '1.SKB5.640181.21.E1'],
                              [Well(3145), '1.SKB5.640181.21.E2'],
                              [Well(3193), '1.SKB5.640181.21.E3'],
                              [Well(3241), '1.SKB5.640181.21.E4'],
                              [Well(3289), '1.SKB5.640181.21.E5'],
                              [Well(3337), '1.SKB5.640181.21.E6'],
                              [Well(3385), '1.SKB5.640181.21.E7'],
                              [Well(3433), '1.SKB5.640181.21.E8'],
                              [Well(3481), '1.SKB5.640181.21.E9'],
                              [Well(3529), '1.SKB5.640181.21.E10'],
                              [Well(3577), '1.SKB5.640181.21.E11'],
                              [Well(3625), '1.SKB5.640181.21.E12']],
            '1.SKB6.640176': [[Well(3103), '1.SKB6.640176.21.F1'],
                              [Well(3151), '1.SKB6.640176.21.F2'],
                              [Well(3199), '1.SKB6.640176.21.F3'],
                              [Well(3247), '1.SKB6.640176.21.F4'],
                              [Well(3295), '1.SKB6.640176.21.F5'],
                              [Well(3343), '1.SKB6.640176.21.F6'],
                              [Well(3391), '1.SKB6.640176.21.F7'],
                              [Well(3439), '1.SKB6.640176.21.F8'],
                              [Well(3487), '1.SKB6.640176.21.F9'],
                              [Well(3535), '1.SKB6.640176.21.F10'],
                              [Well(3583), '1.SKB6.640176.21.F11'],
                              [Well(3631), '1.SKB6.640176.21.F12']]
        }
        self.assertEqual(tester.duplicates, exp)
        self.assertEqual(tester.unknown_samples, [])
        exp = tester.get_well(1, 1)
        exp.composition.update('Unknown')
        self.assertEqual(tester.unknown_samples, [exp])
        exp.composition.update('1.SKB1.640202')

        # test that the quantification_processes attribute correctly
        # orders multiple processes in order from oldest to newest
        tester2 = Plate(26)
        self.assertEqual(len(tester2.quantification_processes), 2)
        self.assertEqual(
            tester2.quantification_processes[0].date,
            datetime.strptime("2017-10-25 19:10:25-0700",
                              '%Y-%m-%d %H:%M:%S%z'))
        self.assertEqual(
            tester2.quantification_processes[1].date,
            datetime.strptime("2017-10-26 03:10:25-0700",
                              '%Y-%m-%d %H:%M:%S%z'))