How to use _get_variants method in avocado

Best Python code snippet using avocado_python

project_version.py

Source:project_version.py Github

copy

Full Screen

...36 self.variants.change_track(track_id=track_id, new_track=new_track)37 self.compositions.change_track(track_id=track_id, new_track=new_track)38 notify(message=NotificationMessage.TRACK_CHANGED, track_id=track_id, new_track=new_track)39 return self40 def _get_variants(self, variant_id: UUID) -> Variants:41 if any(variant.id == variant_id for variant in self.variants):42 return self.variants43 for composition in self.compositions:44 if any(variant.id == variant_id for variant in composition.variants):45 return composition.variants46 raise NoDataFound(47 f"Cannot find variant id {variant_id} in project version {[variant.id for variant in self.variants]} "48 f"{[variant.id for composition in self.compositions for variant in composition.variants]}"49 )50 def get_next_variant(self, variant_id: UUID, repeat: bool, raise_on_last: bool = False) -> Optional[Variant]:51 variants = self._get_variants(variant_id=variant_id)52 if raise_on_last and self.is_last_variant(variant_id=variant_id, repeat=repeat):53 raise OutOfVariants(f"{variant_id} {variants}")54 return variants.get_next_variant(variant_id=variant_id, repeat=repeat)55 def is_last_variant(self, variant_id: UUID, repeat: bool) -> bool:56 variants = self._get_variants(variant_id=variant_id)57 return variants.is_last_variant(variant_id=variant_id, repeat=repeat)58 def get_variant(self, variant_id: UUID) -> Variant:59 variants = self._get_variants(variant_id=variant_id)60 return variants.get_variant(variant_id=variant_id)61 def _get_compiled_sequence(self, variant_id: UUID, track: Track, include_preset: bool = True) -> Sequence:62 variant = self.get_variant(variant_id=variant_id)63 version_id = variant.get_track_variant_item(track=track).version_id64 return track.get_version(identifier=version_id).get_sequence(include_preset=include_preset)65 def get_compiled_sequence(66 self, variant_id: UUID, single_track: Track = None, include_preset: bool = True, raise_not_found: bool = True67 ) -> Sequence:68 variant = self.get_variant(variant_id=variant_id)69 if single_track:70 tracks = [single_track]71 else:72 tracks = [track for track in self.tracks if track.id in variant.get_enabled_tracks_ids()]73 if raise_not_found and not tracks:74 raise NoItemSelected(f"No tracks selected in current variant {variant.name}")75 sequence = None76 if tracks:77 sequence = copy.deepcopy(78 self._get_compiled_sequence(variant_id=variant_id, track=tracks.pop(0), include_preset=include_preset)79 )80 for track in tracks:81 sequence += copy.deepcopy(82 self._get_compiled_sequence(variant_id=variant_id, track=track, include_preset=include_preset)83 )84 return sequence85 def get_total_num_of_bars(self, variant_id: UUID) -> int:86 variant = self.get_variant(variant_id=variant_id)87 variants = self._get_variants(variant_id=variant_id)88 track = self.tracks.get_track(identifier=variant.get_first_track_id())89 if variant.type == VariantType.SINGLE:90 return self.get_compiled_sequence(variant_id=variant_id, single_track=track).num_of_bars()91 return sum(92 self.get_compiled_sequence(variant_id=variant.id, single_track=track).num_of_bars() for variant in variants93 )94 def add_single_variant(self, name: str, selected: bool, enable_all_tracks: bool) -> Variant:95 variant = Variant.from_tracks(96 name=name,97 type_=VariantType.SINGLE,98 tracks=self.tracks,99 selected=selected,100 enable_all_tracks=enable_all_tracks,101 )...

Full Screen

Full Screen

variant.py

Source:variant.py Github

copy

Full Screen

...79 out["variantcaller"] = vc80 if f.find("-germline-") >= 0:81 out["germline"] = full_f82 return out83def _get_variants(data):84 """Retrieve variants from CWL and standard inputs for organizing variants.85 """86 active_vs = []87 if "variants" in data:88 variants = data["variants"]89 # CWL based list of variants90 if isinstance(variants, dict) and "samples" in variants:91 variants = variants["samples"]92 for v in variants:93 # CWL -- a single variant file94 if isinstance(v, six.string_types) and os.path.exists(v):95 active_vs.append(_add_filename_details(v))96 elif (isinstance(v, (list, tuple)) and len(v) > 0 and97 isinstance(v[0], six.string_types) and os.path.exists(v[0])):98 for subv in v:99 active_vs.append(_add_filename_details(subv))100 elif isinstance(v, dict):101 if v.get("vrn_file"):102 active_vs.append(v)103 elif v.get("population"):104 vrnfile = v.get("population").get("vcf")105 active_vs.append(_add_filename_details(vrnfile))106 elif v.get("vcf"):107 active_vs.append(_add_filename_details(v.get("vcf")))108 return active_vs109def get_active_vcinfo(data, use_ensemble=True):110 """Use first caller if ensemble is not active111 """112 active_vs = _get_variants(data)113 if len(active_vs) > 0:114 e_active_vs = []115 if use_ensemble:116 e_active_vs = [v for v in active_vs if v.get("variantcaller") == "ensemble"]117 if len(e_active_vs) == 0:118 e_active_vs = [v for v in active_vs if v.get("variantcaller") != "ensemble"]119 if len(e_active_vs) > 0:120 return e_active_vs[0]121def extract_germline_vcinfo(data, out_dir):122 """Extract germline VCFs from existing tumor inputs.123 """124 supported_germline = set(["vardict", "octopus", "freebayes"])125 if dd.get_phenotype(data) in ["tumor"]:126 for v in _get_variants(data):127 if v.get("variantcaller") in supported_germline:128 if v.get("germline"):129 return v130 else:131 d = utils.deepish_copy(data)132 d["vrn_file"] = v["vrn_file"]133 gd = germline.extract(d, [d], out_dir)134 v["germline"] = gd["vrn_file_plus"]["germline"]135 return v136def extract_population_vcinfo(data):137 """Extract population level VCFs138 """139 for v in _get_variants(data):140 if v.get("population"):...

Full Screen

Full Screen

solve.py

Source:solve.py Github

copy

Full Screen

...62 the_one_ = int(self._bitmask.replace("X", "1"), 2)63 the_zero_ = int(self._bitmask.replace("X", "0"), 2)64 return (integer & the_one_) | the_zero_65class ComputerPart2(Computer):66 def _get_variants(self, addr_mask):67 if "X" in addr_mask:68 for r in ("0", "1"):69 yield from self._get_variants(addr_mask.replace("X", r, 1))70 else:71 yield addr_mask72 def _assign_value(self, command):73 if command.assign_value():74 transformed_memory_address = "{0:036b}".format(command.memory_address)75 transformed_memory_address_ = ""76 for index, letter in enumerate(self._bitmask):77 if letter == "1":78 transformed_memory_address_ += "1"79 elif letter == "0":80 transformed_memory_address_ += transformed_memory_address[index]81 else:82 transformed_memory_address_ += "X"83 for memory_address in self._get_variants(transformed_memory_address_):84 self._memory[int(memory_address, 2)] = command.value85 else:86 pass87def main():88 input_data = get_input_data("advent_of_code_2020/day14/input.txt")89 commands = parse(input_data)90 computer = Computer()91 for command in commands:92 computer.execute_command(command)93 result_part1 = sum(94 computer.get_value(memory_address)95 for memory_address in computer.get_written_memory_addresses()96 )97 print(...

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