Пример #1
0
 private static VariantSample[] createVariants(
     final Variant original,
     final int leftClip,
     final int rightClip,
     Description newDescription,
     int[] alleleMapping) {
   final VariantSample[] newSamples = new VariantSample[original.getNumberOfSamples()];
   for (int k = 0; k < newSamples.length; k++) {
     final VariantSample sample = original.getSample(k);
     if (sample != null) {
       final String newName = createVariantName(leftClip, rightClip, sample.getName());
       newSamples[k] =
           new VariantSample(
               sample.getPloidy(),
               newName,
               sample.isIdentity(),
               sample.getMeasure(),
               sample.isDeNovo(),
               sample.getDeNovoPosterior());
       VariantSample.copy(sample, newSamples[k]);
       // Update counts to correspond to the new description
       final Description d =
           newSamples[k].getStats().counts().getDescription() instanceof DescriptionNone
               ? DescriptionNone.SINGLETON
               : newDescription;
       newSamples[k].setStats((Statistics<?>) newSamples[k].getStats().copy());
       newSamples[k].getStats().remapAlleleStatistics(d, alleleMapping);
       final Map<Set<String>, Double> newMap = newGenotypeLikelihoods(leftClip, rightClip, sample);
       newSamples[k].setGenotypeLikelihoods(newMap);
     } else {
       newSamples[k] = null;
     }
   }
   return newSamples;
 }
Пример #2
0
 // Can't use Description, as that includes hypotheses that weren't necessarily called.
 private static HashSet<String> extractCalledAlleles(final Variant variant) {
   final HashSet<String> alleles = new HashSet<>();
   for (int k = 0; k < variant.getNumberOfSamples(); k++) {
     final VariantSample vs = variant.getSample(k);
     if (vs != null) {
       if (!vs.isIdentity()) {
         Collections.addAll(alleles, StringUtils.split(vs.getName(), VariantUtils.COLON));
       }
     }
   }
   return alleles;
 }
Пример #3
0
 /**
  * changes the de novo flag from true to false on any sample incorrectly marked as de novo. (note
  * does not do the opposite) Also deals with the somatic cause. Some variants after splitting will
  * no longer have a somatic cause.
  *
  * @param variant the variant to check
  * @param checker the de novo checker for the current inheritance scenario
  * @return the corrected variant
  */
 public static Variant denovoCorrect(DenovoChecker checker, Variant variant) {
   final Set<Integer> nonDenovoSamples = new HashSet<>();
   for (int s = 0; s < variant.getNumberOfSamples(); s++) {
     final VariantSample sample = variant.getSample(s);
     if (sample != null) {
       final VariantSample.DeNovoStatus denovoCall = sample.isDeNovo();
       if (denovoCall == VariantSample.DeNovoStatus.IS_DE_NOVO) {
         if (!checker.isDenovo(variant, s)) {
           nonDenovoSamples.add(s);
         }
       }
     }
   }
   final Variant ret;
   if (nonDenovoSamples.size() == 0) {
     ret = variant;
   } else {
     final VariantLocus newLocus = variant.getLocus();
     final VariantSample[] newSamples = new VariantSample[variant.getNumberOfSamples()];
     for (int k = 0; k < newSamples.length; k++) {
       final VariantSample sample = variant.getSample(k);
       if (sample != null) {
         final VariantSample.DeNovoStatus newStatus;
         if (sample.isDeNovo() == VariantSample.DeNovoStatus.UNSPECIFIED) {
           newStatus = VariantSample.DeNovoStatus.UNSPECIFIED;
         } else {
           newStatus =
               sample.isDeNovo() == VariantSample.DeNovoStatus.IS_DE_NOVO
                       && !nonDenovoSamples.contains(k)
                   ? VariantSample.DeNovoStatus.IS_DE_NOVO
                   : VariantSample.DeNovoStatus.NOT_DE_NOVO;
         }
         newSamples[k] =
             new VariantSample(
                 sample.getPloidy(),
                 sample.getName(),
                 sample.isIdentity(),
                 sample.getMeasure(),
                 newStatus,
                 sample.getDeNovoPosterior());
         VariantSample.copy(sample, newSamples[k]);
       }
     }
     final Variant newVariant = new Variant(newLocus, newSamples);
     Variant.copy(variant, newVariant);
     ret = newVariant;
   }
   return ret;
 }