001/* 002 * BioJava development code 003 * 004 * This code may be freely distributed and modified under the 005 * terms of the GNU Lesser General Public Licence. This should 006 * be distributed with the code. If you do not have a copy, 007 * see: 008 * 009 * http://www.gnu.org/copyleft/lesser.html 010 * 011 * Copyright for this code is held jointly by the individual 012 * authors. These should be listed in @author doc comments. 013 * 014 * For more information on the BioJava project and its aims, 015 * or to join the biojava-l mailing list, visit the home page 016 * at: 017 * 018 * http://www.biojava.org/ 019 * 020 */ 021/** 022 * This class stores base URL and some cgi arguments for 023 * accessing web-based sequences in NCBI and Swiss-prot, pubmed articles and locuslinks. 024 */ 025 026package org.biojava.bio.seq.db; 027 028 029/** 030 * @author Lei Lai 031 * @author Thomas Down 032 * @author Matthew Pocock 033 * @author George Waldon 034 */ 035public class FetchURL { 036 037 String baseURL; 038 String db;//database name 039 String rettype;//return type 040 String retmode;//return mode 041 042 /** 043 * Constructs a fetchURL object based on the database name 044 * and specified return format of sequence. 045 */ 046 public FetchURL(String databaseName, String format) { 047 if (databaseName.trim().equalsIgnoreCase("genbank") 048 || databaseName.trim().equalsIgnoreCase("nucleotide")) { 049 db = "nucleotide"; 050 rettype = "gb"; 051 retmode = format; // text or xml 052 } else 053 if (databaseName.trim().equalsIgnoreCase("genpept") 054 || databaseName.trim().equalsIgnoreCase("protein")) { 055 db = "protein"; 056 rettype = "gp"; 057 retmode = format; // text or xml 058 } else 059 if (databaseName.trim().equalsIgnoreCase("swiss-prot")) { 060 db = "swiss-prot"; 061 } else 062 if (databaseName.trim().equalsIgnoreCase("pubmed")) { 063 db = "pubmed"; 064 rettype = "abstract"; 065 retmode = format; 066 } else 067 if (databaseName.trim().equalsIgnoreCase("locuslink")) { 068 db = "locuslink"; 069 } 070 } 071 072 public String getbaseURL() { 073 if (db.equalsIgnoreCase("Genbank") || db.equalsIgnoreCase("nucleotide") 074 || db.equalsIgnoreCase("Genpept") || db.equalsIgnoreCase("protein") 075 || db.equalsIgnoreCase("pubmed")) { 076 baseURL = "http://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?"; 077 } else if (db.equalsIgnoreCase("Swiss-prot")) { 078 baseURL = "http://us.expasy.org/cgi-bin/get-sprot-raw.pl?"; 079 } else if (db.equalsIgnoreCase("LocusLink")) { 080 baseURL = "http://www.ncbi.nlm.nih.gov/LocusLink/LocRpt.cgi?"; 081 } 082 083 return baseURL; 084 } 085 086 // Get the database name */ 087 public String getDB() { 088 return ("db=" + db); 089 } 090 091 //get the return format and type 092 public String getReturnFormat() { 093 return ("rettype=" + rettype + "&retmode=" + retmode); 094 } 095 096 /** Get the retrieval type */ 097 public String getRetrievalType() { 098 return rettype; 099 } 100 101 /** Get the retrieval mode */ 102 public String getRetrievalMode() { 103 return retmode; 104 } 105}