Set data installation targets, handling defaults.

    Sets variation, rnaseq, smallrna as default targets if we're not
    isolated to a single method.

    Provides back compatibility for toolplus specifications.
967597
def _datatarget_defaults(args, default_args):
    
    default_data = default_args.get("datatarget", [])
    # back-compatible toolplus specifications
    for x in default_args.get("toolplus", []):
        val = None
        if x == "data":
            val = "gemini"
        elif x in ["cadd", "dbnsfp", "dbscsnv", "kraken", "gnomad"]:
            val = x
        if val and val not in default_data:
            default_data.append(val)
    new_val = getattr(args, "datatarget")
    for x in default_data:
        if x not in new_val:
            new_val.append(x)
    has_std_target = False
    std_targets = ["variation", "rnaseq", "smallrna"]
    for target in std_targets:
        if target in new_val:
            has_std_target = True
            break
    if not has_std_target:
        new_val = new_val + std_targets
    setattr(args, "datatarget", new_val)
    return args
483027
def set_standard_vars(cls, executor, context, variant, build_type,
                          install, build_path, install_path=None):
        
        vars = cls.get_standard_vars(context=context,
                                     variant=variant,
                                     build_type=build_type,
                                     install=install,
                                     build_path=build_path,
                                     install_path=install_path)

        for var, value in vars.iteritems():
            executor.env[var] = value
771211
public Frame applyTargetEncoding(Frame data,
                                     String targetColumnName,
                                     Map<String, Frame> targetEncodingMap,
                                     byte dataLeakageHandlingStrategy,
                                     String foldColumn,
                                     boolean withBlendedAvg,
                                     boolean imputeNAs,
                                     long seed) {
        double defaultNoiseLevel = 0.01;
        int targetIndex = data.find(targetColumnName);
        Vec targetVec = data.vec(targetIndex);
        double   noiseLevel = targetVec.isNumeric()  ?   defaultNoiseLevel * (targetVec.max() - targetVec.min()) : defaultNoiseLevel;
        return applyTargetEncoding(data, targetColumnName, targetEncodingMap, dataLeakageHandlingStrategy, foldColumn, withBlendedAvg, noiseLevel, true, seed);
    }
38730
def _add_algorithm_defaults(algorithm, analysis, is_cwl):
    
    if not algorithm:
        algorithm = {}
    defaults = {"archive": None,
                "tools_off": [],
                "tools_on": [],
                "qc": [],
                "trim_reads": False,
                "adapters": [],
                "effects": "snpeff",
                "quality_format": "standard",
                "expression_caller": ["salmon"] if analysis.lower().find("rna-seq") >= 0 else None,
                "align_split_size": None,
                "bam_clean": False,
                "nomap_split_size": 250,
                "nomap_split_targets": _get_nomap_split_targets(analysis, is_cwl),
                "mark_duplicates": False if not algorithm.get("aligner") else True,
                "coverage_interval": None,
                "min_allele_fraction": 10.0,
                "recalibrate": False,
                "realign": False,
                "ensemble": None,
                "exclude_regions": [],
                "variant_regions": None,
                "svcaller": [],
                "svvalidate": None,
                "svprioritize": None,
                "validate": None,
                "validate_regions": None,
                "vcfanno": []}
    convert_to_list = set(["tools_off", "tools_on", "hetcaller", "variantcaller", "svcaller", "qc", "disambiguate",
                           "vcfanno", "adapters", "custom_trim", "exclude_regions"])
    convert_to_single = set(["hlacaller", "indelcaller", "validate_method"])
    for k, v in defaults.items():
        if k not in algorithm:
            algorithm[k] = v
    for k, v in algorithm.items():
        if k in convert_to_list:
            if v and not isinstance(v, (list, tuple)) and not isinstance(v, dict):
                algorithm[k] = [v]
            # ensure dictionary specified inputs get converted into individual lists
            elif v and not isinstance(v, (list, tuple)) and isinstance(v, dict):
                new = {}
                for innerk, innerv in v.items():
                    if innerv and not isinstance(innerv, (list, tuple)) and not isinstance(innerv, dict):
                        innerv = [innerv]
                    new[innerk] = innerv
                algorithm[k] = new
            elif v is None:
                algorithm[k] = []
        elif k in convert_to_single:
            if v and not isinstance(v, six.string_types):
                if isinstance(v, (list, tuple)) and len(v) == 1:
                    algorithm[k] = v[0]
                else:
                    raise ValueError("Unexpected input in sample YAML; need a single item for %s: %s" % (k, v))
    return algorithm
806385
def _set_program_defaults(cls, programs):
        """"""
        for program in programs:
            val = getattr(cls, program.__name__) \
                and extern.does_external_program_run(program.__name__,
                                                     Settings.verbose)
            setattr(cls, program.__name__, val)
1301412
def set_target(self, target):
        '''
        '''
        self.targetname = target
        m = __import__('buildozer.targets.{0}'.format(target),
                       fromlist=['buildozer'])
        self.target = m.get_target(self)
        self.check_build_layout()
        self.check_configuration_tokens()
1127677
def _setToDefaults(self):
        

        # Create an empty object, where every item is set to it's default value
        try:
            tmpObj = cfgpars.ConfigObjPars(self._taskParsObj.filename,
                                           associatedPkg=\
                                           self._taskParsObj.getAssocPkg(),
                                           setAllToDefaults=self.taskName,
                                           strict=False)
        except Exception as ex:
            msg = "Error Determining Defaults"
            showerror(message=msg+'\n\n'+ex.message, title="Error Determining Defaults")
            return

        # Set the GUI entries to these values (let the user Save after)
        tmpObj.filename = self._taskParsObj.filename = '' # name it later
        newParList = tmpObj.getParList()
        try:
            self.setAllEntriesFromParList(newParList) # needn't updateModel yet
            self.checkAllTriggers('defaults')
            self.updateTitle('')
            self.showStatus("Loaded default "+self.taskName+" values via: "+ \
                 os.path.basename(tmpObj._original_configspec), keep=1)
        except editpar.UnfoundParamError as pe:
            showerror(message=str(pe), title="Error Setting to Default Values")
602481
def _pack_target_set_default_reset_type(self):
        """"""
        if 0 in self.cores:
            self.cores[0].default_reset_type = self._pack_device.default_reset_type
1168624
def configure_resultproducer(self):
        
        rproducer = javabridge.make_instance("weka/experiment/RandomSplitResultProducer", "()V")
        javabridge.call(rproducer, "setRandomizeData", "(Z)V", not self.preserve_order)
        javabridge.call(rproducer, "setTrainPercent", "(D)V", self.percentage)
        speval, classifier = self.configure_splitevaluator()
        javabridge.call(rproducer, "setSplitEvaluator", "(Lweka/experiment/SplitEvaluator;)V", speval)
        prop_path = javabridge.get_env().make_object_array(
            2, javabridge.get_env().find_class("weka/experiment/PropertyNode"))
        cls = javabridge.get_env().find_class("weka/experiment/RandomSplitResultProducer")
        desc = javabridge.make_instance(
            "java/beans/PropertyDescriptor", "(Ljava/lang/String;Ljava/lang/Class;)V", "splitEvaluator", cls)
        node = javabridge.make_instance(
            "weka/experiment/PropertyNode", "(Ljava/lang/Object;Ljava/beans/PropertyDescriptor;Ljava/lang/Class;)V",
            speval, desc, cls)
        javabridge.get_env().set_object_array_element(prop_path, 0, node)
        cls = javabridge.get_env().get_object_class(speval)
        desc = javabridge.make_instance(
            "java/beans/PropertyDescriptor", "(Ljava/lang/String;Ljava/lang/Class;)V", "classifier", cls)
        node = javabridge.make_instance(
            "weka/experiment/PropertyNode", "(Ljava/lang/Object;Ljava/beans/PropertyDescriptor;Ljava/lang/Class;)V",
            javabridge.call(speval, "getClass", "()Ljava/lang/Class;"), desc, cls)
        javabridge.get_env().set_object_array_element(prop_path, 1, node)

        return rproducer, prop_path
764580
def setTargets(self, targets):
        
        if not self.verifyArguments(targets) and not self.patterned:
            raise NetworkError('setTargets() requires [[...],[...],...] or [{"layerName": [...]}, ...].', targets)
        self.targets = targets
767566
def set_default(self, name, value):
        
        if self.vars is None:
            self.vars = {}
        if name not in self.vars:
            self.vars[name] = value
96610
def _set_defaults(self, namespace, optional_cfg_files):
        
        # Add current configuration directory
        namespace["config_dir"] = self.config_dir

        # Load defaults
        for idx, cfg_file in enumerate([self.CONFIG_INI] + optional_cfg_files):
            if any(i in cfg_file for i in set('/' + os.sep)):
                continue # skip any non-plain filenames

            try:
                defaults = pymagic.resource_string("pyrocore", "data/config/" + cfg_file) #@UndefinedVariable
            except IOError as exc:
                if idx and exc.errno == errno.ENOENT:
                    continue
                raise

            ini_file = ConfigParser.SafeConfigParser()
            ini_file.optionxform = str # case-sensitive option names
            ini_file.readfp(StringIO.StringIO(defaults), "<defaults>")
            self._set_from_ini(namespace, ini_file)
576175
def gatk_rnaseq_calling(data):
    
    from bcbio.bam import callable
    data = utils.deepish_copy(data)
    tools_on = dd.get_tools_on(data)
    if not tools_on:
        tools_on = []
    tools_on.append("gvcf")
    data = dd.set_tools_on(data, tools_on)
    data = dd.set_jointcaller(data, ["%s-joint" % v for v in dd.get_variantcaller(data)])
    out_dir = utils.safe_makedir(os.path.join(dd.get_work_dir(data),
                                              "variation", "rnaseq", "gatk-haplotype"))
    data = _setup_variant_regions(data, out_dir)
    out_file = os.path.join(out_dir, "%s-gatk-haplotype.vcf.gz" % dd.get_sample_name(data))
    if not utils.file_exists(out_file):
        region_files = []
        regions = []
        for cur_region in callable.get_split_regions(dd.get_variant_regions(data), data):
            str_region = "_".join([str(x) for x in cur_region])
            region_file = os.path.join(utils.safe_makedir(os.path.join(dd.get_work_dir(data),
                                                                    "variation", "rnaseq", "gatk-haplotype",
                                                                    "regions")),
                                    "%s-%s-gatk-haplotype.vcf.gz" % (dd.get_sample_name(data), str_region))
            region_file = gatk.haplotype_caller([dd.get_split_bam(data)], [data], dd.get_ref_file(data), {},
                                                region=cur_region, out_file=region_file)
            region_files.append(region_file)
            regions.append(cur_region)
        out_file = vcfutils.concat_variant_files(region_files, out_file, regions,
                                                 dd.get_ref_file(data), data["config"])
    return dd.set_vrn_file(data, out_file)
591397
static void putIfNotSet(Map<String, String> target, Map<String, String> defaults) {
    for (final String key : defaults.keySet()) {
      if (!target.containsKey(key)) {
        target.put(key, defaults.get(key));
      }
    }
  }
44281
protected function setDefaults()
	{
		$this->binary = function()
		{
			if (is_dir(__DIR__.'/../../../vendor'))
			{
				$bin = __DIR__.'/../../../vendor/bin/phantomjs';
			}
			else
			{
				$bin = __DIR__.'/../../../../bin/phantomjs';
			}

			if (!is_executable($bin))
			{
				throw new RuntimeException
				(
					'The phantomjs command ("'.$bin.'") '.
					'was not found or is not executable by the current user! '
				);
			}

			return realpath($bin);
		};

		$this->runner = __DIR__.'/Phantom.js';

		$this->process = $this->protect(function($cmd)
		{
			return new Process($cmd);
		});

		$this->tempFile = $this->protect(function()
		{
			return new TempFile('GearsPdf', 'pdf');
		});

		$this->printFramework = function()
		{
			return
			'
				<style>'.file_get_contents(__DIR__.'/Print.css').'</style>
				<script>'.file_get_contents(__DIR__.'/isVisible.js').'</script>
				<script>'.file_get_contents(__DIR__.'/jQuery.js').'</script>
				<script>'.file_get_contents(__DIR__.'/Print.js').'</script>
			';
		};
	}
427457
def add_custom_options(parser):
    
    parser.add_argument("--report-title", type=str, metavar="TITLE",
                        default="Genetic Data Clean Up",
                        help="The report title. [default: %(default)s]")
    parser.add_argument("--report-author", type=str, metavar="AUTHOR",
                        default="pyGenClean",
                        help="The current project number. "
                             "[default: %(default)s]")
    parser.add_argument("--report-number", type=str, metavar="NUMBER",
                        default="Simple Project",
                        help="The current project author. "
                             "[default: %(default)s]")
    parser.add_argument("--report-background", type=str, metavar="BACKGROUND",
                        default="The aim of this project is to perform data "
                                "QC prior to genetic analysis.",
                        help="Text of file containing the background section "
                             "of the report.")
1012890
def save_install_defaults(args):
    
    install_config = _get_install_config()
    if install_config is None:
        return
    if utils.file_exists(install_config):
        with open(install_config) as in_handle:
            cur_config = yaml.safe_load(in_handle)
    else:
        cur_config = {}
    if args.tooldir:
        cur_config["tooldir"] = args.tooldir
    cur_config["isolate"] = args.isolate
    for attr in ["genomes", "aligners", "datatarget"]:
        if not cur_config.get(attr):
            cur_config[attr] = []
        for x in getattr(args, attr):
            if x not in cur_config[attr]:
                cur_config[attr].append(x)
    # toolplus -- save non-filename inputs
    attr = "toolplus"
    if not cur_config.get(attr):
        cur_config[attr] = []
    for x in getattr(args, attr):
        if not x.fname:
            if x.name not in cur_config[attr]:
                cur_config[attr].append(x.name)
    with open(install_config, "w") as out_handle:
        yaml.safe_dump(cur_config, out_handle, default_flow_style=False, allow_unicode=False)