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 throw new IllegalArgumentException("NCBI LocusLink was replaced by Entrez Gene " + 069 "in 2005. NCBI no longer provides LocusLink, and has also discontinued its URL redirect service."); 070 } 071 } 072 073 public String getbaseURL() { 074 if (db.equalsIgnoreCase("Genbank") || db.equalsIgnoreCase("nucleotide") 075 || db.equalsIgnoreCase("Genpept") || db.equalsIgnoreCase("protein") 076 || db.equalsIgnoreCase("pubmed")) { 077 baseURL = "https://www.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?"; 078 } else if (db.equalsIgnoreCase("Swiss-prot")) { 079 baseURL = "http://us.expasy.org/cgi-bin/get-sprot-raw.pl?"; 080 } 081 return baseURL; 082 } 083 084 // Get the database name */ 085 public String getDB() { 086 return ("db=" + db); 087 } 088 089 //get the return format and type 090 public String getReturnFormat() { 091 return ("rettype=" + rettype + "&retmode=" + retmode); 092 } 093 094 /** Get the retrieval type */ 095 public String getRetrievalType() { 096 return rettype; 097 } 098 099 /** Get the retrieval mode */ 100 public String getRetrievalMode() { 101 return retmode; 102 } 103}