Appends one VariantFeature to variantFeatures
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)
                  )
237456
async def variant(self, elem=None, elem_type=None, params=None):
        
        elem_type = elem_type if elem_type else elem.__class__

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

        if self.writing:
            return await self.dump_variant(elem=elem,
                                           elem_type=elem_type if elem_type else elem.__class__, params=params)
        else:
            return await self.load_variant(elem_type=elem_type if elem_type else elem.__class__,
                                           params=params, elem=elem)
716123
def mutate(self, mutation=None, set_obj=None, del_obj=None, set_nquads=None,
               del_nquads=None, commit_now=None, ignore_index_conflict=None,
               timeout=None, metadata=None, credentials=None):
        """"""
        mutation = self._common_mutate(
            mutation=mutation, set_obj=set_obj, del_obj=del_obj,
            set_nquads=set_nquads, del_nquads=del_nquads,
            commit_now=commit_now, ignore_index_conflict=ignore_index_conflict)

        new_metadata = self._dg.add_login_metadata(metadata)
        mutate_error = None

        try:
            assigned = self._dc.mutate(mutation, timeout=timeout,
                                       metadata=new_metadata,
                                       credentials=credentials)
        except Exception as error:
            if util.is_jwt_expired(error):
                self._dg.retry_login()
                new_metadata = self._dg.add_login_metadata(metadata)
                try:
                    assigned = self._dc.mutate(mutation, timeout=timeout,
                                               metadata=new_metadata,
                                               credentials=credentials)
                except Exception as error:
                    mutate_error = error
            else:
                mutate_error = error

        if mutate_error is not None:
            try:
                self.discard(timeout=timeout, metadata=metadata,
                             credentials=credentials)
            except:
                # Ignore error - user should see the original error.
                pass

            self._common_except_mutate(mutate_error)

        if mutation.commit_now:
            self._finished = True

        self.merge_context(assigned.context)
        return assigned
329640
def insertVariantSet(self, variantSet):
        
        # We cheat a little here with the VariantSetMetadata, and encode these
        # within the table as a JSON dump. These should really be stored in
        # their own table
        metadataJson = json.dumps(
            [protocol.toJsonDict(metadata) for metadata in
             variantSet.getMetadata()])
        urlMapJson = json.dumps(variantSet.getReferenceToDataUrlIndexMap())
        try:
            models.Variantset.create(
                id=variantSet.getId(),
                datasetid=variantSet.getParentContainer().getId(),
                referencesetid=variantSet.getReferenceSet().getId(),
                name=variantSet.getLocalId(),
                created=datetime.datetime.now(),
                updated=datetime.datetime.now(),
                metadata=metadataJson,
                dataurlindexmap=urlMapJson,
                attributes=json.dumps(variantSet.getAttributes()))
        except Exception as e:
            raise exceptions.RepoManagerException(e)
        for callSet in variantSet.getCallSets():
            self.insertCallSet(callSet)
1305445
def annotate_variant(variant, var_obj=None):
    
    if var_obj:
    
        variant.INFO['Obs'] = var_obj['observations']
        if var_obj.get('homozygote'):
            variant.INFO['Hom'] = var_obj['homozygote']
        if var_obj.get('hemizygote'):
            variant.INFO['Hem'] = var_obj['hemizygote']
    
    return variant
552495
def convertVariant(self, record, callSetIds):
        
        variant = self._createGaVariant()
        variant.reference_name = record.contig
        if record.id is not None:
            variant.names.extend(record.id.split(';'))
        variant.start = record.start          # 0-based inclusive
        variant.end = record.stop             # 0-based exclusive
        variant.reference_bases = record.ref
        if record.alts is not None:
            variant.alternate_bases.extend(list(record.alts))
        filterKeys = record.filter.keys()
        if len(filterKeys) == 0:
            variant.filters_applied = False
        else:
            variant.filters_applied = True
            if len(filterKeys) == 1 and filterKeys[0] == 'PASS':
                variant.filters_passed = True
            else:
                variant.filters_passed = False
                variant.filters_failed.extend(filterKeys)
        # record.qual is also available, when supported by GAVariant.
        for key, value in record.info.iteritems():
            if value is None:
                continue
            if key == 'SVTYPE':
                variant.variant_type = value
            elif key == 'SVLEN':
                variant.svlen = int(value[0])
            elif key == 'CIPOS':
                variant.cipos.extend(value)
            elif key == 'CIEND':
                variant.ciend.extend(value)
            elif isinstance(value, str):
                value = value.split(',')
            protocol.setAttribute(
                variant.attributes.attr[key].values, value)
        for callSetId in callSetIds:
            callSet = self.getCallSet(callSetId)
            pysamCall = record.samples[str(callSet.getSampleName())]
            variant.calls.add().CopyFrom(
                self._convertGaCall(callSet, pysamCall))
        variant.id = self.getVariantId(variant)
        return variant
763360
def add_name_variant(self, name):
        
        self._ensure_field('name', {})
        self.obj['name'].setdefault('name_variants', []).append(name)
1370937
def _set_variant_id(self, variant_id=None):
        """"""
        if not variant_id:
            variant_id = '_'.join([
                self.CHROM,
                str(self.POS),
                self.REF,
                self.ALT
                ])

        logger.debug("Updating variant id to {0}".format(
            variant_id))

        self['variant_id'] = variant_id
117945
def annotate_snvs(adapter, vcf_obj):
    
    variants = {}
    
    for nr_variants, variant in enumerate(vcf_obj, 1):
        # Add the variant to current batch
        variants[get_variant_id(variant)] = variant
        # If batch len == 1000 we annotate the batch
        if (nr_variants % 1000) == 0:
            
            for var_obj in adapter.search_variants(list(variants.keys())):
                var_id = var_obj['_id']
                if var_id in variants:
                    annotate_variant(variants[var_id], var_obj)

            for variant_id in variants:
                yield variants[variant_id]
            
            variants = {}
    
    for var_obj in adapter.search_variants(list(variants.keys())):
        var_id = var_obj['_id']
        if var_id in variants:
            annotate_variant(variants[var_id], var_obj)

    for variant_id in variants:
        yield variants[variant_id]
265457
public Variant merge(Variant current, Variant load) {
        return merge(current, Collections.singleton(load));
    }
668550
def set_variant(self, identity, experiment_name, variant_name):
        
        try:
            experiment = model.Experiment.get_by(name=experiment_name)
            variant = model.Variant.get_by(name=variant_name)
            if experiment and variant and model.Participant.query.filter(and_(
                model.Participant.identity == identity,
                model.Participant.experiment_id == experiment.id,
                model.Participant.variant_id == variant.id
            )).count() == 0:
                model.Participant(
                    identity=identity,
                    experiment=experiment,
                    variant=variant
                )
                self.Session.commit()
        finally:
            self.Session.close()
112772
def append(self, tr):
        
        self.transforms.append(tr)
        tr.changed.connect(self._subtr_changed)
        self._rebuild_shaders()
        self.update()
909064
def variant(self, case_id, variant_id):
        """"""
        case_obj = self.case(case_id)
        plugin, case_id = self.select_plugin(case_obj)
        variant = plugin.variant(case_id, variant_id)
        return variant
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
307322
def variant(case_id, variant_id):
    """"""
    case_obj = app.db.case(case_id)
    variant = app.db.variant(case_id, variant_id)
    if variant is None:
        return abort(404, "variant not found")

    comments = app.db.comments(variant_id=variant.md5)
    template = 'sv_variant.html' if app.db.variant_type == 'sv' else 'variant.html'
    return render_template(template, variant=variant, case_id=case_id,
                           comments=comments, case=case_obj)
1280433
public static Map<String, VariantSet> concatVariants(Map<String, VariantSet> variantSet1,
			Map<String, VariantSet> variantSet2) {

		Map<String, VariantSet> result = new HashMap<>();
		if (!isEmpty(variantSet1) && isEmpty(variantSet2)) {
			result.putAll(variantSet1);
		} else if (isEmpty(variantSet1) && !isEmpty(variantSet2)) {
			result.putAll(variantSet2);
		} else if (!isEmpty(variantSet1) && !isEmpty(variantSet2)) {

			Set<String> keySet = new HashSet<>();
			keySet.addAll(variantSet1.keySet());
			keySet.addAll(variantSet2.keySet());
			for (String variantType : keySet) {
				VariantSet variants1 = variantSet1.get(variantType);
				VariantSet variants2 = variantSet2.get(variantType);
				Set<String> variants = new HashSet<>();
				String defaultVariant = null;

				if (variants1 != null && variants2 != null && !variants1.hasSameDefaultVariant(variants2)) {
					throw new BundlingProcessException("For the variant type '" + variantType
							+ "', the variant sets defined in your bundles don't have the same default value.");
				}

				if (variants1 != null) {
					variants.addAll(variants1);
					defaultVariant = variants1.getDefaultVariant();
				}
				if (variants2 != null) {
					variants.addAll(variants2);
					defaultVariant = variants2.getDefaultVariant();
				}

				VariantSet variantSet = new VariantSet(variantType, defaultVariant, variants);
				result.put(variantType, variantSet);
			}
		}

		return result;
	}
1255650
def dynamic_content_item_variant_update(self, item_id, id, data, **kwargs):
        ""
        api_path = "/api/v2/dynamic_content/items/{item_id}/variants/{id}.json"
        api_path = api_path.format(item_id=item_id, id=id)
        return self.call(api_path, method="PUT", data=data, **kwargs)