Package htsjdk.tribble.dbsnp

Examples of htsjdk.tribble.dbsnp.OldDbSNPFeature


        @Override
        public Class<? extends Feature> getAdaptableFeatureType() { return OldDbSNPFeature.class; }

        @Override       
        public VariantContext convert(String name, Object input, ReferenceContext ref) {
            OldDbSNPFeature dbsnp = (OldDbSNPFeature)input;

            int index = dbsnp.getStart() - ref.getWindow().getStart() - 1;
            if ( index < 0 )
                return null; // we weren't given enough reference context to create the VariantContext

            final byte refBaseForIndel = ref.getBases()[index];
            final boolean refBaseIsDash = dbsnp.getNCBIRefBase().equals("-");

            boolean addPaddingBase;
            if ( isSNP(dbsnp) || isMNP(dbsnp) )
                addPaddingBase = false;
            else if ( isIndel(dbsnp) || dbsnp.getVariantType().contains("mixed") )
                addPaddingBase = refBaseIsDash || GATKVariantContextUtils.requiresPaddingBase(stripNullDashes(getAlleleList(dbsnp)));
            else
                return null; // can't handle anything else

            Allele refAllele;
            if ( refBaseIsDash )
                refAllele = Allele.create(refBaseForIndel, true);
            else if ( ! Allele.acceptableAlleleBases(dbsnp.getNCBIRefBase()) )
                return null;
            else
                refAllele = Allele.create((addPaddingBase ? (char)refBaseForIndel : "") + dbsnp.getNCBIRefBase(), true);

            final List<Allele> alleles = new ArrayList<Allele>();
            alleles.add(refAllele);

            // add all of the alt alleles
            for ( String alt : getAlternateAlleleList(dbsnp) ) {
                if ( Allele.wouldBeNullAllele(alt.getBytes()))
                    alt = "";
                else if ( ! Allele.acceptableAlleleBases(alt) )
                    return null;

                alleles.add(Allele.create((addPaddingBase ? (char)refBaseForIndel : "") + alt, false));
            }

            final VariantContextBuilder builder = new VariantContextBuilder();
            builder.source(name).id(dbsnp.getRsID());
            builder.loc(dbsnp.getChr(), dbsnp.getStart() - (addPaddingBase ? 1 : 0), dbsnp.getEnd() - (addPaddingBase && refAllele.length() == 1 ? 1 : 0));
            builder.alleles(alleles);
            return builder.make();
        }
View Full Code Here

TOP

Related Classes of htsjdk.tribble.dbsnp.OldDbSNPFeature

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.