コード例 #1
0
ファイル: BCF2Writer.cs プロジェクト: smith-chem-wisc/Bio.VCF
//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);
        }
コード例 #2
0
        /// <summary>
        /// Setup the FieldWriters appropriate to each INFO and FORMAT in the VCF header
        ///
        /// Must be called before any of the getter methods will work
        /// </summary>
        /// <param name="header"> a VCFHeader containing description for every INFO and FORMAT field we'll attempt to write out to BCF </param>
        /// <param name="encoder"> the encoder we are going to use to write out the BCF2 data </param>
        /// <param name="stringDictionary"> a map from VCFHeader strings to their offsets for encoding </param>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public void setup(final VCFHeader header, final BCF2Encoder encoder, final java.util.Map<String, Integer> stringDictionary)
        public virtual void setup(VCFHeader header, BCF2Encoder encoder, IDictionary <string, int?> stringDictionary)
        {
            foreach (VCFInfoHeaderLine line in header.InfoHeaderLines)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String field = line.getID();
                string field = line.ID;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final BCF2FieldWriter.SiteWriter writer = createInfoWriter(header, line, encoder, stringDictionary);
                BCF2FieldWriter.SiteWriter writer = createInfoWriter(header, line, encoder, stringDictionary);
                add(siteWriters, field, writer);
            }

            foreach (VCFFormatHeaderLine line in header.FormatHeaderLines)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String field = line.getID();
                string field = line.ID;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final BCF2FieldWriter.GenotypesWriter writer = createGenotypesWriter(header, line, encoder, stringDictionary);
                BCF2FieldWriter.GenotypesWriter writer = createGenotypesWriter(header, line, encoder, stringDictionary);
                add(genotypesWriters, field, writer);
            }
        }