You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a strange bug, may be it's not about htsjdk but I would be happy to know the cause of this.
I'm reading a list of variants from a VCFFileReader:
final CloseableIterator<VariantContext> iter2=vcfFileReader.iterator();
final List<VariantContext> inMemoryVariants = Collections.unmodifiableList(iter2.stream().
limit(3).
collect(Collectors.toList())
);
iter2.close();
vcfFileReader.close();
this read-only List is then used by some java Threads , I wait for the end of the thread and I write some variants of a new VCF file:
final VariantContextWriter w = (...)
final VCFHeader header2= (...)
w.writeHeader(header2);
w.add(bestResult.ctx1);
w.add(bestResult.ctx2);
w.close();
but here, I get an exception form VCFEncoder.writeAllele called from addGenotypeData :
java.lang.RuntimeException: Allele C* is not an allele in the variant context
at htsjdk.variant.vcf.VCFEncoder.writeAllele
at the beginning of VCFEncoder.addGenotypeData if I add the statement below, I see my message on stderr: boummm3 {C=1, .=., T*=0} [C*, C*] class java.util.HashMap
I don't fully understand, but this is almost certainly a concurrency bug with LazyGenotypesContext which seems to be highly unsafe for use with threads. I would expect that making LazyGenotypesContext.decode() synchronized would probably fix this.
Subject of the issue
Genotypes in variantcontext look mutable (??)
Minimal example
I've posted an example here: https://gist.github.com/lindenb/7ee76e30dfb662048fff3cf6125b980d
Description
This is a strange bug, may be it's not about htsjdk but I would be happy to know the cause of this.
I'm reading a list of variants from a VCFFileReader:
this read-only List is then used by some java Threads , I wait for the end of the thread and I write some variants of a new VCF file:
but here, I get an exception form VCFEncoder.writeAllele called from addGenotypeData :
at the beginning of VCFEncoder.addGenotypeData if I add the statement below, I see my message on stderr:
boummm3 {C=1, .=., T*=0} [C*, C*] class java.util.HashMap
Adding the following statement (accessing the alleles) before using the list inMemoryVariants fixes the problem.
I'm puzlled, do you have any idea ?
Your environment
The text was updated successfully, but these errors were encountered: