/*------------------------------------------------------------------------------ * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * ------------------------------------------------------------------------------ * * File Name: nrpdbsrv.c * * File Description: Non-redundant-PDB-Set WWW-server * * Created by: Yo Matsuo * Version Creation Date: October 20, 1998 ------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/ /* Header Files Included */ /*----------------------------------------------------------------------------*/ #include #include #include #include #include #include /*----------------------------------------------------------------------------*/ /* Definitions */ /*----------------------------------------------------------------------------*/ /* #define NRTABLE "/net/ncbi/ftp/mmdb/nrtable/nrpdb.latest" */ #define NRTABLE "nrpdb.latest" #define NRPDBHOMEPAGE "nrpdb.html" #define NRPDBSRVPATH "nrpdbsrv.cgi" #define ENTREZSTRUC "http://www.ncbi.nlm.nih.gov/Structure/mmdb/mmdbsrv?uid=" #define THIS_PROGRAM_IS "NRPDBSRV" #define MAXNCHAINS 75000 #define NNRLEVEL 4 #define CPUTIME_MAX 120 #undef NR_DEBUG /*----------------------------------------------------------------------------*/ /* global variables */ /*----------------------------------------------------------------------------*/ /* data items from the NR PDB table (see below for detais) */ static Int4 nchains; /* No. of chains */ static Char pdbcode[MAXNCHAINS][8]; static Char chainid[MAXNCHAINS]; static Int4 mmdbid[MAXNCHAINS]; static Int4 groupid[NNRLEVEL][MAXNCHAINS]; static Int4 rankingroup[NNRLEVEL][MAXNCHAINS]; static Int4 repornot[NNRLEVEL][MAXNCHAINS]; static FloatHi punk[MAXNCHAINS]; static FloatHi picr[MAXNCHAINS]; static FloatHi pmr[MAXNCHAINS]; static FloatHi pics[MAXNCHAINS]; static FloatHi resol[MAXNCHAINS]; static Int4 nch[MAXNCHAINS]; static Int4 nht[MAXNCHAINS]; static Int4 nhtt[MAXNCHAINS]; static Int4 nres[MAXNCHAINS]; static Char expmet[MAXNCHAINS]; static Char accornot[MAXNCHAINS]; /* no. of members in each group */ static Int4 nmem[NNRLEVEL][MAXNCHAINS]; /* work space in listing representatives */ static Int4 chainbuffer[MAXNCHAINS]; /* describe each non-redundancy level */ static Char chNRlevel[NNRLEVEL][40] = {"10e-7", "10e-40", "10e-80", "non-identical"}; /* describe each attribute */ /* attribute - description in the table */ /**/ static Char chPdbcode1[] = "PDB"; static Char chPdbcode2[] = "PDB code"; /**/ static Char chChainid1[] = "Ch"; static Char chChainid2[] = "Chain ID"; /**/ static Char chRankingroup1[] = "Rank"; static Char chRankingroup2[] = "Rank in this sequence-similar group"; /**/ static Char chUnk1[] = "Unk"; static Char chUnk2[] = "Percentage of Unknown residues"; /**/ static Char chIcr1[] = "Icr"; static Char chIcr2[] = "Percentage of Incomplete residues"; /**/ static Char chMr1[] = "Mr"; static Char chMr2[] = "Percentage of Missing residues"; /**/ static Char chIcs1[] = "Ics"; static Char chIcs2[] = "Percentage of Residues with Incomplete side-chain"; /**/ static Char chResol1[] = "Resol"; static Char chResol2[] = "Crystallographic Resolution (0.0 for NMR entry)"; /**/ static Char chNch1[] = "Nch"; static Char chNch2[] = "No. of Chains (subunits) in the PDB entry"; /**/ static Char chNht1[] = "Nht"; static Char chNht2[] = "No. of Heterogens (except for water)"; /**/ static Char chNhtt1[] = "Nhtt"; static Char chNhtt2[] = "No. of Types of Heterogens (except for water)"; /**/ static Char chNres1[] = "Nres"; static Char chNres2[] = "No. of Residues"; /**/ static Char chExpmet1[] = "Exp"; static Char chExpmet2[] = "Experimental methods: X = X-ray, N = NMR, M = theoretical"; /**/ static Char chNmem1[] = "Nmem"; static Char chNmem2[] = "No. of sequence-similar members in its group"; /*---------------------------------------*/ /* print HTML Header */ /*---------------------------------------*/ static void beginHTML() { fprintf(stdout, "Content-type: text/html\n\n"); fprintf(stdout, "\n"); fprintf(stdout, "\n"); fprintf(stdout, "Non-redundant PDB chain set\n"); fprintf(stdout, "\n"); fprintf(stdout, "\n"); } /*---------------------------------------*/ /* print HTML Footer */ /*---------------------------------------*/ static void endHTML() { fprintf(stdout, "\n"); fprintf(stdout, "\n"); } /*---------------------------------------*/ /* trivial routine when an erro occurred */ /*---------------------------------------*/ static void EarlyOut() { fflush(stdout); exit(1); } /*--------------------------------------------------------*/ /* Read in the NR set table */ /*--------------------------------------------------------*/ static void ReadNrTable() { int i, j, k; /* counters */ FILE *fp; /* file pointer for NR PDB set */ Char line[10000]; /* work space to read in string */ Char cWork[10][8]; /* work space to read in string */ Int4 iWork[20]; /* work space for reading in integer */ FloatHi rWork[20]; /* work space for reading in floating point number */ /* This is the format of the NR set table. A line starting with "#" is a comment line, and should be skipped. #--------------------------------------------------------------------- # Non-redundant PDB chain set #--------------------------------------------------------------------- # # 1: PDB code # 2: Chain ID # 3: MMDB ID # # 4: Group ID (BLAST pvalue 10e-7) # 5: Rank (BLAST pvalue 10e-7) # 6: Representative (1) or not (0) (BLAST pvalue 10e-7) # # 7: Group ID (BLAST pvalue 10e-40) # 8: Rank (BLAST pvalue 10e-40) # 9: Representative (1) or not (0) (BLAST pvalue 10e-40) # # A: Group ID (BLAST pvalue 10e-80) # B: Rank (BLAST pvalue 10e-80) # C: Representative (1) or not (0) (BLAST pvalue 10e-40) # # D: Group ID (Non-identical sequences) # E: Rank (Non-identical sequence) # F: Representative (1) or not (0) (Non-identical sequence) # # G: Percentage of Unknown residues # H: Percentage of Incomplete residues # I: Percentage of Missing residues # J: Percentage of Incomplete side-chain residues # K: Resolution (0.0 if NMR) # L: No. of chains (subunits) in the PDB entry # M: No. of heterogens in the PDB entry # N: No. of different heterogen types in the PDB entry # O: No. of residues in the chain # P: Method of coordinate determination (X: X-ray, N: NMR, M: theoretical) # Q: Acceptable (a) in structural quality or not (n) # #--------------------------------------------------------------------------------------------------------------------------- # 1 2 3 4 5 6 7 8 9 A B C D E F G H I J K L M N O P Q #--------------------------------------------------------------------------------------------------------------------------- 1L58 1460 1 1 0 1 1 0 1 1 0 2206 1 1 0.00 0.00 0.00 0.00 1.65 1 1 1 164 X a 237L 7320 1 2 0 1 2 0 1 2 0 3773 1 1 0.00 0.00 0.00 0.00 1.70 1 3 2 164 X a */ if ((fp = FileOpen(NRTABLE, "r")) == NULL) { fprintf(stdout, "Content-type: text/html\n\n"); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

Failed to read data.

\n"); EarlyOut(); } nchains = 0; while (NULL != fgets(line, 500, fp)) { /* skip the comment line */ if (line[0] == '#') continue; /*--------------------------------------------------------- PDB code (columns 1 - 4) chain ID (column 6) domain ID or number (column 8) (if to be printed) ---------------------------------------------------------*/ /* PDB code */ for (i = 0; i < 4; ++i) pdbcode[nchains][i] = line[i]; pdbcode[nchains][4] = '\0'; /* chain ID */ chainid[nchains] = line[5]; for (i = 0; ; ++i) { line[i] = line[i + 9]; if (line[i] == '\0') break; } sscanf(line, "%d%d%d%d%d%d%d%d%d%d%d%d%d%lf%lf%lf%lf%lf%d%d%d%d%s%s", &(iWork[0]), &(iWork[1]), &(iWork[2]), &(iWork[3]), &(iWork[4]), &(iWork[5]), &(iWork[6]), &(iWork[7]), &(iWork[8]), &(iWork[9]), &(iWork[10]), &(iWork[11]), &(iWork[12]), &(rWork[0]), &(rWork[1]), &(rWork[2]), &(rWork[3]), &(rWork[4]), &(iWork[13]), &(iWork[14]), &(iWork[15]), &(iWork[16]), cWork[0], cWork[1] ); /* MMDB ID */ mmdbid[nchains] = iWork[0]; /* group ID, rank in the group, and representative or not */ /* p-value cutoff 10e-7 */ groupid[0][nchains] = iWork[1]; rankingroup[0][nchains] = iWork[2]; repornot[0][nchains] = iWork[3]; /* group ID, rank in the group, and representative or not */ /* p-value cutoff 10e-40 */ groupid[1][nchains] = iWork[4]; rankingroup[1][nchains] = iWork[5]; repornot[1][nchains] = iWork[6]; /* group ID, rank in the group, and representative or not */ /* p-value cutoff 10e-80 */ groupid[2][nchains] = iWork[7]; rankingroup[2][nchains] = iWork[8]; repornot[2][nchains] = iWork[9]; /* group ID, rank in the group, and representative or not */ /* 100% identical */ groupid[3][nchains] = iWork[10]; rankingroup[3][nchains] = iWork[11]; repornot[3][nchains] = iWork[12]; /* Percentage of Unknown residues */ punk[nchains] = rWork[0]; /* Percentage of Incomplete residues */ picr[nchains] = rWork[1]; /* Percentage of Missing residues */ pmr[nchains] = rWork[2]; /* Percentage of Incomplete side-chain residues */ pics[nchains] = rWork[3]; /* Resolution (0.0 if NMR) */ resol[nchains] = rWork[4]; /* No. of chains (subunits) in the PDB entry */ nch[nchains] = iWork[13]; /* No. of heterogens in the PDB entry */ nht[nchains] = iWork[14]; /* No. of different heterogen types in the PDB entry */ nhtt[nchains] = iWork[15]; /* No. of residues in the chain */ nres[nchains] = iWork[16]; /* Method of coordinate determination (X: X-ray, N: NMR, M: theoretical) */ expmet[nchains] = cWork[0][0]; /* Acceptable (a) in structural quality or not (n) */ accornot[nchains] = cWork[1][0]; ++nchains; } } /*----------------------*/ /* List representatives */ /*----------------------*/ static void ListRepresentatives(Int2 NRlevel, CharPtr tableoption, Int4 iPage, Int4 iPagesize) { Int4 ichain; Int4 ic; Int4 nrep; Int4 irep; Int4 nPage; Int4 i1, i2; Int4 nextPage; /* collect representatives */ nrep = 0; for (ichain = 0; ichain < nchains; ++ichain) if (repornot[NRlevel][ichain] == 1) chainbuffer[nrep ++] = ichain; if (0 == strcmp(tableoption, "long")) { /* long table */ /* No. of pages */ nPage = nrep / iPagesize; if (0 < nrep % iPagesize) ++nPage; if (iPage > nPage) iPage = nPage; /* range of representatives to be shown in this page */ i1 = iPagesize * (iPage - 1) + 1; i2 = iPagesize * iPage; if (i2 > nrep) i2 = nrep; nextPage = iPage + 1; if (nextPage > nPage) nextPage = 1; fprintf(stdout, "\n"); fprintf(stdout, "No. of Representatives: %d

\n", nrep); fprintf(stdout, "Page %d / %d
\n", iPage, nPage); fprintf(stdout, "Representatives %d - %d\n", i1, i2); fflush(stdout); fprintf(stdout, "\n"); fprintf(stdout, "\n"); fprintf(stdout, "\n"); fprintf(stdout, "\n", chPdbcode1); fprintf(stdout, "\n", chChainid1); fprintf(stdout, "\n", chUnk1); fprintf(stdout, "\n", chIcr1); fprintf(stdout, "\n", chMr1); fprintf(stdout, "\n", chIcs1); fprintf(stdout, "\n", chResol1); fprintf(stdout, "\n", chNch1); fprintf(stdout, "\n", chNht1); fprintf(stdout, "\n", chNhtt1); fprintf(stdout, "\n", chNres1); fprintf(stdout, "\n", chExpmet1); fprintf(stdout, "\n", chNmem1); fprintf(stdout, "\n"); for (irep = (i1 - 1); irep <= (i2 - 1); ++irep) { ichain = chainbuffer[irep]; fprintf(stdout, "\n"); fprintf(stdout, "\n", irep + 1); fprintf(stdout, "\n", ENTREZSTRUC, mmdbid[ichain], pdbcode[ichain]); if (chainid[ichain] == ' ') fprintf(stdout, "\n"); else fprintf(stdout, "\n", chainid[ichain]); fprintf(stdout, "\n", punk[ichain]); fprintf(stdout, "\n", picr[ichain]); fprintf(stdout, "\n", pmr[ichain]); fprintf(stdout, "\n", pics[ichain]); fprintf(stdout, "\n", resol[ichain]); fprintf(stdout, "\n", nch[ichain]); fprintf(stdout, "\n", nht[ichain]); fprintf(stdout, "\n", nhtt[ichain]); fprintf(stdout, "\n", nres[ichain]); fprintf(stdout, "\n", expmet[ichain]); fprintf(stdout, "\n", NRPDBSRVPATH, NRlevel, pdbcode[ichain], chainid[ichain], nmem[NRlevel][groupid[NRlevel][ichain]]); fprintf(stdout, "\n"); } fprintf(stdout, "
%s%s%s%s%s%s%s%s%s%s%s%s%s
%d%s %c%6.1f%6.1f%6.1f%6.1f%5.2f%3d%3d%3d%5d%c%d
\n"); fprintf(stdout, "
\n"); fprintf(stdout, "
\n", NRPDBSRVPATH); fprintf(stdout, " page\n"); fprintf(stdout, " of %d\n", nextPage, nPage); fprintf(stdout, "          \n"); fprintf(stdout, "          \n"); fprintf(stdout, "No. representatives per page"); fprintf(stdout, "\n", iPagesize); fprintf(stdout, "\n"); fprintf(stdout, "\n", NRlevel); fprintf(stdout, "
\n"); fprintf(stdout, "\n"); fprintf(stdout, "\n", chPdbcode2); fprintf(stdout, "\n", chChainid2); fprintf(stdout, "\n", chUnk2); fprintf(stdout, "\n", chIcr2); fprintf(stdout, "\n", chMr2); fprintf(stdout, "\n", chIcs2); fprintf(stdout, "\n", chResol2); fprintf(stdout, "\n", chNch2); fprintf(stdout, "\n", chNht2); fprintf(stdout, "\n", chNhtt2); fprintf(stdout, "\n", chNres2); fprintf(stdout, "\n", chExpmet2); fprintf(stdout, "\n"); fprintf(stdout, "
%s:\n", chPdbcode1); fprintf(stdout, "%s
%s:\n", chChainid1); fprintf(stdout, "%s
%s:\n", chUnk1); fprintf(stdout, "%s
%s:\n", chIcr1); fprintf(stdout, "%s
%s:\n", chMr1); fprintf(stdout, "%s
%s:\n", chIcs1); fprintf(stdout, "%s
%s:\n", chResol1); fprintf(stdout, "%s
%s:\n", chNch1); fprintf(stdout, "%s
%s:\n", chNht1); fprintf(stdout, "%s
%s:\n", chNhtt1); fprintf(stdout, "%s
%s:\n", chNres1); fprintf(stdout, "%s
%s:\n", chExpmet1); fprintf(stdout, "%s
%s:\n", chNmem1); fprintf(stdout, "%s
", chNmem2); fprintf(stdout, "Click on this number, then you can see a list of those members."); fprintf(stdout, "
\n"); fprintf(stdout, "
\n"); fprintf(stdout, "Top of the Table

\n"); fprintf(stdout, "NR set homepage
\n", NRPDBHOMEPAGE); } else { /* short table */ fprintf(stdout, "No. of Representatives: %d

\n", nrep); fflush(stdout); fprintf(stdout, "\n"); ic = 0; for (irep = 0; irep < nrep; ++irep) { ichain = chainbuffer[irep]; if (ic == 0) fprintf(stdout, "\n"); /* fprintf(stdout, "\n", ENTREZSTRUC, mmdbid[ichain], pdbcode[ichain], chainid[ichain]); */ fprintf(stdout, "\n", pdbcode[ichain], chainid[ichain]); ++ic; if (ic == 10) { fprintf(stdout, "\n"); ic = 0; } } fprintf(stdout, "
%s%c \;%s%c 
\n"); } } /*----------------------------*/ /* Show members of a NR group */ /*----------------------------*/ static void ShowNRGroup(Int2 NRlevel, Int4 querygroupid, Int4 querychain) { Int4 ichain; fprintf(stdout, "\n"); fprintf(stdout, "\n"); fprintf(stdout, "\n"); fprintf(stdout, "\n", chRankingroup1); fprintf(stdout, "\n", chPdbcode1); fprintf(stdout, "\n", chChainid1); fprintf(stdout, "\n", chUnk1); fprintf(stdout, "\n", chIcr1); fprintf(stdout, "\n", chMr1); fprintf(stdout, "\n", chIcs1); fprintf(stdout, "\n", chResol1); fprintf(stdout, "\n", chNch1); fprintf(stdout, "\n", chNht1); fprintf(stdout, "\n", chNhtt1); fprintf(stdout, "\n", chNres1); fprintf(stdout, "\n", chExpmet1); fprintf(stdout, "\n"); for (ichain = 0; ichain < nchains; ++ichain) { if (groupid[NRlevel][ichain] == querygroupid) { fprintf(stdout, "\n"); fprintf(stdout, "\n"); fprintf(stdout, "\n", ENTREZSTRUC, mmdbid[ichain], pdbcode[ichain]); if (chainid[ichain] == ' ') fprintf(stdout, "\n"); else fprintf(stdout, "\n", chainid[ichain]); fprintf(stdout, "\n", punk[ichain]); fprintf(stdout, "\n", picr[ichain]); fprintf(stdout, "\n", pmr[ichain]); fprintf(stdout, "\n", pics[ichain]); fprintf(stdout, "\n", resol[ichain]); fprintf(stdout, "\n", nch[ichain]); fprintf(stdout, "\n", nht[ichain]); fprintf(stdout, "\n", nhtt[ichain]); fprintf(stdout, "\n", nres[ichain]); fprintf(stdout, "\n", expmet[ichain]); fprintf(stdout, "\n"); } } fprintf(stdout, "
%s%s%s%s%s%s%s%s%s%s%s%s%s
%d", rankingroup[NRlevel][ichain]); if (repornot[NRlevel][ichain] == 1) fprintf(stdout, "*"); if (ichain == querychain) fprintf(stdout, "#"); fprintf(stdout, "%s %c%6.1f%6.1f%6.1f%6.1f%5.2f%3d%3d%3d%5d%c
\n"); fprintf(stdout, "
\n"); fprintf(stdout, "\n"); fprintf(stdout, "\n"); fprintf(stdout, "\n", chPdbcode2); fprintf(stdout, "\n", chChainid2); fprintf(stdout, "\n", chUnk2); fprintf(stdout, "\n", chIcr2); fprintf(stdout, "\n", chMr2); fprintf(stdout, "\n", chIcs2); fprintf(stdout, "\n", chResol2); fprintf(stdout, "\n", chNch2); fprintf(stdout, "\n", chNht2); fprintf(stdout, "\n", chNhtt2); fprintf(stdout, "\n", chNres2); fprintf(stdout, "\n", chExpmet2); fprintf(stdout, "
%s:\n", chRankingroup1); fprintf(stdout, "%s
", chRankingroup2); fprintf(stdout, "* if it is the representative of this group
"); fprintf(stdout, "# if it is the query
%s:\n", chPdbcode1); fprintf(stdout, "%s
%s:\n", chChainid1); fprintf(stdout, "%s
%s:\n", chUnk1); fprintf(stdout, "%s
%s:\n", chIcr1); fprintf(stdout, "%s
%s:\n", chMr1); fprintf(stdout, "%s
%s:\n", chIcs1); fprintf(stdout, "%s
%s:\n", chResol1); fprintf(stdout, "%s
%s:\n", chNch1); fprintf(stdout, "%s
%s:\n", chNht1); fprintf(stdout, "%s
%s:\n", chNhtt1); fprintf(stdout, "%s
%s:\n", chNres1); fprintf(stdout, "%s
%s:\n", chExpmet1); fprintf(stdout, "%s
\n"); fprintf(stdout, "
\n"); fprintf(stdout, "Top of the Table

\n"); fprintf(stdout, "NR set homepage
\n", NRPDBHOMEPAGE); } /****************************************************************************** ******************************************************************************* * NRPDBSRV Main ******************************************************************************* *******************************************************************************/ Int2 Main () { int i; /* counters */ FILE *fp; /* file pointer for NR PDB set */ Char line[10000]; /* work space to read in string */ CharPtr Value; /* to extract from the info struct */ struct rlimit rl; /* data structure for run limit */ WWWInfoPtr www_info; /* holds all info accessible */ Int4 NumLabels = 0; /* number of WWW-parameters */ Int4 indx; /* used in parsing WWW-input */ Int4 ichain; Int2 NRlevel; /* NR level: 0=10e-7, 1=10e-40, 2=10e-80, 3=nonidentical */ Char querypdbcode[8]; Char querychainid; Int4 querygroupid; Char tableoption[8]; Int4 iPage; Int4 iPagesize; Int4 iNRlevel; /*----------------------------------------------------------------------------*/ /* this sets up the unix time limit */ /*----------------------------------------------------------------------------*/ getrlimit(RLIMIT_CPU, &rl); rl.rlim_max = rl.rlim_cur = CPUTIME_MAX; setrlimit(RLIMIT_CPU, &rl); /*----------------------------------------------------------------------------*/ /* check whether parameters have been submitted along with the posting */ /*----------------------------------------------------------------------------*/ if (WWWGetArgs(&www_info) != WWWErrOk) { beginHTML(); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

Failed to process posting - check your get/post syntax.

\n"); endHTML(); EarlyOut(); } if ((NumLabels = WWWGetNumEntries(www_info)) == 0) { beginHTML(); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

No input - nothing to report.

\n"); endHTML(); EarlyOut(); } /*--------------------------------------------------------*/ /* Read in the NR set table */ /*--------------------------------------------------------*/ ReadNrTable(); /* count the number of members of each group */ for (iNRlevel = 0; iNRlevel < NNRLEVEL; ++iNRlevel) { for (i = 0; i < MAXNCHAINS; ++i) nmem[iNRlevel][i] = 0; for (ichain = 0; ichain < nchains; ++ichain) nmem[iNRlevel][groupid[iNRlevel][ichain]] ++; } /*----------------------------------------------------------------------------*/ /* extract from the query the level of non-redundancy that should be used */ /*----------------------------------------------------------------------------*/ /* This is a mandatory option */ if ((indx = WWWFindName(www_info, "nrlevel")) >= 0) { Value = WWWGetValueByIndex(www_info, indx); NRlevel = atoi(Value); if (NRlevel >= NNRLEVEL) { beginHTML(); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

Unexpected non-redundancy level submitted.

\n"); endHTML(); EarlyOut(); } } else { beginHTML(); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

NON-REDUNDANCY LEVEL UNKNOWN

\n"); endHTML(); EarlyOut(); } /*----------------------------------------------*/ /*----------------------------------------------*/ /* Action requested */ /*----------------------------------------------*/ /*----------------------------------------------*/ /*----------------------*/ /* List representatives */ /*----------------------*/ if ((indx = WWWFindName(www_info, "replist")) >= 0) { Value = WWWGetValueByIndex(www_info, indx); /* short table or long table? */ if ((indx = WWWFindName(www_info, "ltable")) >= 0) { Value = WWWGetValueByIndex(www_info, indx); sprintf(tableoption, "%s", Value); } else { beginHTML(); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

TABLE TYPE UNKNOWN

\n"); endHTML(); EarlyOut(); } /* Page to be shown */ if ((indx = WWWFindName(www_info, "page")) >= 0) { Value = WWWGetValueByIndex(www_info, indx); iPage = atoi(Value); } else { beginHTML(); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

PAGE NOT SPECIFIED

\n"); endHTML(); EarlyOut(); } /* Page size */ if ((indx = WWWFindName(www_info, "pagesize")) >= 0) { Value = WWWGetValueByIndex(www_info, indx); iPagesize = atoi(Value); } else { beginHTML(); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

PAGE SIZE NOT SPECIFIED

\n"); endHTML(); EarlyOut(); } /* send the page */ beginHTML(); fprintf(stdout, "

List of Representatives

\n"); fprintf(stdout, "Non-redundancy level: \n"); fprintf(stdout, "%s
", chNRlevel[NRlevel]); fflush(stdout); ListRepresentatives(NRlevel, tableoption, iPage, iPagesize); endHTML(); } /*----------------*/ /* Show the group */ /*----------------*/ else if ((indx = WWWFindName(www_info, "group")) >= 0) { Value = WWWGetValueByIndex(www_info, indx); /*----------*/ /* PDB code */ /*----------*/ querypdbcode[0] = '\0'; if ((indx = WWWFindName(www_info, "pdbcode")) >= 0) { Value = WWWGetValueByIndex(www_info, indx); sprintf(querypdbcode, "%s", Value); } if (strlen(querypdbcode) != 4) { beginHTML(); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

Invalid PDB code

\n"); endHTML(); EarlyOut(); } for (i = 0; i < 4; ++i) querypdbcode[i] = toupper(querypdbcode[i]); /*----------*/ /* chain ID */ /*----------*/ querychainid = '\0'; if ((indx = WWWFindName(www_info, "chainid")) >= 0) { Value = WWWGetValueByIndex(www_info, indx); querychainid = Value[0]; } if (querychainid == '\0') querychainid = ' '; querychainid = toupper(querychainid); /* #ifdef NR_DEBUG beginHTML(); fprintf(stdout, "Query: %s %c
\n", querypdbcode, querychainid); endHTML(); #endif */ /*-------------*/ /* NR group ID */ /*-------------*/ querygroupid = -1; for (ichain = 0; ichain < nchains; ++ichain) { if (0 == strcmp(querypdbcode, pdbcode[ichain]) && querychainid == chainid[ichain]) { querygroupid = groupid[NRlevel][ichain]; break; } } if (querygroupid < 0) { beginHTML(); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

The chain does not exit in this NR set.

\n"); endHTML(); EarlyOut(); } beginHTML(); fprintf(stdout, "

Cluster of Sequence-Similar Chains

\n"); fprintf(stdout, "Query: %s %c
\n", ENTREZSTRUC, mmdbid[ichain], querypdbcode, querychainid); fprintf(stdout, "No. of chains in the cluster: %d
\n", nmem[NRlevel][groupid[NRlevel][ichain]]); fprintf(stdout, "Non-redundancy level: \n"); fprintf(stdout, "%s
", chNRlevel[NRlevel]); fprintf(stdout, "
"); fflush(stdout); ShowNRGroup(NRlevel, querygroupid, ichain); endHTML(); } else { beginHTML(); fprintf(stdout, "

%s

\n", THIS_PROGRAM_IS); fprintf(stdout, "

Undefined action requested.

\n"); endHTML(); EarlyOut(); } return(0); }