How to use _log_variants method in avocado

Best Python code snippet using avocado_python

haplotype_labeler.py

Source:haplotype_labeler.py Github

copy

Full Screen

...805 """806 candidates = list(candidates)807 truths = list(truths)808 if _DEBUG_PRINTING_IS_ENABLED:809 _log_variants('candidates', candidates)810 _log_variants('truth', truths)811 if not variant_utils.variants_are_sorted(candidates):812 raise ValueError('candidates are not sorted', candidates)813 if not variant_utils.variants_are_sorted(truths):814 raise ValueError('truths are not sorted', truths)815 def _hom_ref_enum_if_empty(list_of_variants, non_empty_enum):816 """If list_of_variants is empty, use a ONLY_HOM_REF enum for speed."""817 return non_empty_enum if list_of_variants else EnumerationType.ONLY_HOM_REF818 truth_haplotypes = deduplicate_haplotypes(819 enumerate_all_possible_haplotypes(820 truths, ref, _hom_ref_enum_if_empty(candidates,821 EnumerationType.TRUTH)))822 # Note, it may be worth deduplicating these haplotypes as well.823 variant_haplotypes = enumerate_all_possible_haplotypes(824 candidates, ref, _hom_ref_enum_if_empty(truths,825 EnumerationType.CANDIDATES))826 found = []827 for vh, vgt in variant_haplotypes:828 for th, tgt in truth_haplotypes:829 if th == vh:830 found.append(831 HaplotypeMatch(832 haplotypes=th,833 candidates=candidates,834 candidate_genotypes=vgt,835 truths=truths,836 truth_genotypes=tgt))837 if not found:838 return None839 else:840 return select_best_haplotype_match(found)841def select_best_haplotype_match(all_matches):842 """Returns the best HaplotypeMatch among all_matches.843 The best matching HaplotypeMatch is the one with the lowest match_metrics844 score.845 Args:846 all_matches: iterable[HaplotypeMatch]. An iterable of HaplotypeMatch objects847 we want to select the best match from.848 Returns:849 The best matching HaplotypeMatch object.850 """851 sorted_matches = sorted(all_matches, key=lambda x: x.match_metrics)852 best = sorted_matches[0]853 equivalents = [854 f for f in all_matches if f.match_metrics == best.match_metrics855 ]856 # redacted857 if len(equivalents) > 1:858 for i, f in enumerate(equivalents):859 extra_info = 'best' if i == 0 else i860 logging.warning('Equivalent match to best: %s [%s]', f, extra_info)861 return equivalents[0]862# -----------------------------------------------------------------------------863#864# Private utility functions865#866# -----------------------------------------------------------------------------867def _variant_genotypes(variants, missing_genotypes_default=(-1, -1)):868 """Returns the genotypes of variants as a list of tuples.869 Args:870 variants: iterable[nucleus.protos.Variant]. The variants whose genotypes we871 want to get.872 missing_genotypes_default: tuple. If a variant in variants doesn't have873 genotypes, this value is returned. The default value is (-1, -1), the874 standard representation for "missing" diploid genotypes.875 Returns:876 list[nucleus.protos.Variant] protos in the same order as variants.877 """878 return [879 tuple(v.calls[0].genotype) if v.calls else missing_genotypes_default880 for v in variants881 ]882def _log_haplotypes(name, haplotypes):883 """Write basic information about haplotypes to logging.info."""884 logging.info('haplotypes: %s', name)885 for haplotype, genotypes in haplotypes:886 logging.info(' %s with %s', haplotype, genotypes)887def _log_variants(name, variants):888 """Write basic information about variants to logging.info."""889 logging.info('variants: %s [%d]', name, len(variants))890 for v in variants:891 logging.info(' %s gt=%s', variant_utils.variant_key(v),892 _variant_genotypes([v])[0])893def n_zeroes(l):894 """Returns the number of elements of l that are 0."""895 return sum(1 for x in l if x == 0)896def _allele_from_index(variant, allele_index):897 """Gets the reference_bases or alternative_bases for allele_index."""898 if allele_index == 0:899 return variant.reference_bases900 else:901 return variant.alternate_bases[allele_index - 1]

Full Screen

Full Screen

job.py

Source:job.py Github

copy

Full Screen

...376 LOG_JOB.info('data %s', data_dir.get_data_dir())377 LOG_JOB.info('logs %s', self.logdir)378 LOG_JOB.info('')379 @staticmethod380 def _log_variants(variants):381 lines = variants.to_str(summary=1, variants=1, use_utf8=False)382 for line in lines.splitlines():383 LOG_JOB.info(line)384 def _log_tmp_dir(self):385 LOG_JOB.info('Temporary dir: %s', self.tmpdir)386 LOG_JOB.info('')387 def _log_job_debug_info(self, variants):388 """389 Log relevant debug information to the job log.390 """391 self._log_cmdline()392 self._log_avocado_version()393 self._log_avocado_config()394 self._log_avocado_datadir()395 self._log_variants(variants)396 self._log_tmp_dir()397 self._log_job_id()398 def create_test_suite(self):399 """400 Creates the test suite for this Job401 This is a public Job API as part of the documented Job phases402 """403 try:404 self.test_suite = self._make_test_suite(self.references)405 self.result.tests_total = len(self.test_suite)406 except loader.LoaderError as details:407 stacktrace.log_exc_info(sys.exc_info(), LOG_UI.getChild("debug"))408 raise exceptions.OptionValidationError(details)409 if not self.test_suite:...

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