Example #1
0
        // --------------------------------------------------------------------------------
        //
        // implementation functions
        //
        // --------------------------------------------------------------------------------

//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: private final String getFilterString(final VariantContext vc)
        private string getFilterString(VariantContext vc)
        {
            if (vc.Filtered)
            {
                foreach (String filter in vc.Filters)
                {
                    if (!mHeader.hasFilterLine(filter))
                    {
                        fieldIsMissingFromHeaderError(vc, filter, "FILTER");
                    }
                }

                return(ParsingUtils.join(";", ParsingUtils.sortList(vc.Filters)));
            }
            else if (vc.filtersWereApplied())
            {
                return(VCFConstants.PASSES_FILTERS_v4);
            }
            else
            {
                return(VCFConstants.UNFILTERED);
            }
        }
Example #2
0
        /// <summary>
        /// Determine which genotype fields are in use in the genotypes in VC </summary>
        /// <param name="vc"> </param>
        /// <returns> an ordered list of genotype fields in use in VC.  If vc has genotypes this will always include GT first </returns>
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
//ORIGINAL LINE: public static List<String> calcVCFGenotypeKeys(final VariantContext vc, final VCFHeader header)
        public static IList <string> calcVCFGenotypeKeys(VariantContext vc, VCFHeader header)
        {
            Set <string> keys = new HashSet <string>();

            bool sawGoodGT         = false;
            bool sawGoodQual       = false;
            bool sawGenotypeFilter = false;
            bool sawDP             = false;
            bool sawAD             = false;
            bool sawPL             = false;

            foreach (Genotype g in vc.Genotypes)
            {
                keys.addAll(g.ExtendedAttributes.Keys);
                if (g.Available)
                {
                    sawGoodGT = true;
                }
                if (g.hasGQ())
                {
                    sawGoodQual = true;
                }
                if (g.hasDP())
                {
                    sawDP = true;
                }
                if (g.hasAD())
                {
                    sawAD = true;
                }
                if (g.hasPL())
                {
                    sawPL = true;
                }
                if (g.Filtered)
                {
                    sawGenotypeFilter = true;
                }
            }

            if (sawGoodQual)
            {
                keys.add(VCFConstants.GENOTYPE_QUALITY_KEY);
            }
            if (sawDP)
            {
                keys.add(VCFConstants.DEPTH_KEY);
            }
            if (sawAD)
            {
                keys.add(VCFConstants.GENOTYPE_ALLELE_DEPTHS);
            }
            if (sawPL)
            {
                keys.add(VCFConstants.GENOTYPE_PL_KEY);
            }
            if (sawGenotypeFilter)
            {
                keys.add(VCFConstants.GENOTYPE_FILTER_KEY);
            }

            IList <string> sortedList = ParsingUtils.sortList(new List <string>(keys));

            // make sure the GT is first
            if (sawGoodGT)
            {
                IList <string> newList = new List <string>(sortedList.Count + 1);
                newList.Add(VCFConstants.GENOTYPE_KEY);
                newList.AddRange(sortedList);
                sortedList = newList;
            }

            if (sortedList.Count == 0 && header.hasGenotypingData())
            {
                // this needs to be done in case all samples are no-calls
                return(Collections.singletonList(VCFConstants.GENOTYPE_KEY));
            }
            else
            {
                return(sortedList);
            }
        }