Exemplo n.º 1
0
        // --------------------------------------------------------------------------------
        //
        // Writing raw values (don't have a type byte)
        //
        // --------------------------------------------------------------------------------

//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public final <T extends Object> void encodeRawValues(final Collection<T> v, final org.broadinstitute.variant.bcf2.BCF2Type type) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        public void encodeRawValues <T>(ICollection <T> v, BCF2Type type) where T : Object
        {
            foreach (T v1 in v)
            {
                encodeRawValue(v1, type);
            }
        }
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;

                // TODO -- can be restructured to avoid toList operation
                if (isAtomic)
                {
                    // fast path for fields with 1 fixed float value
                    if (value != null)
                    {
                        encoder.encodeRawFloat((double?)value);
                        count++;
                    }
                }
                else
                {
                    // handle generic case
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<Double> doubles = toList(Double.class, value);
                    IList <double?> doubles = toList(typeof(double?), value);
                    foreach (Double d in doubles)
                    {
                        if (d != null)                         // necessary because .,. => [null, null] in VC
                        {
                            encoder.encodeRawFloat(d);
                            count++;
                        }
                    }
                }
                for (; count < minValues; count++)
                {
                    encoder.encodeRawMissingValue(type);
                }
            }
Exemplo n.º 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Requires("! strings.isEmpty()") @Ensures("result.isIntegerType()") private final org.broadinstitute.variant.bcf2.BCF2Type encodeStringsByRef(final Collection<String> strings) throws 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:
        private BCF2Type encodeStringsByRef(ICollection <string> strings)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final List<Integer> offsets = new ArrayList<Integer>(strings.size());
            IList <int?> offsets = new List <int?>(strings.Count);

            // iterate over strings until we find one that needs 16 bits, and break
            foreach (String string in strings)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Integer got = stringDictionaryMap.get(string);
                int?got = stringDictionaryMap[string];
                if (got == null)
                {
                    throw new IllegalStateException("Format error: could not find string " + string + " in header as required by BCF");
                }
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int offset = got;
                int offset = got;
                offsets.Add(offset);
            }

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.broadinstitute.variant.bcf2.BCF2Type type = org.broadinstitute.variant.bcf2.BCF2Utils.determineIntegerType(offsets);
            BCF2Type type = BCF2Utils.determineIntegerType(offsets);

            encoder.encodeTyped(offsets, type);
            return(type);
        }
Exemplo n.º 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Requires("size >= 0") public final void encodeRawMissingValues(final int size, final org.broadinstitute.variant.bcf2.BCF2Type type) 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 void encodeRawMissingValues(int size, BCF2Type type)
        {
            for (int i = 0; i < size; i++)
            {
                encodeRawMissingValue(type);
            }
        }
Exemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeTyped(final Object value, final org.broadinstitute.variant.bcf2.BCF2Type type) 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 void encodeTyped(object value, BCF2Type type)
        {
            if (value == null)
            {
                encodeTypedMissing(type);
            }
            else
            {
                switch (type)
                {
                case BCF2Type.INT8:
                case BCF2Type.INT16:
                case BCF2Type.INT32:
                    encodeTypedInt((int?)value, type);
                    break;

                case BCF2Type.FLOAT:
                    encodeTypedFloat((double?)value);
                    break;

                case BCF2Type.CHAR:
                    encodeTypedString((string)value);
                    break;

                default:
                    throw new System.ArgumentException("Illegal type encountered " + type);
                }
            }
        }
Exemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeTypedInt(final int v) 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 void encodeTypedInt(int v)
        {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.broadinstitute.variant.bcf2.BCF2Type type = org.broadinstitute.variant.bcf2.BCF2Utils.determineIntegerType(v);
            BCF2Type type = BCF2Utils.determineIntegerType(v);

            encodeTypedInt(v, type);
        }
Exemplo n.º 7
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)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String s = javaStringToBCF2String(value);
                string s = javaStringToBCF2String(value);

                encoder.encodeRawString(s, Math.Max(s.Length, minValues));
            }
Exemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeTyped(List<? extends Object> v, final org.broadinstitute.variant.bcf2.BCF2Type type) 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 void encodeTyped <T1>(IList <T1> v, BCF2Type type) where T1 : Object
        {
            if (type == BCF2Type.CHAR && v.Count != 0)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String s = org.broadinstitute.variant.bcf2.BCF2Utils.collapseStringList((List<String>) v);
                string s = BCF2Utils.collapseStringList((IList <string>)v);
                v = stringToBytes(s);
            }

            encodeType(v.Count, type);
            encodeRawValues(v, type);
        }
Exemplo n.º 9
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.º 10
0
        // ----------------------------------------------------------------------
        //
        // Constructor
        //
        // ----------------------------------------------------------------------

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Requires({"headerLine != null", "dict != null"}) private BCF2FieldEncoder(final Bio.VCF.VCFCompoundHeaderLine headerLine, final java.util.Map<String, Integer> dict, final org.broadinstitute.variant.bcf2.BCF2Type staticType)
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        private BCF2FieldEncoder(VCFCompoundHeaderLine headerLine, IDictionary <string, int?> dict, BCF2Type staticType)
        {
            this.headerLine = headerLine;
            this.staticType = staticType;

//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final Integer offset = dict.get(getField());
            int?offset = dict[Field];

            if (offset == null)
            {
                throw new IllegalStateException("Format error: could not find string " + Field + " in header as required by BCF");
            }
            this.dictionaryOffset = offset;
            dictionaryOffsetType  = BCF2Utils.determineIntegerType(offset);
        }
Exemplo n.º 11
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);
                }
            }
Exemplo n.º 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Requires("size >= 0") @Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeType(final int size, final org.broadinstitute.variant.bcf2.BCF2Type type) 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 void encodeType(int size, BCF2Type type)
        {
            if (size <= BCF2Utils.MAX_INLINE_ELEMENTS)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int typeByte = org.broadinstitute.variant.bcf2.BCF2Utils.encodeTypeDescriptor(size, type);
                int typeByte = BCF2Utils.encodeTypeDescriptor(size, type);
                encodeStream.write(typeByte);
            }
            else
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final int typeByte = org.broadinstitute.variant.bcf2.BCF2Utils.encodeTypeDescriptor(org.broadinstitute.variant.bcf2.BCF2Utils.OVERFLOW_ELEMENT_MARKER, type);
                int typeByte = BCF2Utils.encodeTypeDescriptor(BCF2Utils.OVERFLOW_ELEMENT_MARKER, type);
                encodeStream.write(typeByte);
                // write in the overflow size
                encodeTypedInt(size);
            }
        }
Exemplo n.º 13
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.º 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
        /// <summary>
        /// Totally generic encoder that examines o, determines the best way to encode it, and encodes it
        ///
        /// This method is incredibly slow, but it's only used for UnitTests so it doesn't matter
        /// </summary>
        /// <param name="o">
        /// @return </param>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Requires("o != null") public final org.broadinstitute.variant.bcf2.BCF2Type encode(final Object o) 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 BCF2Type encode(object o)
        {
            if (o == null)
            {
                throw new System.ArgumentException("Generic encode cannot deal with null values");
            }

            if (o is IList)
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.broadinstitute.variant.bcf2.BCF2Type type = determineBCFType(((List) o).get(0));
                BCF2Type type = determineBCFType(((IList)o)[0]);
                encodeTyped((IList)o, type);
                return(type);
            }
            else
            {
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.broadinstitute.variant.bcf2.BCF2Type type = determineBCFType(o);
                BCF2Type type = determineBCFType(o);
                encodeTyped(o, type);
                return(type);
            }
        }
Exemplo n.º 16
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public final <T extends Object> void encodeRawValue(final T value, final org.broadinstitute.variant.bcf2.BCF2Type type) throws java.io.IOException
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        public void encodeRawValue <T>(T value, BCF2Type type) where T : Object
        {
            try
            {
                if (value == type.MissingJavaValue)
                {
                    encodeRawMissingValue(type);
                }
                else
                {
                    switch (type)
                    {
                    case BCF2Type.INT8:
                    case BCF2Type.INT16:
                    case BCF2Type.INT32:
                        encodeRawBytes((int?)value, type);
                        break;

                    case BCF2Type.FLOAT:
                        encodeRawFloat((double?)value);
                        break;

                    case BCF2Type.CHAR:
                        encodeRawChar((sbyte?)value);
                        break;

                    default:
                        throw new System.ArgumentException("Illegal type encountered " + type);
                    }
                }
            }
            catch (ClassCastException e)
            {
                throw new ClassCastException("BUG: invalid type cast to " + type + " from " + value);
            }
        }
Exemplo n.º 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeRawBytes(final int value, final org.broadinstitute.variant.bcf2.BCF2Type type) 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 void encodeRawBytes(int value, BCF2Type type)
        {
            type.write(value, encodeStream);
        }
Exemplo n.º 18
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @Requires({"minValues <= 1", "value != null", "value instanceof Boolean", "((Boolean)value) == true"}) 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: Method 'throws' clauses are not available in .NET:
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
            public override void encodeValue(BCF2Encoder encoder, object value, BCF2Type type, int minValues)
            {
                encoder.encodeRawBytes(1, StaticType);
            }
Exemplo n.º 19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeRawMissingValue(final org.broadinstitute.variant.bcf2.BCF2Type type) 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 void encodeRawMissingValue(BCF2Type type)
        {
            encodeRawBytes(type.MissingBytes, type);
        }
Exemplo n.º 20
0
        // --------------------------------------------------------------------------------
        //
        // Writing typed values (have type byte)
        //
        // --------------------------------------------------------------------------------

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeTypedMissing(final org.broadinstitute.variant.bcf2.BCF2Type type) 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 void encodeTypedMissing(BCF2Type type)
        {
            encodeType(0, type);
        }
Exemplo n.º 21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Requires("type.isIntegerType()") @Ensures("encodeStream.size() > old(encodeStream.size())") public final void encodeTypedInt(final int v, final org.broadinstitute.variant.bcf2.BCF2Type type) 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 void encodeTypedInt(int v, BCF2Type type)
        {
            encodeType(1, type);
            encodeRawInt(v, type);
        }
Exemplo n.º 22
0
        // ----------------------------------------------------------------------
        //
        // methods to encode values, including the key abstract method
        //
        // ----------------------------------------------------------------------

        /// <summary>
        /// Key abstract method that should encode a value of the given type into the encoder.
        ///
        /// Value will be of a type appropriate to the underlying encoder.  If the genotype field is represented as
        /// an int[], this will be value, and the encoder needs to handle encoding all of the values in the int[].
        ///
        /// The argument should be used, not the getType() method in the superclass as an outer loop might have
        /// decided a more general type (int16) to use, even through this encoder could have been done with int8.
        ///
        /// If minValues > 0, then encodeValue must write in at least minValues items from value.  If value is atomic,
        /// this means that minValues - 1 MISSING values should be added to the encoder.  If minValues is a collection
        /// type (int[]) then minValues - values.length should be added.  This argument is intended to handle padding
        /// of values in genotype fields.
        /// </summary>
        /// <param name="encoder"> </param>
        /// <param name="value"> </param>
        /// <param name="type"> </param>
        /// <param name="minValues"> </param>
        /// <exception cref="IOException"> </exception>
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Requires({"encoder != null", "isDynamicallyTyped() || type == getStaticType()", "minValues >= 0"}) public abstract 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: Method 'throws' clauses are not available in .NET:
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        public abstract void encodeValue(BCF2Encoder encoder, object value, BCF2Type type, int minValues);