How to use replicate_key method in localstack

Best Python code snippet using localstack_python

test_parsers.py

Source:test_parsers.py Github

copy

Full Screen

1import unittest2import impact3import os4import impact.parsers as parsers5BASE_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))6class TestParsers(unittest.TestCase):7 def test_generic_identifier_parser(self):8 ti = impact.ReplicateTrialIdentifier()9 ti.parse_identifier(10 'time:1|'11 'environment__labware:Falcon96|'12 'environment__shaking_speed:250|'13 'environment__temperature:37|'14 'media__base:LIMS|'15 'media__cc:10 glc__D|'16 'rep:1|'17 'strain__id:D1|'18 'strain__ko:adh,pta,lacI|'19 'strain:MG|'20 'strain__plasmid:pKDL|'21 'strain__plasmid:pKDL3|'22 'strain__plasmid:pKDL2')23 self.assertEqual(ti.time,1.)24 self.assertEqual(ti.environment.labware.name,'Falcon96')25 self.assertEqual(ti.environment.shaking_speed,250)26 self.assertEqual(ti.environment.temperature,37)27 self.assertEqual(ti.media.parent,'LIMS')28 print(ti.media.components)29 self.assertEqual(ti.media.components['glc__D'].component_name,'glc__D')30 self.assertEqual(ti.media.components['glc__D'].concentration,10)31 self.assertEqual(ti.replicate_id,1)32 # self.assertEqual(ti.strain.id,'D1') #TODO update33 self.assertEqual(ti.strain.name,'MG')34 self.assertIn('pKDL',[plasmid.name for plasmid in ti.strain.plasmids])35 self.assertIn('pKDL2',[plasmid.name for plasmid in ti.strain.plasmids])36 self.assertIn('pKDL3',[plasmid.name for plasmid in ti.strain.plasmids])37 def test_default_HPLC_parser(self):38 expt = impact.Experiment()39 parsers.Parser.parse_raw_data(data_format='default_titers', file_name=os.path.join(BASE_DIR, 'tests/test_data/sample_input_data.xlsx'), experiment=expt, id_type='CSV')40 num_replicates = (len(expt.replicate_trial_dict.keys()))41 num_single_trials = len([42 single_trial_key for replicate_key in expt.replicate_trial_dict43 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict44 ])45 num_analyte_data = len([46 analyte_name for replicate_key in expt.replicate_trial_dict47 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict48 for analyte_name in expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict49 ])50 num_time_points = len([51 time_point for replicate_key in expt.replicate_trial_dict52 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict53 for analyte_name in expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict54 for time_point in expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict[analyte_name].time_points55 ])56 self.assertEqual(num_replicates,7)57 self.assertEqual(num_single_trials,18)58 self.assertEqual(num_analyte_data,252)59 self.assertEqual(num_time_points,2884)60 def test_spectromax_parser(self):61 expt = impact.Experiment()62 parsers.Parser.parse_raw_data(data_format='spectromax_OD', id_type='traverse', file_name=os.path.join(BASE_DIR,'tests/test_data/sample_spectromax_data.xlsx'), experiment = expt)63 num_replicates = (len(expt.replicate_trial_dict.keys()))64 num_single_trials = len([65 single_trial_key for replicate_key in expt.replicate_trial_dict66 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict67 ])68 num_analyte_data = len([69 analyte_name for replicate_key in expt.replicate_trial_dict70 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict71 for analyte_name in expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict72 ])73 num_time_points = len([74 time_point for replicate_key in expt.replicate_trial_dict75 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict76 for analyte_name in expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict77 for time_point in expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict[analyte_name].time_points78 ])79 self.assertEqual(num_replicates,32)80 self.assertEqual(num_single_trials,88)81 self.assertEqual(num_analyte_data,88)82 self.assertEqual(num_time_points,880)83 def test_tecan_OD_parser(self):84 expt = impact.Experiment()85 parsers.Parser.parse_raw_data(data_format='tecan', id_type='traverse', file_name=os.path.join(BASE_DIR,'tests/test_data/sample_tecan_OD_data.xlsx'), experiment=expt)86 num_replicates = (len(expt.replicate_trial_dict.keys()))87 num_single_trials = len([88 single_trial_key for replicate_key in expt.replicate_trial_dict89 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict90 ])91 num_analyte_data = len([92 analyte_name for replicate_key in expt.replicate_trial_dict93 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict94 for analyte_name in expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict95 ])96 num_time_points = len([97 time_point for replicate_key in expt.replicate_trial_dict98 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict99 for analyte_name in expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict100 for time_point in expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict[analyte_name].time_points101 ])102 self.assertEqual(num_replicates,56)103 self.assertEqual(num_single_trials,96)104 self.assertEqual(num_analyte_data,96)105 self.assertEqual(num_time_points,960)106 def test_tecan_OD_reporter_parser(self):107 expt = impact.Experiment()108 parsers.Parser.parse_raw_data(data_format='tecan', id_type='traverse',109 file_name=os.path.join(BASE_DIR,110 'tests/test_data/sample_tecan_OD_reporter_data.xlsx'),111 experiment=expt)112 num_replicates = (len(expt.replicate_trial_dict.keys()))113 num_single_trials = len([114 single_trial_key for replicate_key in expt.replicate_trial_dict115 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict116 ])117 num_analyte_data = len([118 analyte_name for replicate_key in expt.replicate_trial_dict119 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict120 for analyte_name in121 expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict122 ])123 num_time_points = len([124 time_point for replicate_key in expt.replicate_trial_dict125 for single_trial_key in expt.replicate_trial_dict[replicate_key].single_trial_dict126 for analyte_name in127 expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict128 for time_point in129 expt.replicate_trial_dict[replicate_key].single_trial_dict[single_trial_key].analyte_dict[130 analyte_name].time_points131 ])132 self.assertEqual(num_replicates, 56)133 self.assertEqual(num_single_trials, 96)134 self.assertEqual(num_analyte_data, 288)135 self.assertEqual(num_time_points, 2880)136if __name__ == '__main__':...

Full Screen

Full Screen

MM_reducer.py

Source:MM_reducer.py Github

copy

Full Screen

1#!/usr/bin/env python32import sys3# NUMBER_OF_COLUMNS_IN_A = int(sys.argv[1])4NUMBER_OF_COLUMNS_IN_A = 5005def main():6 current_key = None7 total_sum = 0.08 value_dict = dict()9 # for key_value_pair in key_value_pairs:10 for key_value_pair in sys.stdin:11 key_value_pair = key_value_pair.strip()12 key, value = key_value_pair.split('\t', 1)13 try:14 row_number, column_number = map(int, key.split(','))15 key = (row_number, column_number)16 value = value.split(',')17 replicate_key, element_value = int(value[1]), float(value[2])18 except:19 continue20 if key == current_key:21 if replicate_key not in value_dict:22 value_dict[replicate_key] = [element_value]23 else:24 value_dict[replicate_key].append(element_value)25 else:26 if current_key:27 for i in range(1, NUMBER_OF_COLUMNS_IN_A + 1):28 if (i in value_dict) and (len(value_dict[i]) == 2):29 total_sum = total_sum + value_dict[i][0] * value_dict[i][1]30 print('({},{}),{}'.format(current_key[0],31 current_key[1],32 total_sum,33 )34 )35 current_key = key36 value_dict = dict()37 value_dict[replicate_key] = [element_value]38 total_sum = 0.039 if current_key:40 for j in range(1, NUMBER_OF_COLUMNS_IN_A + 1):41 if (j in value_dict) and (len(value_dict[j]) == 2):42 total_sum = total_sum + value_dict[j][0] * value_dict[j][1]43 print('({},{}),{}'.format(current_key[0],44 current_key[1],45 total_sum,46 )47 )48if __name__ == '__main__':...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful