use of htsjdk.variant.vcf.VCFCodec in project gatk by broadinstitute.
the class GenomicsDBImport method getReaderFromVCFUri.
/**
* Creates a feature reader object from a given VCF URI (can also be
* a local file path) and returns it
* @param variantPath URI or file path
* @return Feature reader
*/
private AbstractFeatureReader<VariantContext, LineIterator> getReaderFromVCFUri(final String variantPath) {
final String variantURI = IOUtils.getPath(variantPath).toAbsolutePath().toUri().toString();
final Function<SeekableByteChannel, SeekableByteChannel> cloudWrapper = (cloudPrefetchBuffer > 0 ? is -> SeekableByteChannelPrefetcher.addPrefetcher(cloudPrefetchBuffer, is) : Function.identity());
final Function<SeekableByteChannel, SeekableByteChannel> cloudIndexWrapper = (cloudIndexPrefetchBuffer > 0 ? is -> SeekableByteChannelPrefetcher.addPrefetcher(cloudIndexPrefetchBuffer, is) : Function.identity());
return AbstractFeatureReader.getFeatureReader(variantURI, null, new VCFCodec(), true, cloudWrapper, cloudIndexWrapper);
}
use of htsjdk.variant.vcf.VCFCodec in project gatk by broadinstitute.
the class GatherVcfs method getReaderFromVCFUri.
private static FeatureReader<VariantContext> getReaderFromVCFUri(final Path variantPath, final int cloudPrefetchBuffer) {
final String variantURI = variantPath.toUri().toString();
final Function<SeekableByteChannel, SeekableByteChannel> cloudWrapper = (cloudPrefetchBuffer > 0 ? is -> SeekableByteChannelPrefetcher.addPrefetcher(cloudPrefetchBuffer, is) : Function.identity());
return AbstractFeatureReader.getFeatureReader(variantURI, null, new VCFCodec(), false, cloudWrapper, Function.identity());
}
use of htsjdk.variant.vcf.VCFCodec in project hmftools by hartwigmedical.
the class SvVCFAnnotator method readFromVcf.
private List<VariantContext> readFromVcf(String vcfFilename) {
List<VariantContext> variants = Lists.newArrayList();
final StructuralVariantFactory factory = new StructuralVariantFactory(false);
try (final AbstractFeatureReader<VariantContext, LineIterator> reader = AbstractFeatureReader.getFeatureReader(vcfFilename, new VCFCodec(), false)) {
while (reader.iterator().hasNext()) variants.add(reader.iterator().next());
} catch (Exception e) {
}
return variants;
}
use of htsjdk.variant.vcf.VCFCodec in project hmftools by hartwigmedical.
the class BachelorApplication method processSV.
private static Collection<EligibilityReport> processSV(final String patient, final File vcf, final BachelorEligibility eligibility) {
LOGGER.info("processing sv: {}", vcf.getPath());
final StructuralVariantFactory factory = new StructuralVariantFactory(true);
try {
try (final AbstractFeatureReader<VariantContext, LineIterator> reader = AbstractFeatureReader.getFeatureReader(vcf.getPath(), new VCFCodec(), false)) {
reader.iterator().forEach(factory::addVariantContext);
}
} catch (IOException e) {
LOGGER.error("error with SV file {}: {}", vcf.getPath(), e.getMessage());
return Collections.emptyList();
}
return eligibility.processStructuralVariants(patient, factory.results());
}
use of htsjdk.variant.vcf.VCFCodec in project ASCIIGenome by dariober.
the class IntervalFeatureTest method canFormatVCFLine.
@Test
public void canFormatVCFLine() throws InvalidGenomicCoordsException, InvalidColourException, IOException, InvalidConfigException {
List<Double> rulerMap = new ArrayList<Double>();
for (int i = 1; i < 100; i++) {
rulerMap.add((double) i);
}
// Prepare header
VCFFileReader reader = new VCFFileReader(new File("test_data/CHD.exon.2010_03.sites.vcf.gz"));
VCFHeader vcfHeader = reader.getFileHeader();
reader.close();
VCFCodec vcfCodec = new VCFCodec();
vcfCodec.setVCFHeader(vcfHeader, Utils.getVCFHeaderVersion(vcfHeader));
String vcfLine = "1 10 . C G 23 PASS AA=.;AC=.;AN=.DP=.".replaceAll(" ", "\t");
IntervalFeature ift = new IntervalFeature(vcfLine, TrackFormat.VCF, vcfCodec);
ift.mapToScreen(rulerMap);
assertEquals(1, ift.getIdeogram(true, true).size());
assertEquals('G', ift.getIdeogram(true, true).get(0).getText());
// Just check there is a formatting char
assertTrue(ift.getIdeogram(true, true).get(0).format(false).contains("["));
// Deletion
vcfLine = "1 10 . CTTG C 23 PASS AA=.;AC=.;AN=.DP=.".replaceAll(" ", "\t");
ift = new IntervalFeature(vcfLine, TrackFormat.VCF, vcfCodec);
ift.mapToScreen(rulerMap);
assertEquals('D', ift.getIdeogram(true, true).get(0).getText());
assertEquals(3, ift.getIdeogram(true, true).size());
// Insertion
vcfLine = "1 10 . C CTTG 23 PASS AA=.;AC=.;AN=.DP=.".replaceAll(" ", "\t");
ift = new IntervalFeature(vcfLine, TrackFormat.VCF, vcfCodec);
ift.mapToScreen(rulerMap);
assertEquals("I", ift.getIdeogram(true, true).get(0).format(true));
assertEquals(3, ift.getIdeogram(true, true).size());
// Multiple alleles
vcfLine = "1 10 . C CTTG,A 23 PASS AA=.;AC=.;AN=.DP=.".replaceAll(" ", "\t");
ift = new IntervalFeature(vcfLine, TrackFormat.VCF, vcfCodec);
ift.mapToScreen(rulerMap);
assertEquals("|", ift.getIdeogram(true, true).get(0).format(true));
}
Aggregations