Package org.broadinstitute.gatk.engine.refdata.tracks

Examples of org.broadinstitute.gatk.engine.refdata.tracks.FeatureManager


            final String targetFilePath = target.file != null ? target.file.getAbsolutePath() : "/dev/stdin";
            logger.debug(String.format("Merging VariantContextWriterStorage from %s into %s", file.getAbsolutePath(), targetFilePath));

            // use the feature manager to determine the right codec for the tmp file
            // that way we don't assume it's a specific type
            final FeatureManager.FeatureDescriptor fd = new FeatureManager().getByFiletype(file);
            if ( fd == null )
                throw new UserException.LocalParallelizationProblem(file);

            final FeatureCodec codec = fd.getCodec();
            final AbstractFeatureReader<Feature, ?> source = AbstractFeatureReader.getFeatureReader(file.getAbsolutePath(), codec, false);
View Full Code Here


        // Construct a help string to output details on this walker.
        StringBuilder additionalHelp = new StringBuilder();
        Formatter formatter = new Formatter(additionalHelp);

        formatter.format("Available Reference Ordered Data types:%n");
        formatter.format(new FeatureManager().userFriendlyListOfAvailableFeatures());
        formatter.format("%n");

        formatter.format("For a full description of this walker, see its GATKdocs at:%n");
        formatter.format("%s%n", GATKDocUtils.helpLinksToGATKDocs(walkerType));
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public static Collection<RMDTriplet> unpackRODBindings(final Collection<RodBinding> RODBindings, @SuppressWarnings("unused") final ParsingEngine parser) {
        // todo -- this is a strange home for this code.  Move into ROD system
        Collection<RMDTriplet> rodBindings = new ArrayList<RMDTriplet>();
        FeatureManager builderForValidation = new FeatureManager();

        for (RodBinding rodBinding: RODBindings) {
            String argValue = rodBinding.getSource();
            String fileName = expandFileName(argValue);
            String name = rodBinding.getName();
            String type = rodBinding.getTribbleType();

            RMDTriplet.RMDStorageType storageType;
            if(rodBinding.getTags().getValue("storage") != null)
                storageType = Enum.valueOf(RMDTriplet.RMDStorageType.class,rodBinding.getTags().getValue("storage"));
            else if(fileName.toLowerCase().endsWith("stdin"))
                storageType = RMDTriplet.RMDStorageType.STREAM;
            else
                storageType = RMDTriplet.RMDStorageType.FILE;

            RMDTriplet triplet = new RMDTriplet(name,type,fileName,storageType,rodBinding.getTags());

            // validate triplet type
            FeatureManager.FeatureDescriptor descriptor = builderForValidation.getByTriplet(triplet);
            if ( descriptor == null )
                throw new UserException.UnknownTribbleType(rodBinding.getTribbleType(),
                        String.format("Field %s had provided type %s but there's no such Tribble type.  The compatible types are: %n%s",
                                rodBinding.getName(), rodBinding.getTribbleType(), builderForValidation.userFriendlyListOfAvailableFeatures(rodBinding.getType())));
            if ( ! rodBinding.getType().isAssignableFrom(descriptor.getFeatureClass()) )
                throw new UserException.BadArgumentValue(rodBinding.getName(),
                        String.format("Field %s expects Features of type %s, but the input file produces Features of type %s. The compatible types are: %n%s",
                                rodBinding.getName(), rodBinding.getType().getSimpleName(), descriptor.getSimpleFeatureName(),
                                builderForValidation.userFriendlyListOfAvailableFeatures(rodBinding.getType())));


            rodBindings.add(triplet);
        }

View Full Code Here

            } else if ( tags.getPositionalTags().size() == 2 ) {
                // -X:name,type style
                bindingName = tags.getPositionalTags().get(0);
                tribbleType = tags.getPositionalTags().get(1);

                FeatureManager manager = new FeatureManager();
                if ( manager.getByName(tribbleType) == null )
                    throw new UserException.UnknownTribbleType(
                            tribbleType,
                            String.format("Unable to find tribble type '%s' provided on the command line. " +
                                    "Please select a correct type from among the supported types:%n%s",
                                    tribbleType, manager.userFriendlyListOfAvailableFeatures(parameterType)));

            } else {
                // case with 0 or 1 positional tags
                FeatureManager manager = new FeatureManager();

                // -X:type style is a type when we cannot determine the type dynamically
                String tag1 = tags.getPositionalTags().size() == 1 ? tags.getPositionalTags().get(0) : null;
                if ( tag1 != null ) {
                    if ( manager.getByName(tag1) != null ) // this a type
                        tribbleType = tag1;
                    else
                        bindingName = tag1;
                }

                if ( tribbleType == null ) {
                    // try to determine the file type dynamically
                    File file = value.asFile();
                    if ( file.canRead() && file.isFile() ) {
                        FeatureManager.FeatureDescriptor featureDescriptor = manager.getByFiletype(file);
                        if ( featureDescriptor != null ) {
                            tribbleType = featureDescriptor.getName();
                            logger.debug("Dynamically determined type of " + file + " to be " + tribbleType);
                        }
                    }

                    if ( tribbleType == null ) {
                        // IntervalBinding can be created from a normal String
                        Class rawType = (makeRawTypeIfNecessary(bindingClass));
                        try {
                            return rawType.getConstructor(String.class).newInstance(value.asString());
                        } catch (NoSuchMethodException e) {
                            /* ignore */
                        }

                        if ( ! file.exists() ) {
                            throw new UserException.CouldNotReadInputFile(file, "file does not exist");
                        } else if ( ! file.canRead() || ! file.isFile() ) {
                            throw new UserException.CouldNotReadInputFile(file, "file could not be read");
                        } else {
                            throw new UserException.CommandLineException(
                                    String.format("No tribble type was provided on the command line and the type of the file could not be determined dynamically. " +
                                            "Please add an explicit type tag :NAME listing the correct type from among the supported types:%n%s",
                                            manager.userFriendlyListOfAvailableFeatures(parameterType)));
                        }
                    }
                }
            }

View Full Code Here

        root.put("type", argumentTypeString(source.field.getGenericType()));

        Class<? extends Feature> featureClass = getFeatureTypeIfPossible(source.field.getGenericType());
        if (featureClass != null) {
            // deal with the allowable types
            FeatureManager manager = new FeatureManager();
            List<String> rodTypes = new ArrayList<String>();
            for (FeatureManager.FeatureDescriptor descriptor : manager.getByFeature(featureClass)) {
                rodTypes.add(String.format("<a href=%s>%s</a>",
                        GATKDocUtils.phpFilenameForClass(descriptor.getCodecClass()),
                        descriptor.getName()));
            }
View Full Code Here

        if ( featureIntervals != null ) {
            intervals = new ArrayList<>();

            // TODO -- after ROD system cleanup, go through the ROD system so that we can handle things like gzipped files

            final FeatureCodec codec = new FeatureManager().getByName(featureIntervals.getTribbleType()).getCodec();
            if ( codec instanceof ReferenceDependentFeatureCodec )
                ((ReferenceDependentFeatureCodec)codec).setGenomeLocParser(genomeLocParser);
            try {
                FeatureReader<Feature> reader = AbstractFeatureReader.getFeatureReader(featureIntervals.getSource(), codec, false);
                for ( Feature feature : reader.iterator() )
View Full Code Here

TOP

Related Classes of org.broadinstitute.gatk.engine.refdata.tracks.FeatureManager

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.