コード例 #1
0
  /* Need to special-case some URLs.  It's yucky to do this,
   * but that's the only way this will work for some of the Drosophila
   * result types.  The assumption in the code is that there is one URL
   * per type, but for us it depends on which database the hit is on. */
  protected String getURLPrefix(FeatureProperty prop, SeqFeatureI f, String id) {
    String defaultURL = prop.getURLString();

    if (!(f instanceof FeaturePair)) return (defaultURL);

    FeaturePair fp = (FeaturePair) f;
    SeqFeatureI fs = (SeqFeatureI) fp.getRefFeature();
    String database = fs.getDatabase();

    String url = defaultURL;

    /* Here we go--a bunch of special cases.
     * It sucks that these are in the code--
     * these should be in the style file or something! */
    String nucleotide = "nucleotide";
    String protein = "protein";
    String ENTREZ_N =
        "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&db="
            + nucleotide
            + "&doptcmdl=GenBank&term=";
    String ENTREZ_P =
        "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=search&db="
            + protein
            + "&doptcmdl=GenBank&term=";
    // In most cases, the IDs for BLASTX Similarity to Fly seem to work better
    // with the default SWALL URL; however, the AA ones seem not to be in SWALL
    // and we have to look in Entrez.  Yuck.
    //    if (prop.typeEquals("BLASTX Similarity to Fly") && id.startsWith("AA")) {
    if (prop.getDisplayType().startsWith("BLASTX") && id.startsWith("AA")) {
      url = ENTREZ_P;
    } else if (prop.typeEquals("Rodent") && (database.indexOf("unigene") >= 0)) {
      url = ENTREZ_N;
    } else if (prop.typeEquals("Insect") && (database.indexOf("dbEST") >= 0)) {
      url = ENTREZ_N;
    }
    // This isn't working right yet.  The tRNA ids look like:
    // gb|AE002593|AE002593.trna5-ArgTCG
    // and we want just the part between the first two ||s.
    else {
      String acc;
      if (prop.typeEquals("tRNA-result") && (database.indexOf("na_tRNA.dros") >= 0)) {
        acc = id.substring(id.indexOf("|") + 1);
        acc = acc.substring(0, acc.indexOf("|"));
      } else if (prop.typeEquals("New Fly Sequence")) {
        // These accs look like gi||gb|AY135216|AY135216
        acc = id;
        if (acc.indexOf("|") >= 0) acc = acc.substring(acc.lastIndexOf("|") + 1);

        /* We've already appended the correct acc,
         * but the URL constructor will automatically
         * slap the uncorrected one at the end.
         * The last # is so that when the whole ID is appended at the end, it
         * won't have any effect. */
        url = ENTREZ_N + acc + "#";
      }
    }
    return url;
  }
コード例 #2
0
  protected String getIdForURL(SeqFeatureI f) {
    /* 02/06/2004: If user selected a whole result (a FeatureSet),
     * neither the id nor the name is what we want.
     * So just look at the first child of the FeatureSet
     * (which is probably a FeaturePair).  Is this bad?  --NH */
    if (f instanceof FeatureSet) {
      f = ((FeatureSet) f).getFeatureAt(0);
    }
    String id;
    if (f instanceof FeaturePair) {
      FeaturePair fp = (FeaturePair) f;
      SeqFeatureI sbjct = (SeqFeatureI) fp.getHitFeature();
      id = sbjct.getName();
      if (id.equals("") || id.equals("no_name")) id = f.getName();
      //      System.out.println("getIdForURL: for feature pair " + f.getName() + ", subject name =
      // " + id); // DEL
    } else {
      id = getDisplayName(f);
      //      System.out.println("getIdForURL: for feature " + f.getName() + ", display name = " +
      // id); // DEL
    }
    // Special case:  BDGP EST IDs look like "LD18592.5prime" rather than "LD18592",
    // which isn't what we want.  Need to leave out the .[53]prime part.
    // (Sima says there aren't any cases where we'd want to preserve that part.)
    if (id.endsWith(".3prime") || id.endsWith(".5prime")) {
      //      System.out.println("Truncating EST/cDNA ID " + id + " to remove .[35]prime");
      id = id.substring(0, id.lastIndexOf("."));
    }
    // Some ESTs IDs have :contig1 at the end
    if (id.indexOf(":contig") > 0) {
      id = id.substring(0, id.indexOf(":contig"));
      // In r4.1, I see EST IDs like UNKNOWN_RE01983:contig1 and INVERTED_GH07123:contig1
      if (id.indexOf("_") > 0) id = id.substring(id.indexOf("_") + 1);
    }
    // Some ESTs have _revcomp at the end, e.g. BE975849_revcomp
    if (id.indexOf("_revcomp") > 0) id = id.substring(0, id.indexOf("_revcomp"));

    return id;
  }