//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: public void start(final BCF2Encoder encoder, final org.broadinstitute.variant.variantcontext.VariantContext vc) throws java.io.IOException //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET: public override void start(BCF2Encoder encoder, VariantContext vc) { // TODO // TODO this piece of code consumes like 10% of the runtime alone because fo the vc.getGenotypes() iteration // TODO encodingType = BCF2Type.INT8; foreach (Genotype g in vc.Genotypes) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int[] pls = ige.getValues(g); int[] pls = ige.getValues(g); //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final org.broadinstitute.variant.bcf2.BCF2Type plsType = getFieldEncoder().getType(pls); BCF2Type plsType = FieldEncoder.getType(pls); encodingType = BCF2Utils.maxIntegerType(encodingType, plsType); if (encodingType == BCF2Type.INT32) { break; // stop early } } base.start(encoder, vc); }
/// <summary> /// add the genotype data /// </summary> /// <param name="vc"> the variant context </param> /// <param name="genotypeFormatKeys"> Genotype formatting string </param> /// <param name="alleleMap"> alleles for this context </param> /// <exception cref="IOException"> for writer </exception> //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: private void addGenotypeData(VariantContext vc, Map<Allele, String> alleleMap, List<String> genotypeFormatKeys) throws IOException private void addGenotypeData(VariantContext vc, IDictionary <Allele, string> alleleMap, IList <string> genotypeFormatKeys) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int ploidy = vc.getMaxPloidy(2); int ploidy = vc.getMaxPloidy(2); foreach (string sample in mHeader.GenotypeSampleNames) { write(VCFConstants.FIELD_SEPARATOR); Genotype g = vc.getGenotype(sample); if (g == null) { g = GenotypeBuilder.createMissing(sample, ploidy); } //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final List<String> attrs = new ArrayList<String>(genotypeFormatKeys.size()); IList <string> attrs = new List <string>(genotypeFormatKeys.Count); foreach (string field in genotypeFormatKeys) { if (field.Equals(VCFConstants.GENOTYPE_KEY)) { if (!g.Available) { throw new IllegalStateException("GTs cannot be missing for some samples if they are available for others in the record"); } writeAllele(g.getAllele(0), alleleMap); for (int i = 1; i < g.Ploidy; i++) { write(g.Phased ? VCFConstants.PHASED : VCFConstants.UNPHASED); writeAllele(g.getAllele(i), alleleMap); } continue; } else { string outputValue; if (field.Equals(VCFConstants.GENOTYPE_FILTER_KEY)) { outputValue = g.Filtered ? g.Filters : VCFConstants.PASSES_FILTERS_v4; } else { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final IntGenotypeFieldAccessors.Accessor accessor = intGenotypeFieldAccessors.getAccessor(field); IntGenotypeFieldAccessors.Accessor accessor = intGenotypeFieldAccessors.getAccessor(field); if (accessor != null) { //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final': //ORIGINAL LINE: final int[] intValues = accessor.getValues(g); int[] intValues = accessor.getValues(g); if (intValues == null) { outputValue = VCFConstants.MISSING_VALUE_v4; } else if (intValues.Length == 1) // fast path { outputValue = Convert.ToString(intValues[0]); } else { StringBuilder sb = new StringBuilder(); sb.Append(intValues[0]); for (int i = 1; i < intValues.Length; i++) { sb.Append(","); sb.Append(intValues[i]); } outputValue = sb.ToString(); } } else { object val = g.hasExtendedAttribute(field) ? g.getExtendedAttribute(field) : VCFConstants.MISSING_VALUE_v4; VCFFormatHeaderLine metaData = mHeader.getFormatHeaderLine(field); if (metaData != null) { int numInFormatField = metaData.getCount(vc); if (numInFormatField > 1 && val.Equals(VCFConstants.MISSING_VALUE_v4)) { // If we have a missing field but multiple values are expected, we need to construct a new string with all fields. // For example, if Number=2, the string has to be ".,." StringBuilder sb = new StringBuilder(VCFConstants.MISSING_VALUE_v4); for (int i = 1; i < numInFormatField; i++) { sb.Append(","); sb.Append(VCFConstants.MISSING_VALUE_v4); } val = sb.ToString(); } } // assume that if key is absent, then the given string encoding suffices outputValue = formatVCFField(val); } } if (outputValue != null) { attrs.Add(outputValue); } } } // strip off trailing missing values for (int i = attrs.Count - 1; i >= 0; i--) { if (isMissingValue(attrs[i])) { attrs.RemoveAt(i); } else { break; } } for (int i = 0; i < attrs.Count; i++) { if (i > 0 || genotypeFormatKeys.Contains(VCFConstants.GENOTYPE_KEY)) { write(VCFConstants.GENOTYPE_FIELD_SEPARATOR); } write(attrs[i]); } } }