Example #1
0
  void analyze(int i, int pos, String ref, String mnp) {
    String codons = codons();

    Variant seqChange = new Variant(chromosome, pos, ref + "", mnp + "", "");

    // ---
    // Calculate effects
    // ---
    VariantEffects effects = snpEffectPredictor.variantEffect(seqChange);

    // Show
    VariantEffect effect = null;
    if (effects.size() > 1) { // Usually there is only one effect
      for (VariantEffect ce : effects) {
        if ((ce.getEffectType() != EffectType.SPLICE_SITE_ACCEPTOR) //
            && (ce.getEffectType() != EffectType.SPLICE_SITE_DONOR) //
            && (ce.getEffectType() != EffectType.INTRON) //
            && (ce.getEffectType() != EffectType.INTERGENIC) //
        ) //
        effect = ce;
      }
    } else effect = effects.get();

    if (effect != null) {
      String effStr = effect.effect(true, true, true, false);

      if (codons.length() > 1) {
        String codonsExp[] = codons.split("/");

        boolean error =
            (!codonsExp[0].toUpperCase().equals(effect.getCodonsRef().toUpperCase()) //
                || !codonsExp[1].toUpperCase().equals(effect.getCodonsAlt().toUpperCase()));

        if (error || debug) {
          Gpr.debug(
              "Fatal error:" //
                  + "\n\tPos           : "
                  + pos //
                  + "\n\tSeqChange     : "
                  + seqChange
                  + (seqChange.isStrandPlus() ? "+" : "-") //
                  + "\n\tCodon (exp)   : "
                  + codons //
                  + "\n\tCodon (pred)  : "
                  + effect.getCodonsRef().toUpperCase()
                  + "/"
                  + effect.getCodonsAlt().toUpperCase() //
                  + "\n\tEffect (pred) : "
                  + effStr //
                  + "\n\tEffect (pred) : "
                  + effect //
                  + "\n\tGene          : "
                  + gene //
                  + "\n\tChromo        : "
                  + chromoSequence //
              );
        }

        /** Error? Dump so we can debug... */
        if (error) {
          System.err.println("Error. Dumping data");
          Save save = new Save();
          save.snpEffectPredictor = snpEffectPredictor;
          save.chromoSequence = chromoSequence;
          save.chromoNewSequence = chromoNewSequence;
          save.ref = ref;
          save.pos = pos;
          save.mnp = mnp;
          String outFile = "/tmp/sep_" + i + "_" + pos + ".bin";
          Gpr.toFileSerialize(outFile, save);
          throw new RuntimeException("Codons do not match!\n\tData dumped: '" + outFile + "'");
        }
      }
    }
  }