Int2 Main() { PMSD pmsdRoot = NULL; static char valfilein[PATH_MAX]; Int2 iDotLen = 0; AsnIoPtr aip=NULL; NcbiMimeAsn1Ptr nmap=NULL; BiostrucPtr bsp=NULL; BiostrucSeqPtr bssp=NULL; PDNMS pdnmsModelstruc = NULL; ErrSev esMsg,esLog,esFatal; PDNML pdnmlModel; PMLD pmldThis; Boolean isMime = FALSE; Int4 iModels = 0, iNCBImodel = 0, iPDBmodel = 0, iAscii = 0; /* Initialize MMDB-API */ ErrSetLogfile("error_strSummary.log", ELOG_APPEND|ELOG_BANNER); ErrSetOptFlags(EO_SHOW_SEVERITY|EO_SHOW_CODES|EO_LOG_FILELINE|EO_SHOW_USERSTR|EO_SHOW_ERRTEXT|EO_BEEP|EO_WAIT_KEY|EO_LOGTO_USRFILE); if (!GetArgs("strSummary reports on what is inside .val or .cn3 or .prt file to stdout.\nCaution - will not work on Biounits downloaded from NCBI, use Asymmetric Units\n",3,Rargs)) return 1; /* we use exact filenames and extensions to avoid confusion */ StringCpy(valfilein, Rargs[0].strvalue); if (FileLength(valfilein) == 0) { ErrPostEx(SEV_FATAL,13,1,"Unable to find input file %s",Rargs[0].strvalue); return 13; } if (!OpenMMDBAPI(0,NULL)) { ErrPostEx(SEV_FATAL,12,1,"Unable to open MMDBAPI, check for missing bstdt.val dictionary file."); return 12; } /* load an ASN.1 file *.val or *.c3d or *.prt write out Biostruc only */ aip=AsnIoOpen(valfilein,"rb"); if (aip==NULL) { ErrPostEx(SEV_FATAL,11,1,"Unable open ASN.1 stream in file %s",valfilein); return 11; } /* first try biostruc load */ /* printf("try biostruc\n"); */ esMsg=ErrGetMessageLevel(); esLog=ErrGetLogLevel(); esFatal=ErrGetFatalLevel(); ErrSetMessageLevel(SEV_MAX); ErrSetLogLevel(SEV_MAX); ErrSetFatalLevel(SEV_MAX); bsp=BiostrucAsnRead(aip,NULL); AsnIoClose(aip); ErrSetMessageLevel(esMsg); ErrSetLogLevel(esLog); ErrSetFatalLevel(esFatal); if (bsp == NULL) { /* try ascii */ aip = AsnIoOpen(valfilein,"r"); if (aip==NULL) { ErrPostEx(SEV_FATAL,10,1,"Unable open binary or ascii ASN.1 from file %s",valfilein); return 10; } esMsg=ErrGetMessageLevel(); esLog=ErrGetLogLevel(); esFatal=ErrGetFatalLevel(); ErrSetMessageLevel(SEV_MAX); ErrSetLogLevel(SEV_MAX); ErrSetFatalLevel(SEV_MAX); bsp=BiostrucAsnRead(aip,NULL); AsnIoClose(aip); ErrSetMessageLevel(esMsg); ErrSetLogLevel(esLog); ErrSetFatalLevel(esFatal); if (bsp) iAscii = 1; } if (bsp==NULL) { /* printf("try mime binary\n"); */ /* then try NCBIMime load */ aip=NULL; aip=AsnIoOpen(valfilein,"rb"); ErrSetMessageLevel(SEV_MAX); ErrSetLogLevel(SEV_MAX); ErrSetFatalLevel(SEV_MAX); nmap=NcbiMimeAsn1AsnRead(aip,NULL); ErrSetMessageLevel(esMsg); ErrSetLogLevel(esLog); ErrSetFatalLevel(esFatal); AsnIoClose(aip); if (nmap == NULL) { /* printf("try mime ascii\n"); */ aip=AsnIoOpen(valfilein,"r"); ErrSetMessageLevel(SEV_MAX); ErrSetLogLevel(SEV_MAX); ErrSetFatalLevel(SEV_MAX); nmap=NcbiMimeAsn1AsnRead(aip,NULL); ErrSetMessageLevel(esMsg); ErrSetLogLevel(esLog); ErrSetFatalLevel(esFatal); AsnIoClose(aip); if (nmap) iAscii = 1; } if (nmap!=NULL) { /* got an NCBI mime */ if (nmap->choice!=NcbiMimeAsn1_strucseq && nmap->choice!=NcbiMimeAsn1_strucseqs) { /* wrong MIME type */ nmap=NcbiMimeAsn1Free(nmap); ErrPostEx(SEV_ERROR,9,1,"MIME-type wrapper is not a strucseq or strucseqs - no Biostruc to report in: %s",valfilein); return 9; } isMime = TRUE; /* unwrap the mime and leave the bsp for PDB conversion */ bssp=(BiostrucSeqPtr)(nmap->data.ptrvalue); bsp=bssp->structure; bssp->structure = NULL; /* may want to report on contents of wrapper ... */ nmap=NcbiMimeAsn1Free(nmap); /* discard the wrapper */ nmap = NULL; bssp = NULL; } } if (bsp == NULL) { ErrPostEx(SEV_ERROR,8,1,"No Biostruc in files to report in: %s",valfilein); return 8; } pdnmsModelstruc=MakeAModelstruc(bsp); if (pdnmsModelstruc==NULL) { ErrPostEx(SEV_ERROR,7,1,"Unable to convert Biostruc to Modelstruc"); return 7; } pmsdRoot=(PMSD)(pdnmsModelstruc->data.ptrvalue); if (pmsdRoot==NULL) { ErrPostEx(SEV_ERROR,6,1,"Internal error."); return 6; } /* OK, Ready to Start Reporting */ printf("Filename: %s\n", valfilein); if (Rargs[1].intvalue == FALSE) { if (iAscii) printf("ASCII Asn.1 (.prt) "); else printf("Binary Asn.1 (.val) "); if (isMime) printf("Entry Point: NCBIMime\n"); else printf("Entry Point: Biostruc\n"); if (pmsdRoot->pcPDBName != NULL) printf("PDB code: %s\n",pmsdRoot->pcPDBName); printf("MMDB Id: %d\n", (int) pmsdRoot->iMMDBid); printf("Name: %s\n",GetStrucStrings(pdnmsModelstruc, LONG_NAME)); printf("PDB Class: %s\n",GetStrucStrings(pdnmsModelstruc, PDB_CLASS)); printf("PDB Source: %s\n",GetStrucStrings(pdnmsModelstruc, PDB_SOURCE)); pdnmlModel=pmsdRoot->pdnmlModels; while (pdnmlModel) { iModels++; pmldThis=(PMLD)(pdnmlModel->data.ptrvalue); if (pmldThis->iType==Model_type_ncbi_all_atom) { iNCBImodel = pdnmlModel->choice; } if (pmldThis->iType==Model_type_pdb_model) { iPDBmodel = pdnmlModel->choice; } pdnmlModel=pdnmlModel->next; } printf("Number of Models: %d\n",iModels); if(iNCBImodel) printf("NCBI All Atom Model: %d\n",iNCBImodel); if (iPDBmodel) printf("PDB All Atom Model: %d\n",iPDBmodel); if (pmsdRoot->pDictLocal) printf("Has Local Chemical Graph Dictionary\n"); printf("Number of Molecules: %d\n", (int) pmsdRoot->iMolCount); /* number of molecules */ printf("Number of Objects: %d\n",(int) pmsdRoot->iObjCount); /* number of objects */ printf("Number of Density Sets: %d\n",(int) pmsdRoot->iDensCount); /* number of densities */ printf("Number of Inter-Molecule Bonds: %d\n", (int) pmsdRoot->iIMBCount); if (Rargs[2].intvalue == TRUE) { printf("\n\nRAMACHANDRAN Angles for all Proteins:\n"); if (iNCBImodel) { printf("NCBI All Atom Coordinate Model Number %d\n\nChain, AA, Num, Phi, Psi\n",iNCBImodel); WriteStdoutRamaOneModel(pmsdRoot, iNCBImodel ); } else if (iPDBmodel) { printf("PDB All Atom Coordinate Model Number %d:\n\nChain, AA, Num, Phi, Psi\n",iPDBmodel); WriteStdoutRamaOneModel(pmsdRoot, iPDBmodel ); } } } printf("\n\n"); /* Output FASTA for each chain and dump het list - oldie but goodie code ! */ WriteFASTASeqHet(pdnmsModelstruc, stdout); /* Shut Down MMDB-API */ /* All Modelstrucs remaining are freed in CloseMMDB-API() */ CloseMMDBAPI(); return 0; }
Boolean LIBCALL VastToCn3D(WWWInfoPtr www_info) { FILE *pFile = NULL; FILE *pIn = NULL; Char pcBuf[100], pcLine[256], giBuf[20], URL[200]; CharPtr pcTest, pcL1 = NULL, Name, www_arg; Int4 GetGi, Fid, Fsid, iFileExists = 0, indx; BiostrucAnnotSetPtr pbsa = NULL; BiostrucAnnotSetPtr pbsaShort = NULL; BiostrucFeatureSetPtr pbsfs = NULL; BiostrucFeaturePtr pbsf = NULL; BiostrucResidueGraphSetPtr stdDictionary; ValNodePtr pvnFids = NULL, pvnFid = NULL; Int2 iTest = 0, iPDB = 0, iColor; AsnIoPtr aip = NULL; Byte bRender; Char *IPAddress = getenv("REMOTE_HOST"); Int4 NumLabels, iMMDBId; ValNode * pbsidThis; BiostrucPtr pbsMaster, pbsSlave, pbsSlaveHead = NULL, pbsSlaveTail, pbsTemp; Char szName[5], chain[2]; Char * szTemp; SeqAnnotPtr psaAlignHead = NULL, psaAlignTail; SeqAlignPtr salpHead, salpTail; SeqIdPtr sip; DenseSegPtr dsp; BioseqPtr bsp; SeqEntryPtr sep; char str [52]; NcbiMimeAsn1Ptr pvnNcbi; BiostrucAlignPtr pbsaStruct; AsnIoPtr paiFile, aipr; Boolean is_network; Int4 uid, uidmaster = 0; Int2 retcode = 3; CharPtr JobID = NULL, pcPass; Char AsnPath[PATH_MAX]; Char AsnName[10]; Int2 ret, complexity; Int4 iFidCount = 0; Boolean Chain; /* SeqAsnLoad(); objmmdb1AsnLoad(); objmmdb2AsnLoad(); objmmdb3AsnLoad(); SeqAlignAsnLoad(); objmimeAsnLoad(); */ if ((indx = WWWFindName(www_info, "uid")) < 0) { printf("Content-type: text/html\n\n"); printf("<h3>No accession (PDB ID) was input - nothing to report.</h3>\n"); return 0; } www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) GetGi = (Int4) atoi(www_arg); else { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Non-numeric MMDB-id input - no results.</h3>\n"); return 0; } /* vsid and pass are to look at alignments from VAST Search */ if ((indx = WWWFindName(www_info, "vsid")) >= 0) { www_arg = WWWGetValueByIndex(www_info, indx); JobID = StringSave(www_arg); if ((indx = WWWFindName(www_info, "pass")) < 0) { printf("Content-type: text/html\n\n"); printf("<body bgcolor = \"#f0f0f0\">\n"); printf("<h2>VAST SEARCH</h2>\n"); printf("<h3>Password required.</h3>\n"); return 0; } else { www_arg = WWWGetValueByIndex(www_info, indx); pcPass = StringSave(www_arg); if ((ret = Check_VastSearch_Password(pcPass, JobID)) != 1) { if (ret == 2) return 0; printf("Content-type: text/html\n\n"); printf("<body bgcolor = \"#f0f0f0\">\n"); printf("<h2>VAST SEARCH</h2>\n"); printf("<h3>Incorrect password.</h3>\n"); return 0; } } } if ((indx = WWWFindName(www_info, "hit")) < 0) { printf("Content-type: text/html\n\n"); printf("<body bgcolor = \"#f0f0f0\">\n"); printf("<br>\n<h2>No alignment was selected!</h2>\n"); printf("<h3>Please click on up to 5 boxes in the leftmost column of the table.</h3>\n"); return 0; } /* loop over all the "hit" values in the list */ NumLabels = WWWGetNumEntries(www_info); for (indx = 0; indx < NumLabels; indx++) { Name = WWWGetNameByIndex(www_info, indx); if (StrICmp(Name, "hit") == 0) { www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) Fid = (Int4) atol(www_arg); else { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Non-numeric slave alignment code - no results.</h3>\n"); return 0; } if (++iFidCount > 5) break; pvnFid = ValNodeAddInt(&pvnFids, 0, Fid); } } if ((indx = WWWFindName(www_info, "chaindom")) < 0) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>No feature set ID (master alignment code) - nothing to report.</h3>\n"); return 0; } www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) Fsid = (Int4) atoi(www_arg); else { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Non-numeric master alignment code - no results.</h3>\n"); return 0; } if ((indx = WWWFindName(www_info, "chn_complexity")) < 0) Chain = TRUE; else { www_arg = WWWGetValueByIndex(www_info, indx); complexity =(Int2)atoi(www_arg); if (complexity) Chain = TRUE; else Chain = FALSE; } if ((indx = WWWFindName(www_info, "atm_complexity")) < 0) /* select alpha Carbons only by default */ complexity = ONECOORDRES; else { www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) complexity = (Int2) atoi(www_arg); else complexity = ONECOORDRES; } if ((complexity != ONECOORDRES) && (complexity != ONECOORDATOM)) /* bizarre value, but default to alpha-Carbons only */ complexity = ONECOORDRES; /* action == 0 indicates MIME; action == 1 is text; action == 2 is save */ if ((indx = WWWFindName(www_info, "action")) < 0) iPDB = 0; else { www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) iPDB = (Int4) atoi(www_arg); else iPDB = 0; } if (VASTInit() != TRUE) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Can't find VAST data on server.\n"); printf("Contact [email protected]</h3>\n"); return 0; } OpenMMDBAPI((POWER_VIEW /* ^ FETCH_ENTREZ */), NULL); pbsa = LocalGetFeatureSet(GetGi, Fsid, JobID); if (pbsa == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>No master alignment record exists for %ld.</h3>\n", (long) GetGi); return 0; } if (iFidCount == 1) pbsaShort = BiostrucAnnotSetGetByFid(pbsa, Fid, Fsid); else pbsaShort = PruneBiostrucAnnotHits(pbsa, Fsid, pvnFids); if (pbsaShort == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Can't find alignment record.</h3>\n"); return 0; } if (MMDBInit() == FALSE) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>MMDBInit failed.</h3>\n"); return 0; } pbsfs = pbsaShort->features; pbsaStruct = BiostrucAlignNew(); if (pbsfs) { pbsf = pbsfs->features; szTemp = pbsf->name; szName[0] = szTemp[0]; szName[1] = szTemp[1]; szName[2] = szTemp[2]; szName[3] = szTemp[3]; szName[4] = '\0'; } if (JobID == NULL) pbsMaster = FetchBiostrucPDB(szName, complexity, 1); else { AsnName[0]='\0'; StringCpy(AsnName, "/b"); StringCat(AsnName, szName); AsnPath[0]='\0'; StringCpy(AsnPath, VSPATH); StringCat(AsnPath, JobID); StringCat(AsnPath, AsnName); pbsMaster = FetchBS(AsnPath, 0, complexity, 1, POWER_VIEW); } if (pbsMaster == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3> Unable to load master structure.</h3>\n"); return 0; } /* Load in Standard Dictionary to make sequences - Ken */ aipr = NULL; aipr = AsnIoOpen("bstdt", "rb"); if (aipr == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3>Can't find standard dictionary.</h3>\n"); return 0; } stdDictionary = BiostrucResidueGraphSetAsnRead(aipr, NULL); AsnIoFlush(aipr); aipr = AsnIoClose(aipr); /* retrieve the bioseq for master and put in ValNode */ sep = (SeqEntryPtr) MakeBioseqs(pbsMaster, stdDictionary); if ( sep == NULL ) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3d)</h2>\n"); printf("<h3>Unable to get SeqEntry.</h3>\n"); return 0; } ValNodeLink(&(pbsaStruct->sequences), sep); /* PruneBiostruc if Aligned Chain Options has been chosen */ if (Chain) { if (szTemp[4] != ' ') { chain[0] = szTemp[4]; chain[1] = '\0'; pbsTemp = (BiostrucPtr)PruneBiostruc(pbsMaster, chain); pbsMaster = NULL; pbsMaster = pbsTemp; } } /* Make a linked list of Biostrucs of the slave structures*/ while (pbsf) { szTemp = pbsf->name; szName[0] = szTemp[7]; szName[1] = szTemp[8]; szName[2] = szTemp[9]; szName[3] = szTemp[10]; szName[4] = '\0'; if (!pbsSlaveHead) { pbsSlaveHead = FetchBiostrucPDB(szName, complexity, 1); if (!pbsSlaveHead) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3> Unable to load slave structure.</h3>\n"); return 0; } /* Make Bioseq for Slaves */ sep = (SeqEntryPtr) MakeBioseqs(pbsSlaveHead, stdDictionary); if ( sep == NULL ) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3d)</h2>\n"); printf("<h3>Unable to get SeqEntry.</h3>\n"); return 0; } ValNodeLink(&(pbsaStruct->sequences), sep); /* PruneBiostruc if Aligned Chain Options has been chosen */ if (Chain) { if (szTemp[11] != ' ') { chain[0] = szTemp[11]; chain[1] = '\0'; pbsTemp = (BiostrucPtr)PruneBiostruc(pbsSlaveHead, chain); pbsSlaveHead = NULL; pbsSlaveHead = pbsTemp; } } pbsSlaveTail = pbsSlaveHead; } else { pbsSlave = FetchBiostrucPDB(szName, complexity, 1); if (!pbsSlave) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3D)</h2>\n"); printf("<h3> Unable to load slave structure.</h3>\n"); return 0; } /* Make Bioseq for Slaves */ sep = (SeqEntryPtr) MakeBioseqs(pbsSlave, stdDictionary); if ( sep == NULL ) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3d)</h2>\n"); printf("<h3>Unable to get SeqEntry.</h3>\n"); return 0; } ValNodeLink(&(pbsaStruct->sequences), sep); /* PruneBiostruc if Aligned Chain Options has been chosen */ if (Chain) { if (szTemp[11] != ' ') { chain[0] = szTemp[11]; chain[1] = '\0'; pbsTemp = (BiostrucPtr)PruneBiostruc(pbsSlave, chain); pbsSlave = NULL; pbsSlave = pbsTemp; } } pbsSlaveTail->next = pbsSlave; pbsSlaveTail = pbsSlaveTail->next; pbsSlaveTail->next = NULL; } pbsf = pbsf->next; } /* Make a linked list of sequence alignments of master and slaves */ pbsf=pbsfs->features; while (pbsf) { if (!psaAlignHead) { psaAlignHead = fnPBSFtoPSA (pbsf); /* get the sequence alignments */ if (psaAlignHead == NULL || psaAlignHead->data == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3d)</h2>\n"); printf("<h3>Unable to create SeqAnnot.</h3>\n"); return 0; } salpHead = (SeqAlignPtr)(psaAlignHead->data); salpTail = salpHead; } else { psaAlignTail = fnPBSFtoPSA (pbsf); salpTail->next = (SeqAlignPtr)(psaAlignTail->data); if (psaAlignTail == NULL || psaAlignTail->data == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToCn3d)</h2>\n"); printf("<h3>Unable to create SeqAnnot.</h3>\n"); return 0; } salpTail = salpTail->next; salpTail->next = NULL; } pbsf = pbsf->next; } pbsaStruct->master = pbsMaster; pbsaStruct->slaves = pbsSlaveHead; pbsaStruct->alignments = pbsaShort; pbsaStruct->seqalign = psaAlignHead; pvnNcbi = ValNodeNew(NULL); pvnNcbi->choice = NcbiMimeAsn1_alignstruc; pvnNcbi->data.ptrvalue = pbsaStruct; pvnNcbi = (NcbiMimeAsn1Ptr) CheckId(pvnNcbi, JobID); /* to check identity, yanli */ OutputFile = stdout; if (iPDB == 0) /* cn3d MIME */ printf ("Content-type: chemical/ncbi-asn1-binary\n\n"); else if (iPDB == 1) { /* "See File" */ printf ("Content-type: text/html\n\n"); printf ("<HTML><body><pre>\n"); } else /* "Save File" */ printf ("Content-type: application/octet-stream\n\n"); if (iPDB != 1) paiFile = AsnIoNew(ASNIO_BIN_OUT, stdout, NULL, NULL, NULL); else paiFile = AsnIoNew(ASNIO_TEXT_OUT, stdout, NULL, NULL, NULL); NcbiMimeAsn1AsnWrite(pvnNcbi, paiFile, NULL); AsnIoFlush(paiFile); AsnIoClose(paiFile); CloseMMDBAPI(); MMDBFini(); VASTFini(); return 0; } /* end of VastToCn3D */
Nlm_Int2 Main () { Int2 iTest; Byte bRender; Int2 iColor; PDNMS pdnmsModelstruc; BiostrucPtr pbsBiostruc; Char cOut[254]; FILE *pFile; ErrSetFatalLevel(SEV_MAX); if (! GetArgs("GetMMDB",NUMARGS,myargs)) return 1; /* Initialize MMDBAPI */ if (! OpenMMDBAPI(0, NULL)) { printf("Have not opened mmdbapi"); return 2; } /* load an ASN.1 Biostruc */ /* Any other method of obtaining a Biostruc is fine... */ /* This one does a built-in lookup of PDB accesion numbers */ /* then fetches the file using the Entrez clinet-server interface */ pbsBiostruc = FetchBiostrucPDB(myargs[0].strvalue, myargs[3].intvalue, 100); if (pbsBiostruc == NULL) { printf("Have not fetched Biostruc"); return 3; } /* convert it into a Modelstruc pointed to by pdnmsModelstruc */ pdnmsModelstruc= MakeAModelstruc(pbsBiostruc); if ( pdnmsModelstruc == NULL ) { printf("Have not converted Biostruc"); return 4; } if (myargs[1].intvalue == 0) /* Summary */ { if (!myargs[2].strvalue) { sprintf(cOut,"%s.sum", myargs[0].strvalue); pFile = fopen(cOut, "w"); } else pFile = fopen(myargs[2].strvalue,"w"); iTest = WriteStructSummary(pdnmsModelstruc,pFile); } if (myargs[1].intvalue == 2) /* Kinemage */ { bRender = (Byte) myargs[5].intvalue; iColor = (Int2) myargs[4].intvalue; if (!myargs[2].strvalue) { sprintf(cOut,"%s.kin", myargs[0].strvalue); pFile = fopen(cOut, "w"); } else pFile = fopen(myargs[2].strvalue,"w"); iTest = WriteKinAllModel(pdnmsModelstruc,pFile, iColor,bRender); } if (myargs[1].intvalue == 1) /* PDB */ { if (!myargs[2].strvalue) { sprintf(cOut,"%s.pdb", myargs[0].strvalue); pFile = fopen(cOut, "w"); } else pFile = fopen(myargs[2].strvalue,"w"); iTest = WritePDBAllModel(pdnmsModelstruc,pFile); } /* Free the Modelstruc (and its enclosed Biostruc) */ /* FreeAModelstruc(PDNMS pdnmsThis); not necessary */ /* This can be done individually - but all Modelstrucs */ /* remaining are freed in CloseMMDBAPI() */ /* Shut Down MMDBAPI */ CloseMMDBAPI(); return TRUE; }
Boolean LIBCALL VastToMage(WWWInfoPtr www_info) { FILE *pFile = NULL; FILE *pIn = NULL; Char pcBuf[100], pcLine[256], giBuf[20], URL[200]; CharPtr pcTest, pcL1 = NULL, www_arg; CharPtr JobID = NULL, pcPass; Int4 GetGi, Fid, Fsid, iFileExists = 0, indx, complexity; BiostrucAnnotSetPtr pbsa = NULL; BiostrucAnnotSetPtr pbsaShort = NULL; PDNMS pdnmsMaster = NULL, pdnmsSlave = NULL; Int2 iTest = 0, iPDB = 0, iColor, ret; AsnIoPtr aip = NULL; Byte bRender; Char *IPAddress = getenv("REMOTE_HOST"); Boolean Chain; if ((indx = WWWFindName(www_info, "uid")) < 0) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>No accession (PDB ID) was input - nothing to report.</h3>\n"); return 0; } www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) GetGi = (Int4) atoi(www_arg); else { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>Non-numeric MMDB-id input - no results.</h3>\n"); return 0; } /* vsid and pass are to look at alignments from VAST Search */ if ((indx = WWWFindName(www_info, "vsid")) >= 0) { www_arg = WWWGetValueByIndex(www_info, indx); JobID = StringSave(www_arg); if ((indx = WWWFindName(www_info, "pass")) < 0) { printf("Content-type: text/html\n\n"); printf("<body bgcolor = \"#f0f0f0\">\n"); printf("<h2>VAST SEARCH</h2>\n"); printf("<h3>Password required.</h3>\n"); return 0; } else { www_arg = WWWGetValueByIndex(www_info, indx); pcPass = StringSave(www_arg); if ((ret = Check_VastSearch_Password(pcPass, JobID)) != 1) { if (ret == 2) return 0; printf("Content-type: text/html\n\n"); printf("<body bgcolor = \"#f0f0f0\">\n"); printf("<h2>VAST SEARCH</h2>\n"); printf("<h3>Incorrect password.</h3>\n"); return 0; } } } if ((indx = WWWFindName(www_info, "hit")) < 0) { printf("Content-type: text/html\n\n"); printf("<body bgcolor = \"#f0f0f0\">\n"); printf("<br>\n<h2>No alignment was selected!</h2>\n"); printf("<h3>Please click on a box in the leftmost column of the table.</h3>\n"); return 0; } www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) Fid = (Int4) atoi(www_arg); else { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>Non-numeric slave alignment code - no results.</h3>\n"); return 0; } if ((indx = WWWFindName(www_info, "chaindom")) < 0) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>No feature set ID (master alignment code) - nothing to report.</h3>\n"); return 0; } www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) Fsid = (Int4) atoi(www_arg); else { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>Non-numeric master alignment code - no results.</h3>\n"); return 0; } if ((indx = WWWFindName(www_info, "chn_complexity")) < 0) Chain = TRUE; else { www_arg = WWWGetValueByIndex(www_info, indx); complexity =(Int2)atoi(www_arg); if (complexity) Chain = TRUE; else Chain = FALSE; } /* action == 0 indicates MIME; action == 1 is text; action == 2 is save */ if ((indx = WWWFindName(www_info, "action")) < 0) iPDB = 0; else { www_arg = WWWGetValueByIndex(www_info, indx); if (isdigit(www_arg[0])) iPDB = (Int4) atoi(www_arg); else iPDB = 0; } if (VASTInit() != TRUE) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>Can't find VAST data on server.\n"); printf("Contact [email protected]</h3>\n"); return 0; } OpenMMDBAPI((POWER_VIEW /* ^ FETCH_ENTREZ */), NULL); if (JobID == NULL) pbsa = VASTBsAnnotSetGet(Fsid); else pbsa = LocalGetFeatureSet(GetGi, Fsid, JobID); if (pbsa == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>No master alignment record exists for %ld.</h3>\n", (long) GetGi); return 0; } pbsaShort = BiostrucAnnotSetGetByFid(pbsa, Fid, Fsid); if (pbsaShort == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>Can't find alignment record.</h3>\n"); return 0; } if (MMDBInit() == FALSE) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>MMDBInit failed.</h3>\n"); return 0; } /* A note to myself for when I get back from Xmas break. This is the situation: * The call to VastToMage is failing on the check where pdnmsSlave == NULL. For * some reason the slave structure is not getting loaded into the global data * structure. It appears that the next function call to InstBSAnnotSet() loads * the master structure. However, I do not see where the slave structure gets * loaded. Absurdly enough, though, the locally compiled vastsrv works fine, and * the slave is indeed getting properly loaded there. * * I think I see it. There are massive differences between the local mmdbapi1.c * and the checked-in one. In particular, BiostrucAddFeature is grossly different * between the two. It looks like the slaves are loaded in the latter routine. * InstBSAnnotSet calls BiostrucAddFeature. */ InstBSAnnotSet(pbsaShort, JobID, Chain, VSPATH); /* now uses mmdbapi1 version */ pdnmsMaster = GetMasterModelstruc(); /***** This is causing a problem at line 126, where pmsdThis->pbsBS does not exist! pdnmsMaster = GetSelectedModelstruc(); *****/ if (pdnmsMaster == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>Unable to load master structure.</h3>\n"); return 0; } pdnmsSlave = GetSlaveModelstruc(); if (pdnmsSlave == NULL) { printf("Content-type: text/html\n\n"); printf("<h2>VASTSERV Error (VastToMage)</h2>\n"); printf("<h3>Unable to load slave structure.</h3>\n"); return 0; } /* Kinemage file generation */ if (iPDB == 2) { fprintf(stdout, "Content-type: application/octet-stream\n\n"); } else if (iPDB == 1) { fprintf(stdout, "Content-type: text/html\n\n"); fprintf(stdout, "<HTML><body><pre>\n"); } else fprintf(stdout, "Content-type: chemical/x-kinemage\n\n"); /* MIME */ bRender = (Byte) (KIN_VIRTUAL | KIN_HET); iColor = KIN_COLOR_NUMBER; iTest = WriteKinPairAlign(pdnmsMaster, pdnmsSlave, stdout, iColor, bRender); if (!iTest) { printf("Content-type: text/html\n\n"); printf("<h2>Error</h2>\n"); printf("Kinemage File write failed on Server.<p>\n"); RemoveTempFiles(); CloseMMDBAPI(); MMDBFini(); VASTFini(); exit(1); } fflush(stdout); CloseMMDBAPI(); MMDBFini(); VASTFini(); RemoveTempFiles(); return 0; } /* end of VastToMage */