Search in sources :

Example 1 with TargetTableReader

use of org.broadinstitute.hellbender.tools.exome.TargetTableReader in project gatk by broadinstitute.

the class TargetCodec method canDecode.

@Override
public boolean canDecode(final String path) {
    File file;
    try {
        // Use the URI constructor so that we can handle file:// URIs
        final URI uri = new URI(path);
        file = uri.isAbsolute() ? new File(uri) : new File(path);
    } catch (Exception e) {
        // Contract for canDecode() mandates that all exception be trapped
        return false;
    }
    if (!file.canRead() || !file.isFile()) {
        return false;
    }
    try {
        new TargetTableReader(file).close();
    } catch (final IOException | RuntimeException ex) {
        // whereas RuntimeException would be caused by a formatting error in the file.
        return false;
    }
    //disallow .bed extension
    final String toDecode = AbstractFeatureReader.hasBlockCompressedExtension(path) ? path.substring(0, path.lastIndexOf(".")) : path;
    return !toDecode.toLowerCase().endsWith(BED_EXTENSION);
}
Also used : TargetTableReader(org.broadinstitute.hellbender.tools.exome.TargetTableReader) IOException(java.io.IOException) File(java.io.File) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) GATKException(org.broadinstitute.hellbender.exceptions.GATKException)

Example 2 with TargetTableReader

use of org.broadinstitute.hellbender.tools.exome.TargetTableReader in project gatk-protected by broadinstitute.

the class TargetCodec method canDecode.

@Override
public boolean canDecode(final String path) {
    File file;
    try {
        // Use the URI constructor so that we can handle file:// URIs
        final URI uri = new URI(path);
        file = uri.isAbsolute() ? new File(uri) : new File(path);
    } catch (Exception e) {
        // Contract for canDecode() mandates that all exception be trapped
        return false;
    }
    if (!file.canRead() || !file.isFile()) {
        return false;
    }
    try {
        new TargetTableReader(file).close();
    } catch (final IOException | RuntimeException ex) {
        // whereas RuntimeException would be caused by a formatting error in the file.
        return false;
    }
    //disallow .bed extension
    final String toDecode = AbstractFeatureReader.hasBlockCompressedExtension(path) ? path.substring(0, path.lastIndexOf(".")) : path;
    return !toDecode.toLowerCase().endsWith(BED_EXTENSION);
}
Also used : TargetTableReader(org.broadinstitute.hellbender.tools.exome.TargetTableReader) IOException(java.io.IOException) File(java.io.File) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) GATKException(org.broadinstitute.hellbender.exceptions.GATKException)

Aggregations

File (java.io.File)2 IOException (java.io.IOException)2 URI (java.net.URI)2 URISyntaxException (java.net.URISyntaxException)2 GATKException (org.broadinstitute.hellbender.exceptions.GATKException)2 TargetTableReader (org.broadinstitute.hellbender.tools.exome.TargetTableReader)2