2 /* copyright (c) 1998, 1999 William R. Pearson and the
5 /* $Name: fa_34_26_5 $ - $Id: url_subs.c,v 1.9 2006/08/20 18:18:33 wrp Exp $ */
7 /* 30 Dec 2004 - modify REF_URL to accomodate current Entrez */
18 #define DEF_PROT_LIB "q"
22 #define FASTA_HOST "your.fasta.host.here/fasta/cgi"
25 void do_url1(FILE *fp, struct mngmsg m_msg, struct pstruct pst,
26 char *l_name, int n1, struct a_struct aln, long loffset)
30 char pgm[10], lib[MAX_FN];
31 char *ref_url, *lbp=NULL;
32 char *srch_url, *srch_url1;
34 if (m_msg.ldnaseq==SEQT_DNA) db="nucleotide";
37 if (strncmp(m_msg.f_id0,"rss",3)==0) {
38 strncpy(pgm,"fa",sizeof(pgm));
40 else if (strncmp(m_msg.f_id0,"rfx",3)==0) {
41 strncpy(pgm,"fx",sizeof(pgm));
43 else { strncpy(pgm,m_msg.f_id0,sizeof(pgm)); }
45 if (m_msg.lname[0]!='%') {
46 strncpy(lib,m_msg.lname,sizeof(lib));
49 strncpy(lib,"%25",sizeof(lib));
50 strncat(lib,&m_msg.lname[1],sizeof(lib));
52 lib[sizeof(lib)-1]='\0';
54 strncpy(my_l_name,l_name,sizeof(my_l_name));
55 my_l_name[sizeof(my_l_name)-1]='\0';
57 if (pgm[0]=='t' || strcmp(pgm,"fx") || strcmp(pgm,"fy")==0 ) {
58 if ((lbp=strchr(my_l_name,':'))!=NULL) *lbp='\0';
59 lbp = &my_l_name[strlen(my_l_name)-2];
60 if ( *lbp == '_' ) *lbp = '\0';
63 /* change the program name for fastx, tfastx, tfasta */
64 /* fastx returns proteins */
65 if (strcmp(pgm,"fx")==0 || strcmp(pgm,"fy")==0) strncpy(pgm,"fa",sizeof(pgm));
66 else if (strcmp(pgm,"ff")==0) strncpy(pgm,"fa",sizeof(pgm));
67 else if (pgm[0]=='t') {
68 strncpy(pgm,"fx",sizeof(pgm));
69 strncpy(lib,DEF_PROT_LIB,sizeof(lib));
73 if ((ref_url = getenv("REF_URL"))==NULL)
74 fprintf(fp,"<A HREF=\"http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=%s&fcmd=Search&doptcmd1=DocSum&term=%s\">Entrez lookup</A> ",
77 fprintf(fp,ref_url,db,my_l_name);
79 if ((srch_url = getenv("SRCH_URL"))==NULL)
80 fprintf(fp,"<A HREF=\"http://%s/searchfa.cgi?query=%s&db=%s&lib=%s&pgm=%s&start=%ld&stop=%ld&n1=%d\">Re-search database</A> ",
81 FASTA_HOST,my_l_name,db,lib,pgm,
82 loffset+aln.amin1+1,loffset+aln.amax1,n1);
84 fprintf(fp,srch_url,my_l_name,db,lib,pgm,
85 loffset+aln.amin1+1,loffset+aln.amax1,n1);
87 if ((srch_url1 = getenv("SRCH_URL1"))==NULL)
88 fprintf(fp,"<A HREF=\"http://%s/searchxf.cgi?query=%s&db=%s&lib=%s&pgm=%s&start=%ld&stop=%ld&n1=%d\">General re-search</A>\n<p>\n",
89 FASTA_HOST,my_l_name,db,lib,pgm,
90 loffset+aln.amin1+1,loffset+aln.amax1,n1);
92 fprintf(fp,srch_url1,my_l_name,db,lib,pgm,
93 loffset+aln.amin1+1,loffset+aln.amax1,n1);
96 if (lbp!=NULL) *lbp = '_';
99 if ((srch_url2 = getenv("SRCH_URL2"))==NULL)
100 fprintf(fp,"<A HREF=\"http://fasta.bioch.virginia.edu/fasta/cgi/lalignx.cgi?seq1=\"%s\"&in_seq1=\"FASTA\"&seq2=\"%s\"&in_seq2=\"Accession\"&ssr2=%ld:%ld\">lalign</A>\n<p>\n",my_l_name,db,lib,pgm,loffset+aln.amin1+1,loffset+aln.amax1,n1);
102 fprintf(fp,srch_url1,my_l_name,db,lib,pgm,
103 loffset+aln.amin1+1,loffset+aln.amax1,n1);