Exemplo n.º 1
0
		protected internal override void noteCurrentRecord(VariantContext vc)
		{
			base.noteCurrentRecord(vc); // first, check for errors

			// then, update mostUpstreamWritableLoc:
			int mostUpstreamWritableIndex = vc.Start - maxCachingStartDistance;
			this.mostUpstreamWritableLoc = Math.Max(BEFORE_MOST_UPSTREAM_LOC, mostUpstreamWritableIndex);
		}
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public abstract void site(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 abstract void site(BCF2Encoder encoder, VariantContext vc);
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private byte[] buildSamplesData(final VariantContext vc) throws IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
		private sbyte[] buildSamplesData(VariantContext vc)
		{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.broadinstitute.variant.bcf2.BCF2Codec.LazyData lazyData = getLazyData(vc);
			BCF2Codec.LazyData lazyData = getLazyData(vc); // has critical side effects
			if (lazyData != null)
			{
				// we never decoded any data from this BCF file, so just pass it back
				return lazyData.bytes;
			}

			// we have to do work to convert the VC into a BCF2 byte stream
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final List<String> genotypeFields = VCFWriter.calcVCFGenotypeKeys(vc, header);
			IList<string> genotypeFields = VCFWriter.calcVCFGenotypeKeys(vc, header);
			foreach (String field in genotypeFields)
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final BCF2FieldWriter.GenotypesWriter writer = fieldManager.getGenotypeFieldWriter(field);
				BCF2FieldWriter.GenotypesWriter writer = fieldManager.getGenotypeFieldWriter(field);
				if (writer == null)
				{
					errorUnexpectedFieldToWrite(vc, field, "FORMAT");
				}

				Debug.Assert(writer != null);

				writer.start(encoder, vc);
				foreach (String name in sampleNames)
				{
					Genotype g = vc.getGenotype(name);
					if (g == null)
					{
						g = GenotypeBuilder.createMissing(name, writer.nValuesPerGenotype);
					}
					writer.addGenotype(encoder, vc, g);
				}
				writer.done(encoder, vc);
			}
			return encoder.RecordBytes;
		}
Exemplo n.º 4
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void buildFilter(VariantContext vc) throws IOException
		private void buildFilter(VariantContext vc)
		{
			if (vc.Filtered)
			{
				encodeStringsByRef(vc.Filters);
			}
			else if (vc.filtersWereApplied())
			{
				encodeStringsByRef(Collections.singleton(VCFConstants.PASSES_FILTERS_v4));
			}
			else
			{
				encoder.encodeTypedMissing(BCF2Type.INT8);
			}
		}
Exemplo n.º 5
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void buildID(VariantContext vc) throws IOException
		private void buildID(VariantContext vc)
		{
			encoder.encodeTypedString(vc.ID);
		}
Exemplo n.º 6
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: private org.broadinstitute.variant.bcf2.BCF2Codec.LazyData getLazyData(final VariantContext vc)
		private BCF2Codec.LazyData getLazyData(VariantContext vc)
		{
			if (vc.Genotypes.LazyWithData)
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final LazyGenotypesContext lgc = (LazyGenotypesContext)vc.getGenotypes();
				LazyGenotypesContext lgc = (LazyGenotypesContext)vc.Genotypes;

				if (lgc.UnparsedGenotypeData is BCF2Codec.LazyData && canSafelyWriteRawGenotypesBytes((BCF2Codec.LazyData) lgc.UnparsedGenotypeData))
				{
					return (BCF2Codec.LazyData)lgc.UnparsedGenotypeData;
				}
				else
				{
					lgc.decode(); // WARNING -- required to avoid keeping around bad lazy data for too long
				}
			}

			return null;
		}
Exemplo n.º 7
0
		public override void add(VariantContext vc)
		{
			if (doNotWriteGenotypes)
			{
				vc = (new VariantContextBuilder(vc)).noGenotypes().make();
			}
			vc = vc.fullyDecode(header, false);

			base.add(vc); // allow on the fly indexing

			try
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final byte[] infoBlock = buildSitesData(vc);
				sbyte[] infoBlock = buildSitesData(vc);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final byte[] genotypesBlock = buildSamplesData(vc);
				sbyte[] genotypesBlock = buildSamplesData(vc);

				// write the two blocks to disk
				writeBlock(infoBlock, genotypesBlock);
			}
			catch (IOException e)
			{
				throw new Exception("Error writing record to BCF2 file: " + vc.ToString(), e);
			}
		}
Exemplo n.º 8
0
		/// <summary>
		/// add a record to the file
		/// </summary>
		/// <param name="vc">      the Variant Context object </param>
		public virtual void add(VariantContext vc)
		{
			// if we are doing on the fly indexing, add the record ***before*** we write any bytes
			if (indexer != null)
			{
				indexer.addFeature(vc, positionalOutputStream.Position);
			}
		}
Exemplo n.º 9
0
//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)
			{
				// the only value that is dynamic are integers
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<Integer> values = new java.util.ArrayList<Integer>(vc.getNSamples());
				IList<int?> values = new List<int?>(vc.NSamples);
				foreach (Genotype g in vc.Genotypes)
				{
					foreach (Object i in BCF2Utils.toList(g.getExtendedAttribute(Field, null)))
					{
						if (i != null) // we know they are all integers
						{
							values.Add((int?)i);
						}
					}
				}

				encodingType = BCF2Utils.determineIntegerType(values);
				base.start(encoder, vc);
			}
Exemplo n.º 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Ensures({"result >= 0"}) private final int computeMaxSizeOfGenotypeFieldFromValues(final org.broadinstitute.variant.variantcontext.VariantContext vc)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
			private int computeMaxSizeOfGenotypeFieldFromValues(VariantContext vc)
			{
				int size = -1;

				foreach (Genotype g in vc.Genotypes)
				{
					size = Math.Max(size, numElements(vc, g));
				}

				return size;
			}
Exemplo n.º 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Ensures({"result >= 0"}) protected int numElements(final org.broadinstitute.variant.variantcontext.VariantContext vc, final org.broadinstitute.variant.variantcontext.Genotype g)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
			protected internal virtual int numElements(VariantContext vc, Genotype g)
			{
				return FieldEncoder.numElements(vc, g.getExtendedAttribute(Field));
			}
Exemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Requires({"encodingType != null", "nValuesPerGenotype >= 0"}) public void addGenotype(final BCF2Encoder encoder, final org.broadinstitute.variant.variantcontext.VariantContext vc, final org.broadinstitute.variant.variantcontext.Genotype g) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
			public virtual void addGenotype(BCF2Encoder encoder, VariantContext vc, Genotype g)
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Object fieldValue = g.getExtendedAttribute(getField(), null);
				object fieldValue = g.getExtendedAttribute(Field, null);
				FieldEncoder.encodeValue(encoder, fieldValue, encodingType, nValuesPerGenotype);
			}
Exemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @Requires({"encodingType != null", "nValuesPerGenotype >= 0 || ! getFieldEncoder().hasConstantNumElements()"}) @Ensures("nValuesPerGenotype >= 0") public void start(final BCF2Encoder encoder, final org.broadinstitute.variant.variantcontext.VariantContext vc) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
			public override void start(BCF2Encoder encoder, VariantContext vc)
			{
				// writes the key information
				base.start(encoder, vc);

				// only update if we need to
				if (!FieldEncoder.hasConstantNumElements())
				{
					if (FieldEncoder.hasContextDeterminedNumElements())
						// we are cheap -- just depends on genotype of allele counts
					{
						nValuesPerGenotype = FieldEncoder.numElements(vc);
					}
					else
						// we have to go fishing through the values themselves (expensive)
					{
						nValuesPerGenotype = computeMaxSizeOfGenotypeFieldFromValues(vc);
					}
				}

				encoder.encodeType(nValuesPerGenotype, encodingType);
			}
Exemplo n.º 14
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void site(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 site(BCF2Encoder encoder, VariantContext vc)
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Object rawValue = vc.getAttribute(getField(), null);
				object rawValue = vc.getAttribute(Field, null);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.broadinstitute.variant.bcf2.BCF2Type type = getFieldEncoder().getType(rawValue);
				BCF2Type type = FieldEncoder.getType(rawValue);
				if (rawValue == null)
				{
					// the value is missing, just write in null
					encoder.encodeType(0, type);
				}
				else
				{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int valueCount = getFieldEncoder().numElements(vc, rawValue);
					int valueCount = FieldEncoder.numElements(vc, rawValue);
					encoder.encodeType(valueCount, type);
					FieldEncoder.encodeValue(encoder, rawValue, type, valueCount);
				}
			}
Exemplo n.º 15
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: private final void buildAlleleMap(final org.broadinstitute.variant.variantcontext.VariantContext vc)
			private void buildAlleleMap(VariantContext vc)
			{
				// these are fast path options to determine the offsets for
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int nAlleles = vc.getNAlleles();
				int nAlleles = vc.NAlleles;
				@ref = vc.Reference;
				alt1 = nAlleles > 1 ? vc.getAlternateAllele(0) : null;

				if (nAlleles > 2)
				{
					// for multi-allelics we need to clear the map, and add additional looks
					alleleMapForTriPlus.Clear();
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<org.broadinstitute.variant.variantcontext.Allele> alleles = vc.getAlleles();
					IList<Allele> alleles = vc.Alleles;
					for (int i = 2; i < alleles.Count; i++)
					{
						alleleMapForTriPlus[alleles[i]] = i;
					}
				}
			}
Exemplo n.º 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Requires("vc != null") public void start(final BCF2Encoder encoder, final org.broadinstitute.variant.variantcontext.VariantContext vc) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
		public virtual void start(BCF2Encoder encoder, VariantContext vc)
		{
			fieldEncoder.writeFieldKey(encoder);
		}
Exemplo n.º 17
0
//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);
			}
Exemplo n.º 18
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void addGenotype(final BCF2Encoder encoder, final org.broadinstitute.variant.variantcontext.VariantContext vc, final org.broadinstitute.variant.variantcontext.Genotype g) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
			public override void addGenotype(BCF2Encoder encoder, VariantContext vc, Genotype g)
			{
				FieldEncoder.encodeValue(encoder, ige.getValues(g), encodingType, nValuesPerGenotype);
			}
Exemplo n.º 19
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: protected int numElements(final org.broadinstitute.variant.variantcontext.VariantContext vc, final org.broadinstitute.variant.variantcontext.Genotype g)
			protected internal override int numElements(VariantContext vc, Genotype g)
			{
				return ige.getSize(g);
			}
Exemplo n.º 20
0
		// --------------------------------------------------------------------------------
		//
		// implicit block
		//
		// The first four records of BCF are inline untype encoded data of:
		//
		// 4 byte integer chrom offset
		// 4 byte integer start
		// 4 byte integer ref length
		// 4 byte float qual
		//
		// --------------------------------------------------------------------------------
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private byte[] buildSitesData(VariantContext vc) throws IOException
		private sbyte[] buildSitesData(VariantContext vc)
		{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int contigIndex = contigDictionary.get(vc.getChr());
			int contigIndex = contigDictionary[vc.Chr];
			if (contigIndex == -1)
			{
				throw new IllegalStateException(string.Format("Contig {0} not found in sequence dictionary from reference", vc.Chr));
			}

			// note use of encodeRawValue to not insert the typing byte
			encoder.encodeRawValue(contigIndex, BCF2Type.INT32);

			// pos.  GATK is 1 based, BCF2 is 0 based
			encoder.encodeRawValue(vc.Start - 1, BCF2Type.INT32);

			// ref length.  GATK is closed, but BCF2 is open so the ref length is GATK end - GATK start + 1
			// for example, a SNP is in GATK at 1:10-10, which has ref length 10 - 10 + 1 = 1
			encoder.encodeRawValue(vc.End - vc.Start + 1, BCF2Type.INT32);

			// qual
			if (vc.hasLog10PError())
			{
				encoder.encodeRawFloat((float) vc.PhredScaledQual);
			}
			else
			{
				encoder.encodeRawMissingValue(BCF2Type.FLOAT);
			}

			// info fields
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int nAlleles = vc.getNAlleles();
			int nAlleles = vc.NAlleles;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int nInfo = vc.getAttributes().size();
			int nInfo = vc.Attributes.Count;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int nGenotypeFormatFields = getNGenotypeFormatFields(vc);
			int nGenotypeFormatFields = getNGenotypeFormatFields(vc);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int nSamples = header.getNGenotypeSamples();
			int nSamples = header.NGenotypeSamples;

			encoder.encodeRawInt((nAlleles << 16) | (nInfo & 0x0000FFFF), BCF2Type.INT32);
			encoder.encodeRawInt((nGenotypeFormatFields << 24) | (nSamples & 0x00FFFFF), BCF2Type.INT32);

			buildID(vc);
			buildAlleles(vc);
			buildFilter(vc);
			buildInfo(vc);

			return encoder.RecordBytes;
		}
Exemplo n.º 21
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void addGenotype(final BCF2Encoder encoder, final org.broadinstitute.variant.variantcontext.VariantContext vc, final org.broadinstitute.variant.variantcontext.Genotype g) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
			public override void addGenotype(BCF2Encoder encoder, VariantContext vc, Genotype g)
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String fieldValue = g.getFilters();
				string fieldValue = g.Filters;
				FieldEncoder.encodeValue(encoder, fieldValue, encodingType, nValuesPerGenotype);
			}
Exemplo n.º 22
0
		/// <summary>
		/// Try to get the nGenotypeFields as efficiently as possible.
		/// 
		/// If this is a lazy BCF2 object just grab the field count from there,
		/// otherwise do the whole counting by types test in the actual data
		/// </summary>
		/// <param name="vc">
		/// @return </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: private final int getNGenotypeFormatFields(final VariantContext vc)
		private int getNGenotypeFormatFields(VariantContext vc)
		{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.broadinstitute.variant.bcf2.BCF2Codec.LazyData lazyData = getLazyData(vc);
			BCF2Codec.LazyData lazyData = getLazyData(vc);
			return lazyData != null ? lazyData.nGenotypeFields : VCFWriter.calcVCFGenotypeKeys(vc, header).Count;
		}
Exemplo n.º 23
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: protected int numElements(final org.broadinstitute.variant.variantcontext.VariantContext vc, final org.broadinstitute.variant.variantcontext.Genotype g)
			protected internal override int numElements(VariantContext vc, Genotype g)
			{
				return FieldEncoder.numElements(vc, g.Filters);
			}
Exemplo n.º 24
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void buildAlleles(VariantContext vc) throws IOException
		private void buildAlleles(VariantContext vc)
		{
			foreach (Allele allele in vc.Alleles)
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final byte[] s = allele.getDisplayBases();
				sbyte[] s = allele.DisplayBases;
				if (s == null)
				{
					throw new IllegalStateException("BUG: BCF2Writer encountered null padded allele" + allele);
				}
				encoder.encodeTypedString(s);
			}
		}
Exemplo n.º 25
0
//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)
			{
				if (vc.NAlleles > BCF2Utils.MAX_ALLELES_IN_GENOTYPES)
				{
					throw new IllegalStateException("Current BCF2 encoder cannot handle sites " + "with > " + BCF2Utils.MAX_ALLELES_IN_GENOTYPES + " alleles, but you have " + vc.NAlleles + " at " + vc.Chr + ":" + vc.Start);
				}

				encodingType = BCF2Type.INT8;
				buildAlleleMap(vc);
				nValuesPerGenotype = vc.getMaxPloidy(2);

				base.start(encoder, vc);
			}
Exemplo n.º 26
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void buildInfo(VariantContext vc) throws IOException
		private void buildInfo(VariantContext vc)
		{
			foreach (KeyValuePair<string, object> infoFieldEntry in vc.Attributes)
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String field = infoFieldEntry.getKey();
				string field = infoFieldEntry.Key;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final BCF2FieldWriter.SiteWriter writer = fieldManager.getSiteFieldWriter(field);
				BCF2FieldWriter.SiteWriter writer = fieldManager.getSiteFieldWriter(field);
				if (writer == null)
				{
					errorUnexpectedFieldToWrite(vc, field, "INFO");
				}
				writer.start(encoder, vc);
				writer.site(encoder, vc);
				writer.done(encoder, vc);
			}
		}
Exemplo n.º 27
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void addGenotype(final BCF2Encoder encoder, final org.broadinstitute.variant.variantcontext.VariantContext vc, final org.broadinstitute.variant.variantcontext.Genotype g) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
			public override void addGenotype(BCF2Encoder encoder, VariantContext vc, Genotype g)
			{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int samplePloidy = g.getPloidy();
				int samplePloidy = g.Ploidy;
				for (int i = 0; i < nValuesPerGenotype; i++)
				{
					if (i < samplePloidy)
					{
						// we encode the actual allele
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.broadinstitute.variant.variantcontext.Allele a = g.getAllele(i);
						Allele a = g.getAllele(i);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int offset = getAlleleOffset(a);
						int offset = getAlleleOffset(a);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int encoded = ((offset+1) << 1) | (g.isPhased() ? 0x01 : 0x00);
						int encoded = ((offset + 1) << 1) | (g.Phased ? 0x01 : 0x00);
						encoder.encodeRawBytes(encoded, encodingType);
					}
					else
					{
						// we need to pad with missing as we have ploidy < max for this sample
						encoder.encodeRawBytes(encodingType.MissingBytes, encodingType);
					}
				}
			}
Exemplo n.º 28
0
		/// <summary>
		/// Throws a meaningful error message when a field (INFO or FORMAT) is found when writing out a file
		/// but there's no header line for it.
		/// </summary>
		/// <param name="vc"> </param>
		/// <param name="field"> </param>
		/// <param name="fieldType"> </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: private final void errorUnexpectedFieldToWrite(final VariantContext vc, final String field, final String fieldType)
		private void errorUnexpectedFieldToWrite(VariantContext vc, string field, string fieldType)
		{
			throw new IllegalStateException("Found field " + field + " in the " + fieldType + " fields of VariantContext at " + vc.Chr + ":" + vc.Start + " from " + vc.Source + " but this hasn't been defined in the VCFHeader");
		}
Exemplo n.º 29
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void done(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 virtual void done(BCF2Encoder encoder, VariantContext vc) // TODO -- overload done so that we null out values and test for correctness
		{
		}