コード例 #1
0
ファイル: VariantEffect.java プロジェクト: Tmacme/SnpEff
 public Transcript getTranscript() {
   if (marker != null) {
     if (marker instanceof Transcript) return (Transcript) marker;
     return (Transcript) marker.findParent(Transcript.class);
   }
   return null;
 }
コード例 #2
0
ファイル: VariantEffect.java プロジェクト: Tmacme/SnpEff
 /** Get intron (if any) */
 public Intron getIntron() {
   if (marker != null) {
     if (marker instanceof Intron) return (Intron) marker;
     return (Intron) marker.findParent(Intron.class);
   }
   return null;
 }
コード例 #3
0
ファイル: VariantEffect.java プロジェクト: Tmacme/SnpEff
 public Gene getGene() {
   if (marker != null) {
     if (marker instanceof Gene) return (Gene) marker;
     return (Gene) marker.findParent(Gene.class);
   }
   return null;
 }
コード例 #4
0
ファイル: VariantEffect.java プロジェクト: Tmacme/SnpEff
 /** Get exon (if any) */
 public Exon getExon() {
   if (marker != null) {
     if (marker instanceof Exon) return (Exon) marker;
     return (Exon) marker.findParent(Exon.class);
   }
   return null;
 }
コード例 #5
0
  /**
   * Add into to a hash
   *
   * @param hits
   * @param marker
   * @param hit2add
   * @param showGeneDetails
   * @param compareTemplate
   */
  void regionsAddHit(
      HashSet<String> hits,
      Marker hit2add,
      Marker marker,
      boolean showGeneDetails,
      boolean compareTemplate) {
    String hitStr = hit2add.getClass().getSimpleName();

    if (compareTemplate) {
      Gene gene = (Gene) hit2add.findParent(Gene.class);
      if (gene != null)
        hitStr +=
            (hit2add.isStrandPlus() == marker.isStrandPlus())
                ? "_TEMPLATE_STRAND"
                : "_NON_TEMPLATE_STRAND";
    }

    if (showGeneDetails && (hit2add instanceof Gene)) {
      Gene gene = (Gene) hit2add;
      hitStr +=
          "["
              + gene.getBioType()
              + ", "
              + gene.getGeneName()
              + ", "
              + (gene.isProteinCoding() ? "protein" : "not-protein")
              + "]";
    }

    hits.add(hitStr); // Add marker name to the list
  }
コード例 #6
0
  /**
   * Name of the regions hit by a marker
   *
   * @param marker
   * @param showGeneDetails
   * @param compareTemplate
   * @param id : Only use genes or transcripts matching this ID
   * @return
   */
  public Set<String> regions(
      Marker marker, boolean showGeneDetails, boolean compareTemplate, String id) {
    if (Config.get().isErrorOnMissingChromo() && isChromosomeMissing(marker))
      throw new RuntimeEOFException("Chromosome missing for marker: " + marker);

    boolean hitChromo = false;
    HashSet<String> hits = new HashSet<String>();

    Markers intersects = query(marker);
    if (intersects.size() > 0) {
      for (Marker markerInt : intersects) {

        if (markerInt instanceof Chromosome) {
          hitChromo = true; // OK (we have to hit a chromosome, otherwise it's an error
          hits.add(markerInt.getClass().getSimpleName()); // Add marker name to the list
        } else if (markerInt instanceof Gene) {
          // Analyze Genes
          Gene gene = (Gene) markerInt;
          regionsAddHit(hits, gene, marker, showGeneDetails, compareTemplate);

          // For all transcripts...
          for (Transcript tr : gene) {
            if ((id == null)
                || gene.getId().equals(id)
                || tr.getId().equals(id)) { // Mathes ID? (...or no ID to match)

              // Does it intersect this transcript?
              if (tr.intersects(marker)) {
                regionsAddHit(hits, tr, marker, showGeneDetails, compareTemplate);

                // Does it intersect a UTR?
                for (Utr utr : tr.getUtrs())
                  if (utr.intersects(marker))
                    regionsAddHit(hits, utr, marker, showGeneDetails, compareTemplate);

                // Does it intersect an exon?
                for (Exon ex : tr)
                  if (ex.intersects(marker))
                    regionsAddHit(hits, ex, marker, showGeneDetails, compareTemplate);

                // Does it intersect an intron?
                for (Intron intron : tr.introns())
                  if (intron.intersects(marker))
                    regionsAddHit(hits, intron, marker, showGeneDetails, compareTemplate);
              }
            }
          }
        } else {
          // No ID to match?
          if (id == null) regionsAddHit(hits, markerInt, marker, showGeneDetails, compareTemplate);
          else {
            // Is ID from transcript?
            Transcript tr = (Transcript) markerInt.findParent(Transcript.class);
            if ((tr != null) && (tr.getId().equals(id))) {
              regionsAddHit(
                  hits,
                  markerInt,
                  marker,
                  showGeneDetails,
                  compareTemplate); // Transcript ID matches => count
            } else {
              // Is ID from gene?
              Gene gene = (Gene) markerInt.findParent(Gene.class);
              if ((gene != null) && (gene.getId().equals(id)))
                regionsAddHit(
                    hits,
                    markerInt,
                    marker,
                    showGeneDetails,
                    compareTemplate); // Gene ID matches => count
            }
          }
        }
      }
    }

    if (!hitChromo) throw new RuntimeException("ERROR: Out of chromosome range. " + marker);
    return hits;
  }