Retrieve configured structural variation caller, handling multiple.
770607
def _handle_multiple_svcallers(data, stage):
    
    svs = get_svcallers(data)
    # special cases -- prioritization
    if stage == "ensemble" and dd.get_svprioritize(data):
        svs.append("prioritize")
    out = []
    for svcaller in svs:
        if svcaller in _get_callers([data], stage):
            base = copy.deepcopy(data)
            # clean SV callers present in multiple rounds and not this caller
            final_svs = []
            for sv in data.get("sv", []):
                if (stage == "ensemble" or sv["variantcaller"] == svcaller or sv["variantcaller"] not in svs
                      or svcaller not in _get_callers([data], stage, special_cases=True)):
                    final_svs.append(sv)
            base["sv"] = final_svs
            base["config"]["algorithm"]["svcaller"] = svcaller
            base["config"]["algorithm"]["svcaller_orig"] = svs
            out.append(base)
    return out
358617
def _define_variant(self):
        """"""
        space = None
        variants = {
            # to be expanded once addtional spaces are supported
            'space1': ['fsaverage5', 'MNI152NLin2009cAsym'],
            'space2': ['fsaverage6', 'MNI152NLin2009cAsym'],
        }
        for sp, targets in variants.items():
            if all(target in targets for target in
                    [self.inputs.surface_target, self.inputs.volume_target]):
                space = sp
        if space is None:
            raise NotImplementedError

        variant_key = os.path.abspath('dtseries_variant.json')
        with open(variant_key, 'w') as fp:
            json.dump({space: variants[space]}, fp)
        return variant_key, space
1340237
def read_structure(self, cls=Structure):
        """"""
        if self.ngroups != 1:
            raise NotImplementedError("In file %s: ngroups != 1" % self.path)

        return structure_from_ncdata(self, cls=cls)
62558
def runGetVariant(self, id_):
        
        compoundId = datamodel.VariantCompoundId.parse(id_)
        dataset = self.getDataRepository().getDataset(compoundId.dataset_id)
        variantSet = dataset.getVariantSet(compoundId.variant_set_id)
        gaVariant = variantSet.getVariant(compoundId)
        # TODO variant is a special case here, as it's returning a
        # protocol element rather than a datamodel object. We should
        # fix this for consistency.
        jsonString = protocol.toJson(gaVariant)
        return jsonString
65093
def iter_variants_by_names(self, names):
        
        for name in names:
            for result in self.get_variant_by_name(name):
                yield result
4284
def _get_caller_supplement(caller, data):
    
    if caller == "mutect":
        icaller = tz.get_in(["config", "algorithm", "indelcaller"], data)
        if icaller:
            caller = "%s/%s" % (caller, icaller)
    return caller
267454
def _get_variant_silent(parser, variant):
    """"""
    prev_log = config.LOG_NOT_FOUND
    config.LOG_NOT_FOUND = False
    results = parser.get_variant_genotypes(variant)
    config.LOG_NOT_FOUND = prev_log
    return results
246676
def _clean_flat_variantcaller(data):
    
    vc = dd.get_variantcaller(data)
    if isinstance(vc, (list, tuple)) and all([x.count(":") == 1 for x in vc]):
        out = {}
        for v in vc:
            k, v = v.split(":")
            if k in out:
                out[k].append(v)
            else:
                out[k] = [v]
        data = dd.set_variantcaller(data, out)
    return data
128022
def get_variant_id(variant_dict=None, variant_line=None):
    
    
    if variant_dict:
        chrom = variant_dict['CHROM']
        position = variant_dict['POS']
        ref = variant_dict['REF']
        alt = variant_dict['ALT']
    elif variant_line:
        splitted_line = variant_line.rstrip().split('\t')
        chrom = splitted_line[0]
        position = splitted_line[1]
        ref = splitted_line[3]
        alt = splitted_line[4]
    else:
        raise Exception("Have to provide variant dict or variant line")
    
    return '_'.join([
        chrom,
        position,
        ref,
        alt,
    ])
790581
def _get_by_trace(self, structure, trace):
        
        for i in trace:
            structure = structure[i]

        return structure
164584
def get_variant_by_name(self, name):
        
        results = []

        try:
            for info, dosage in self._bgen.get_variant(name):
                results.append(Genotypes(
                    Variant(
                        info.name,
                        CHROM_STR_ENCODE.get(info.chrom, info.chrom),
                        info.pos,
                        [info.a1, info.a2],
                    ),
                    dosage,
                    reference=info.a1,
                    coded=info.a2,
                    multiallelic=False,
                ))

        except ValueError:
            logging.variant_name_not_found(name)

        return results
1139447
def extract_call(self, call, from_name, settings):
        '''
        
        '''

        call = defaultdict(lambda: None, call[0])

        try:
            call['section'] = settings['section']
        except KeyError:
            call['section'] = ''

        project = call['project']

        # If there is more than one call in a single file
        if type(project) == list:
            calls = []

            for name in project:
                calls.append(self.create_call(name, call, from_name))

            return calls
        else:
            return [self.create_call(project, call, from_name)]
54997
def get_variation_from_key(self, experiment_key, variation_key):
    

    variation_map = self.variation_key_map.get(experiment_key)

    if variation_map:
      variation = variation_map.get(variation_key)
      if variation:
        return variation
      else:
        self.logger.error('Variation key "%s" is not in datafile.' % variation_key)
        self.error_handler.handle_error(exceptions.InvalidVariationException(enums.Errors.INVALID_VARIATION_ERROR))
        return None

    self.logger.error('Experiment key "%s" is not in datafile.' % experiment_key)
    self.error_handler.handle_error(exceptions.InvalidExperimentException(enums.Errors.INVALID_EXPERIMENT_KEY_ERROR))
    return None
1323521
private Map<String, VariantSet> getVariants(ResourceBrowser rsBrowser, String rootDir, String defaultSkinName,
			String defaultLocaleName, boolean mappingSkinLocale) {
		Set<String> paths = rsBrowser.getResourceNames(rootDir);
		Set<String> skinNames = new HashSet<>();
		Set<String> localeVariants = new HashSet<>();
		for (Iterator<String> itPath = paths.iterator(); itPath.hasNext();) {
			String path = rootDir + itPath.next();
			if (rsBrowser.isDirectory(path)) {
				String dirName = PathNormalizer.getPathName(path);
				if (mappingSkinLocale) {
					skinNames.add(dirName);
					// check if there are locale variants for this skin,
					// and update the localeVariants if needed
					updateLocaleVariants(rsBrowser, path, localeVariants);
				} else {
					if (LocaleUtils.LOCALE_SUFFIXES.contains(dirName)) {
						localeVariants.add(dirName);
						// check if there are skin variants for this locales,
						// and update the skinVariants if needed
						updateSkinVariants(rsBrowser, path, skinNames);
					}
				}
			}
		}

		// Initialize the variant mapping for the skin root directory
		return getVariants(defaultSkinName, skinNames, defaultLocaleName, localeVariants);
	}
533356
def get_variants(self, arch=None, types=None, recursive=False):
        
        types = types or []
        result = []

        if "self" in types:
            result.append(self)

        for variant in six.itervalues(self.variants):
            if types and variant.type not in types:
                continue
            if arch and arch not in variant.arches.union(["src"]):
                continue
            result.append(variant)
            if recursive:
                result.extend(variant.get_variants(types=[i for i in types if i != "self"], recursive=True))

        result.sort(key=lambda x: x.uid)
        return result
660918
private Variant getGenomicVariant(Variant variant) {
        if (variant.getAlternate().equals(".")) {  // reference positions are not variants
            return null;
        } else {
            String ref;
            // large deletion
            if (variant.getAlternate().equals("<DEL>")) {
                // .get("_") because studyId and fileId are empty strings when VariantSource is initialized at readInputFile
                int end = Integer.valueOf(variant.getSourceEntries().get("_").getAttributes().get("END"));
                ref = StringUtils.repeat("N", end - variant.getStart());
                return new Variant(variant.getChromosome(), variant.getStart(),
                        ref, variant.getAlternate().equals("") ? "-" : variant.getAlternate());
                // TODO: structural variants are not yet properly handled. Implement and remove this patch asap
            } else if (variant.getAlternate().startsWith("<")
                    || (variant.getAlternate().length() > 1 && variant.getReference().length() > 1)) {
                return null;
            } else {
                ref = variant.getReference().equals("") ? "-" : variant.getReference();
                return new Variant(variant.getChromosome(), variant.getStart(),
                        ref, variant.getAlternate().equals("") ? "-" : variant.getAlternate());
            }
        }
    }
281637
def iter_variants(self):
        """"""
        if not self.has_index:
            raise NotImplementedError("Not implemented when IMPUTE2 file is "
                                      "not indexed (see genipe)")

        for name, row in self._impute2_index.iterrows():
            # Seeking to the right place in the file
            f = self._impute2_file
            f.seek(int(row.seek))
            chrom, name, pos, a1, a2 = f.read(1024).split(" ")[:5]
            pos = int(pos)

            yield Variant(name, CHROM_STR_ENCODE.get(chrom, chrom), pos,
                          [a1, a2])