Exemplo n.º 1
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.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void encodeValue(final BCF2Encoder encoder, final Object value, final org.broadinstitute.variant.bcf2.BCF2Type type, final int minValues) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
            public override void encodeValue(BCF2Encoder encoder, object value, BCF2Type type, int minValues)
            {
                int count = 0;

                if (value != null)
                {
                    encoder.encodeRawInt((int?)value, type);
                    count++;
                }
                for (; count < minValues; count++)
                {
                    encoder.encodeRawMissingValue(type);
                }
            }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public void encodeValue(final BCF2Encoder encoder, final Object value, final org.broadinstitute.variant.bcf2.BCF2Type type, final int minValues) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
            public override void encodeValue(BCF2Encoder encoder, object value, BCF2Type type, int minValues)
            {
                int count = 0;

                foreach (Integer i in toList(typeof(Integer), value))
                {
                    if (i != null)                     // necessary because .,. => [null, null] in VC
                    {
                        encoder.encodeRawInt(i, type);
                        count++;
                    }
                }
                for (; count < minValues; count++)
                {
                    encoder.encodeRawMissingValue(type);
                }
            }