How to use simulated method in fMBT

Best Python code snippet using fMBT_python

data_augmentation.py

Source:data_augmentation.py Github

copy

Full Screen

1import ants2import numpy as np3import random4def data_augmentation(input_image_list,5 segmentation_image_list=None,6 pointset_list=None,7 number_of_simulations=10,8 reference_image=None,9 transform_type='affineAndDeformation',10 noise_model='additivegaussian',11 noise_parameters=(0.0, 0.05),12 sd_simulated_bias_field=0.05,13 sd_histogram_warping=0.05,14 sd_affine=0.05,15 output_numpy_file_prefix=None,16 verbose=False17 ):18 """19 Randomly transform image data.20 Given an input image list (possibly multi-modal) and an optional corresponding21 segmentation image list, this function will perform data augmentation with22 the following augmentation possibilities:23 * spatial transformations24 * added image noise25 * simulated bias field26 * histogram warping27 Arguments28 ---------29 input_image_list : list of lists of ANTsImages30 List of lists of input images to warp. The internal list sets contain one31 or more images (per subject) which are assumed to be mutually aligned. The32 outer list contains multiple subject lists which are randomly sampled to33 produce output image list.34 segmentation_image_list : list of ANTsImages35 List of segmentation images corresponding to the input image list (optional).36 pointset_list: list of pointsets37 Numpy arrays corresponding to the input image list (optional). If using this38 option, the transform_type must be invertible.39 number_of_simulations : integer40 Number of simulated output image sets. Default = 10.41 reference_image : ANTsImage42 Defines the spatial domain for all output images. If one is not specified,43 we used the first image in the input image list.44 transform_type : string45 One of the following options: "translation", "rigid", "scaleShear", "affine",46 "deformation", "affineAndDeformation".47 noise_model : string48 'additivegaussian', 'saltandpepper', 'shot', or 'speckle'.49 noise_parameters : tuple or array or float50 'additivegaussian': (mean, standardDeviation)51 'saltandpepper': (probability, saltValue, pepperValue)52 'shot': scale53 'speckle': standardDeviation54 Note that the standard deviation, scale, and probability values are *max* values55 and are randomly selected in the range [0, noise_parameter]. Also, the "mean",56 "saltValue" and "pepperValue" are assumed to be in the intensity normalized range57 of [0, 1].58 sd_simulated_bias_field : float59 Characterize the standard deviation of the amplitude.60 sd_histogram_warping : float61 Determines the strength of the bias field.62 sd_affine : float63 Determines the amount of transformation based change.64 output_numpy_file_prefix : string65 Filename of output numpy array containing all the simulated images and segmentations.66 Returns67 -------68 list of lists of transformed images and/or outputs to a numpy array.69 Example70 -------71 >>> image1_list = list()72 >>> image1_list.append(ants.image_read(ants.get_ants_data("r16")))73 >>> image2_list = list()74 >>> image2_list.append(ants.image_read(ants.get_ants_data("r64")))75 >>> segmentation1 = ants.threshold_image(image1_list[0], "Otsu", 3)76 >>> segmentation2 = ants.threshold_image(image2_list[0], "Otsu", 3)77 >>> input_segmentations = list()78 >>> input_segmentations.append(segmentation1)79 >>> input_segmentations.append(segmentation2)80 >>> points1 = ants.get_centroids(segmentation1)[:,0:2]81 >>> points2 = ants.get_centroids(segmentation2)[:,0:2]82 >>> input_points = list()83 >>> input_points.append(points1)84 >>> input_points.append(points2)85 >>> input_images = list()86 >>> input_images.append(image1_list)87 >>> input_images.append(image2_list)88 >>> data = data_augmentation(input_images,89 input_segmentations,90 input_points,91 tranform_type="scaleShear")92 """93 from ..utilities import histogram_warp_image_intensities94 from ..utilities import simulate_bias_field95 from ..utilities import randomly_transform_image_data96 if reference_image is None:97 reference_image = input_image_list[0][0]98 number_of_modalities = len(input_image_list[0])99 # Set up numpy arrays if outputing to file.100 batch_X = None101 batch_Y = None102 batch_Y_points = None103 number_of_points = 0104 if pointset_list is not None:105 number_of_points = pointset_list[0].shape[0]106 batch_Y_points = np.zeros((number_of_simulations, number_of_points, reference_image.dimension))107 if output_numpy_file_prefix is not None:108 batch_X = np.zeros((number_of_simulations, *reference_image.shape, number_of_modalities))109 if segmentation_image_list is not None:110 batch_Y = np.zeros((number_of_simulations, *reference_image.shape))111 # Spatially transform input image data112 if verbose:113 print("Randomly spatially transforming the image data.")114 transform_augmentation = randomly_transform_image_data(reference_image,115 input_image_list=input_image_list,116 segmentation_image_list=segmentation_image_list,117 number_of_simulations=number_of_simulations,118 transform_type=transform_type,119 sd_affine=sd_affine,120 deformation_transform_type="bspline",121 number_of_random_points=1000,122 sd_noise=2.0,123 number_of_fitting_levels=4,124 mesh_size=1,125 sd_smoothing=4.0,126 input_image_interpolator='linear',127 segmentation_image_interpolator='nearestNeighbor')128 simulated_image_list = list()129 simulated_segmentation_image_list = list()130 simulated_pointset_list = list()131 for i in range(number_of_simulations):132 if verbose:133 print("Processing simulation " + str(i))134 segmentation = None135 if segmentation_image_list is not None:136 segmentation = transform_augmentation['simulated_segmentation_images'][i]137 simulated_segmentation_image_list.append(segmentation)138 if batch_Y is not None:139 if reference_image.dimension == 2:140 batch_Y[i, :, :] = segmentation.numpy()141 else:142 batch_Y[i, :, :, :] = segmentation.numpy()143 if pointset_list is not None:144 simulated_transform = transform_augmentation['simulated_transforms'][i]145 simulated_transform_inverse = ants.invert_ants_transform(simulated_transform)146 which_subject = transform_augmentation['which_subject'][i]147 simulated_points = np.zeros((number_of_points, reference_image.dimension))148 for j in range(number_of_points):149 simulated_points[j,:] = ants.apply_ants_transform_to_point(150 simulated_transform_inverse, pointset_list[which_subject][j,:])151 simulated_pointset_list.append(simulated_points)152 if batch_Y_points is not None:153 batch_Y_points[i,:,:] = simulated_points154 simulated_local_image_list = list()155 for j in range(number_of_modalities):156 if verbose:157 print(" Modality " + str(j))158 image = transform_augmentation['simulated_images'][i][j]159 image_range = image.range()160 # Normalize to [0, 1] before applying augmentation161 if verbose:162 print(" Normalizing to [0, 1].")163 image = ants.iMath(image, "Normalize")164 # Noise165 if noise_model is not None:166 if verbose:167 print(" Adding noise (" + noise_model + ").")168 if any( np.array(noise_parameters) > 0 ):169 if noise_model.lower() == "additivegaussian":170 parameters = (noise_parameters[0], random.uniform(0.0, noise_parameters[1]))171 image = ants.add_noise_to_image(image,172 noise_model="additivegaussian",173 noise_parameters=parameters)174 elif noise_model.lower() == "saltandpepper":175 parameters = (random.uniform(0.0, noise_parameters[0]), noise_parameters[1], noise_parameters[2])176 image = ants.add_noise_to_image(image,177 noise_model="saltandpepper",178 noise_parameters=parameters)179 elif noise_model.lower() == "shot":180 parameters = (random.uniform(0.0, noise_parameters[0]))181 image = ants.add_noise_to_image(image,182 noise_model="shot",183 noise_parameters=parameters)184 elif noise_model.lower() == "speckle":185 parameters = (random.uniform(0.0, noise_parameters[0]))186 image = ants.add_noise_to_image(image,187 noise_model="speckle",188 noise_parameters=parameters)189 else:190 raise ValueError("Unrecognized noise model.")191 # Simulated bias field192 if sd_simulated_bias_field > 0:193 if verbose:194 print(" Adding simulated bias field.")195 bias_field = simulate_bias_field(image, sd_bias_field=sd_simulated_bias_field)196 image = image * (bias_field + 1)197 # Histogram intensity warping198 if sd_histogram_warping > 0:199 if verbose:200 print(" Performing intensity histogram warping.")201 break_points = [0.2, 0.4, 0.6, 0.8]202 displacements = list()203 for b in range(len(break_points)):204 displacements.append(random.gauss(0, sd_histogram_warping))205 image = histogram_warp_image_intensities(image,206 break_points=break_points,207 clamp_end_points=(False, False),208 displacements=displacements)209 # Rescale to original intensity range210 if verbose:211 print(" Rescaling to original intensity range.")212 image = ants.iMath(image, "Normalize") * (image_range[1] - image_range[0]) + image_range[0]213 simulated_local_image_list.append(image)214 if batch_X is not None:215 if reference_image.dimension == 2:216 batch_X[i, :, :, j] = image.numpy()217 else:218 batch_X[i, :, :, :, j] = image.numpy()219 simulated_image_list.append(simulated_local_image_list)220 if batch_X is not None:221 if output_numpy_file_prefix is not None:222 if verbose:223 print("Writing images to numpy array.")224 np.save(output_numpy_file_prefix + "SimulatedImages.npy", batch_X)225 if batch_Y is not None:226 if output_numpy_file_prefix is not None:227 if verbose:228 print("Writing segmentation images to numpy array.")229 np.save(output_numpy_file_prefix + "SimulatedSegmentationImages.npy", batch_Y)230 if batch_Y_points is not None:231 if output_numpy_file_prefix is not None:232 if verbose:233 print("Writing segmentation images to numpy array.")234 np.save(output_numpy_file_prefix + "SimulatedPointsets.npy", batch_Y_points)235 if segmentation_image_list is None and pointset_list is None:236 return({'simulated_images' : simulated_image_list})237 elif segmentation_image_list is None:238 return({'simulated_images' : simulated_image_list,239 'simulated_pointset_list' : simulated_pointset_list})240 elif pointset_list is None:241 return({'simulated_images' : simulated_image_list,242 'simulated_segmentation_images' : simulated_segmentation_image_list})243 else:244 return({'simulated_images' : simulated_image_list,245 'simulated_segmentation_images' : simulated_segmentation_image_list,...

Full Screen

Full Screen

script_simulation.py

Source:script_simulation.py Github

copy

Full Screen

1import functions_bit_computation as bit_computation2import functions_preprocessing as preprocessing3import functions_simulation as simulation4import functions_reconstruction as reconstruction5import functions_evaluation_index as evaluation_index6import numpy as np7from scipy import interpolate8# The script of the simulation9# Parameters of the reconstruction methods10rct = 60 # Attenuation parameter (sigma) of ED-SG11half_window = 10 # Half window size of SG filter12order = 3 # Three order polynomial for SG filter13window_size = half_window * 2 + 114hants_order = 15 # The number of harmonic waves15ws_lamda = 2.5 # smoothing parameter (lambda) for WS filter16method_list = ['original', 'sg', 'hants', 'bise', 'ed_sg', 'ws', 'mvi']17file_path = 'E:\\Envelope_Detection\\code\\'18# Input simulated real NDVI timeseries19simulated_actual = preprocessing.real_read_in(file_path + 'simulated_real.txt')20# Input the frequency distribution of the duration of the pixel state21probability_density = preprocessing.probability_density_read_in(file_path + 'probablity_density.txt')22# Input the frequency distribution of cloud covered NDVI values23cloud_density = preprocessing.cloud_density_read_in(file_path + 'cloudcover_ndvi.txt')24# repetition of the experiment25repetition = 126# compute the probability of the NDVI27integral_cloud = simulation.integral_cloud_ndvi(cloud_density)28overall_ac = np.zeros((len(method_list), repetition), float)29overall_variance = np.zeros((len(method_list), repetition), float)30ac_mean = np.zeros((len(method_list), 21, 21), float) # record the mean of ac31# pixel_state includes "clear", "cloud cover" and "shadows and other states".32pixel_state = bit_computation.compute_pixel_state(file_path + 'cloud_timeseries.xls', file_path + 'cloud_timeseries.xls')33cloudcover_rate = pixel_state[1] / (pixel_state[1] + pixel_state[2])34shadow_rate = 1 - cloudcover_rate35for repeat in range(repetition):36 print('Repeation: ', repeat)37 ac_array = np.zeros((len(method_list), 21, 21), float)38 for i in range(21):39 for j in range(21):40 noise_random = 0.01 * i41 noise_subpixel = 0.01 * j42 ac_list = []43 # Creat simulated quality band44 simulated_quality = simulation.create_simulate_quality(probability_density, cloudcover_rate)45 # Add artificial noises46 simulated_observation = simulation.create_simulate_data\47 (simulated_actual, simulated_quality, integral_cloud, noise_random, noise_subpixel)48 # The performances of SG, HANTS and WS depend on the precision of the quality band. Here we randomly add49 # to the quality band to test the algorithms50 # pixel_state = bit_operation.compute_pixel_state(file_path + 'cloud_timeseries.xls', file_path + 'cloud_timeseries.xls')51 # cloudcover_rate = pixel_state[1] / (pixel_state[1] + pixel_state[2])52 # shadow_rate = 1 - cloudcover_rate53 # error_rate = 0.154 # for k in range(len(simulated_quality)):55 # random_value = random.uniform(0, 1)56 # if random_value <= 1 - error_rate:57 # if simulated_quality[k] == 2:58 # # simulated_quality[k] = 159 # random_cloud = random.uniform(0, 1)60 # if random_cloud < cloudcover_rate:61 # simulated_quality[k] = 0 # 云遮盖62 # else:63 # simulated_quality[k] = 1 # 云阴影64 # else:65 # simulated_quality[k] = 266 # SG filtering, HANTS and WS need masked bad quality data based on simulated quality band67 value_effective = [simulated_observation[0]]68 t_effective = [1]69 for k in range(1, len(simulated_observation) - 1):70 if simulated_quality[k] == 2:71 value_effective.append(simulated_observation[k])72 t_effective.append(k + 1)73 value_effective.append(value_effective[-1])74 t_effective.append(len(simulated_observation))75 t_new = range(1, len(simulated_observation) + 1)76 linear_interpolate = interpolate.interp1d(t_effective, value_effective, kind="slinear")77 value_effective_interpolated = linear_interpolate(t_new)78 data_sg = reconstruction.sg_filtering(value_effective_interpolated, half_window, 3)79 #80 hants = reconstruction.hants(hants_order)81 data_hants = hants.hants(value_effective, t_effective, t_new)82 data_hants_sg = reconstruction.sg_filtering(data_hants, half_window, 3)83 data_hants = data_hants[half_window: len(data_hants) - half_window - 1] # Unite the length of the data84 # data_idr = filtering_data.idr(simulated_observation)85 # data_idr_sg = filtering_data.sg_filtering(data_idr, half_window, 3)86 # data_idr = data_idr[half_window: len(data_idr) - half_window - 1]87 data_bise = reconstruction.bise(simulated_observation, 20, 0.1, 0.2)88 data_bise_sg = reconstruction.sg_filtering(data_bise, half_window, 3)89 data_bise = data_bise[half_window: len(data_bise) - half_window - 1]90 data_envelope_detection = reconstruction.envelope_detection(simulated_observation, t_new, rct)91 data_ed_sg = reconstruction.sg_filtering(data_envelope_detection, half_window, 3)92 data_envelope_detection = data_envelope_detection[93 half_window: len(data_envelope_detection) - half_window - 1]94 data_ws = reconstruction.ws(simulated_observation, simulated_quality, ws_lamda)95 data_ws_sg = reconstruction.sg_filtering(data_ws, half_window, order)96 data_ws = data_ws[half_window: len(data_ws) - half_window - 1]97 data_mvi = reconstruction.mvi(simulated_observation)98 data_mvi_sg = reconstruction.sg_filtering(data_mvi, half_window, 3)99 data_mvi = data_mvi[half_window: len(data_mvi) - half_window - 1]100 simulated_actual_show = simulated_actual[101 half_window: len(simulated_actual) - half_window - 1]102 ac_list.append(evaluation_index.ac(simulated_actual, simulated_observation))103 simulated_observation = simulated_observation[half_window: len(simulated_observation) - half_window - 1]104 ac_list.append(evaluation_index.ac(simulated_actual_show, data_sg))105 ac_list.append(evaluation_index.ac(simulated_actual_show, data_hants))106 # ac_list.append(evaluation_index.ac(simulated_actual_show, data_idr_sg))107 ac_list.append(evaluation_index.ac(simulated_actual_show, data_bise_sg))108 ac_list.append(evaluation_index.ac(simulated_actual_show, data_ed_sg))109 ac_list.append(evaluation_index.ac(simulated_actual_show, data_ws))110 ac_list.append(evaluation_index.ac(simulated_actual_show, data_mvi_sg))111 for k in range(len(ac_list)):112 ac_array[k, i, j] = ac_array[k, i, j] + ac_list[k]113 # simulated_observation = simulated_observation[half_window: len(simulated_observation) - half_window - 1]114 # data_output = np.array(simulated_observation)115 # data_output = np.row_stack((data_output, simulated_actual_show, data_sg))116 # print('sg')117 # postprocessing_data.plot_data(data_output)118 # #119 # data_output = np.array(simulated_observation)120 # data_output = np.row_stack((data_output, simulated_actual_show, data_hants, data_hants_sg))121 # print('hants')122 # postprocessing_data.plot_data(data_output)123 #124 # data_output = np.array(simulated_observation)125 # data_output = np.row_stack((data_output, simulated_actual_show, data_idr, data_idr_sg))126 # print('idr')127 # postprocessing_data.plot_data(data_output)128 #129 # data_output = np.array(simulated_observation)130 # data_output = np.row_stack((data_output, simulated_actual_show, data_bise, data_bise_sg))131 # print('bise')132 # postprocessing_data.plot_data(data_output)133 #134 # data_output = np.array(simulated_observation)135 # data_output = np.row_stack((data_output, simulated_actual_show, data_envelope_detection, data_ed_sg))136 # print('ed')137 # postprocessing_data.plot_data(data_output)138 #139 # data_output = np.array(simulated_observation)140 # data_output = np.row_stack((data_output, simulated_actual_show, data_ws, data_ws_sg))141 # print('ws')142 # postprocessing_data.plot_data(data_output)143 #144 # data_output = np.array(simulated_observation)145 # data_output = np.row_stack((data_output, simulated_actual_show, data_mvi, data_mvi_sg))146 # print('mvi')147 # postprocessing_data.plot_data(data_output)148 for i in range(len(method_list)):149 overall_ac[i][repeat] = ac_array[i].mean()150 overall_variance[i][repeat] = ac_array[i].var()151 ac_mean[i] = ac_mean[i] + ac_array[i]152ac_mean = ac_mean / repetition153for i in range(len(method_list)):154 print(method_list[i])155 print(overall_ac[i].mean())156 print(overall_variance[i].mean())157# Output AC array158ac_mean = ac_mean.tolist()159index = 0160for method in method_list:161 method_ac = ac_mean[index]162 ac_list = []163 # 将数据字符串化164 for item in method_ac:165 ac_string = ''166 for i in range(len(item)):167 ac_string = ac_string + ' ' + str(item[i])168 ac_list.append(ac_string)169 index += 1170 headline = "\t"171 output_name = file_path + method + '.txt'172 # with open(output_name, 'w') as file_handle: #以w格式打开之后直接关闭会会清除文本文件内容173 # file_handle.close()174 with open(output_name, 'a') as file_handle: # .txt可以不自己新建,代码会自动新建175 for line in ac_list:176 file_handle.write(line)177 file_handle.write('\n')...

Full Screen

Full Screen

test_simulator.py

Source:test_simulator.py Github

copy

Full Screen

1"""2Tests for simulated data3"""4from __future__ import division5from __future__ import print_function6from __future__ import unicode_literals7import unittest8import datetime9import ga4gh.server.datamodel as datamodel10import ga4gh.server.datamodel.datasets as datasets11import ga4gh.server.datamodel.reads as reads12import ga4gh.server.datamodel.references as references13import ga4gh.server.datamodel.variants as variants14class TestSimulatedVariantSet(unittest.TestCase):15 """16 Test properties of the SimulatedVariantSet17 """18 def setUp(self):19 self.randomSeed = 020 self.numCalls = 221 # ensure variantDensity is >= 1 so we get deterministic behavoir22 self.variantDensity = 123 self.simulatedVariantSet = self._getSimulatedVariantSet()24 self.referenceName = 'ref'25 self.startPosition = 10026 self.endPosition = 10327 self.callSetIds = ['unused']28 self.bases = ["A", "C", "G", "T"]29 def _getSimulatedVariantSet(self):30 dataset = datasets.Dataset('dataset1')31 referenceSet = references.SimulatedReferenceSet("srs1")32 simulatedVariantSet = variants.SimulatedVariantSet(33 dataset, referenceSet, 'variantSet1', randomSeed=self.randomSeed,34 numCalls=self.numCalls, variantDensity=self.variantDensity)35 return simulatedVariantSet36 def _getSimulatedVariantsList(self, simulatedVariantSet=None):37 if simulatedVariantSet is None:38 simulatedVariantSet = self.simulatedVariantSet39 simulatedVariants = simulatedVariantSet.getVariants(40 self.referenceName, self.startPosition, self.endPosition,41 self.callSetIds)42 variantList = list(simulatedVariants)43 return variantList44 def testConstruction(self):45 # initializing SimulatedVariantSet should store values correctly46 self.assertEqual(47 self.randomSeed, self.simulatedVariantSet._randomSeed)48 self.assertEqual(49 self.numCalls, self.simulatedVariantSet._numCalls)50 self.assertEqual(51 self.variantDensity, self.simulatedVariantSet._variantDensity)52 self.assertEqual(53 self.simulatedVariantSet.getCreationTime(),54 self.simulatedVariantSet.getUpdatedTime())55 def testGetVariants(self):56 # calling getVariants should produce the expected results57 variantList = self._getSimulatedVariantsList()58 self.assertEqual(59 len(variantList), self.endPosition - self.startPosition)60 for offset, simulatedVariant in enumerate(variantList):61 start = self.startPosition + offset62 variantSetCompoundId = self.simulatedVariantSet.getCompoundId()63 variantCompoundId = datamodel.VariantCompoundId.parse(64 simulatedVariant.id)65 self.assertEqual(66 variantSetCompoundId.variant_set_id,67 self.simulatedVariantSet.getId())68 self.assertEqual(69 variantSetCompoundId.variant_set_id,70 variantCompoundId.variant_set_id)71 self.assertEqual(72 variantCompoundId.reference_name, self.referenceName)73 self.assertEqual(74 variantCompoundId.start, str(simulatedVariant.start))75 self.assertEqual(76 simulatedVariant.variant_set_id,77 self.simulatedVariantSet.getId())78 self.assertEqual(79 simulatedVariant.reference_name, self.referenceName)80 self.assertEqual(81 simulatedVariant.created, simulatedVariant.updated)82 self.assertEqual(simulatedVariant.start, start)83 self.assertEqual(simulatedVariant.end, start + 1)84 self.assertIn(simulatedVariant.reference_bases, self.bases)85 self.assertIn(86 simulatedVariant.alternate_bases[0], self.bases)87 self.assertEqual(len(simulatedVariant.calls), self.numCalls)88 def testConsistency(self):89 # two SimulatedBackend objects given the same parameters90 # should produce identical variant lists91 variantListOne = self._getSimulatedVariantsList()92 simulatedVariantSetTwo = self._getSimulatedVariantSet()93 variantListTwo = self._getSimulatedVariantsList(94 simulatedVariantSetTwo)95 self._assertEqualVariantLists(variantListOne, variantListTwo)96 def testSelfConsistent(self):97 # the same SimulatedBackend should produce identical98 # variant lists given the same parameters99 variantListOne = self._getSimulatedVariantsList()100 variantListTwo = self._getSimulatedVariantsList()101 self.assertEqual(variantListOne, variantListTwo)102 def _assertEqualVariantLists(self, variantListOne, variantListTwo):103 # need to make time-dependent fields equal before the comparison,104 # otherwise we're introducing a race condition105 timeDependentFields = ['created', 'updated']106 for variantList in (variantListOne, variantListTwo):107 for variant in variantList:108 for field in timeDependentFields:109 setattr(variant, field, 0)110 self.assertEqual(variantListOne, variantListTwo)111class TestSimulatedVariantAnnotationSet(unittest.TestCase):112 def setUp(self):113 self.randomSeed = 1114 self.numCalls = 2115 # ensure variantDensity is >= 1 so we get deterministic behavoir116 self.variantDensity = 1117 self.referenceName = 'ref'118 self.startPosition = 100119 self.endPosition = 120120 self.callSetIds = ['unused']121 self.bases = ["A", "C", "G", "T"]122 def testCreation(self):123 dataset = datasets.Dataset('dataset1')124 referenceSet = references.SimulatedReferenceSet("srs1")125 localId = "variantAnnotationSetId"126 simulatedVariantSet = variants.SimulatedVariantSet(127 dataset, referenceSet, 'variantSet1', randomSeed=self.randomSeed,128 numCalls=self.numCalls, variantDensity=self.variantDensity)129 simulatedVariantAnnotationSet = variants.SimulatedVariantAnnotationSet(130 simulatedVariantSet, localId, self.randomSeed)131 annotations = simulatedVariantAnnotationSet.getVariantAnnotations(132 self.referenceName, self.startPosition, self.endPosition)133 self.assertEquals(134 simulatedVariantSet.toProtocolElement().id,135 simulatedVariantAnnotationSet.toProtocolElement().variant_set_id,136 "Variant Set ID should match the annotation's variant set ID")137 for variant, ann in annotations:138 self.assertEquals(datetime.datetime.strptime(139 ann.created, "%Y-%m-%dT%H:%M:%S.%fZ").strftime(140 "%Y-%m-%dT%H:%M:%S.%fZ"), ann.created,141 "Expect time format to be in ISO8601")142 self.assertEqual(variant.id, ann.variant_id)143class TestSimulatedReadGroupSet(unittest.TestCase):144 """145 Test properties of the simulated ReadGroupSet146 """147 def testCreation(self):148 dataset = datasets.Dataset('dataset1')149 localId = "readGroupSetId"150 referenceSet = references.SimulatedReferenceSet("srs1")151 simulatedReadGroupSet = reads.SimulatedReadGroupSet(152 dataset, localId, referenceSet)153 for readGroup in simulatedReadGroupSet.getReadGroups():154 alignments = list(readGroup.getReadAlignments())...

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 fMBT 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