1
/* ===========================================================================
4
* National Center for Biotechnology Information
6
* This software/database is a "United States Government Work" under the
7
* terms of the United States Copyright Act. It was written as part of
8
* the author's official duties as a United States Government employee and
9
* thus cannot be copyrighted. This software/database is freely available
10
* to the public for use. The National Library of Medicine and the U.S.
11
* Government have not placed any restriction on its use or reproduction.
13
* Although all reasonable efforts have been taken to ensure the accuracy
14
* and reliability of the software and data, the NLM and the U.S.
15
* Government do not and cannot warrant the performance or results that
16
* may be obtained by using this software or data. The NLM and the U.S.
17
* Government disclaim all warranties, express or implied, including
18
* warranties of performance, merchantability or fitness for any particular
21
* Please cite the author in any work or product based on this material.
23
* ===========================================================================
25
* File Name: vastsrv.c
27
* Author: Christopher Hogue, Tom Madej
29
* Version Creation Date: 10 March 1998
32
* Revision 6.26 2000/12/06 20:58:53 lewisg
33
* change cn3d 2.5 string
35
* Revision 6.25 2000/06/23 22:35:58 lewisg
36
* get rid of hardcoded urls
38
* Revision 6.24 1999/10/14 14:03:27 zimmerma
39
* DZ: changed exit status to 0 when WWWargs is empty - see line 1402
40
* This was done to prevent error reports being generated by wrapper script.
42
* Revision 6.23 1999/10/13 20:15:56 zimmerma
43
* DZ: Removed use of temporary files - html output redirected to stdout
45
* Revision 6.22 1999/07/30 19:46:27 addess
46
* more changes to ValidateMMDBID by Diane and Ken
48
* Revision 6.21 1999/07/29 20:56:02 addess
49
* added ValidateMMDBID() to determine if MMDBID from neighbor is live
51
* Revision 6.20 1999/07/21 17:25:36 addess
52
* changed printout from Cn3D v2.0 to Cn3D v2.5
54
* Revision 6.19 1999/05/13 16:31:58 kimelman
57
* Revision 6.18 1999/05/11 20:34:14 kimelman
60
* Revision 6.17 1999/05/07 14:02:13 zimmerma
61
* Removed local copy of MMDBBiostrucGet
63
* Revision 6.16 1999/02/09 15:14:00 addess
64
* Modified by DZ to extract html path dependencies:
65
* - created two new static Char vars: DATApath and VASTpath - read by GetAppParam -
66
* and modified .vastrc to include these new vars.
67
* - created text file getCn3D.txt in data directory - used by WWWPrintFileData
69
* Revision 6.15 1998/12/22 18:01:51 addess
70
* changes relevant to reading new type of annot-set data
72
* Revision 6.14 1998/12/01 15:12:56 addess
73
* removed unused variable pbsaShort
75
* Revision 6.13 1998/11/20 20:03:08 addess
76
* related to platform independence of VAST Search
78
* Revision 6.12 1998/10/23 19:48:50 addess
81
* Revision 6.11 1998/10/21 14:07:13 addess
82
* add error statement related to NR subset filtering
84
* Revision 6.10 1998/10/14 17:12:54 addess
85
* pagination and aligned chain
87
* Revision 6.9 1998/08/06 17:48:52 madej
88
* Fix Display/Show hits button for Vast Search.
90
* Revision 6.8 1998/07/27 16:08:15 madej
91
* Minor change having to do with gifs.
93
* Revision 6.7 1998/07/17 18:48:14 madej
94
* Miscellaneous changes.
96
* Revision 6.6 1998/06/11 19:13:57 madej
97
* Modifications to html.
99
* Revision 6.5 1998/05/19 20:26:13 madej
100
* Comment out VastViewAlign feature.
102
* Revision 6.4 1998/05/19 20:17:12 madej
103
* Add general WWW routines for running on Sun servers.
105
* Revision 6.3 1998/03/30 19:11:50 madej
106
* Added subset filtering, changes to neighbor page layout.
108
* Revision 6.2 1998/03/16 17:59:59 lewisg
109
* added temporary hooks to communicate to cn3d
111
* Revision 6.1 1998/03/10 16:29:12 madej
112
* First official version of vastsrv.c
118
/* Main program for VAST structure neighbor server. */
120
/* define DEBUG_1 1 */
127
#include <sys/resource.h>
129
#include <accutils.h>
131
#include "vastlocl.h"
132
#include "mmdblocl.h"
133
#include "mmdbdata.h"
138
#define CPUTIME_MAX 120
140
#define MAX_MMDBIDS 4096
141
#define DEFAULT_SUBSET_NUM 2 /* default to the NR set BLAST 10e-7 */
142
#define ABRIDGED_DISPLAY 0 /* display only Rmsd, Nres, %Id */
143
#define FULL_DISPLAY 1 /* display all columns in table */
144
#define SORT_BY_SCORE 1 /* sort table by Score */
145
#define SORT_BY_PVAL 2 /* sort table by P-value */
146
#define SORT_BY_RMSD 3 /* sort table by Rmsd */
147
#define SORT_BY_NRES 4 /* sort table by Nres */
148
#define SORT_BY_ID 5 /* sort table by %Id */
149
#define VIEW_ALIGNMENT 4 /* selects action "View Alignment" */
150
#define LOG10_500 2.69897 /* -log10(500); database size correction */
151
#define LOG_10 2.302585 /* log(10.0) */
152
#define NUM_HITS_PER_PAGE 20
153
#define DEFAULT_PAGE 1
155
static Char URLBase[PATH_MAX];
156
static Char URLcgi[PATH_MAX];
157
static Char DATApath[PATH_MAX];
158
static Char VASTpath[PATH_MAX];
159
static Char ENTREZurl[PATH_MAX];
160
static Char DOCSUMurl[PATH_MAX];
161
static Char MAILto[PATH_MAX];
162
static FILE *OutputFile = NULL;
163
static char OutputName[200];
164
static Char gunzip[PATH_MAX];
165
static Char MMDBpath[PATH_MAX];
166
static Char CGIname[PATH_MAX];
167
static Char MMDBCGIname[PATH_MAX];
168
static Int2 SortOn = 0;
169
static Int4 cnt_MMDBid;
170
static long save_MMDBid[MAX_MMDBIDS];
172
Char VSPATH[PATH_MAX];
177
VnpHeapSort (ValNodePtr PNTR vnp, int (LIBCALLBACK *compar )PROTO ((Nlm_VoidPtr, Nlm_VoidPtr )))
181
ValNodePtr PNTR temp;
184
for (vnp1 = *vnp; vnp1; vnp1=vnp1->next)
187
temp = (ValNodePtr PNTR) MemNew(total*sizeof(ValNodePtr));
190
for (vnp1 = *vnp; vnp1; vnp1=vnp1->next)
196
HeapSort ((VoidPtr) temp, (size_t) index, sizeof(ValNodePtr), compar);
199
for (vnp1 = *vnp, index=0; index<(total-1); vnp1=vnp1->next, index++)
201
vnp1->next = temp[index+1];
203
vnp1 = temp[total-1];
206
temp = MemFree(temp);
211
/* Common code for the vastsrv page header is collected here. This generates the html for
212
* the title bar, the domain name, and the defline.
216
VastPageHeader(FILE *table, CharPtr pcPDB, Char cChain, int iDomain, Int4 iMMDBid, CharPtr JobID)
220
fprintf(table, "Content-type: text/html\n\n");
221
fprintf(table, "<html><title>Vast Results</title>\n");
222
fprintf(table, "<body bgcolor = \"ffffff\">\n");
223
fprintf(table, "<img src=\"%s/vast2.gif\" alt=\"VAST Structure Neighbors\" usemap=#map ISMAP>\n", VASTpath);
224
fprintf(table, "<map name=map>\n");
225
fprintf(table, "<area shape=rect coords=4,5,42,18 href=\"http://www.ncbi.nlm.nih.gov\">\n");
226
fprintf(table, "<area shape=rect coords=43,3,438,18 href=\"%s/vast.html\">\n", VASTpath);
227
fprintf(table, "<area shape=rect coords=439,3,485,18 href=\"%s\">\n", ENTREZurl);
228
fprintf(table, "<area shape=rect coords=490,3,507,18 href=\"%s/vasthelp.html\">\n", VASTpath);
229
fprintf(table, "</map><p>\n");
230
fprintf(table, "\n\n<HR SIZE=5 NOSHADE>\n");
233
fprintf(table, "<h1>Structures similar to MMDB\n");
234
fprintf(table, "<a href=\"%s%s?uid=%s", URLcgi, MMDBCGIname, pcPDB);
235
fprintf(table, "&form=6&db=t&Dopt=s\">\n%d</a>", (long)iMMDBid);
236
fprintf(table, ", \n");
240
fprintf(table, "<h1>Structures similar to VAST Search\n");
241
fprintf(table, " %s\n", JobID);
242
fprintf(table, ", \n");
244
fprintf(table, "%s", pcPDB);
247
fprintf(table, " chain %c", cChain);
250
fprintf(table, " domain %d", (int) iDomain);
252
fprintf(table, "</h1>\n");
253
dsp = NetDocSum(TYP_ST, (DocUid) iMMDBid);
257
fprintf(table, "%s\n", dsp->title);
262
} /* end VastPageHeader */
265
/************************** DZ: extracted from mmdbsrv.c ************************
266
* WWWPrintFileData looks in the current CGI-BIN directory
267
* or the "data" subdirectory for the data file.
268
* and prints it out to pFile
271
static void WWWPrintFileData(CharPtr FName, FILE *pFile)
275
Char fullpath [PATH_MAX];
280
StringCpy(fullpath, DATApath); /* look in DATApath */
281
StringCat(fullpath, FName);
282
f = FileOpen (fullpath, "r");
284
f = FileOpen (FName, "r"); /* look in curent */
285
if (f == NULL) { /* look in ./data/ */
286
ProgramPath (fullpath, sizeof (fullpath) - 1);
287
ptr = StringRChr (fullpath, DIRDELIMCHR);
291
FileBuildPath (fullpath, "data", FName);
292
f = FileOpen (fullpath, "r");
301
ptr = fgets(pcBuf, (size_t)1024, f);
302
if (ptr) fprintf(pFile, ptr);
310
/* Note: A lot of this common html text could be put into a header file, read in, and then
311
* spewed out. Cf. the way this is done in mmdbsrv with WWWPrintFile. Sometime I'll take
312
* the time to write a more general version of the latter function that can be used for this
317
DZ: most of the HTML file URLs are inside the new VAST subdirectory, and references to these
318
are interwoven with many query-specific references. Becasue of this interleaving, using
319
WWWPrintFileData would require several invocations and corresponding text files. Instead.
320
WWWPrintFileData is only used to define the new path to CN3D, and all vast html references
321
are now prefixed with the VASTpath string. This variable has been added to .vastrc and to
322
the list of parameters to be extracted using GetVastParams.
326
VastTableBegin (FILE *table, CharPtr pcPDB, CharPtr JobID, CharPtr pcPass,
327
Char cChain, int iDomain, Int4 iMMDBid, Int4 iFSID,
328
Int2 iFull, Int4 numhits, Int4 upper, Int4 lower, Int4 numpages, Int4 HitsPerPage, Int4 pagenum)
332
VastPageHeader(table, pcPDB, cChain, iDomain, iMMDBid, JobID);
333
fprintf(table,"<FORM METHOD=\"POST\" ACTION=\"%s%s\">\n", URLcgi, CGIname);
334
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"uid\" VALUE=\"%ld\">\n", (long)iMMDBid);
335
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"chaindom\" VALUE=\"%ld\">\n", (long) iFSID);
338
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"vsid\" VALUE=\"%s\">\n", JobID);
339
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"pass\" VALUE=\"%s\">\n", pcPass);
342
fprintf(table, "<TABLE CELLPADDING=0 CELLSPACING=4>\n");
343
fprintf(table, "<TR><TH COLSPAN=2 ALIGN=LEFT>\n");
344
fprintf(table, "<strong><INPUT TYPE=SUBMIT VALUE=\"View / Save Alignments\"></strong>\n");
345
fprintf(table, " <img src=\"%s/new.gif\" alt=\"New\">\n", VASTpath);
346
WWWPrintFileData("getCn3D.txt", table);
347
fprintf(table, "</TH></TR>");
348
fprintf(table, "<tr><td colspan = 1><strong>Options:</strong></td>\n");
349
fprintf(table, "<td colspan = 1><strong>Viewer:</strong></td>\n");
350
fprintf(table, "<td colspan = 2><strong>Complexity:</strong></td></tr>\n");
351
/*fprintf(table, "<td colspan = 1><strong>Cn3D Atom Complexity:</strong></td></tr>\n");*/
352
fprintf(table,"<TD VALIGN=TOP NOWRAP>\n");
353
fprintf(table,"<INPUT TYPE=\"radio\" NAME=\"action\" value=\"0\"CHECKED> Launch Viewer<BR>\n");
354
fprintf(table,"<INPUT TYPE=\"radio\" NAME=\"action\" value=\"1\"> See File<BR>\n");
355
fprintf(table,"<INPUT TYPE=\"radio\" NAME=\"action\" value=\"2\"> Save File<BR></TD>\n");
356
fprintf(table,"<TD VALIGN=TOP NOWRAP>\n");
357
fprintf(table,"<INPUT TYPE=\"radio\" NAME=\"calltype\" value=\"a\"CHECKED> Cn3D (asn.1)<BR>\n");
358
fprintf(table,"<INPUT TYPE=\"radio\" NAME=\"calltype\" value=\"m\"> Mage (Kinemage)<BR>\n");
359
fprintf(table,"<INPUT TYPE=\"radio\" NAME=\"calltype\" value=\"p\"> (PDB)<BR></TD>\n");
360
fprintf(table, "<TD VALIGN=TOP NOWRAP>\n");
361
fprintf(table, "<INPUT TYPE=\"radio\" NAME=\"chn_complexity\" value=\"1\"CHECKED> Aligned Chains only<BR>\n");
362
fprintf(table, "<INPUT TYPE=\"radio\" NAME=\"chn_complexity\" value=\"0\"> All Chains<BR></TD>\n");
363
fprintf(table, "<TD VALIGN=TOP NOWRAP>\n");
364
fprintf(table, "<INPUT TYPE=\"radio\" NAME=\"atm_complexity\" value=\"1\"CHECKED> Alpha Carbons only<BR>\n");
365
fprintf(table, "<INPUT TYPE=\"radio\" NAME=\"atm_complexity\" value=\"0\"> All Atoms<BR></TD>\n");
366
fprintf(table, "</TR>\n</TABLE>\n");
368
DisplayOpt = upper - lower;
371
fprintf(table, "<H4>Structure neighbor %d out of %d displayed. ", lower, numhits);
373
fprintf(table, "<H4>Structure neighbors %d-%d out of %d displayed. ", lower, upper, numhits);
374
fprintf(table, "Page %d of %d.</H4>\n", pagenum, numpages);
376
/* VAST data table begins here */
378
fprintf(table,"<table cellspacing=3 cellpadding=2 width=100%% border=1>\n");
379
fprintf(table,"<tr valign=middle>\n");
380
fprintf(table,"<th> </th>\n");
381
fprintf(table,"<th align=left><pre> <a href=\"%s/vasthelp.html#Structure\">PDB</a>", VASTpath);
382
fprintf(table," <a href=\"%s/vasthelp.html#C\">C</a>", VASTpath);
383
fprintf(table," <a href=\"%s/vasthelp.html#D\">D</a></pre></th>\n", VASTpath);
386
fprintf(table,"<th align=right><pre><a href=\"%s/vasthelp.html#SCORE\">SCO</a></pre></th>\n", VASTpath);
387
fprintf(table,"<th align=right><pre><a href=\"%s/vasthelp.html#P-VAL\">P-VAL</a></pre></th>\n", VASTpath);
390
fprintf(table,"<th align=right><pre><a href=\"%s/vasthelp.html#RMSD\">RMSD</a></pre></th>\n", VASTpath);
391
fprintf(table,"<th align=right><pre><a href=\"%s/vasthelp.html#NRES\">NRES</a></pre></th>\n",VASTpath);
392
fprintf(table,"<th align=right><pre><a href=\"%s/vasthelp.html#Id\">%s</a></pre></th>\n", VASTpath, "%Id");
393
fprintf(table,"<th align=left><pre><a href=\"%s/vasthelp.html#Contents\">Description</pre></th>\n",VASTpath);
394
fprintf(table,"</tr><br>\n");
397
} /* end of VastTableBegin */
400
static Boolean ValidateMMDBID(CharPtr pcAccession, Int4 iMMDBid)
404
uid = MMDBEvalPDB(pcAccession);
405
if ((Int4)uid == iMMDBid) return TRUE;
412
VastTableRows(FILE *table, BiostrucFeatureSetPtr pbsfs, Int4 iMMDBid1, Int4 iFSID, Int2 iFull, ValNodePtr pvnBools)
414
BiostrucFeaturePtr pbsf = NULL;
415
ChemGraphAlignmentPtr pcga = NULL;
416
BiostrucIdPtr pbsidThis = NULL;
417
AlignStatsPtr pasp = NULL;
418
ValNodePtr pvn = NULL;
419
DocSumPtr dsp = NULL;
429
/* use cnt_MMDBid and save_MMDBid[] for docsum display of the correct subset hits */
432
for (pbsf = pbsfs->features; pbsf != NULL || pvnBools != NULL ; pbsf = pbsf->next, pvnBools = pvnBools->next) {
433
/* Filter Hits By Page*/
434
page = pvnBools->data.boolvalue;
435
if (page == FALSE) continue;
437
/* get the embedded PDB code of the hit */
438
pcPDB = StringSave(PDBNAME_DEFAULT);
440
if (pbsf->name[14] != '\0') pcSlaveName = StringSave(&pbsf->name[14]);
443
if (StringLen(pbsf->name) >= 13)
445
pcPDB[0] = pbsf->name[7];
446
pcPDB[1] = pbsf->name[8];
447
pcPDB[2] = pbsf->name[9];
448
pcPDB[3] = pbsf->name[10];
449
cChain = pbsf->name[11];
450
iDomain = atoi((char *) &pbsf->name[12]);
453
pvn = ValNodeFindNext(pbsf->Location_location,NULL,Location_location_alignment);
454
if (pvn) pcga = (ChemGraphAlignmentPtr) pvn->data.ptrvalue;
459
pbsidThis = ValNodeFindNext(pcga->biostruc_ids,NULL,BiostrucId_mmdb_id);
462
if (pbsidThis->next) /* want only the second one - the slave */
463
iMMDBid = (long) pbsidThis->next->data.intvalue;
467
/* save the MMDB id for later output for the docsum format */
468
if (cnt_MMDBid < MAX_MMDBIDS)
469
save_MMDBid[cnt_MMDBid++] = (long) iMMDBid;
471
/* PDB and Kinemage file generators */
473
fprintf(table, "(<a href=\"%s%s?calltype=p&uid=%ld&fid=%ld&fsid=%ld&pdb=1\">P</a>) ",
474
URLcgi, CGIname, (long) iMMDBid1, pbsf->id, iFSID);
475
fprintf(table, "(<a href=\"%s%s?calltype=m&uid=%ld&fid=%ld&fsid=%ld&pdb=1\">K</a>) ",
476
URLcgi, CGIname, (long) iMMDBid1, pbsf->id, iFSID);
478
/* Please do not delete. for testing. lyg */
480
fprintf(table, "(<a href=\"%s%s?calltype=c&uid=%ld&fid=%ld&fsid=%ld&pdb=1\">C</a>) ",
481
URLcgi, CGIname, (long) iMMDBid1, pbsf->id, iFSID);
485
fprintf(table,"<a href=\"%s%s?uid=%ld&form=6&db=t&Dopt=s\">%ld</a></pre></td>\n",
486
MMDBCGIname, URLcgi, (long) iMMDBid, iMMDBid);
488
fprintf(table, "<tr>\n");
489
fprintf(table, "<td VALIGN=TOP><INPUT TYPE=\"checkbox\" NAME=\"hit\"");
490
fprintf(table, "VALUE=\"%ld\"></td>\n", (long) pbsf->id);
491
fprintf(table,"<td VALIGN=TOP><pre>");
492
fprintf(table, "<a href=\"%s%s?uid=%ld&form=6&db=t&Dopt=s\">%s</a>",
494
(long) iMMDBid, pcPDB);
497
fprintf(table, "  ");
499
fprintf(table, " <a href=\"%s%s?uid=%ld&form=6&db=t&Dopt=s\">%c</a>",
500
URLcgi, MMDBCGIname, (long) iMMDBid, cChain);
502
/* get the alignment number from the id */
503
iDomain = (int) (pbsf->id/10) % 100;
506
fprintf(table, " <a href=\"%s%s?uid=%ld&form=6&db=t&Dopt=s\">%d</a></pre></td>\n",
507
URLcgi, MMDBCGIname, (long) iMMDBid, iDomain);
509
fprintf(table, " </pre></td>\n");
511
/* dig into aligndata */
514
pasp = pcga->aligndata;
517
if (pasp->vast_score)
519
f = (FloatLo) pasp->vast_score;
520
f = f/(FloatLo) pasp->scale_factor;
521
fprintf(table,"<td VALIGN=top ALIGN=right>%.1f</td>\n",(float)f);
524
fprintf(table,"<td> </td>\n");
525
if (pasp->vast_mlogp)
527
f = (float) pasp->vast_mlogp;
528
f = f/(float) pasp->scale_factor;
530
/* adjust for database size */
534
f = (float) exp(-LOG_10*f);
535
fprintf(table, "<td VALIGN=top ALIGN=right>%.4f</td>\n", f);
538
fprintf(table,"<td VALIGN=top ALIGN=right>10e-%.1f</td>\n", f);
541
fprintf(table,"<td> </td>\n");
545
f = (FloatLo) pasp->rmsd;
546
f = f/(FloatLo) pasp->scale_factor;
547
fprintf(table,"<td VALIGN=top ALIGN=right>%.1f</td>\n",(float)f);
550
fprintf(table,"<td> </td>\n");
553
fprintf(table,"<td VALIGN=top ALIGN=center>%d</td>\n",(int) pasp->align_res);
556
fprintf(table,"<td> </td>\n");
557
if (pasp->other_score)
559
f = (FloatLo) pasp->other_score;
560
f = f/(FloatLo) pasp->scale_factor;
561
fprintf(table,"<td VALIGN=top ALIGN=right>%.1f</td>\n",(float)f * 100.0);
564
fprintf(table,"<td VALIGN=top ALIGN=right>0.0</td>\n");
568
fprintf(table, "<td> </td><td> </td><td> </td><td> </td><td> </td>\n");
571
/* get the Entrez docsum */
572
fprintf(table,"<td VALIGN=top>\n");
573
/* Names are read directly from Annot-set. DocSums are used no longer */
574
if(StringLen(pbsf->name) <= 13)
577
dsp = NetDocSum(TYP_ST, (DocUid) iMMDBid);
582
fprintf(table,"%s" , dsp->title);
596
fprintf(table,"%s" , pcSlaveName);
600
fprintf(table,"<BR>\n");
601
fprintf(table,"</td>\n</tr>\n");
604
MemFree(pcSlaveName);
608
} /* end of VastTableRows */
613
VastTableEnd(FILE *table, Int4 iMMDBid, Int4 FSID, BiostrucAnnotSetPtr pbsas, Int4 subsetnum,
614
Int4 iSort, Int2 iFull, CharPtr JobID, CharPtr pcPass, Int4 numpages, Int4 pagenum, Int4 HitsPerPage)
616
BiostrucFeatureSetPtr pbsfs = NULL;
617
BiostrucFeaturePtr pbsf = NULL;
618
ChemGraphAlignmentPtr pcga = NULL;
619
BiostrucIdPtr pbsidThis = NULL;
620
ValNodePtr pvn = NULL;
623
fprintf(table,"</table><hr>\n");
624
fprintf(table,"</form>\n\n");
625
fprintf(table,"<FORM METHOD=\"POST\" ACTION=\"%s%s\">\n", URLcgi, CGIname);
626
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"uid\" VALUE=\"%ld\">\n", (long) iMMDBid);
627
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"chaindom\" VALUE=\"%ld\">\n",(long) FSID);
630
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"vsid\" VALUE=\"%s\">\n", JobID);
631
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"pass\" VALUE=\"%s\">\n", pcPass);
633
fprintf(table, "<TABLE CELLPADDING=0 CELLSPACING=4>\n");
634
fprintf(table, "<TR><TD COLSPAN=3 ALIGN=LEFT> <strong><INPUT TYPE=SUBMIT VALUE=\"Display / Sort Hits\"></strong>\n");
635
fprintf(table, "     page number:\n");
636
fprintf(table, "<SELECT name=\"doclistpage\">\n");
638
for (i = 1; i<= numpages; i++) {
639
if (pagenum < numpages) {
641
fprintf(table,"<OPTION VALUE = \"%d\" SELECTED>%d\n", i, i);
643
fprintf(table,"<OPTION VALUE = \"%d\">%d\n", i, i);
647
fprintf(table,"<OPTION VALUE = \"%d\" SELECTED>%d\n", i, i);
649
fprintf(table,"<OPTION VALUE = \"%d\">%d\n", i, i);
653
fprintf(table, "</SELECT>\n");
654
fprintf(table, "  <small>Hits to display per page:\n");
655
fprintf(table, "<INPUT name = \"dispmax\" size=6 Value=%d> choose between 20-100 neighbors per page.</small></TD></TR>\n", HitsPerPage);
656
fprintf(table, "<TR>\n");
657
fprintf(table, "<TD><a href=\"%s/vasthelp.html#NRSet\"><strong>Display Subset:</strong></a></TD>\n", VASTpath);
658
fprintf(table, "<TD COLSPAN=1><strong>Sorted by:</strong></TD>\n");
659
fprintf(table, "<TD COLSPAN=1><strong>Column Format:</strong></TD>\n");
660
fprintf(table, "</TR>\n");
661
fprintf(table, "<TR><TD VALIGN=TOP NOWRAP>\n");
662
n = GetNumberOfSubsets();
664
/* subset 1 should be "All of PDB"; put it last */
665
for (i = 2; i <= n; i++) {
666
fprintf(table, "<INPUT TYPE=radio NAME=subset VALUE=\"%s\"", GetSubsetName(i));
669
fprintf(table, " CHECKED");
671
fprintf(table, "> %s<BR>\n", GetSubsetName(i));
674
fprintf(table, "<INPUT TYPE=radio NAME=subset VALUE=\"%s\"", GetSubsetName(1));
677
fprintf(table, " CHECKED");
679
fprintf(table, "> %s<BR>\n", GetSubsetName(1));
680
fprintf(table, "<TD VALIGN=TOP NOWRAP>\n");
681
fprintf(table, "<INPUT TYPE=radio NAME=sort VALUE=\"1\"");
682
if ((iSort == SORT_BY_SCORE) || (iSort == 0)) fprintf(table, " CHECKED");
683
fprintf(table, "> VAST Score<BR>\n");
684
fprintf(table, "<INPUT TYPE=radio NAME=sort VALUE=\"2\"");
685
if (iSort == SORT_BY_PVAL) fprintf(table, " CHECKED");
686
fprintf(table, "> VAST P-value<BR>\n");
687
fprintf(table, "<INPUT TYPE=radio NAME=sort VALUE=\"3\"");
688
if (iSort == SORT_BY_RMSD) fprintf(table, " CHECKED");
689
fprintf(table, "> Rmsd<BR>\n");
691
fprintf(table, "<TD VALIGN=TOP NOWRAP>\n");
693
fprintf(table, "<INPUT TYPE=radio NAME=sort VALUE=\"4\"");
694
if (iSort == SORT_BY_NRES) fprintf(table, " CHECKED");
695
fprintf(table, "> Aligned residues<BR>\n");
696
fprintf(table, "<INPUT TYPE=radio NAME=sort VALUE=\"5\"");
697
if (iSort == SORT_BY_ID) fprintf(table, " CHECKED");
698
fprintf(table, "> Identities<BR>\n");
699
fprintf(table, "<TD VALIGN=TOP NOWRAP>\n");
700
fprintf(table, "<INPUT TYPE=radio NAME=version VALUE=\"0\"");
701
if (iFull == ABRIDGED_DISPLAY) fprintf(table, " CHECKED");
702
fprintf(table, "> RMSD, NRES, %s<BR>\n", "%Id");
703
fprintf(table, "<INPUT TYPE=radio NAME=version VALUE=\"1\"");
704
if (iFull == FULL_DISPLAY) fprintf(table, " CHECKED");
705
fprintf(table, "> All values<BR>\n");
706
fprintf(table, "</TR>\n");
707
fprintf(table, "</TABLE>\n");
708
fprintf(table, "</FORM>\n");
710
/***** Removing docsum button:
711
fprintf(table,"<FORM METHOD=\"POST\" ACTION=\"%s/query\">\n", DOCSUMurl);
712
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"form\" VALUE=\"6\">\n");
713
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"db\" VALUE=\"t\">\n");
714
fprintf(table,"<INPUT TYPE=\"hidden\" NAME=\"uid\" VALUE=\"%ld,", (long) iMMDBid);
717
/* output the MMDB id's for the slaves */
718
/***** Removing docsum button:
719
if (cnt_MMDBid > 0) {
720
for (i = 0; i < cnt_MMDBid - 1; i++)
721
fprintf(table, "%ld,", save_MMDBid[i]);
723
fprintf(table, "%ld ", save_MMDBid[cnt_MMDBid - 1]);
726
fprintf(table,"\">\n");
727
fprintf(table,"<INPUT TYPE=\"submit\" VALUE=\"Display\"> table as an Entrez Document Summary form.</form>\n");
729
fprintf(table, "\n<HR SIZE=5 NOSHADE>\n");
730
fprintf(table,"</body></html>\n");
732
} /* end of VastTableEnd */
734
/* I decided to filter by domain subset first because it make writing the pagination code much easier Ken */
736
static BiostrucFeaturePtr FilterHitsByDomainSubset(BiostrucFeaturePtr pbsf, Int4 subsetnum)
738
BiostrucFeaturePtr current, pbsfHead = NULL, pbsfTail;
740
Int4 gn, gr, hcnt, *min_ranks, *group_num, *group_rank;
741
Char domid[DOMID_SIZE + 1], pdbcode[4+1];
743
/* The next bit of code is used for filtering the hit lists. When we go through a hit
744
* list we skip domains that do not belong to the subset of interest, or which belong to
745
* the subset but for which a group representative has already been encountered.
747
for (i = 0; i <= DOMID_SIZE; i++)
750
n = GetNumberOfDomains();
751
min_ranks = (Int4 *) MemNew(n*sizeof(Int4));
752
group_num = (Int4 *) MemNew(n*sizeof(Int4));
753
group_rank = (Int4 *) MemNew(n*sizeof(Int4));
755
/* use a first pass to "flag" the selected hits in the specified subset
756
If group_num[i] = 0 or group_rank[i] is larger than min_ranks[i],
757
then the ith neighbor should not be included in summary page */
759
if (group_rank != NULL) { /* check mem alloc */
761
for (i = 0; i < n; i++) { /* initializations */
763
min_ranks[i] = n + 1;
764
group_rank[i] = n + 1;
767
for (current = pbsf, hcnt = 0; current != NULL; current = current->next, hcnt++) {
768
/* copy domain identifier into domid[] */
769
domid[0] = current->name[7];
770
domid[1] = current->name[8];
771
domid[2] = current->name[9];
772
domid[3] = current->name[10];
773
domid[4] = current->name[11];
774
domid[5] = current->name[12];
776
if (domid[5] == '0') domid[5] = ' ';
778
/* if not in subset then skip over this domain */
779
if (BelongsToSubset(domid, subsetnum, &gn, &gr) <= 0) {
783
/* otherwise record group data for this hit */
784
group_num[hcnt] = gn;
785
group_rank[hcnt] = gr;
787
/* and reset minimum rank for this group */
788
if (gr < min_ranks[gn - 1])
789
min_ranks[gn - 1] = gr;
793
/* Now use the values just set in group_num, group_rank, and min_ranks
794
to decide whether or not the current neighbor should be linked
795
into the new feature list */
800
if (group_rank != NULL) /* check mem alloc */
802
if (group_num[hcnt] == 0) /* group_num not set so NOT in subset */
803
{ /* incr hcnt and do NOT link */
805
current = current->next;
809
gn = group_num[hcnt];
811
if (group_rank[hcnt] != min_ranks[gn - 1]) /* neighbor is in subset but of lower rank */
813
hcnt++; /* incr hcnt and do NOT link */
814
current = current->next;
819
/* With the new rcsb depositions we now need to validate mmdbids
820
in the .bas files. Extract pdbcode and use it with mmdbID to validate */
822
pdbcode[0] = current->name[7];
823
pdbcode[1] = current->name[8];
824
pdbcode[2] = current->name[9];
825
pdbcode[3] = current->name[10];
828
if (!ValidateMMDBID(pdbcode, (current->id)/100000)) {
830
current = current->next; /* incr hcnt and do NOT link */
834
if (pbsfHead == NULL) /* neighbor has passed all tests - include it! */
836
pbsfHead = BiostrucFeatureNew();
840
current = current->next;
841
pbsfTail->next = NULL;
845
pbsfTail->next = current;
848
current = current->next;
849
pbsfTail->next = NULL;
859
static ValNodePtr FilterHitsByPage(BiostrucFeatureSetPtr pbsfs, Int4 PageNum, Int4 HitsPerPage, Int4 *numhits, Int4 *numpages, Int4 *upper, Int4 *lower)
862
BiostrucFeaturePtr pbsf;
863
Int4 index, FidCount, RemainFids, CompleteFidSet;
864
Int4 UpperLimit, LowerLimit;
865
ValNodePtr pvnBools = NULL;
870
pbsf = pbsfs->features;
888
if (FidCount <= HitsPerPage)
892
RemainFids = FidCount % HitsPerPage;
896
CompleteFidSet = FidCount - RemainFids;
897
*numpages = (CompleteFidSet/HitsPerPage) + 1;
899
else *numpages = FidCount/HitsPerPage;
902
UpperLimit = HitsPerPage * PageNum;
903
LowerLimit = UpperLimit - HitsPerPage + 1;
905
if ((FidCount < HitsPerPage ) || (LowerLimit > FidCount)) {
906
UpperLimit = FidCount;
910
if (UpperLimit > FidCount) UpperLimit = FidCount;
915
for (index = 1; index <= FidCount; index++)
917
if ((index >= LowerLimit) && (index <= UpperLimit)) ValNodeAddBoolean(&pvnBools, 0, TRUE);
918
else ValNodeAddBoolean(&pvnBools, 0, FALSE);
925
MakeVastTable(Int4 FSID, BiostrucAnnotSetPtr pbsas, Int2 iSort, Int4 subsetnum, Int4 pagenum, Int4 HitsPerPage, Int2 iFull, CharPtr JobID, CharPtr pcPass)
927
BiostrucFeatureSetPtr pbsfs = NULL, pbsfs2 = NULL;
929
CharPtr pcPDB = NULL;
933
Int4 numhits, numpages, upper, lower;
934
BiostrucIdPtr pbsidThis = NULL;
935
BiostrucDescrPtr pbsdrThis = NULL;
936
CharPtr pcVast = NULL;
937
ValNodePtr pvnBools = NULL;
939
if ((!pbsas) || (!FSID) ) return;
941
/* pull values out of BiostrucAnnotSet */
942
pbsidThis = ValNodeFindNext(pbsas->id,NULL,BiostrucId_mmdb_id);
945
iMMDBid = (Int4) pbsidThis->data.intvalue; /* Get MMDB id no (only the first one) */
949
printf("Content-type: text/html\n\n");
950
printf("<h2>Error</h2>\n");
951
printf("Internal VASTSERV Error. No MMDB-ID in Data on Server.<p>\n");
955
pbsfs = pbsas->features;
958
if (pbsfs->id == FSID)
960
/* got the right one - make the table */
962
/* pull out the PDB chain code and domain number from the name string */
963
pbsidThis = ValNodeFindNext(pbsfs->descr,NULL,BiostrucFeatureSetDescr_name);
966
pcVast = (CharPtr) pbsidThis->data.ptrvalue;
967
pcPDB = StringSave(PDBNAME_DEFAULT);
970
if (StringLen(pcVast) >= 6)
972
pcPDB[0] = pcVast[0];
973
pcPDB[1] = pcVast[1];
974
pcPDB[2] = pcVast[2];
975
pcPDB[3] = pcVast[3];
977
iDomain = (Int4) FSID % 100;
981
if (EntrezInit("vastsrv", NULL, FALSE) == FALSE)
983
printf("Content-type: text/html\n\n");
984
printf("<h2>Error</h2>\n");
985
printf("VASTSERV: EntrezInit Failed.<p>\n");
986
if (pcPDB) MemFree(pcPDB);
990
if (pbsfs->features != NULL) {
991
pbsfs2 = BiostrucFeatureSetNew();
992
pbsfs2->id = pbsfs->id;
994
pbsfs2->descr = pbsfs->descr;
996
pbsfs2->features = FilterHitsByDomainSubset(pbsfs->features, subsetnum);
997
pbsfs->features = NULL;
998
pvnBools = FilterHitsByPage(pbsfs2, pagenum, HitsPerPage, &numhits, &numpages, &upper, &lower);
999
if (numhits < HitsPerPage || lower > numhits) pagenum = DEFAULT_PAGE;
1000
if (pbsfs2->features != NULL) VastTableSort(pbsfs2, iSort);
1001
VastTableBegin(stdout, pcPDB, JobID, pcPass, cChain, iDomain, iMMDBid, FSID, iFull,
1002
numhits, upper, lower, numpages, HitsPerPage, pagenum);
1003
if (pbsfs2->features != NULL || pvnBools != NULL)
1004
VastTableRows(stdout, pbsfs2, iMMDBid, FSID, iFull, pvnBools);
1006
fprintf(stdout,"<h2><p>Hits are not present in the selected subset</p></h2>\n");
1007
VastTableEnd(stdout, iMMDBid, FSID, pbsas, subsetnum, iSort, iFull, JobID, pcPass, numpages, pagenum, HitsPerPage);
1010
VastPageHeader(stdout, pcPDB, cChain, iDomain, iMMDBid, JobID);
1011
fprintf(stdout, "<h1><a href=\"%s/vasthelp.html#NoNeighbor\">%s</a></h1>\n", VASTpath,
1012
"VAST did not find any structure neighbors.");
1013
fprintf(stdout, "<HR SIZE=5 NOSHADE>\n");
1014
fprintf(stdout, "</body></html>\n");
1020
if (pcPDB) MemFree(pcPDB);
1023
pbsfs = pbsfs->next;
1025
printf("Content-type: text/html\n\n");
1026
printf("<h2>Error</h2>\n");
1027
printf("VASTSERV: Could Not Create VAST Table because Data Not Found.<p>\n");
1028
if (pcPDB) MemFree(pcPDB);
1032
/* Used ONLY by vastsearch - to retrieve from local file rather than .bas or dbase */
1034
BiostrucAnnotSetPtr LIBCALL LocalGetBiostrucAnnotSet(Int4 mmdbid, CharPtr JobID)
1037
AsnIoPtr aip = NULL;
1038
AsnTypePtr atp = NULL;
1039
BiostrucAnnotSetPtr pbsa = NULL;
1040
Char path[PATH_MAX];
1042
Int2 iFileExists = 0;
1044
sprintf(pcId, "/%ld", (long) mmdbid);
1046
StringCpy(path, VSPATH);
1047
StringCat(path, JobID);
1048
StringCat(path, pcId);
1049
StringCat(path, ".bas");
1050
iFileExists = FileLength(path);
1051
if (iFileExists == 0)
1056
aip = AsnIoOpen(path, "r");
1057
pbsa = BiostrucAnnotSetAsnRead(aip, NULL);
1059
if (!pbsa) return NULL;
1065
BiostrucAnnotSetPtr LIBCALL
1066
LocalGetFeatureSet(Int4 mmdbid, Int4 feature_set_id, CharPtr JobID)
1068
BiostrucAnnotSetPtr basp2 = NULL;
1069
BiostrucFeatureSetPtr pbsfs = NULL;
1070
BiostrucAnnotSetPtr basp = NULL;
1071
BiostrucFeatureSetPtr pbsfsLast = NULL;
1073
if (IsVASTData(mmdbid))
1074
basp = VASTBsAnnotSetGet(mmdbid);
1075
else if (IsVASTData(feature_set_id)) {
1076
basp = VASTBsAnnotSetGet(feature_set_id);
1077
if (basp != NULL) return basp;
1080
basp = LocalGetBiostrucAnnotSet(mmdbid, JobID);
1085
pbsfs = basp->features;
1090
if (pbsfs->id == feature_set_id)
1092
basp2 = BiostrucAnnotSetNew();
1093
basp2->id = basp->id;
1094
basp->id = NULL; /* unlink the id valnode from basp object */
1095
basp2->descr = basp->descr;
1096
basp->descr = NULL; /* unlink the descr from basp object */
1097
basp2->features = pbsfs;
1098
if (pbsfsLast) /* relink next to prev */
1099
pbsfsLast->next = pbsfs->next;
1101
basp->features = pbsfs->next;
1102
basp2->features->next = NULL;
1103
BiostrucAnnotSetFree(basp);
1107
pbsfs = pbsfs->next;
1109
BiostrucAnnotSetFree(basp);
1115
BiostrucAnnotSetPtr PruneBiostrucAnnotHits(
1116
BiostrucAnnotSetPtr basp, Int4 FSID, ValNodePtr pvnFids)
1118
BiostrucAnnotSetPtr basp2 = NULL;
1119
BiostrucFeatureSetPtr pbsfs = NULL;
1120
BiostrucFeaturePtr pbsf = NULL;
1121
BiostrucFeaturePtr pbsfHold = NULL;
1122
BiostrucFeaturePtr pbsf2 = NULL;
1123
BiostrucFeaturePtr pbsfDie = NULL;
1125
ValNodePtr pvnFid = NULL;
1126
Boolean found = FALSE;
1128
if ((basp == NULL) || (pvnFids == NULL) || (FSID == 0))
1131
pbsfs = basp->features;
1134
if (pbsfs->id == FSID)
1136
basp2 = BiostrucAnnotSetNew();
1137
basp2->id = basp->id;
1138
basp->id = NULL; /* unlink the id valnode from basp object */
1139
basp2->descr = basp->descr;
1140
basp->descr = NULL; /* unlink the descr from basp object */
1141
basp2->features = BiostrucFeatureSetNew();
1142
basp2->features->id = pbsfs->id;
1144
basp2->features->descr = pbsfs->descr;
1145
pbsfs->descr = NULL; /* unlink the feature-set descr from basp object */
1146
pbsfHold = pbsfs->features;
1147
pbsfs->features = NULL;
1148
BiostrucAnnotSetFree(basp);
1157
if (pbsf->id == (Int4) pvnFid->data.intvalue)
1162
pvnFid = pvnFid->next;
1168
pbsfDie->next = NULL;
1172
if (!basp2->features->features)
1174
basp2->features->features = pbsf;
1175
pbsf2 = basp2->features->features;
1176
pbsf = pbsf->next; /* keep next for loop */
1177
pbsf2->next = NULL; /* chop it */
1183
pbsf = pbsf->next; /* keep next for loop */
1184
pbsf2->next = NULL; /* chop it */
1189
if(pbsfs) pbsfs = pbsfs->next;
1196
BiostrucAnnotSetPtr LIBCALL BiostrucAnnotSetGetByFid (
1197
BiostrucAnnotSetPtr basp, Int4 feature_id, Int4 feature_set_id)
1199
BiostrucAnnotSetPtr basp2 = NULL;
1200
BiostrucFeatureSetPtr pbsfs = NULL;
1201
BiostrucFeaturePtr pbsf = NULL;
1206
pbsfs = basp->features;
1209
if (pbsfs->id == feature_set_id)
1211
pbsf = pbsfs->features;
1214
if (pbsf->id == feature_id)
1216
basp2 = BiostrucAnnotSetNew();
1217
basp2->id = basp->id;
1218
basp->id = NULL; /* unlink the id valnode from basp object */
1219
basp2->descr = basp->descr;
1220
basp->descr = NULL; /* unlink the descr from basp object */
1221
basp2->features = BiostrucFeatureSetNew();
1222
basp2->features->id = pbsfs->id;
1223
basp2->features->descr = pbsfs->descr;
1224
pbsfs->descr = NULL; /* unlink the feature-set descr from basp object */
1225
basp2->features->features = BiostrucFeatureNew();
1226
basp2->features->features->id = pbsf->id;
1227
basp2->features->features->name = StringSave(pbsf->name);
1228
basp2->features->features->type = pbsf->type;
1229
basp2->features->features->Property_property = pbsf->Property_property;
1230
pbsf->Property_property = NULL; /* unlink the property from basp object */
1231
basp2->features->features->Location_location = pbsf->Location_location;
1232
pbsf->Location_location = NULL; /* unlink the location from basp object */
1233
BiostrucAnnotSetFree(basp);
1239
pbsfs = pbsfs->next;
1242
BiostrucAnnotSetFree(basp);
1248
Int2 LIBCALL Check_VastSearch_Password(CharPtr pcPassNew, CharPtr JobID)
1251
Char pcPassFile[24];
1252
Char PassPath[PATH_MAX];
1257
iPassLen = StringLen(pcPassNew);
1258
pcPassOld = StringSave(pcPassNew);
1260
sprintf(pcPassFile, "/%s.passwd", JobID);
1262
StringCpy(PassPath, VSPATH);
1263
StringCat(PassPath, JobID);
1264
StringCat(PassPath, pcPassFile);
1266
if ((passwdfile = FileOpen(PassPath, "r")) == NULL)
1269
printf("Content-type: text/html\n\n");
1270
printf("<h2>Error</h2>\n");
1271
printf("<body><h2>Cannot examine password</h2>\n");
1272
printf("Please alert info@ncbi.nlm.nih.gov\n");
1273
printf("of this problem\n");
1274
printf("</BODY>\n</HTML>\n");
1278
fscanf(passwdfile, "%s", pcPassOld);
1279
FileClose(passwdfile);
1281
if (!StringNCmp(pcPassOld, pcPassNew, iPassLen))
1287
/* Extract vastsrv parameters from the config file. */
1292
URLBase[0] = URLcgi[0] = ENTREZurl[0] = DOCSUMurl[0] = MAILto[0] = '\0';
1293
MMDBpath[0] = gunzip[0] = CGIname[0] = MMDBCGIname[0] = '\0';
1295
GetAppParam("vast", "VASTSRV", "URLBase", "", URLBase, PATH_MAX);
1297
if (URLBase[0] == '\0') {
1298
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no URLBase...\n");
1302
GetAppParam("vast", "VASTSRV", "URLcgi", "", URLcgi, PATH_MAX);
1304
if (URLcgi[0] == '\0') {
1305
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no URLcgi...\n");
1309
GetAppParam("vast", "VASTSRV", "ENTREZurl", "", ENTREZurl, PATH_MAX);
1311
if (ENTREZurl[0] == '\0') {
1312
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no ENTREZurl...\n");
1316
GetAppParam("vast", "VASTSRV", "DOCSUMurl", "", DOCSUMurl, PATH_MAX);
1318
if (DOCSUMurl[0] == '\0') {
1319
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no DOCSUMurl...\n");
1323
GetAppParam("vast", "VASTSRV", "Gunzip", "", gunzip, (size_t) 256*(sizeof(char)));
1325
if (gunzip[0] == '\0') {
1326
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no Gunzip...\n");
1330
GetAppParam("vast", "VASTSRV", "CGIname", "", CGIname, PATH_MAX);
1332
if (CGIname[0] == '\0') {
1333
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no CGIname...\n");
1337
GetAppParam("vast", "VASTSRV", "MMDBCGIname", "", MMDBCGIname, PATH_MAX);
1339
if (MMDBCGIname[0] == '\0') {
1340
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no MMDBCGIname...\n");
1344
GetAppParam("mmdb", "MMDB", "Database", "", MMDBpath, PATH_MAX);
1346
if (MMDBpath[0] == '\0') {
1347
ErrPostEx(SEV_FATAL, 0, 0, "MMDB config file\nMMDBSRV section has no Database...\n");
1351
GetAppParam("vast", "VASTSRV", "MAILto", "", MAILto, PATH_MAX);
1353
if (MAILto[0] == '\0') {
1354
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no MAILto...\n");
1358
GetAppParam("vast", "VASTSRV", "VSPATH", "", VSPATH, PATH_MAX);
1360
if (VSPATH[0] == '\0') {
1361
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no VAST Search path...\n");
1365
GetAppParam("vast", "VASTSRV", "DATApath", "", DATApath, PATH_MAX);
1366
if (DATApath[0] == '\0') {
1367
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no VAST Data path...\n");
1371
GetAppParam("vast", "VASTSRV", "VASTpath", "", VASTpath, PATH_MAX);
1372
if (DATApath[0] == '\0') {
1373
ErrPostEx(SEV_FATAL, 0, 0, "VAST config file\nVASTSRV section has no VAST html path...\n");
1379
} /* end GetVastParams */
1386
FILE *pFile = NULL, *pIn = NULL;
1388
CharPtr pcTest, pcL1 = NULL;
1389
Int4 GetGi, Fid, Fsid, iFileExists = 0, NumLabels = 0;
1390
BiostrucAnnotSetPtr pbsa = NULL;
1391
PDNMS pdnmsMaster = NULL, pdnmsSlave = NULL;
1392
AsnIoPtr aip = NULL;
1393
Int2 iTest = 0, iPDB = 0, iSort = 0, action = 0, viewer = 0, level = 0;
1394
CharPtr Name, Value, IPAddress = getenv("REMOTE_HOST");
1396
ValNodePtr pvnFid = NULL, pvnFids = NULL;
1397
Int4 iFidCount = 0, count = 0, subsetnum, pagenum, HitsPerPage, indx;
1398
Char subsetname[256];
1399
CharPtr JobID = NULL, pcPass, www_arg;
1400
Int2 ret, iFull = 0;
1401
WWWInfoPtr www_info;
1405
/* this sets up the unix time limit */
1406
getrlimit(RLIMIT_CPU, &rl);
1407
rl.rlim_max = rl.rlim_cur = CPUTIME_MAX;
1408
setrlimit(RLIMIT_CPU, &rl);
1410
if (!GetVastParams()) {
1411
printf("Content-type: text/html\n\n");
1412
printf("<h2>VASTSERV Error</h2>\n");
1413
printf("<h3>Couldn't read from config file...</h3>\n");
1417
if (WWWGetArgs(&www_info) != WWWErrOk) {
1418
printf("Content-type: text/html\n\n");
1419
printf("<h2>VASTSERV</h2>\n");
1420
printf("<h3>Failed to process posting - check your get/post syntax.</h3>\n");
1424
if ((NumLabels = WWWGetNumEntries(www_info)) == 0) {
1425
printf("Content-type: text/html\n\n");
1426
printf("<h2>VASTSERV</h2>\n");
1427
printf("<h3>No input - nothing to report.</h3>\n");
1431
if ((indx = WWWFindName(www_info, "action")) >= 0) {
1432
www_arg = WWWGetValueByIndex(www_info, indx);
1434
if (isdigit(www_arg[0]))
1435
action = (Int2) atoi(www_arg);
1437
/* default to asn.1 text */
1443
/***** We may not add this feature, comment it out for now.
1444
if (action == VIEW_ALIGNMENT) {
1445
(void) VastViewAlign(www_info);
1450
/* check whether or not to launch a viewer */
1451
if ((indx = WWWFindName(www_info, "calltype")) >= 0) {
1452
www_arg = WWWGetValueByIndex(www_info, indx);
1454
switch (www_arg[0]) {
1456
(void) VastToMage(www_info);
1459
(void) VastToPDB(www_info);
1462
(void) VastToCn3D(www_info);
1465
printf("Content-type: text/html\n\n");
1466
printf("<h2>VASTSERV Error</h2>\n");
1467
printf("<h3>Internal failure (bad calltype).\nContact %s</h3>\n", MAILto);
1473
printf("Content-type: text/html\n\n");
1474
printf("<h2>VASTSERV Error</h2>\n");
1475
printf("<h3>Cannot find VAST data on server.\nContact %s</h3>\n", MAILto);
1480
printf("Content-type: text/html\n\n");
1481
printf("<h2>VASTSERV Error</h2>\n");
1482
printf("<h3>Cannot find MMDB data on server.\nContact %s</h3>\n", MAILto);
1486
if ((indx = WWWFindName(www_info, "chaindom")) < 0) {
1487
printf("Content-type: text/html\n\n");
1488
printf("<h2>VASTSERV Error</h2>\n");
1489
printf("<h3>Internal failure (no chaindom).\nContact %s</h3>\n", MAILto);
1493
www_arg = WWWGetValueByIndex(www_info, indx);
1495
if (isdigit(www_arg[0]))
1496
Fsid = (Int4) atol(www_arg);
1498
printf("Content-type: text/html\n\n");
1499
printf("<h2>VASTSERV Error</h2>\n");
1500
printf("<h3>Invalid feature set id input; no results.</h3>\n");
1506
if ((indx = WWWFindName(www_info, "vsid")) >= 0) {
1507
/* we have a VAST Search job */
1508
www_arg = WWWGetValueByIndex(www_info, indx);
1509
JobID = StringSave(www_arg);
1511
if ((indx = WWWFindName(www_info, "pass")) < 0) {
1512
printf("Content-type: text/html\n\n");
1513
printf("<body bgcolor = \"#f0f0f0\"\n");
1514
printf("<h2>VAST SEARCH</h2>\n");
1515
printf("<h3>Password required.</h3>\n");
1519
www_arg = WWWGetValueByIndex(www_info, indx);
1520
pcPass = StringSave(www_arg);
1522
if ((ret = Check_VastSearch_Password(pcPass, JobID)) != 1) {
1523
if (ret == 2) exit(0);
1524
printf("Content-type: text/html\n\n");
1525
printf("<body bgcolor = \"#f0f0f0\"\n");
1526
printf("<h2>VAST SEARCH</h2>\n");
1527
printf("<h3>Incorrect password.</h3>\n");
1532
/* load in the chaindom into memory */
1536
pbsa = LocalGetFeatureSet(GetGi, Fsid, JobID);
1539
printf("Content-type: text/html\n\n");
1540
printf("<body bgcolor = \"#f0f0f0\">\n");
1541
printf("<br>\n<h2>VAST structure neighbor calculations for this entry are in progress.</h2>\n");
1545
/* at this point, there is a valid feature set id and pbsa in memory */
1547
/* subset filtering; identify which subset we're working with */
1548
if ((indx = WWWFindName(www_info, "subset")) < 0)
1549
subsetnum = DEFAULT_SUBSET_NUM;
1551
www_arg = WWWGetValueByIndex(www_info, indx);
1552
StringCpy(subsetname, www_arg);
1553
subsetnum = GetSubsetNum(subsetname);
1556
if ((indx = WWWFindName(www_info, "doclistpage")) < 0)
1557
pagenum = DEFAULT_PAGE;
1559
www_arg = WWWGetValueByIndex(www_info, indx);
1560
if (isdigit(www_arg[0]))
1561
pagenum = (Int4) atoi(www_arg);
1563
pagenum = DEFAULT_PAGE;
1566
if ((indx = WWWFindName(www_info, "dispmax")) < 0)
1567
HitsPerPage = NUM_HITS_PER_PAGE;
1569
www_arg = WWWGetValueByIndex(www_info, indx);
1570
if (isdigit(www_arg[0])) {
1571
HitsPerPage = (Int4) atoi(www_arg);
1572
if ((HitsPerPage < NUM_HITS_PER_PAGE) || (HitsPerPage > 100)) {
1573
printf("Content-type: text/html\n\n");
1574
printf("<h2>VASTSERV Error</h2>\n");
1575
printf("<h3>Can only display between 20 and 100 neighbors per page!</h3>");
1580
HitsPerPage = NUM_HITS_PER_PAGE;
1583
if ((indx = WWWFindName(www_info, "sort")) < 0)
1586
www_arg = WWWGetValueByIndex(www_info, indx);
1588
if (isdigit(www_arg[0]))
1589
iSort = (Int2) atoi(www_arg);
1594
if ((indx = WWWFindName(www_info, "version")) < 0)
1595
iFull = ABRIDGED_DISPLAY;
1597
www_arg = WWWGetValueByIndex(www_info, indx);
1599
if (isdigit(www_arg[0]))
1600
iFull = (Int2) atoi(www_arg);
1602
iFull = ABRIDGED_DISPLAY;
1605
/* only two possibilities (so far)! */
1606
if ((iFull != FULL_DISPLAY) && (iFull != ABRIDGED_DISPLAY))
1607
iFull = ABRIDGED_DISPLAY;
1609
if ((indx = WWWFindName(www_info, "hit")) < 0) {
1610
MakeVastTable(Fsid, pbsa, iSort, subsetnum, pagenum, HitsPerPage, iFull, JobID, pcPass);
1611
BiostrucAnnotSetFree(pbsa);
1616
/* if we get to here then something's wrong! */