How to use _valid_variant method in avocado

Best Python code snippet using avocado_python

utils.py

Source:utils.py Github

copy

Full Screen

...274 else:275 query_cmd = 'virt-install --os-variant list'276 os_variants = run(query_cmd).stdout277 os_patterns = [r"rhel\d+.?\d*", r"win\d+[.k]?\d?[r]?2?"]278 def _valid_variant(variant):279 return bool(re.search(r"%s" % variant, os_variants, re.MULTILINE))280 def _replace_variant(variant):281 if variant.startswith("win"):282 var_dict = {'2000': '2k', '2003': '2k3', '2008': '2k8'}283 for key in var_dict:284 if key in variant:285 return variant.replace(key, var_dict[key])286 return variant287 os_variant = None288 for pat in os_patterns:289 os_variant = re.search(pat, vm_name, re.I)290 if os_variant:291 break292 if os_variant is None:293 LOGGER.warning("Can't determine os variant from name: %s", vm_name)294 return 'none'295 os_variant = _replace_variant(os_variant.group().lower())296 if _valid_variant(os_variant):297 return os_variant298 else:299 if os_variant.startswith('rhel'):300 default_rhel = "rhel7"301 if _valid_variant(os_variant[:5]):302 return os_variant[:5]303 else:304 return default_rhel305 if os_variant.startswith('win'):306 default_win = "win7"307 return default_win308def clean_vm(vm_name, uri=None, host=None):309 """310 Clean up specific VM name311 """312 cmd = 'virsh'313 if uri is not None:314 cmd += ' -c %s' % uri315 destroy_cmd = cmd + " destroy"...

Full Screen

Full Screen

mux.py

Source:mux.py Github

copy

Full Screen

...62 Iterates through variants and process the internal filters63 :yield valid variants64 """65 for variant in self.iter_variants():66 if self._valid_variant(variant):67 yield variant68 def iter_variants(self):69 """70 Iterates through variants without verifying the internal filters71 :yield all existing variants72 """73 pools = []74 for pool in self.pools:75 if isinstance(pool, list):76 # Don't process 2nd level filters in non-root pools77 pools.append(itertools.chain(*(_.iter_variants()78 for _ in pool)))79 else:80 pools.append([pool])81 variants = itertools.product(*pools)82 while True:83 try:84 yield list(itertools.chain(*next(variants)))85 except StopIteration:86 return87 @staticmethod88 def _valid_variant(variant):89 """90 Check the variant for validity of internal filters91 :return: whether the variant is valid or should be ignored/filtered92 """93 _filter_out = set()94 _filter_only = set()95 for node in variant:96 _filter_only.update(node.environment.filter_only)97 _filter_out.update(node.environment.filter_out)98 if not (_filter_only or _filter_out):99 return True100 filter_only = tuple(_filter_only)101 filter_out = tuple(_filter_out)102 filter_only_parents = [str(_).rsplit('/', 2)[0] + '/'...

Full Screen

Full Screen

features.py

Source:features.py Github

copy

Full Screen

...16 easy translation to a BED-like file. This allows variants to be17 worked on via genomic arithmetic18 """19 @staticmethod20 def _valid_variant(var: str, mode: str='reference') -> None:21 if mode not in {'reference', 'alternate'}:22 mode: str = 'reference'23 valid_chars: Set[str] = set('ACGT')24 msg: str = 'The %s allele must contain only %s' % (mode, ','.join(valid_chars))25 if mode == 'alternate':26 valid_chars.update(',*')27 if not set(var.upper()).issubset(valid_chars):28 raise ValueError(msg)29 @staticmethod30 def default_id(chrom: str, position: int, ref: str, alt: str) -> str:31 """Create a default variant ID32 Args:33 chrom (str): Chromomosome or contig of the variant34 position (int): Position of the variant35 ref (str): Reference allele36 alt (str): Alternate alleles separated by commas37 Returns:38 str: The variant ID as '%(chrom)s_%(position)s_%(ref)s_%(alt)s'39 """40 Bpileup._valid_variant(var=ref, mode='reference')41 Bpileup._valid_variant(var=alt, mode='alternate')42 return "%(chr)s_%(pos)s_%(ref)s_%(alt)s" % {43 'chr': chrom,44 'pos': position,45 'ref': ref,46 'alt': alt47 }48 @classmethod49 def frominterval(cls, interval: pybedtools.cbedtools.Interval) -> 'Bpileup':50 """Create a Bpileup from an Interval"""51 if interval.file_type != 'bed':52 raise TypeError("Must be a BED interval")53 elif len(interval.fields) != 6:54 raise ValueError("wrong number of fields")55 return cls(56 chrom=interval.chrom,57 position=interval.end,58 ref=interval.fields[4],59 alt=interval.fields[5],60 name=interval.fields[3]61 )62 def __init__(self, chrom: str, position: int, ref: str, alt: str, name: Optional[str]=None) -> None:63 """Initialize a Bpileup object64 Args:65 chrom (str): Chromosome/contig of the variant66 position (int): Position of the variant67 ref (str): Refererence allele of the variant68 alt (str): Alternate alleles in a comma-separated string69 name (str): Optional variant ID; if not provided, generated by Bpileup.default_id70 """71 # Validate data72 ref: str = str(ref)73 alt: str = str(alt)74 self._valid_variant(var=ref, mode='reference')75 self._valid_variant(var=alt, mode='alternate')76 # Fill in the data77 self._chrom: str = str(chrom)78 self._pos: int = int(position)79 self._ref: str = ref80 self._alt: Tuple[str, ...] = tuple(alt.split(','))81 if name:82 self._id: str = str(name)83 else:84 self._id: str = self._default_id()85 def __str__(self) -> str:86 out: Tuple = (87 self.chrom,88 self.dummy,89 self.position,...

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