Search in sources :

Example 6 with BufferedVCFReader

use of com.github.lindenb.jvarkit.variant.vcf.BufferedVCFReader in project jvarkit by lindenb.

the class VcfGnomadExomeVsGenome method isVariantIn.

boolean isVariantIn(final VariantContext ctx, final BufferedVCFReader reader) {
    final String ctg = this.ctgNameConverter.apply(ctx.getContig());
    if (StringUtils.isBlank(ctg))
        return false;
    try (CloseableIterator<VariantContext> iterE = reader.query(new SimpleInterval(ctg, ctx.getStart(), ctx.getEnd()))) {
        while (iterE.hasNext()) {
            final VariantContext ctx2 = iterE.next();
            if (ctx.getStart() != ctx2.getStart())
                continue;
            if (!ctx.getReference().equals(ctx2.getReference()))
                continue;
            final Set<Allele> alt2 = ctx2.getAlternateAlleles().stream().filter(A -> AcidNucleics.isATGC(A)).collect(Collectors.toSet());
            if (ctx.getAlternateAlleles().stream().anyMatch(A -> alt2.contains(A)))
                return true;
        }
    }
    return false;
}
Also used : CloseableIterator(htsjdk.samtools.util.CloseableIterator) Allele(htsjdk.variant.variantcontext.Allele) SequenceUtil(htsjdk.samtools.util.SequenceUtil) ContigNameConverter(com.github.lindenb.jvarkit.util.bio.fasta.ContigNameConverter) Program(com.github.lindenb.jvarkit.util.jcommander.Program) VCFIterator(htsjdk.variant.vcf.VCFIterator) Parameter(com.beust.jcommander.Parameter) VCFHeader(htsjdk.variant.vcf.VCFHeader) AcidNucleics(com.github.lindenb.jvarkit.util.bio.AcidNucleics) BufferedVCFReader(com.github.lindenb.jvarkit.variant.vcf.BufferedVCFReader) UnaryOperator(java.util.function.UnaryOperator) DistanceParser(com.github.lindenb.jvarkit.util.bio.DistanceParser) VCFReaderFactory(com.github.lindenb.jvarkit.variant.vcf.VCFReaderFactory) Path(java.nio.file.Path) SimpleInterval(com.github.lindenb.jvarkit.samtools.util.SimpleInterval) SequenceDictionaryUtils(com.github.lindenb.jvarkit.util.bio.SequenceDictionaryUtils) VCFFilterHeaderLine(htsjdk.variant.vcf.VCFFilterHeaderLine) Logger(com.github.lindenb.jvarkit.util.log.Logger) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) VCFReader(htsjdk.variant.vcf.VCFReader) Set(java.util.Set) JVarkitVersion(com.github.lindenb.jvarkit.util.JVarkitVersion) Collectors(java.util.stream.Collectors) StringUtils(com.github.lindenb.jvarkit.lang.StringUtils) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) VariantContext(htsjdk.variant.variantcontext.VariantContext) OnePassVcfLauncher(com.github.lindenb.jvarkit.jcommander.OnePassVcfLauncher) Collections(java.util.Collections) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) Allele(htsjdk.variant.variantcontext.Allele) VariantContext(htsjdk.variant.variantcontext.VariantContext) SimpleInterval(com.github.lindenb.jvarkit.samtools.util.SimpleInterval)

Example 7 with BufferedVCFReader

use of com.github.lindenb.jvarkit.variant.vcf.BufferedVCFReader in project jvarkit by lindenb.

the class BamToHaplotypes method beforeSam.

@Override
protected int beforeSam() {
    this.vcfReader = VCFReaderFactory.makeDefault().open(this.vcfFile, true);
    this.bufferedVCFReader = new BufferedVCFReader(this.vcfReader, this.buffSizeInBp);
    this.bufferedVCFReader.setSimplifier(V -> simplify(V));
    return 0;
}
Also used : BufferedVCFReader(com.github.lindenb.jvarkit.variant.vcf.BufferedVCFReader)

Aggregations

BufferedVCFReader (com.github.lindenb.jvarkit.variant.vcf.BufferedVCFReader)7 Parameter (com.beust.jcommander.Parameter)4 OnePassVcfLauncher (com.github.lindenb.jvarkit.jcommander.OnePassVcfLauncher)4 StringUtils (com.github.lindenb.jvarkit.lang.StringUtils)4 JVarkitVersion (com.github.lindenb.jvarkit.util.JVarkitVersion)4 DistanceParser (com.github.lindenb.jvarkit.util.bio.DistanceParser)4 ContigNameConverter (com.github.lindenb.jvarkit.util.bio.fasta.ContigNameConverter)4 Program (com.github.lindenb.jvarkit.util.jcommander.Program)4 Logger (com.github.lindenb.jvarkit.util.log.Logger)4 VCFReaderFactory (com.github.lindenb.jvarkit.variant.vcf.VCFReaderFactory)4 CloseableIterator (htsjdk.samtools.util.CloseableIterator)4 Allele (htsjdk.variant.variantcontext.Allele)4 VariantContext (htsjdk.variant.variantcontext.VariantContext)4 VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)4 VariantContextWriter (htsjdk.variant.variantcontext.writer.VariantContextWriter)4 VCFFilterHeaderLine (htsjdk.variant.vcf.VCFFilterHeaderLine)4 VCFHeader (htsjdk.variant.vcf.VCFHeader)4 VCFIterator (htsjdk.variant.vcf.VCFIterator)4 VCFReader (htsjdk.variant.vcf.VCFReader)4 Path (java.nio.file.Path)4