Exemple #1
0
 /**
  * Creates a new {@code VcfEmission} instance from a VCF record containing phased, non-missing
  * genotypes for a list of reference samples.
  *
  * @param gtp a parser for the VCF record
  * @throws IllegalArgumentException if a format error, a missing genotype, or an unphased genotype
  *     is detected in the VCF record
  * @throws NullPointerException if {@code gtp==null}
  */
 public BitSetRefGT(VcfRecGTParser gtp) {
   this.marker = gtp.marker();
   this.samples = gtp.samples();
   this.bitsPerAllele = bitsPerAllele(marker);
   this.allele1 = new BitSet(gtp.nSamples() * bitsPerAllele);
   this.allele2 = new BitSet(gtp.nSamples() * bitsPerAllele);
   storeAlleles(gtp, bitsPerAllele, allele1, allele2);
 }
Exemple #2
0
 private static void storeAlleles(
     VcfRecGTParser gtp, int bitsPerAllele, BitSet allele1, BitSet allele2) {
   int nSamples = gtp.nSamples();
   for (int sample = 0; sample < nSamples; ++sample) {
     int a1 = gtp.allele1();
     int a2 = gtp.allele2();
     if (gtp.isPhased() == false || a1 == -1 || a2 == -2) {
       String s = "Unphased or missing reference genotype at marker: " + gtp.marker();
       throw new IllegalArgumentException(s);
     }
     storeAllele(allele1, sample, bitsPerAllele, a1);
     storeAllele(allele2, sample, bitsPerAllele, a2);
     if (sample + 1 < nSamples) {
       gtp.nextSample();
     }
   }
 }