protected boolean isCustomAnnotation(String fileName) { return !VariantReaderUtils.isAvro(fileName) && !VariantReaderUtils.isJson(fileName); }
protected DataReader<VariantAnnotation> newVariantAnnotationDataReader(URI uri) { DataReader<VariantAnnotation> reader; if (VariantReaderUtils.isAvro(uri.toString())) { reader = new AvroDataReader<>(Paths.get(uri).toFile(), VariantAnnotation.class); } else if (VariantReaderUtils.isJson(uri.toString())) { reader = new VariantAnnotationJsonDataReader(Paths.get(uri).toFile()); // } else if (VariantReaderUtils.isVcf(uri.toString())) { // //TODO: Read from VEP file // reader = new VepFormatReader(Paths.get(uri).toString()); } else { throw new IllegalArgumentException("Unable to load annotations from file " + uri); } return reader; }
protected static VariantAvroReader getVariantAvroReader(Path input, VariantStudyMetadata metadata, boolean stdin) throws StorageEngineException { VariantAvroReader variantAvroReader; if (isAvro(input.toString())) { String sourceFile = getMetaFromTransformedFile(input.toAbsolutePath().toString()); if (stdin) { variantAvroReader = new VariantAvroReader(System.in, new File(sourceFile), metadata); } else { variantAvroReader = new VariantAvroReader(input.toAbsolutePath().toFile(), new File(sourceFile), metadata); } } else { throw variantInputNotSupported(input); } return variantAvroReader; }
/** * Get a variant data reader depending on the type of the input file. * * @param input Stream Input variant file (avro, json, vcf) * @param metadata Optional VariantSource * @param stdin Indicate if the file should be read from the Standard Input * @return VariantReader * @throws StorageEngineException if the format is not valid or there is an error reading */ public static VariantReader getVariantReader(Path input, VariantStudyMetadata metadata, boolean stdin) throws StorageEngineException { String fileName = input.getFileName().toString(); if (metadata == null) { VariantFileMetadata variantFileMetadata = createEmptyVariantFileMetadata(input); metadata = variantFileMetadata.toVariantStudyMetadata(""); } if (isJson(fileName)) { return getVariantJsonReader(input, metadata); } else if (isAvro(fileName)) { return getVariantAvroReader(input, metadata, stdin); } else if (isVcf(fileName)) { return getVariantVcfReader(input, metadata, stdin); } else { throw variantInputNotSupported(input); } }