Exports a variant.

@param variant Variant to print
@return        True by default.
331960
@Override
    public boolean write(Variant variant) {
        StudyEntry studyEntry = variant.getStudy(study);
        if (studyEntry == null) {
            return true;
//            List<String> studies = variant.getStudies().stream().map(StudyEntry::getStudyId).collect(Collectors.toList());
//            throw new IllegalArgumentException("Can not export more than one study at the same time. Found: " + studies);
        }

        dataOutputStream.print(variant.getChromosome());
        dataOutputStream.print(TAB);
        dataOutputStream.print(variant.getStart());
        dataOutputStream.print(TAB);
        if (variant.getReference().isEmpty()) {
            dataOutputStream.print(MISSING_ALLELE);
        } else {
            dataOutputStream.print(variant.getReference());
        }
        dataOutputStream.print(TAB);
        if (variant.getAlternate().isEmpty()) {
            dataOutputStream.print(MISSING_ALLELE);
        } else {
            dataOutputStream.print(variant.getAlternate());
        }
        dataOutputStream.print(TAB);
        for (Iterator<String> cohortIterator = cohorts.iterator(); cohortIterator.hasNext(); ) {
            String cohort = cohortIterator.next();
            VariantStats stats = studyEntry.getStats(cohort);
            if (stats == null) {
                dataOutputStream.print(".\t.\t.\t.\t.");
            } else {

                int an = stats.getAlleleCount();
                Integer ac = stats.getAltAlleleCount();
                Float af = stats.getAltAlleleFreq();

                if (an >= 0) {
                    dataOutputStream.print(an);
                } else {
                    dataOutputStream.print(MISSING_NUMBER);
                }
                dataOutputStream.print(TAB);
                if (ac >= 0) {
                    dataOutputStream.print(ac);
                } else {
                    dataOutputStream.print(MISSING_NUMBER);
                }
                dataOutputStream.print(TAB);
                if (af >= 0) {
                    dataOutputStream.print(DECIMAL_FORMAT.format(af));
                } else {
                    dataOutputStream.print(MISSING_NUMBER);
                }
                dataOutputStream.print(TAB);


                if (stats.getGenotypeFreq() != null && !stats.getGenotypeFreq().isEmpty()) {
                    PopulationFrequency frequency = converter.convert("", "", stats, "", "");
                    dataOutputStream.print(frequency.getHetGenotypeFreq() + TAB + frequency.getAltHomGenotypeFreq());
                } else {
                    dataOutputStream.print(".\t.");
                }

            }
            if (cohortIterator.hasNext()) {
                dataOutputStream.print(TAB);
            } else {
                dataOutputStream.print("\n");
            }
        }
        writtenVariants++;

        return true;
    }
1102519
def addVariant(self,variant):
        '''

        '''
        if isinstance(variant, Variant):
            self.variants.append(variant)
        else:
            raise (VariantError,
                   'variant Type should be Variant, not %s' % type(variant))
414317
private static String serializeVariantSets(Map<String, VariantSet> map) {
		StringBuilder result = new StringBuilder();

		for (Entry<String, VariantSet> entry : map.entrySet()) {
			result.append(entry.getKey()).append(":");
			VariantSet variantSet = (VariantSet) entry.getValue();
			result.append(variantSet.getDefaultVariant()).append(":");
			result.append(getCommaSeparatedString(variantSet));
			result.append(";");
		}

		return result.toString();
	}
442876
public static String getVariantBundleName(String bundleName, Map<String, String> variants,
			boolean isGeneratedResource) {

		String variantKey = getVariantKey(variants);
		return getVariantBundleName(bundleName, variantKey, isGeneratedResource);
	}
820619
public void run(List<Variant> variantList) {
        for (int i = 0; i < variantList.size(); i++) {
            List<PopulationFrequency> populationFrequencies = getPopulationFrequencies(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 (populationFrequencies != null && populationFrequencies.size() > 0) {
                VariantAnnotation variantAnnotation = variantList.get(i).getAnnotation();
                if (variantAnnotation != null) {
                    // variantList and variantAnnotationList must contain variants in the SAME order: variantAnnotation
                    // at position i must correspond to variant i
                    variantAnnotation.setPopulationFrequencies(populationFrequencies);
                }
            }
        }
    }
1206018
public function variantExtension($variant)
    {
        if (    ! array_key_exists($variant, $this->variants)
            ||  ! is_array($this->variants[ $variant ])
            ||  ! array_key_exists('extension', $this->variants[ $variant ])
        ) {
            return false;
        }

        return $this->variants[ $variant ]['extension'];
    }
805937
def _node_has_variant(node: BaseEntity, variant: str) -> bool:
    
    return VARIANTS in node and any(
        variant_dict[KIND] == variant
        for variant_dict in node[VARIANTS]
    )
899469
@Nullable
    public static String setVariantForView(@NonNull View view, @Nullable String variant) {
        String previousVariant = null;
        String previousAttribute = null;
        for (Map.Entry<String, HashMap<Integer, String>> entry : bindings.entrySet()) {
            if (entry.getValue().containsKey(view.getId())) {
                previousVariant = entry.getKey();
                previousAttribute = entry.getValue().get(view.getId());
                bindings.remove(previousVariant);
                break;
            }
        }
        mapAttribute(previousAttribute, view.getId(), variant, view.getClass().getSimpleName());
        return previousVariant;
    }
1087975
private String getAvailableVariant(Map<String, String> curVariants) {

		String variantKey = null;
		if (variants != null) {
			Map<String, String> availableVariants = generatorRegistry.getAvailableVariantMap(variants, curVariants);
			variantKey = VariantUtils.getVariantKey(availableVariants);
		}

		return variantKey;
	}
796221
final public JSVariant Variant(Map refs) throws ParseException {
                                JSVariant ans = new JSVariant(); JSType mem;
    jj_consume_token(5);
    mem = TypeDecl(refs);
                             ans.addCase(mem);
    label_2:
    while (true) {
      switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
      case 6:
        ;
        break;
      default:
        jj_la1[3] = jj_gen;
        break label_2;
      }
      jj_consume_token(6);
      mem = TypeDecl(refs);
                               ans.addCase(mem);
    }
    jj_consume_token(7);
                                                            {if (true) return ans;}
    throw new Error("Missing return statement in function");
  }
60369
public boolean hasSameDefaultVariant(VariantSet obj) {

		return (this.defaultVariant == null && obj.defaultVariant == null)
				|| (this.defaultVariant != null && this.defaultVariant.equals(obj.defaultVariant));
	}
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;
	}
359749
public JSType createUnionType(JSTypeNative... variants) {
    UnionTypeBuilder builder = UnionTypeBuilder.create(this);
    for (JSTypeNative typeId : variants) {
      builder.addAlternate(getNativeType(typeId));
    }
    return builder.build();
  }
1188216
private static String reduceVariant(final String variant){
		if (isEmpty(variant))
			throw new AssertionError("Shouldn't happen, can't reduce non existent variant");
		
		int indexOfUnderscore = variant.lastIndexOf('_');
		if (indexOfUnderscore==-1)
			return "";
		return variant.substring(0, indexOfUnderscore);
	}
255513
public JSType createUnionType(JSType... variants) {
    UnionTypeBuilder builder = UnionTypeBuilder.create(this);
    for (JSType type : variants) {
      builder.addAlternate(type);
    }
    return builder.build();
  }
794138
public static List<String> getAllVariantKeysFromFixedVariants(Map<String, VariantSet> variants,
			Map<String, String> fixedVariants) {

		Map<String, VariantSet> tempVariants = new HashMap<>(variants);

		if (fixedVariants != null) {

			for (Entry<String, String> entry : fixedVariants.entrySet()) {
				VariantSet variantSet = tempVariants.get(entry.getKey());
				if (variantSet != null) {
					String variantValue = variantSet.getDefaultVariant();
					if (variantSet.contains(entry.getValue())) {
						variantValue = entry.getValue();
					}

					VariantSet newVariantSet = new VariantSet(variantSet.getType(), variantValue,
							Arrays.asList(variantValue));
					tempVariants.put(variantSet.getType(), newVariantSet);
				}
			}
		}

		return getAllVariantKeys(tempVariants);
	}
750092
public static Object toObject(COMObject parent, Variant variant, String key, Object defaultValue) {
	try {
	    return toObject(parent, variant, key);
	}
	catch (ExpressionException ee) {
	    return defaultValue;
	}
    }