Add the neccesary sv coordinates for a variant
        
        Args:
            variant (puzzle.models.variant)
2288
def _add_sv_coordinates(self, variant):
        
        variant.stop_chrom = variant.CHROM
        variant.start = int(variant.POS)
        
        # If we have a translocation:
        if ':' in variant.ALT:
            other_coordinates = variant.ALT.strip('ACGTN[]').split(':')
            variant.stop_chrom = other_coordinates[0].lstrip('chrCHR')
            other_position = other_coordinates[1]
            # variant.stop = other_position

            #Set 'infinity' to length if translocation
            variant.sv_len = float('inf')
            variant.sv_type = 'BND'
        else:
            variant.sv_len = variant.stop - variant.start

        variant['cytoband_start'] = get_cytoband_coord(
                                        chrom=variant.CHROM,
                                        pos=variant.start
                                        )

        variant['cytoband_stop'] = get_cytoband_coord(
                                    chrom=variant.stop_chrom,
                                    pos=variant.stop
                                    )
43030
def _add_thousand_g(self, variant_obj, info_dict):
        
        thousand_g = info_dict.get('1000GAF')
        if thousand_g:
            logger.debug("Updating thousand_g to: {0}".format(
                thousand_g))
            variant_obj.thousand_g = float(thousand_g)
            variant_obj.add_frequency('1000GAF', variant_obj.get('thousand_g'))
1242921
public SimpleFormatter getByVariant(CharSequence variant) {
        assert isValid();
        int idx = StandardPlural.indexOrOtherIndexFromString(variant);
        SimpleFormatter template = templates[idx];
        return (template == null && idx != StandardPlural.OTHER_INDEX) ?
                templates[StandardPlural.OTHER_INDEX] : template;
    }
582697
def update(ctx, variant_file, sv_variants, family_file, family_type, skip_case_id, gq_treshold, 
           case_id, ensure_index, max_window):
    
    if not (family_file or case_id):
        LOG.warning("Please provide a family file or a case id")
        ctx.abort()
    
    if not (variant_file or sv_variants):
        LOG.warning("Please provide a VCF file")
        ctx.abort()
    

    variant_path = None
    if variant_file:
        variant_path = os.path.abspath(variant_file)
        
    variant_sv_path = None
    if sv_variants:
        variant_sv_path = os.path.abspath(sv_variants)
    
    adapter = ctx.obj['adapter']

    start_inserting = datetime.now()
    
    
    try:
        nr_inserted = update_database(
            adapter=adapter,
            variant_file=variant_path,
            sv_file=variant_sv_path,
            family_file=family_file,
            family_type=family_type,
            skip_case_id=skip_case_id,
            case_id=case_id,
            gq_treshold=gq_treshold,
            max_window=max_window,
        )
    except (SyntaxError, CaseError, IOError, VcfError) as error:
        LOG.warning(error)
        ctx.abort()

    LOG.info("Nr variants inserted: %s", nr_inserted)
    LOG.info("Time to insert variants: {0}".format(
                datetime.now() - start_inserting))
    
    if ensure_index:
        adapter.ensure_indexes()
    else:
        adapter.check_indexes()
321553
def _variant_sv(checkpoints):
    
    if not checkpoints.get("sv"):
        return [], []
    sv = [s("detect_sv", "batch-single",
            [["sv_batch_rec"]],
            [cwlout("sv_rec", "record",
                    fields=[cwlout(["sv", "variantcaller"], ["string", "null"]),
                            cwlout(["sv", "vrn_file"], ["File", "null"], [".tbi"]),
                            cwlout(["sv", "supplemental"], {"type": "array", "items": ["File"]}),
                            cwlout(["svvalidate", "summary"], ["File", "null"]),
                            cwlout("inherit", exclude=[["align_bam"], ["work_bam_plus"],
                                                       ["reference", "snpeff"]])])],
            "bcbio-vc", ["bedtools", "cnvkit", "delly", "duphold", "extract-sv-reads", "gsort",
                         "lumpy-sv;env=python2", "manta;env=python2", "break-point-inspector", "mosdepth", "samtools",
                         "smoove;env=python2", "pysam>=0.13.0",
                         "seq2c", "simple_sv_annotation;env=python2", "survivor", "svtools;env=python2",
                         "svtyper;env=python2",
                         "r=3.5.1", "r-base", "xorg-libxt", "vawk;env=python2"],
            disk={"files": 2.0})]
    sv_batch_inputs = [["analysis"], ["genome_build"],
                       ["work_bam_plus", "disc"], ["work_bam_plus", "sr"],
                       ["config", "algorithm", "background", "cnv_reference"],
                       ["config", "algorithm", "tools_on"],
                       ["config", "algorithm", "tools_off"],
                       ["config", "algorithm", "svprioritize"],
                       ["config", "algorithm", "svvalidate"], ["regions", "sample_callable"],
                       ["genome_resources", "variation", "gc_profile"],
                       ["genome_resources", "variation", "germline_het_pon"],
                       ["genome_resources", "aliases", "snpeff"], ["reference", "snpeff", "genome_build"],
                       ["sv_coverage_rec"]]
    if checkpoints.get("vc"):
        sv_batch_inputs.append(["variants", "samples"])
    steps = [s("calculate_sv_bins", "multi-combined",
               [["align_bam"], ["reference", "fasta", "base"],
                ["metadata", "batch"], ["metadata", "phenotype"],
                ["config", "algorithm", "background", "cnv_reference"],
                ["config", "algorithm", "callable_regions"],
                ["config", "algorithm", "coverage_interval"],
                ["config", "algorithm", "exclude_regions"],
                ["config", "algorithm", "sv_regions"],
                ["config", "algorithm", "variant_regions"],
                ["config", "algorithm", "variant_regions_merged"],
                ["config", "algorithm", "seq2c_bed_ready"],
                ["config", "algorithm", "svcaller"],
                ["depth", "variant_regions", "regions"],
                ["genome_resources", "variation", "lcr"], ["genome_resources", "variation", "polyx"],
                ["genome_resources", "variation", "encode_blacklist"],
                ["genome_resources", "rnaseq", "gene_bed"]],
               [cwlout("sv_bin_rec", "record",
                       fields=[cwlout(["regions", "bins", "target"], ["File", "null"]),
                               cwlout(["regions", "bins", "antitarget"], ["File", "null"]),
                               cwlout(["regions", "bins", "gcannotated"], ["File", "null"]),
                               cwlout(["regions", "bins", "group"], ["string", "null"]),
                               cwlout("inherit")])],
               "bcbio-vc", ["bedtools", "cnvkit"],
               disk={"files": 1.5}, cores=1),
             s("calculate_sv_coverage", "multi-parallel",
               [["sv_bin_rec"]],
               [cwlout("sv_rawcoverage_rec", "record",
                       fields=[cwlout(["depth", "bins", "target"], ["File", "null"]),
                               cwlout(["depth", "bins", "antitarget"], ["File", "null"]),
                               cwlout(["depth", "bins", "seq2c"], ["File", "null"]),
                               cwlout("inherit")])],
               "bcbio-vc", ["mosdepth", "cnvkit", "seq2c"],
               disk={"files": 1.5}),
             s("normalize_sv_coverage", "multi-combined",
               [["sv_rawcoverage_rec"]],
               [cwlout("sv_coverage_rec", "record",
                       fields=[cwlout(["depth", "bins", "normalized"], ["File", "null"]),
                               cwlout(["depth", "bins", "background"], ["File", "null"]),
                               cwlout("inherit")])],
               "bcbio-vc", ["cnvkit"],
               disk={"files": 1.5}),
             s("batch_for_sv", "multi-batch", sv_batch_inputs,
               [cwlout("sv_batch_rec", "record")],
               "bcbio-vc",
               unlist=[["config", "algorithm", "svcaller"]]),
             w("svcall", "multi-parallel", sv, []),
             s("summarize_sv", "multi-combined",
               [["sv_rec"]],
               [cwlout(["sv", "calls"], {"type": "array", "items": ["File", "null"]}),
                cwlout(["sv", "supplemental"], {"type": "array", "items": ["File"]}),
                cwlout(["sv", "prioritize", "tsv"], {"type": "array", "items": ["File", "null"]}),
                cwlout(["sv", "prioritize", "raw"], {"type": "array", "items": ["File", "null"]}),
                cwlout(["svvalidate", "grading_summary"], ["File", "null"]),
                cwlout(["svvalidate", "grading_plots"], {"type": "array", "items": ["File", "null"]})],
               "bcbio-vc", ["bcbio-prioritize"], disk={"files": 1.0}, cores=1)]
    final_outputs = [["sv", "calls"], ["svvalidate", "grading_summary"], ["sv", "prioritize", "tsv"],
                     ["sv", "prioritize", "raw"], ["sv", "supplemental"]]
    return steps, final_outputs
858605
def _add_impact_severity(self, variant_obj, gemini_variant):
        
        gemini_impact = gemini_variant['impact_severity']
        if gemini_impact == 'MED':
            gemini_impact = 'MEDIUM'
        variant_obj.impact_severity = gemini_impact
601127
def register_variant(cls):
        

        if hasattr(cls, "val"):
            cls.registered_attributes[cls.val] = cls
        else:
            cls.registered_attributes[cls.type.default] = cls
994492
def _maybe_normalize(self, var):
        
        if self.normalize:
            try:
                return self._norm.normalize(var)
            except HGVSUnsupportedOperationError as e:
                _logger.warning(str(e) + "; returning unnormalized variant")
                # fall through to return unnormalized variant
        return var
233591
async def _load_variant(
            self, reader, elem_type, params=None, elem=None, wrapped=None
    ):
        
        is_wrapped = (
            (isinstance(elem, VariantType) or elem_type.WRAPS_VALUE)
            if wrapped is None
            else wrapped
        )
        if is_wrapped:
            elem = elem_type() if elem is None else elem

        tag = await load_uint(reader, 1)
        for field in elem_type.f_specs():
            ftype = field[1]
            if ftype.VARIANT_CODE == tag:
                fvalue = await self.load_field(
                    reader, ftype, field[2:], elem if not is_wrapped else None
                )
                if is_wrapped:
                    elem.set_variant(field[0], fvalue)
                return elem if is_wrapped else fvalue
        raise ValueError("Unknown tag: %s" % tag)
316444
async def variant(self, elem=None, elem_type=None, params=None, obj=None):
        
        elem_type = elem_type if elem_type else elem.__class__

        if hasattr(elem_type, 'kv_serialize'):
            elem = elem_type() if elem is None else elem
            return await elem.kv_serialize(self, elem=elem, elem_type=elem_type, params=params, obj=obj)

        if self.writing:
            return await self.dump_variant(elem=elem,
                                           elem_type=elem_type if elem_type else elem.__class__, params=params, obj=obj)
        else:
            return await self.load_variant(elem_type=elem_type if elem_type else elem.__class__,
                                           params=params, elem=elem, obj=obj)
178136
def addVariantFeature(self,variantFeature):
        '''
        '''
        if isinstance(variantFeature, Feature):
            self.features.append(variantFeature)
        else:
            raise(TypeError,
                  'variantFeature Type should be Feature, not %s' % type(
                    variantFeature)
                  )
270084
def variants(ctx, variant_id, chromosome, end_chromosome, start, end, variant_type,
             sv_type):
    """"""
    if sv_type:
        variant_type = 'sv'

    adapter = ctx.obj['adapter']

    if (start or end):
        if not (chromosome and start and end):
            LOG.warning("Regions must be specified with chromosome, start and end")
            return

    if variant_id:
        variant = adapter.get_variant({'_id':variant_id})
        if variant:
            click.echo(variant)
        else:
            LOG.info("Variant {0} does not exist in database".format(variant_id))
        return

    if variant_type == 'snv':
        result = adapter.get_variants(
            chromosome=chromosome,
            start=start,
            end=end
        )
    else:
        LOG.info("Search for svs")
        result = adapter.get_sv_variants(
            chromosome=chromosome,
            end_chromosome=end_chromosome,
            sv_type=sv_type,
            pos=start,
            end=end
        )

    i = 0
    for variant in result:
        i += 1
        pp(variant)

    LOG.info("Number of variants found in database: %s", i)
1221530
public void run(List<Variant> variantList) {
        for (int i = 0; i < variantList.size(); i++) {
            Map<String, AdditionalAttribute> customAnnotation = getCustomAnnotation(variantList.get(i));
            // Update only if there are annotations for this variant. customAnnotation may be empty if the variant
            // exists in the vcf but the info field does not contain any of the required attributes
            if (customAnnotation != null && customAnnotation.get(fileId).getAttribute().size() > 0) {
                VariantAnnotation variantAnnotation = variantList.get(i).getAnnotation();
                if (variantAnnotation != null) {
                    Map<String, AdditionalAttribute> additionalAttributes = variantAnnotation.getAdditionalAttributes();
                    if (additionalAttributes == null) {
                        // variantList and variantAnnotationList must contain variants in the SAME order: variantAnnotation
                        // at position i must correspond to variant i
                        variantAnnotation.setAdditionalAttributes(customAnnotation);
                    } else {
                        additionalAttributes.putAll(customAnnotation);
                        // variantList and variantAnnotationList must contain variants in the SAME order: variantAnnotation
                        // at position i must correspond to variant i
//                        variantAnnotation.setAdditionalAttributes(additionalAttributes);
                    }
                }
            }
        }
    }
432456
def add_gene(self, gene):
        
        logger.debug("Adding gene {0} to variant {1}".format(
            gene, self['variant_id']))
        self['genes'].append(gene)
51498
def firstVariant():
        
        def fget(self):
            if self.variants:
                return self.variants[0]
            else:
                variant = Variant()
                return variant

        return locals()
328786
public void setVariant(int variant) {
        if (symbolMode != Mode.MICRO) {
            throw new IllegalArgumentException("Can only set variant when using MICRO mode.");
        }
        if (variant < 1 || variant > 34) {
            throw new IllegalArgumentException("Variant must be between 1 and 34.");
        }
        this.columns = MICRO_VARIANTS[variant - 1];
        this.rows = MICRO_VARIANTS[variant - 1 + 34];
    }
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,
    ])