Exemplo n.º 1
0
  String codons() {
    char seq[] = chromoSequence.toCharArray();
    char seqNew[] = chromoNewSequence.toCharArray();

    codonsOld = "";
    codonsNew = "";
    int codonIdx = 0;
    int i = 0;
    int step = transcript.isStrandPlus() ? 1 : -1;
    char codonOld[] = new char[3];
    char codonNew[] = new char[3];
    for (Exon ex : transcript.sortedStrand()) {
      int start = ex.isStrandPlus() ? ex.getStart() : ex.getEnd();
      for (i = start; ex.intersects(i); i += step, codonIdx = (codonIdx + 1) % 3) {
        codonOld[codonIdx] = seq[i];
        codonNew[codonIdx] = seqNew[i];
        if (codonIdx == 2) addIfDiff(codonOld, codonNew);
      }
    }

    for (; codonIdx != 0; i += step, codonIdx = (codonIdx + 1) % 3) {
      codonOld[codonIdx] = 'N';
      codonNew[codonIdx] = 'N';
      if (codonIdx == 2) addIfDiff(codonOld, codonNew);
    }

    return codonsOld + "/" + codonsNew;
  }
Exemplo n.º 2
0
  /**
   * Find the last position where a nonsense mediated decay is supposed to occurr This is 50 bases
   * (MND_BASES_BEFORE_LAST_JUNCTION bases) before the last exon-exon junction.
   *
   * @param tr
   * @return
   */
  public int lastNmdPos(Transcript tr) {
    // ---
    // Get last exon
    // ---
    int cdsEnd = tr.getCdsEnd();
    int cdsStart = tr.getCdsStart();
    Marker cds =
        new Marker(
            tr.getChromosome(),
            Math.min(cdsStart, cdsEnd),
            Math.max(cdsStart, cdsEnd),
            tr.getStrand(),
            ""); // Create a cds marker
    Exon lastExon = null;
    int countCodingExons = 0;
    for (Exon exon : tr.sortedStrand()) {
      if (exon.intersects(cdsEnd)) lastExon = exon;
      if (cds.intersects(exon)) countCodingExons++;
    }

    // Only one coding exon? => No NMD
    // Note: I'm assuming that we should have a splice event in a coding part of the transcript for
    // NMD to happen.
    if (countCodingExons <= 1) return -1;

    // Sanity check
    if (lastExon == null)
      throw new RuntimeException(
          "Cannot find last coding exon for transcript '"
              + tr.getId()
              + "' (cdsEnd: "
              + cdsEnd
              + ")\n\t"
              + tr);

    // ---
    // Find that position of MND_BASES_BEFORE_LAST_JUNCTION before the last exon-exon junction
    // ---
    int lastExonJunction = tr.isStrandPlus() ? lastExon.getStart() : lastExon.getEnd();
    int chrPos[] = tr.baseNumberCds2Pos();
    int lastNmdPos = -1;
    for (int cdsi = chrPos.length - 1; cdsi >= 0; cdsi--) {
      if (chrPos[cdsi] == lastExonJunction) {
        if (cdsi > MND_BASES_BEFORE_LAST_JUNCTION)
          lastNmdPos = chrPos[cdsi - MND_BASES_BEFORE_LAST_JUNCTION - 1];
        else return tr.isStrandPlus() ? 0 : Integer.MAX_VALUE; // Out of CDS range
        return lastNmdPos;
      }
    }

    throw new RuntimeException(
        "Cannot find last exon junction position for transcript '" + tr.getId() + "'\n\t" + tr);
    // return -1;
  }