Best Python code snippet using localstack_python
cluster.py
Source:cluster.py
...62 # FIXME: this is not a good place to run install, and it only works because we're63 # assuming that there will only ever be one running Elasticsearch cluster64 install.install_elasticsearch(self.version)65 self._init_directories()66 cmd = self._create_run_command(additional_settings=self.command_settings)67 cmd = " ".join(cmd)68 user = constants.OS_USER_ELASTICSEARCH69 if is_root() and user:70 # run the elasticsearch process as a non-root user (when running in docker)71 cmd = f"su {user} -c '{cmd}'"72 env_vars = self._create_env_vars()73 LOG.info("starting elasticsearch: %s with env %s", cmd, env_vars)74 t = ShellCommandThread(75 cmd,76 env_vars=env_vars,77 strip_color=True,78 log_listener=self._log_listener,79 )80 t.start()81 return t82 def _log_listener(self, line, **_kwargs):83 LOG.info(line.rstrip())84 def _create_run_command(85 self, additional_settings: Optional[CommandSettings] = None86 ) -> List[str]:87 # delete Elasticsearch data that may be cached locally from a previous test run88 dirs = self.directories89 bin_path = os.path.join(dirs.base, "bin/elasticsearch")90 # build command settings for bin/elasticsearch91 settings = {92 "http.port": self.port,93 "http.publish_port": self.port,94 "transport.port": "0",95 "network.host": self.host,96 "http.compression": "false",97 "path.data": f'"{dirs.data}"',98 "path.repo": f'"{dirs.backup}"',...
_mutect2_variantcaller.py
Source:_mutect2_variantcaller.py
...5from .._pipeline_config import PipelineConfig6from ._variantcallers import _Callable, _VariantCaller7class Mutect2VariantCaller(_Callable, _VariantCaller):8 @classmethod9 def _create_run_command(10 cls, caller_config: PipelineConfig, library_paths: LibraryPaths11 ) -> list:12 bam_paths = cls._get_bam_paths(caller_config)13 germline_sample_name = cls._get_sample_name(bam_paths["germline_bam_path"])14 tumor_sample_name = cls._get_sample_name(bam_paths["tumor_bam_path"])15 output_name = cls._create_output_filename(16 caller_config, sample_name=tumor_sample_name17 )18 command = [19 library_paths.GATK4,20 "Mutect2",21 "-R",22 library_paths.REF_DIR,23 "-I",24 bam_paths["tumor_bam_path"],25 "-tumor",26 tumor_sample_name,27 "-I",28 bam_paths["germline_bam_path"],29 "-normal",30 germline_sample_name,31 "-O",32 output_name,33 ]34 return command35 @classmethod36 def _create_get_snp_variants_command(37 cls, caller_config: Dict, library_paths: LibraryPaths38 ) -> str:39 bam_paths = cls._get_bam_paths(caller_config)40 tumor_sample_name = cls._get_sample_name(bam_paths["tumor_bam_path"])41 input_name = cls._create_output_filename(42 caller_config, sample_name=tumor_sample_name43 )44 output_name = cls._create_output_filename(45 caller_config, sample_name=f"SNP_{tumor_sample_name}"46 )47 command = [48 library_paths.GATK4,49 "SelectVariants",50 "-R",51 library_paths.REF_DIR,52 "-V",53 input_name,54 "--select-type-to-include",55 "SNP",56 "-O",57 output_name,58 ]59 return command60 @classmethod61 def _create_get_indel_variants_command(62 cls, caller_config: Dict, library_paths: LibraryPaths63 ) -> str:64 bam_paths = cls._get_bam_paths(caller_config)65 tumor_sample_name = cls._get_sample_name(bam_paths["tumor_bam_path"])66 input_name = cls._create_output_filename(67 caller_config, sample_name=tumor_sample_name68 )69 output_name = cls._create_output_filename(70 caller_config, sample_name=f"SNP_{tumor_sample_name}"71 )72 command = [73 library_paths.GATK4,74 "SeleckVariants",75 "-R",76 library_paths.REF_DIR,77 "-V",78 input_name,79 "--select-type-to-include",80 "INDEL",81 "-O",82 output_name,83 ]84 return command85 @classmethod86 def _create_get_other_variants_command(87 cls, caller_config: Dict, library_paths: LibraryPaths88 ) -> str:89 bam_paths = cls._get_bam_paths(caller_config)90 tumor_sample_name = cls._get_sample_name(bam_paths["tumor_bam_path"])91 input_name = cls._create_output_filename(92 caller_config, sample_name=tumor_sample_name93 )94 output_name = cls._create_output_filename(95 caller_config, sample_name=f"SNP_{tumor_sample_name}"96 )97 command = [98 library_paths.GATK4,99 "SeleckVariants",100 "-R",101 library_paths.REF_DIR,102 "-V",103 input_name,104 "--select-type-to-exclude",105 "SNP",106 "--select-type-to-exclude",107 "INDEL",108 "-O",109 output_name,110 ]111 return command112 @classmethod113 def call_variants(cls, caller_config: Dict):114 library_paths = LibraryPaths()115 mutect_command = cls._create_run_command(116 caller_config=caller_config, library_paths=library_paths117 )118 get_snp_command = cls._create_get_snp_variants_command(119 caller_config=caller_config, library_paths=library_paths120 )121 get_indel_command = cls._create_get_indel_variants_command(122 caller_config=caller_config, library_paths=library_paths123 )124 get_other_variants_command = cls._create_get_other_variants_command(125 caller_config=caller_config, library_paths=library_paths126 )127 run(mutect_command, cwd=caller_config.VCF_OUTPUT_DIR)128 run(get_snp_command, cwd=caller_config.VCF_OUTPUT_DIR)129 run(get_indel_command, cwd=caller_config.VCF_OUTPUT_DIR)...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!